@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | error_reporting(E_ALL); |
| 30 | 30 | |
| 31 | 31 | if (PHP_MAJOR_VERSION < 7) { |
| 32 | - echo "CMS is required PHP 7.0.0 or greater! Please install PHP 7 (current version: " . PHP_VERSION . ")."; |
|
| 33 | - exit; |
|
| 32 | + echo "CMS is required PHP 7.0.0 or greater! Please install PHP 7 (current version: " . PHP_VERSION . ")."; |
|
| 33 | + exit; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | //define some constants |
@@ -919,35 +919,35 @@ discard block |
||
| 919 | 919 | |
| 920 | 920 | //get main menuID |
| 921 | 921 | if (!Settings::contains("main_menuID")) { |
| 922 | - //create menu_names if absent |
|
| 923 | - $main_menuID = Menu::createMenuName("Main Menu", "main_menu"); |
|
| 922 | + //create menu_names if absent |
|
| 923 | + $main_menuID = Menu::createMenuName("Main Menu", "main_menu"); |
|
| 924 | 924 | |
| 925 | - //set setting |
|
| 926 | - Settings::create("main_menuID", $main_menuID, "Main MenuID", "id of main menu (in menu area)", "system", "general", "none", "none", 1); |
|
| 925 | + //set setting |
|
| 926 | + Settings::create("main_menuID", $main_menuID, "Main MenuID", "id of main menu (in menu area)", "system", "general", "none", "none", 1); |
|
| 927 | 927 | } else { |
| 928 | - $main_menuID = Settings::get("main_menuID"); |
|
| 928 | + $main_menuID = Settings::get("main_menuID"); |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | //get admin area menuID |
| 932 | 932 | if (!Settings::contains("admin_menuID")) { |
| 933 | - //create menu_names if absent |
|
| 934 | - $admin_menuID = Menu::createMenuName("Admin Menu", "admin_menu"); |
|
| 933 | + //create menu_names if absent |
|
| 934 | + $admin_menuID = Menu::createMenuName("Admin Menu", "admin_menu"); |
|
| 935 | 935 | |
| 936 | - //set setting |
|
| 937 | - Settings::create("admin_menuID", $admin_menuID, "Admin MenuID", "id of admin menu (in admin area)", "system", "general", "none", "none", 2); |
|
| 936 | + //set setting |
|
| 937 | + Settings::create("admin_menuID", $admin_menuID, "Admin MenuID", "id of admin menu (in admin area)", "system", "general", "none", "none", 2); |
|
| 938 | 938 | } else { |
| 939 | - $admin_menuID = Settings::get("admin_menuID"); |
|
| 939 | + $admin_menuID = Settings::get("admin_menuID"); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | //get local menuID |
| 943 | 943 | if (!Settings::contains("local_menuID")) { |
| 944 | - //create menu_names if absent |
|
| 945 | - $local_menuID = Menu::createMenuName("Default Local Menu", "local_menu"); |
|
| 944 | + //create menu_names if absent |
|
| 945 | + $local_menuID = Menu::createMenuName("Default Local Menu", "local_menu"); |
|
| 946 | 946 | |
| 947 | - //set setting |
|
| 948 | - Settings::create("local_menuID", $local_menuID, "Default Local MenuID", "id of default local menu (in menu area)", "system", "general", "none", "none", 1); |
|
| 947 | + //set setting |
|
| 948 | + Settings::create("local_menuID", $local_menuID, "Default Local MenuID", "id of default local menu (in menu area)", "system", "general", "none", "none", 1); |
|
| 949 | 949 | } else { |
| 950 | - $local_menuID = Settings::get("local_menuID"); |
|
| 950 | + $local_menuID = Settings::get("local_menuID"); |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | //create default folders, if absent |
@@ -1069,11 +1069,11 @@ discard block |
||
| 1069 | 1069 | echo "<br /><br />Finished DB Upgrade!"; |
| 1070 | 1070 | |
| 1071 | 1071 | if (file_exists(ROOT_PATH . "setup/add-install.php")) { |
| 1072 | - echo "<br />Call add-install.php...<br />"; |
|
| 1072 | + echo "<br />Call add-install.php...<br />"; |
|
| 1073 | 1073 | |
| 1074 | - require(ROOT_PATH . "setup/add-install.php"); |
|
| 1074 | + require(ROOT_PATH . "setup/add-install.php"); |
|
| 1075 | 1075 | |
| 1076 | - echo "<br /><br />Finished additional Upgrade!"; |
|
| 1076 | + echo "<br /><br />Finished additional Upgrade!"; |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | ?> |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | $this->conn = new PDO("mysql:host=" . $this->host . ";port=" . $this->port . ";dbname=" . $this->database . "", $this->username, $this->password, $this->options); |
| 56 | 56 | |
| 57 | 57 | if (DEBUG_MODE) { |
| 58 | - //$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 59 | - //$this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); |
|
| 60 | - } |
|
| 58 | + //$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 59 | + //$this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); |
|
| 60 | + } |
|
| 61 | 61 | } catch (PDOException $e) { |
| 62 | 62 | echo "Couldnt connect to database!"; |
| 63 | 63 | echo $e->getTraceAsString(); |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | $res = $stmt->execute(); |
| 104 | 104 | |
| 105 | 105 | if (!$res) { |
| 106 | - if (DEBUG_MODE) { |
|
| 107 | - echo "SQL Query: " + $sql; |
|
| 108 | - } |
|
| 106 | + if (DEBUG_MODE) { |
|
| 107 | + echo "SQL Query: " + $sql; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | //TODO: throw exception instead |
| 111 | 111 | |
| 112 | 112 | print_r($stmt->errorInfo()); |
| 113 | 113 | |
| 114 | - ob_end_flush(); |
|
| 114 | + ob_end_flush(); |
|
| 115 | 115 | exit; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | exit; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - print_r($e); |
|
| 126 | + print_r($e); |
|
| 127 | 127 | |
| 128 | 128 | echo "<br /><br /><b>Query</b>: " . $sql . ", parameters: "; |
| 129 | 129 | var_dump($params); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | exit; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - print_r($e); |
|
| 145 | + print_r($e); |
|
| 146 | 146 | |
| 147 | 147 | echo "<br /><br /><b>Query</b>: " . $sql . ", parameters: "; |
| 148 | 148 | var_dump($params); |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | $sql = str_replace("{DBPRAEFIX}", $this->praefix, $sql); |
| 208 | 208 | $sql = str_replace("{praefix}", $this->praefix, $sql); |
| 209 | - $sql = str_replace("{prefix}", $this->praefix, $sql); |
|
| 210 | - $sql = str_replace("{PREFIX}", $this->praefix, $sql); |
|
| 209 | + $sql = str_replace("{prefix}", $this->praefix, $sql); |
|
| 210 | + $sql = str_replace("{PREFIX}", $this->praefix, $sql); |
|
| 211 | 211 | return str_replace("{PRAEFIX}", $this->praefix, $sql); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -332,9 +332,9 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - public function lastInsertId(): int { |
|
| 336 | - return $this->conn->lastInsertId(); |
|
| 337 | - } |
|
| 335 | + public function lastInsertId(): int { |
|
| 336 | + return $this->conn->lastInsertId(); |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | 339 | public function listQueryHistory() : array { |
| 340 | 340 | return self::$query_history; |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function get($area, $key) { |
| 33 | - if ($this->contains($area, $key)) { |
|
| 34 | - $file_path = $this->getFilePath($area, $key); |
|
| 35 | - //echo "area: " . $area . ", key: " . $key . ", File path: " . $file_path . "<br />\n"; |
|
| 33 | + if ($this->contains($area, $key)) { |
|
| 34 | + $file_path = $this->getFilePath($area, $key); |
|
| 35 | + //echo "area: " . $area . ", key: " . $key . ", File path: " . $file_path . "<br />\n"; |
|
| 36 | 36 | |
| 37 | - $content = file_get_contents($file_path); |
|
| 37 | + $content = file_get_contents($file_path); |
|
| 38 | 38 | |
| 39 | - //echo $content; |
|
| 39 | + //echo $content; |
|
| 40 | 40 | |
| 41 | 41 | return unserialize($content); |
| 42 | 42 | } else { |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function contains ($area, $key) : bool { |
| 48 | - return CACHING && file_exists($this->getFilePath($area, $key)); |
|
| 48 | + return CACHING && file_exists($this->getFilePath($area, $key)); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | protected function getFilePath (string $area, string $key) : string { |
| 52 | - return CACHE_PATH . md5($area) . "/" . md5($key) . ".php"; |
|
| 53 | - } |
|
| 52 | + return CACHE_PATH . md5($area) . "/" . md5($key) . ".php"; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | private function check_directory ($name) { |
| 56 | 56 | if (!file_exists(CACHE_PATH . $name . "/")) { |
@@ -74,23 +74,23 @@ discard block |
||
| 74 | 74 | if (empty($area)) { |
| 75 | 75 | $this->rrmdir(CACHE_PATH, CACHE_PATH); |
| 76 | 76 | } else { |
| 77 | - //area is not null |
|
| 78 | - |
|
| 79 | - $area_path = CACHE_PATH . md5($area) . "/"; |
|
| 80 | - |
|
| 81 | - if (!empty($key)) { |
|
| 82 | - $file_path = CACHE_PATH . md5($area) . "/" + md5($key) + ".php"; |
|
| 83 | - |
|
| 84 | - //check, if file exists |
|
| 85 | - if (file_exists($file_path)) { |
|
| 86 | - //remove file |
|
| 87 | - unlink($file_path); |
|
| 88 | - } |
|
| 89 | - } else { |
|
| 90 | - //clear full area |
|
| 91 | - $this->rrmdir($area_path, CACHE_PATH); |
|
| 92 | - } |
|
| 93 | - } |
|
| 77 | + //area is not null |
|
| 78 | + |
|
| 79 | + $area_path = CACHE_PATH . md5($area) . "/"; |
|
| 80 | + |
|
| 81 | + if (!empty($key)) { |
|
| 82 | + $file_path = CACHE_PATH . md5($area) . "/" + md5($key) + ".php"; |
|
| 83 | + |
|
| 84 | + //check, if file exists |
|
| 85 | + if (file_exists($file_path)) { |
|
| 86 | + //remove file |
|
| 87 | + unlink($file_path); |
|
| 88 | + } |
|
| 89 | + } else { |
|
| 90 | + //clear full area |
|
| 91 | + $this->rrmdir($area_path, CACHE_PATH); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | // TODO: Implement clear() method. |
| 95 | 95 | } |
| 96 | 96 | |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if (!(self::$second_level_cache instanceof ICache)) { |
| 118 | - throw new Exception("second level cache is not instance of ICache."); |
|
| 119 | - } |
|
| 118 | + throw new Exception("second level cache is not instance of ICache."); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | return self::$second_level_cache; |
| 122 | 122 | } |
@@ -148,27 +148,27 @@ discard block |
||
| 148 | 148 | unset(self::$cache_instances[$name]); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * put session |
|
| 153 | - * |
|
| 154 | - * @param $area cache area |
|
| 155 | - * @param $key cache key |
|
| 156 | - * @param $value cache entry value, can also be an object |
|
| 157 | - * @param $ttl time to live of cache entry in seconds (optional) |
|
| 158 | - */ |
|
| 159 | - public static function put(string $area, string $key, $value, $ttl = 180 * 60) { |
|
| 160 | - self::getCache()->put($area, $key, $value, $ttl); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - public static function get(string $area, string $key) { |
|
| 164 | - return self::getCache()->get($area, $key); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - public static function contains(string $area, string $key) : bool { |
|
| 168 | - return self::getCache()->contains($area, $key); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - public static function clear(string $area = "", string $key = "") { |
|
| 172 | - self::getCache()->clear($area, $key); |
|
| 173 | - } |
|
| 151 | + /** |
|
| 152 | + * put session |
|
| 153 | + * |
|
| 154 | + * @param $area cache area |
|
| 155 | + * @param $key cache key |
|
| 156 | + * @param $value cache entry value, can also be an object |
|
| 157 | + * @param $ttl time to live of cache entry in seconds (optional) |
|
| 158 | + */ |
|
| 159 | + public static function put(string $area, string $key, $value, $ttl = 180 * 60) { |
|
| 160 | + self::getCache()->put($area, $key, $value, $ttl); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + public static function get(string $area, string $key) { |
|
| 164 | + return self::getCache()->get($area, $key); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + public static function contains(string $area, string $key) : bool { |
|
| 168 | + return self::getCache()->contains($area, $key); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + public static function clear(string $area = "", string $key = "") { |
|
| 172 | + self::getCache()->clear($area, $key); |
|
| 173 | + } |
|
| 174 | 174 | } |
@@ -18,61 +18,61 @@ |
||
| 18 | 18 | |
| 19 | 19 | class AutoLoaderCache { |
| 20 | 20 | |
| 21 | - public static function init () { |
|
| 22 | - //check, if directory autoloader in cache exists |
|
| 23 | - if (!file_exists(CACHE_PATH . "autoloader")) { |
|
| 24 | - mkdir(CACHE_PATH . "autoloader"); |
|
| 25 | - } |
|
| 26 | - //check, if autoloader configuration exists |
|
| 27 | - if (!file_exists(STORE_PATH . "autoloader/autoloader.php")) { |
|
| 28 | - //TODO: generate file automatically (self repair) |
|
| 21 | + public static function init () { |
|
| 22 | + //check, if directory autoloader in cache exists |
|
| 23 | + if (!file_exists(CACHE_PATH . "autoloader")) { |
|
| 24 | + mkdir(CACHE_PATH . "autoloader"); |
|
| 25 | + } |
|
| 26 | + //check, if autoloader configuration exists |
|
| 27 | + if (!file_exists(STORE_PATH . "autoloader/autoloader.php")) { |
|
| 28 | + //TODO: generate file automatically (self repair) |
|
| 29 | 29 | |
| 30 | - throw new ConfigurationException("autoloader configuration not found in store."); |
|
| 31 | - } |
|
| 32 | - if (!file_exists(CACHE_PATH . "autoloader/preloaded_classes.php")) { |
|
| 33 | - //create cache |
|
| 34 | - self::createCache(); |
|
| 35 | - } |
|
| 36 | - } |
|
| 37 | - public static function load () { |
|
| 38 | - if (!file_exists(STORE_PATH . "autoloader/autoloader.php")) { |
|
| 39 | - throw new ConfigurationException("autoloader configuration not found in store."); |
|
| 40 | - } |
|
| 41 | - if (!file_exists(CACHE_PATH . "autoloader/preloaded_classes.php")) { |
|
| 42 | - //cache file doesnt exists |
|
| 43 | - self::createCache(); |
|
| 44 | - } |
|
| 45 | - //load classes from cache to save I/O |
|
| 46 | - require(CACHE_PATH . "autoloader/preloaded_classes.php"); |
|
| 47 | - } |
|
| 48 | - private static function createCache () { |
|
| 49 | - require(STORE_PATH . "autoloader/autoloader.php"); |
|
| 50 | - //create new cache file |
|
| 51 | - $data = ""; |
|
| 30 | + throw new ConfigurationException("autoloader configuration not found in store."); |
|
| 31 | + } |
|
| 32 | + if (!file_exists(CACHE_PATH . "autoloader/preloaded_classes.php")) { |
|
| 33 | + //create cache |
|
| 34 | + self::createCache(); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + public static function load () { |
|
| 38 | + if (!file_exists(STORE_PATH . "autoloader/autoloader.php")) { |
|
| 39 | + throw new ConfigurationException("autoloader configuration not found in store."); |
|
| 40 | + } |
|
| 41 | + if (!file_exists(CACHE_PATH . "autoloader/preloaded_classes.php")) { |
|
| 42 | + //cache file doesnt exists |
|
| 43 | + self::createCache(); |
|
| 44 | + } |
|
| 45 | + //load classes from cache to save I/O |
|
| 46 | + require(CACHE_PATH . "autoloader/preloaded_classes.php"); |
|
| 47 | + } |
|
| 48 | + private static function createCache () { |
|
| 49 | + require(STORE_PATH . "autoloader/autoloader.php"); |
|
| 50 | + //create new cache file |
|
| 51 | + $data = ""; |
|
| 52 | 52 | |
| 53 | - foreach ($autoloader_classes as $class_path) { |
|
| 54 | - if (file_exists($class_path)) { |
|
| 55 | - //get php code directly |
|
| 56 | - $data .= file_get_contents($class_path); |
|
| 57 | - } else if (file_exists(ROOT_PATH . $class_path)) { |
|
| 58 | - //use ROOT_PATH prefix |
|
| 59 | - $data .= file_get_contents(ROOT_PATH . $class_path); |
|
| 60 | - } else { |
|
| 61 | - echo "<!-- class " . $class_path . " couldnt be cached, file path doesnt exists. -->"; |
|
| 62 | - } |
|
| 63 | - } |
|
| 53 | + foreach ($autoloader_classes as $class_path) { |
|
| 54 | + if (file_exists($class_path)) { |
|
| 55 | + //get php code directly |
|
| 56 | + $data .= file_get_contents($class_path); |
|
| 57 | + } else if (file_exists(ROOT_PATH . $class_path)) { |
|
| 58 | + //use ROOT_PATH prefix |
|
| 59 | + $data .= file_get_contents(ROOT_PATH . $class_path); |
|
| 60 | + } else { |
|
| 61 | + echo "<!-- class " . $class_path . " couldnt be cached, file path doesnt exists. -->"; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - //remove unneccessary php tags |
|
| 66 | - $data = str_replace("<?php", "", $data); |
|
| 67 | - $data = str_replace("?>", "", $data); |
|
| 68 | - $text = "<" . "?" . "php " . $data . " ?" . ">"; |
|
| 65 | + //remove unneccessary php tags |
|
| 66 | + $data = str_replace("<?php", "", $data); |
|
| 67 | + $data = str_replace("?>", "", $data); |
|
| 68 | + $text = "<" . "?" . "php " . $data . " ?" . ">"; |
|
| 69 | 69 | |
| 70 | - //write data to file in uncrommpressed way |
|
| 71 | - file_put_contents(CACHE_PATH . "autoloader/preloaded_classes_uncompressed.php", $text); |
|
| 70 | + //write data to file in uncrommpressed way |
|
| 71 | + file_put_contents(CACHE_PATH . "autoloader/preloaded_classes_uncompressed.php", $text); |
|
| 72 | 72 | |
| 73 | - //compress code, remove comments and unneccessary whitespaces with php_strip_whitespace() |
|
| 74 | - file_put_contents(CACHE_PATH . "autoloader/preloaded_classes.php", php_strip_whitespace(CACHE_PATH . "autoloader/preloaded_classes_uncompressed.php")); |
|
| 75 | - } |
|
| 73 | + //compress code, remove comments and unneccessary whitespaces with php_strip_whitespace() |
|
| 74 | + file_put_contents(CACHE_PATH . "autoloader/preloaded_classes.php", php_strip_whitespace(CACHE_PATH . "autoloader/preloaded_classes_uncompressed.php")); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
@@ -34,20 +34,20 @@ discard block |
||
| 34 | 34 | @ini_set("expose_php", "off"); |
| 35 | 35 | |
| 36 | 36 | //dont allow include($url) to avoid code injection |
| 37 | - @ini_set("allow_url_include", "0"); |
|
| 37 | + @ini_set("allow_url_include", "0"); |
|
| 38 | 38 | |
| 39 | - header("X-Content-Type-Options: nosniff"); |
|
| 39 | + header("X-Content-Type-Options: nosniff"); |
|
| 40 | 40 | |
| 41 | - //enable internet explorer XSS protection, https://www.perpetual-beta.org/weblog/security-headers.html |
|
| 42 | - header("X-XSS-Protection: 1; mode=block"); |
|
| 41 | + //enable internet explorer XSS protection, https://www.perpetual-beta.org/weblog/security-headers.html |
|
| 42 | + header("X-XSS-Protection: 1; mode=block"); |
|
| 43 | 43 | |
| 44 | - //https://developer.mozilla.org/de/docs/Web/HTTP/Headers/X-Frame-Options |
|
| 45 | - $x_frame_options = Settings::get("x_frame_options", "SAMEORIGIN"); |
|
| 44 | + //https://developer.mozilla.org/de/docs/Web/HTTP/Headers/X-Frame-Options |
|
| 45 | + $x_frame_options = Settings::get("x_frame_options", "SAMEORIGIN"); |
|
| 46 | 46 | |
| 47 | - if (strcmp($x_frame_options, "none") !== 0) { |
|
| 48 | - //set X-Frame-Options header to avoid clickjacking attacks |
|
| 49 | - header("X-Frame-Options: " . $x_frame_options); |
|
| 50 | - } |
|
| 47 | + if (strcmp($x_frame_options, "none") !== 0) { |
|
| 48 | + //set X-Frame-Options header to avoid clickjacking attacks |
|
| 49 | + header("X-Frame-Options: " . $x_frame_options); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * dont allow some XSS attacks or SQL Injections from host or server name |
@@ -96,13 +96,13 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | public static function checkCSRFToken ($value = null) { |
| 99 | - if (is_null($value)) { |
|
| 100 | - if (!isset($_REQUEST['csrf_token']) || empty($_REQUEST['csrf_token'])) { |
|
| 101 | - return false; |
|
| 102 | - } |
|
| 99 | + if (is_null($value)) { |
|
| 100 | + if (!isset($_REQUEST['csrf_token']) || empty($_REQUEST['csrf_token'])) { |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - $value = $_REQUEST['csrf_token']; |
|
| 105 | - } |
|
| 104 | + $value = $_REQUEST['csrf_token']; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | return self::$csrf_token === $value; |
| 108 | 108 | } |
@@ -28,59 +28,59 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class Registry { |
| 30 | 30 | |
| 31 | - protected static $objects = array(); |
|
| 32 | - protected static $settings = array(); |
|
| 33 | - protected static $instance = null; |
|
| 31 | + protected static $objects = array(); |
|
| 32 | + protected static $settings = array(); |
|
| 33 | + protected static $instance = null; |
|
| 34 | 34 | |
| 35 | - public function __construct () { |
|
| 36 | - // |
|
| 37 | - } |
|
| 35 | + public function __construct () { |
|
| 36 | + // |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public static function &singleton () { |
|
| 39 | + public static function &singleton () { |
|
| 40 | 40 | |
| 41 | - if (self::$instance == null) { |
|
| 42 | - self::$instance = new Registry(); |
|
| 43 | - } |
|
| 41 | + if (self::$instance == null) { |
|
| 42 | + self::$instance = new Registry(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return self::$instance; |
|
| 45 | + return self::$instance; |
|
| 46 | 46 | |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function storeObject ($key, &$object) { |
|
| 50 | - if (is_string($object)) { |
|
| 51 | - $object = new $object(); |
|
| 52 | - } |
|
| 49 | + public function storeObject ($key, &$object) { |
|
| 50 | + if (is_string($object)) { |
|
| 51 | + $object = new $object(); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - self::$objects[$key] = $object; |
|
| 55 | - } |
|
| 54 | + self::$objects[$key] = $object; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function getObject ($key) { |
|
| 58 | - if (!isset(self::$objects[$key])) { |
|
| 59 | - throw new IllegalStateException("registry key '" . $key . "' doesnt exists."); |
|
| 60 | - } |
|
| 57 | + public function getObject ($key) { |
|
| 58 | + if (!isset(self::$objects[$key])) { |
|
| 59 | + throw new IllegalStateException("registry key '" . $key . "' doesnt exists."); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - if (is_object(self::$objects[$key])) { |
|
| 63 | - return self::$objects[$key]; |
|
| 64 | - } else { |
|
| 65 | - throw new IllegalStateException("key '" . $key. "' isnt an object."); |
|
| 66 | - } |
|
| 67 | - } |
|
| 62 | + if (is_object(self::$objects[$key])) { |
|
| 63 | + return self::$objects[$key]; |
|
| 64 | + } else { |
|
| 65 | + throw new IllegalStateException("key '" . $key. "' isnt an object."); |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - public function setSetting ($key, $value) { |
|
| 70 | - self::$settings[$key] = $value; |
|
| 71 | - } |
|
| 69 | + public function setSetting ($key, $value) { |
|
| 70 | + self::$settings[$key] = $value; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - public function getSetting ($key) { |
|
| 74 | - if (!isset(self::$settings[$key])) { |
|
| 75 | - throw new IllegalStateException("Registry-Settings key '" . htmlentities($key) . "' doesnt exists."); |
|
| 76 | - } |
|
| 73 | + public function getSetting ($key) { |
|
| 74 | + if (!isset(self::$settings[$key])) { |
|
| 75 | + throw new IllegalStateException("Registry-Settings key '" . htmlentities($key) . "' doesnt exists."); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - return self::$settings[$key]; |
|
| 79 | - } |
|
| 78 | + return self::$settings[$key]; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - public function listSettings () { |
|
| 82 | - return self::$settings; |
|
| 83 | - } |
|
| 81 | + public function listSettings () { |
|
| 82 | + return self::$settings; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | self::$instances[$name]->connect($db_config_path); |
| 75 | 75 | } else { |
| 76 | 76 | //Logger::error("Couldnt find database configuration file for database '" . $name . "'."); |
| 77 | - echo "Couldnt find database configuration file for database '" . $name . "'."; |
|
| 77 | + echo "Couldnt find database configuration file for database '" . $name . "'."; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | require(ROOT_PATH . "system/core/classes/" . strtolower($classname) . ".php"); |
| 108 | 108 | return null; |
| 109 | 109 | } else if (file_exists(ROOT_PATH . "system/core/exception/" . strtolower($classname) . ".php")) { |
| 110 | - require(ROOT_PATH . "system/core/exception/" . strtolower($classname) . ".php"); |
|
| 111 | - return null; |
|
| 112 | - } else if (file_exists(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php")) { |
|
| 113 | - require(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php"); |
|
| 114 | - return null; |
|
| 115 | - } |
|
| 110 | + require(ROOT_PATH . "system/core/exception/" . strtolower($classname) . ".php"); |
|
| 111 | + return null; |
|
| 112 | + } else if (file_exists(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php")) { |
|
| 113 | + require(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php"); |
|
| 114 | + return null; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | $array = explode("_", strtolower($classname)); |
| 118 | 118 | |
@@ -135,16 +135,16 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | } else if (sizeof($array) == 2) { |
| 138 | - if ($array[0] == "validator") { |
|
| 139 | - if (file_exists(ROOT_PATH . "system/core/validator/" . $array[1] . ".php")) { |
|
| 140 | - require(ROOT_PATH . "system/core/validator/" . $array[1] . ".php"); |
|
| 141 | - } else { |
|
| 142 | - echo "Could not load validator class " . $classname . "!"; |
|
| 143 | - } |
|
| 144 | - } else { |
|
| 145 | - echo "Could not load class " . $classname . ", unknown prefix '" . $array[0] . "'!"; |
|
| 138 | + if ($array[0] == "validator") { |
|
| 139 | + if (file_exists(ROOT_PATH . "system/core/validator/" . $array[1] . ".php")) { |
|
| 140 | + require(ROOT_PATH . "system/core/validator/" . $array[1] . ".php"); |
|
| 141 | + } else { |
|
| 142 | + echo "Could not load validator class " . $classname . "!"; |
|
| 143 | + } |
|
| 144 | + } else { |
|
| 145 | + echo "Could not load class " . $classname . ", unknown prefix '" . $array[0] . "'!"; |
|
| 146 | 146 | } |
| 147 | - } else if (sizeOf($array) == 1) { |
|
| 147 | + } else if (sizeOf($array) == 1) { |
|
| 148 | 148 | |
| 149 | 149 | if (file_exists(ROOT_PATH . "system/classes/" . strtolower($classname) . ".php")) { |
| 150 | 150 | include ROOT_PATH . "system/classes/" . strtolower($classname) . ".php"; |