@@ -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 | ?> |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | $table->addVarchar("home_page", 255, true, "home"); |
| 160 | 160 | $table->addEnum("wildcard", array("YES", "NO"), true, "NO"); |
| 161 | 161 | $table->addInt("styleID", 10, true, false, "-1"); |
| 162 | -$table->addVarchar("redirect_url", 255, true, "none");# |
|
| 162 | +$table->addVarchar("redirect_url", 255, true, "none"); # |
|
| 163 | 163 | $table->addInt("redirect_code", 10, true, false, "301"); |
| 164 | 164 | $table->addVarchar("base_dir", 255, true, "/"); |
| 165 | -$table->addInt("force_ssl", 10, true, false, "0");//if 1 then all http urls would be rewritten to https urls |
|
| 165 | +$table->addInt("force_ssl", 10, true, false, "0"); //if 1 then all http urls would be rewritten to https urls |
|
| 166 | 166 | $table->addTimestamp("lastUpdate", true, "CURRENT_TIMESTAMP"); |
| 167 | 167 | $table->addInt("activated", 10, true, false, "1"); |
| 168 | 168 | |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | $table->addInt("local_menu", 10, true, false, -1); |
| 413 | 413 | $table->addVarchar("page_type", 255, true, "HTMLPage"); |
| 414 | 414 | $table->addVarchar("design", 255, true, "none"); |
| 415 | -$table->addInt("sitemap", 10, true, false, 1);//should page be shown in sitemap? |
|
| 415 | +$table->addInt("sitemap", 10, true, false, 1); //should page be shown in sitemap? |
|
| 416 | 416 | $table->addInt("published", 10, true, false, 0); |
| 417 | 417 | $table->addInt("version", 10, true, false, 1); |
| 418 | 418 | $table->addTimestamp("last_update", true, "0000-00-00 00:00:00", true); |
@@ -449,9 +449,9 @@ discard block |
||
| 449 | 449 | //fields |
| 450 | 450 | $table->addVarchar("page_type", 255, true); |
| 451 | 451 | $table->addVarchar("title", 255, true); |
| 452 | -$table->addVarchar("create_permissions", 255, true, "none");//list with permissions (OR), one of this permissions is required to create pages with this page type |
|
| 453 | -$table->addInt("advanced", 10, true, false, 0);//flag, if page type is only shown in expert (advanced) mode |
|
| 454 | -$table->addInt("order", 10, true, false, 10);//order in admin area on page creation selection |
|
| 452 | +$table->addVarchar("create_permissions", 255, true, "none"); //list with permissions (OR), one of this permissions is required to create pages with this page type |
|
| 453 | +$table->addInt("advanced", 10, true, false, 0); //flag, if page type is only shown in expert (advanced) mode |
|
| 454 | +$table->addInt("order", 10, true, false, 10); //order in admin area on page creation selection |
|
| 455 | 455 | $table->addInt("activated", 10, true, false, 1); |
| 456 | 456 | |
| 457 | 457 | //add keys to table |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $table->addInt("menuID", 10, true, false); |
| 513 | 513 | $table->addVarchar("title", 255, true); |
| 514 | 514 | $table->addVarchar("url", 600, true); |
| 515 | -$table->addVarchar("type", 255, true, "page");//page / link / url / external_link / js_link |
|
| 515 | +$table->addVarchar("type", 255, true, "page"); //page / link / url / external_link / js_link |
|
| 516 | 516 | $table->addVarchar("icon", 255, true, "none"); |
| 517 | 517 | $table->addVarchar("permissions", 600, true, "all"); |
| 518 | 518 | $table->addInt("login_required", 10, true, false, 0); |
@@ -590,9 +590,9 @@ discard block |
||
| 590 | 590 | $table->addVarchar("color", 50, true, "#0066ff"); |
| 591 | 591 | $table->addVarchar("rank_title", 255, true, "none"); |
| 592 | 592 | $table->addVarchar("rank_image", 255, true, "none"); |
| 593 | -$table->addInt("auto_assign_regist", 10, true, false, "0");//flag, if group is automatically assigned to registered users |
|
| 593 | +$table->addInt("auto_assign_regist", 10, true, false, "0"); //flag, if group is automatically assigned to registered users |
|
| 594 | 594 | $table->addInt("system_group", 10, true, false, "0"); |
| 595 | -$table->addInt("show", 10, true, false, "1");//show group name on index page |
|
| 595 | +$table->addInt("show", 10, true, false, "1"); //show group name on index page |
|
| 596 | 596 | $table->addInt("activated", 10, true, false, "1"); |
| 597 | 597 | |
| 598 | 598 | //https://www.w3schools.com/colors/colors_picker.asp |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | $table->addVarchar("description", 600, true); |
| 757 | 757 | $table->addVarchar("category", 255, true, "general"); |
| 758 | 758 | $table->addVarchar("owner", 255, true, "system"); |
| 759 | -$table->addInt("show", 10, true, false, 1);//flag, if permission is shown on permissions page |
|
| 759 | +$table->addInt("show", 10, true, false, 1); //flag, if permission is shown on permissions page |
|
| 760 | 760 | $table->addInt("order", 10, true, false, 100); |
| 761 | 761 | $table->addInt("activated", 10, true, false, 1); |
| 762 | 762 | |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | Settings::create("guest_username", "Guest", "Guest Username", "Username of not-logged-in users (default: Guest).", "system", "general"); |
| 899 | 899 | Settings::create("online_interval", 5, "Online Interval", "Interval-Angabe in minues, how long a user is set as online (since last page request). IMPORTANT: This is independent from login interval!", "system", "general"); |
| 900 | 900 | Settings::create("x_frame_options", "DENY", "X-Frame-Options header value (none = dont set header).", "values: DENY, SAMEORIGIN, ALLOW-FROM https://example.com/, none", "system", "security"); |
| 901 | -Settings::create("login_page","login", "Alias of Login Page (incl. directory, if necessary)", "Alias of Login Page (incl. directory, if necessary). Default: login", "system", "general"); |
|
| 901 | +Settings::create("login_page", "login", "Alias of Login Page (incl. directory, if necessary)", "Alias of Login Page (incl. directory, if necessary). Default: login", "system", "general"); |
|
| 902 | 902 | Settings::create("logout_page", "logout", "Alias of Logout Page (incl. directory, if necessary)", "Alias of Logout Page (incl. directory, if necessary). Default: logout", "system", "general"); |
| 903 | 903 | //Settings::create("base_dir", "/", "Base directory", "Base directory (if this CMS is installed in root directory, the right option is '/', but if it is installed in a sub directory, the right option is '/sub-dir/'). Default: /", "system", "general"); |
| 904 | 904 | Settings::create("css_cache_strategy", "expires_header", "CSS Browser Cache Strategy", "CSS Browser Cache Strategy, values: expires_header, etag_header, none", "system", "general"); |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | |
| 979 | 979 | echo "Create default page types if absent...<br />"; |
| 980 | 980 | |
| 981 | -PageType::createPageType("HTMLPage", "HTML page", false, 1);//order 1 - so show as first page type in admin area |
|
| 981 | +PageType::createPageType("HTMLPage", "HTML page", false, 1); //order 1 - so show as first page type in admin area |
|
| 982 | 982 | PageType::createPageType("Error404Page", "Error 404 page", true); |
| 983 | 983 | PageType::createPageType("Error403Page", "Error 403 page", true); |
| 984 | 984 | PageType::createPageType("IndexPage", "index page (supports extra template)", true); |
@@ -1009,7 +1009,7 @@ discard block |
||
| 1009 | 1009 | |
| 1010 | 1010 | echo "Create default permission categories...<br />"; |
| 1011 | 1011 | Permissions::createOrUpdateCategory("general", "General", 1); |
| 1012 | -Permissions::createOrUpdateCategory("users", "Users", 3);//user permissions, like "can_create_user" |
|
| 1012 | +Permissions::createOrUpdateCategory("users", "Users", 3); //user permissions, like "can_create_user" |
|
| 1013 | 1013 | Permissions::createOrUpdateCategory("groups", "Groups", 3); |
| 1014 | 1014 | Permissions::createOrUpdateCategory("pages", "Pages", 4); |
| 1015 | 1015 | Permissions::createOrUpdateCategory("permissions", "Permissions", 5); |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | Permissions::createPermission("can_see_own_permissions", "Can see own permissions", "User can see his own permissions", "permissions", "system", 1); |
| 1026 | 1026 | Permissions::createPermission("can_see_permissions", "Can see permissions of other users", "Can see permissions of other users", "permissions", "system", 2); |
| 1027 | 1027 | Permissions::createPermission("can_edit_group_permissions", "Can edit group permissions", "Can edit group permissions (expect administrator group)", "permissions", "system", 3); |
| 1028 | -Permissions::createPermission("can_edit_administrator_group_permissions", "Can edit administrator group permissions", "Can edit administrator group permissions", "permissions", "system", 4);//can edit permissions of group "administrator" |
|
| 1028 | +Permissions::createPermission("can_edit_administrator_group_permissions", "Can edit administrator group permissions", "Can edit administrator group permissions", "permissions", "system", 4); //can edit permissions of group "administrator" |
|
| 1029 | 1029 | |
| 1030 | 1030 | //user permissions |
| 1031 | 1031 | Permissions::createPermission("can_see_all_users", "Can see all users", "Can see all users and see their private information like mail address, ip address and so on", "users", "system", 1); |
@@ -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; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | protected $prepared_cache = array(); |
| 34 | 34 | |
| 35 | - public function connect ($config_path) { |
|
| 35 | + public function connect($config_path) { |
|
| 36 | 36 | if (file_exists($config_path)) { |
| 37 | 37 | require($config_path); |
| 38 | 38 | } else if (file_exists(CONFIG_PATH . $config_path)) { |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function update ($sql, $params = array()) { |
|
| 69 | + public function update($sql, $params = array()) { |
|
| 70 | 70 | $this->execute($sql, $params); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function close () { |
|
| 73 | + public function close() { |
|
| 74 | 74 | $this->conn = null; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function execute ($sql, $params = array()) { |
|
| 77 | + public function execute($sql, $params = array()) { |
|
| 78 | 78 | //dont allow SELECT statements |
| 79 | 79 | if (strstr($sql, "SELECT")) { |
| 80 | 80 | throw new IllegalArgumentException("method DBDriver::execute() isnt for select statements, its only for write statements, use getRow() or listRows() instead."); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | if (!$res) { |
| 106 | 106 | if (DEBUG_MODE) { |
| 107 | - echo "SQL Query: " + $sql; |
|
| 107 | + echo "SQL Query: " +$sql; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | //TODO: throw exception instead |
@@ -157,15 +157,15 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function listAllDrivers () { |
|
| 160 | + public function listAllDrivers() { |
|
| 161 | 161 | return $this->conn->getAvailableDrivers(); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - public function quote ($str) : string { |
|
| 164 | + public function quote($str) : string { |
|
| 165 | 165 | return $this->conn->quote($str); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - protected function getQuery ($sql, bool $allow_information_schema = false) { |
|
| 168 | + protected function getQuery($sql, bool $allow_information_schema = false) { |
|
| 169 | 169 | /** |
| 170 | 170 | * check, if sql query contains comments |
| 171 | 171 | * |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | return $this->queries; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - public function beginTransaction () { |
|
| 302 | + public function beginTransaction() { |
|
| 303 | 303 | $this->conn->beginTransaction(); |
| 304 | 304 | } |
| 305 | 305 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $this->memcache = new Memcache(); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function connect ($host, $port) { |
|
| 38 | + public function connect($host, $port) { |
|
| 39 | 39 | $this->memcache->connect($host, $port); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - protected function getKey ($area, $key) { |
|
| 91 | + protected function getKey($area, $key) { |
|
| 92 | 92 | return md5($area) . md5($key); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - private function listAllKeys ($limit = 10000) { |
|
| 95 | + private function listAllKeys($limit = 10000) { |
|
| 96 | 96 | //list with keys |
| 97 | 97 | $keys = array(); |
| 98 | 98 | |
@@ -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 | |
@@ -44,15 +44,15 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function contains ($area, $key) : bool { |
|
| 47 | + public function contains($area, $key) : bool { |
|
| 48 | 48 | return CACHING && file_exists($this->getFilePath($area, $key)); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - protected function getFilePath (string $area, string $key) : string { |
|
| 51 | + protected function getFilePath(string $area, string $key) : string { |
|
| 52 | 52 | return CACHE_PATH . md5($area) . "/" . md5($key) . ".php"; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - private function check_directory ($name) { |
|
| 55 | + private function check_directory($name) { |
|
| 56 | 56 | if (!file_exists(CACHE_PATH . $name . "/")) { |
| 57 | 57 | mkdir(CACHE_PATH . $name . "/"); |
| 58 | 58 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $area_path = CACHE_PATH . md5($area) . "/"; |
| 80 | 80 | |
| 81 | 81 | if (!empty($key)) { |
| 82 | - $file_path = CACHE_PATH . md5($area) . "/" + md5($key) + ".php"; |
|
| 82 | + $file_path = CACHE_PATH . md5($area) . "/" +md5($key) + ".php"; |
|
| 83 | 83 | |
| 84 | 84 | //check, if file exists |
| 85 | 85 | if (file_exists($file_path)) { |
@@ -94,15 +94,15 @@ discard block |
||
| 94 | 94 | // TODO: Implement clear() method. |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - protected function rrmdir ($dir, $cache_dir) { |
|
| 97 | + protected function rrmdir($dir, $cache_dir) { |
|
| 98 | 98 | if (is_dir($dir)) { |
| 99 | 99 | $objects = scandir($dir); |
| 100 | 100 | foreach ($objects as $object) { |
| 101 | 101 | if ($object != "." && $object != "..") { |
| 102 | - if (is_dir($dir."/".$object)) |
|
| 103 | - $this->rrmdir($dir."/".$object, $cache_dir); |
|
| 102 | + if (is_dir($dir . "/" . $object)) |
|
| 103 | + $this->rrmdir($dir . "/" . $object, $cache_dir); |
|
| 104 | 104 | else |
| 105 | - unlink($dir."/".$object); |
|
| 105 | + unlink($dir . "/" . $object); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
@@ -99,10 +99,11 @@ |
||
| 99 | 99 | $objects = scandir($dir); |
| 100 | 100 | foreach ($objects as $object) { |
| 101 | 101 | if ($object != "." && $object != "..") { |
| 102 | - if (is_dir($dir."/".$object)) |
|
| 103 | - $this->rrmdir($dir."/".$object, $cache_dir); |
|
| 104 | - else |
|
| 105 | - unlink($dir."/".$object); |
|
| 102 | + if (is_dir($dir."/".$object)) { |
|
| 103 | + $this->rrmdir($dir."/".$object, $cache_dir); |
|
| 104 | + } else { |
|
| 105 | + unlink($dir."/".$object); |
|
| 106 | + } |
|
| 106 | 107 | } |
| 107 | 108 | } |
| 108 | 109 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | |
| 18 | 18 | class PostGreSQLDriver extends MySQLDriver { |
| 19 | 19 | |
| 20 | - public function connect ($config_path) { |
|
| 20 | + public function connect($config_path) { |
|
| 21 | 21 | if (file_exists($config_path)) { |
| 22 | 22 | require($config_path); |
| 23 | 23 | } else if (file_exists(CONFIG_PATH . $config_path)) { |
@@ -163,7 +163,7 @@ |
||
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - protected function getKey ($area, $key) { |
|
| 166 | + protected function getKey($area, $key) { |
|
| 167 | 167 | return md5($area) . md5($key); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | class Packages { |
| 20 | 20 | |
| 21 | - public static function listPackages (bool $installed_required = true) : array { |
|
| 21 | + public static function listPackages(bool $installed_required = true) : array { |
|
| 22 | 22 | |
| 23 | 23 | if (!file_exists(ROOT_PATH . "store/package_list.php")) { |
| 24 | 24 | return array(); |
@@ -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 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | protected static $cache_instances = array(); |
| 34 | 34 | |
| 35 | - public static function init () { |
|
| 35 | + public static function init() { |
|
| 36 | 36 | require(CONFIG_PATH . "cache.php"); |
| 37 | 37 | |
| 38 | 38 | if (!isset($config['first_lvl_cache']) || !isset($config['first_lvl_cache']['class_name'])) { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | //TODO: load other caches |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public static function &getCache ($name = "") : ICache { |
|
| 99 | + public static function &getCache($name = "") : ICache { |
|
| 100 | 100 | if (empty($name)) { |
| 101 | 101 | return self::$instance; |
| 102 | 102 | } else { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public static function &get2ndLvlCache () : ICache { |
|
| 112 | + public static function &get2ndLvlCache() : ICache { |
|
| 113 | 113 | if (self::$second_level_cache == null) { |
| 114 | 114 | throw new Exception("second level cache is null."); |
| 115 | 115 | } |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | return self::$second_level_cache; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public static function containsCache ($name) { |
|
| 124 | + public static function containsCache($name) { |
|
| 125 | 125 | return isset(self::$cache_instances[$name]); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public static function putCache ($name, &$cache_instance) { |
|
| 128 | + public static function putCache($name, &$cache_instance) { |
|
| 129 | 129 | if ($name == null || $name == "") { |
| 130 | 130 | throw new NullPointerException("cache name cannot be null."); |
| 131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public static function removeCache ($name) { |
|
| 147 | + public static function removeCache($name) { |
|
| 148 | 148 | unset(self::$cache_instances[$name]); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -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 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | class AutoLoaderCache { |
| 20 | 20 | |
| 21 | - public static function init () { |
|
| 21 | + public static function init() { |
|
| 22 | 22 | //check, if directory autoloader in cache exists |
| 23 | 23 | if (!file_exists(CACHE_PATH . "autoloader")) { |
| 24 | 24 | mkdir(CACHE_PATH . "autoloader"); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | self::createCache(); |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | - public static function load () { |
|
| 37 | + public static function load() { |
|
| 38 | 38 | if (!file_exists(STORE_PATH . "autoloader/autoloader.php")) { |
| 39 | 39 | throw new ConfigurationException("autoloader configuration not found in store."); |
| 40 | 40 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | //load classes from cache to save I/O |
| 46 | 46 | require(CACHE_PATH . "autoloader/preloaded_classes.php"); |
| 47 | 47 | } |
| 48 | - private static function createCache () { |
|
| 48 | + private static function createCache() { |
|
| 49 | 49 | require(STORE_PATH . "autoloader/autoloader.php"); |
| 50 | 50 | //create new cache file |
| 51 | 51 | $data = ""; |