diff --git a/src/includes/class.config.php b/src/includes/class.config.php index 8f1fd9d..ed41516 100644 --- a/src/includes/class.config.php +++ b/src/includes/class.config.php @@ -112,6 +112,9 @@ class Config public static function set($key, $value) { + if ($key == "prefix" && $value !== "" && !preg_match("/^[a-zA-Z0-9_]+$/", $value)) { + throw new Exception("Incorrect table prefix. Can contain only latin letters, digits and underscore character."); + } self::$config[$key] = $value; } diff --git a/src/setup.php b/src/setup.php index 234b775..6e6ac08 100644 --- a/src/setup.php +++ b/src/setup.php @@ -87,7 +87,7 @@ if (!$ver) Config::set('prefix', trim(_post('prefix'))); } if(!testConnect($error)) { - exitMessage("Database connection error: $error"); + exitMessage("Database connection error: ". htmlspecialchars($error)); } if(!is_writable('./db/config.php')) { exitMessage("Config file ('db/config.php') is not writable."); @@ -279,10 +279,10 @@ elseif($ver == $lastVer) else { if(!in_array($ver, array('1.4'))) { - exitMessage("Can not update. Unsupported database version ($ver)."); + exitMessage(htmlspecialchars("Can not update. Unsupported database version ($ver).")); } if(!isset($_POST['update'])) { - exitMessage("Update database v$ver to v$lastVer

+ exitMessage(htmlspecialchars("Update database v$ver to v$lastVer"). "

"); @@ -400,10 +400,16 @@ function testConnect(&$error) return 1; } +function debugExceptionHandler($e) +{ + echo '
Error: \''. htmlspecialchars($e->getMessage()) .'\' in '. htmlspecialchars($e->getFile() .':'. $e->getLine()). ''. + "\n
". htmlspecialchars($e->getTraceAsString()) . "
\n"; + exit; +} + function myExceptionHandler($e) { - echo '
Fatal Error: \''. $e->getMessage() .'\' in '. $e->getFile() .':'. $e->getLine() . ''. - "\n
". $e->getTraceAsString() . "
\n"; + echo '
Error: '. htmlspecialchars($e->getMessage()) ; exit; }