@@ -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 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | protected static $csrf_token = ""; |
| 6 | 6 | |
| 7 | - public static function checkPHPOptions () { |
|
| 7 | + public static function checkPHPOptions() { |
|
| 8 | 8 | if (get_magic_quotes_gpc()) { |
| 9 | 9 | throw new SecurityException("magic quotes is on."); |
| 10 | 10 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | libxml_disable_entity_loader(true); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public static function check () { |
|
| 24 | + public static function check() { |
|
| 25 | 25 | //check php options |
| 26 | 26 | self::checkPHPOptions(); |
| 27 | 27 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | self::initCSRFToken(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - protected static function initCSRFToken () { |
|
| 71 | + protected static function initCSRFToken() { |
|
| 72 | 72 | if (!isset($_SESSION['csrf_token'])) { |
| 73 | 73 | /*self::$csrf_token = hash_hmac( |
| 74 | 74 | 'sha512', |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | );*/ |
| 78 | 78 | |
| 79 | 79 | //generate new random token with 32 bytes |
| 80 | - self::$csrf_token = base64_encode( openssl_random_pseudo_bytes(32)); |
|
| 80 | + self::$csrf_token = base64_encode(openssl_random_pseudo_bytes(32)); |
|
| 81 | 81 | |
| 82 | 82 | $_SESSION['csrf_token'] = self::$csrf_token; |
| 83 | 83 | } else { |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public static function getCSRFToken () { |
|
| 89 | + public static function getCSRFToken() { |
|
| 90 | 90 | //return CSRF token |
| 91 | 91 | return self::$csrf_token; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public static function getCSRFTokenField () { |
|
| 94 | + public static function getCSRFTokenField() { |
|
| 95 | 95 | return "<input type=\"hidden\" name=<\"csrf_token\" value=\"" . self::$csrf_token . "\" />"; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public static function checkCSRFToken ($value = null) { |
|
| 98 | + public static function checkCSRFToken($value = null) { |
|
| 99 | 99 | if (is_null($value)) { |
| 100 | 100 | if (!isset($_REQUEST['csrf_token']) || empty($_REQUEST['csrf_token'])) { |
| 101 | 101 | return false; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | return self::$csrf_token === $value; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public static function containsPort ($address) { |
|
| 110 | + public static function containsPort($address) { |
|
| 111 | 111 | if (strpos($address, ":") === false) { |
| 112 | 112 | return false; |
| 113 | 113 | } |
@@ -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 | |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | protected static $settings = array(); |
| 33 | 33 | protected static $instance = null; |
| 34 | 34 | |
| 35 | - public function __construct () { |
|
| 35 | + public function __construct() { |
|
| 36 | 36 | // |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public static function &singleton () { |
|
| 39 | + public static function &singleton() { |
|
| 40 | 40 | |
| 41 | 41 | if (self::$instance == null) { |
| 42 | 42 | self::$instance = new Registry(); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function storeObject ($key, &$object) { |
|
| 49 | + public function storeObject($key, &$object) { |
|
| 50 | 50 | if (is_string($object)) { |
| 51 | 51 | $object = new $object(); |
| 52 | 52 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | self::$objects[$key] = $object; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function getObject ($key) { |
|
| 57 | + public function getObject($key) { |
|
| 58 | 58 | if (!isset(self::$objects[$key])) { |
| 59 | 59 | throw new IllegalStateException("registry key '" . $key . "' doesnt exists."); |
| 60 | 60 | } |
@@ -62,15 +62,15 @@ discard block |
||
| 62 | 62 | if (is_object(self::$objects[$key])) { |
| 63 | 63 | return self::$objects[$key]; |
| 64 | 64 | } else { |
| 65 | - throw new IllegalStateException("key '" . $key. "' isnt an object."); |
|
| 65 | + throw new IllegalStateException("key '" . $key . "' isnt an object."); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function setSetting ($key, $value) { |
|
| 69 | + public function setSetting($key, $value) { |
|
| 70 | 70 | self::$settings[$key] = $value; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function getSetting ($key) { |
|
| 73 | + public function getSetting($key) { |
|
| 74 | 74 | if (!isset(self::$settings[$key])) { |
| 75 | 75 | throw new IllegalStateException("Registry-Settings key '" . htmlentities($key) . "' doesnt exists."); |
| 76 | 76 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | return self::$settings[$key]; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function listSettings () { |
|
| 81 | + public function listSettings() { |
|
| 82 | 82 | return self::$settings; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | interface ICache { |
| 19 | 19 | |
| 20 | - public function init ($config); |
|
| 20 | + public function init($config); |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * put session |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | * @param $value cache entry value, can also be an object |
| 28 | 28 | * @param $ttl time to live of cache entry in seconds (optional) |
| 29 | 29 | */ |
| 30 | - public function put ($area, $key, $value, $ttl = 180 * 60); |
|
| 30 | + public function put($area, $key, $value, $ttl = 180 * 60); |
|
| 31 | 31 | |
| 32 | - public function get ($area, $key); |
|
| 32 | + public function get($area, $key); |
|
| 33 | 33 | |
| 34 | - public function contains ($area, $key) : bool; |
|
| 34 | + public function contains($area, $key) : bool; |
|
| 35 | 35 | |
| 36 | - public function clear ($area = "", $key = ""); |
|
| 36 | + public function clear($area = "", $key = ""); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -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 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | protected static $db_settings = null; |
| 14 | 14 | |
| 15 | - public static function &getInstance ($name = "") : DBDriver { |
|
| 15 | + public static function &getInstance($name = "") : DBDriver { |
|
| 16 | 16 | if ($name == "") { |
| 17 | 17 | $name = "default"; |
| 18 | 18 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | return self::$instances[$name]; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public static function createInstance ($name = "default") { |
|
| 28 | + public static function createInstance($name = "default") { |
|
| 29 | 29 | if ($name == "default") { |
| 30 | 30 | //get database configuration |
| 31 | 31 | require(CONFIG_PATH . "database.php"); |
@@ -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"; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * initialize classloader (called only once / request) |
| 27 | 27 | */ |
| 28 | - public static function init () { |
|
| 28 | + public static function init() { |
|
| 29 | 29 | |
| 30 | 30 | //register autoloader |
| 31 | 31 | spl_autoload_register('cms_autoloader'); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public static function rebuildCache () { |
|
| 46 | + public static function rebuildCache() { |
|
| 47 | 47 | |
| 48 | 48 | require_once(ROOT_PATH . "system/core/classes/packages.php"); |
| 49 | 49 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | /** |
| 95 | 95 | * autoload function |
| 96 | 96 | */ |
| 97 | -function cms_autoloader ($classname) { |
|
| 97 | +function cms_autoloader($classname) { |
|
| 98 | 98 | |
| 99 | 99 | ClassLoader::$loadedClasses++; |
| 100 | 100 | |
@@ -27,60 +27,60 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Events { |
| 29 | 29 | |
| 30 | - protected static $events = array(); |
|
| 31 | - |
|
| 32 | - protected static $isInitialized = false; |
|
| 33 | - |
|
| 34 | - public static function init () { |
|
| 35 | - if (Cache::getCache()->contains("events", "events")) { |
|
| 36 | - self::$events = Cache::getCache()->get("events", "events"); |
|
| 37 | - } else { |
|
| 38 | - //load events from database |
|
| 39 | - $rows = Database::getInstance()->listRows("SELECT * FROM `{PRAEFIX}events` WHERE `activated` = '1'; "); |
|
| 40 | - |
|
| 41 | - //iterate through rows |
|
| 42 | - foreach ($rows as $row) { |
|
| 43 | - //get name of event |
|
| 44 | - $name = $row['name']; |
|
| 45 | - |
|
| 46 | - //check, if name exists in array |
|
| 47 | - if (!isset(self::$events[$name])) { |
|
| 48 | - self::$events[$name] = array(); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - //add row to array |
|
| 52 | - self::$events[$name][] = $row; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - //put events into cache |
|
| 56 | - Cache::getCache()->put("events", "events", self::$events); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - //set initialized flag to true |
|
| 60 | - self::$isInitialized = true; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - public static function throwEvent ($name, $params = array()) { |
|
| 64 | - if (!is_array($params)) { |
|
| 65 | - throw new IllegalArgumentException("second parameter params has to be an array."); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - //check, if events was initialized first |
|
| 69 | - if (!self::$isInitialized) { |
|
| 70 | - //initialize events |
|
| 71 | - self::init(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if (isset(self::$events[$name])) { |
|
| 75 | - foreach (self::$events as $event) { |
|
| 76 | - self::executeEvent($event, $params); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - protected static function executeEvent ($row, $params) { |
|
| 82 | - //TODO: execute event here |
|
| 83 | - } |
|
| 30 | + protected static $events = array(); |
|
| 31 | + |
|
| 32 | + protected static $isInitialized = false; |
|
| 33 | + |
|
| 34 | + public static function init () { |
|
| 35 | + if (Cache::getCache()->contains("events", "events")) { |
|
| 36 | + self::$events = Cache::getCache()->get("events", "events"); |
|
| 37 | + } else { |
|
| 38 | + //load events from database |
|
| 39 | + $rows = Database::getInstance()->listRows("SELECT * FROM `{PRAEFIX}events` WHERE `activated` = '1'; "); |
|
| 40 | + |
|
| 41 | + //iterate through rows |
|
| 42 | + foreach ($rows as $row) { |
|
| 43 | + //get name of event |
|
| 44 | + $name = $row['name']; |
|
| 45 | + |
|
| 46 | + //check, if name exists in array |
|
| 47 | + if (!isset(self::$events[$name])) { |
|
| 48 | + self::$events[$name] = array(); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + //add row to array |
|
| 52 | + self::$events[$name][] = $row; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + //put events into cache |
|
| 56 | + Cache::getCache()->put("events", "events", self::$events); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + //set initialized flag to true |
|
| 60 | + self::$isInitialized = true; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + public static function throwEvent ($name, $params = array()) { |
|
| 64 | + if (!is_array($params)) { |
|
| 65 | + throw new IllegalArgumentException("second parameter params has to be an array."); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + //check, if events was initialized first |
|
| 69 | + if (!self::$isInitialized) { |
|
| 70 | + //initialize events |
|
| 71 | + self::init(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if (isset(self::$events[$name])) { |
|
| 75 | + foreach (self::$events as $event) { |
|
| 76 | + self::executeEvent($event, $params); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + protected static function executeEvent ($row, $params) { |
|
| 82 | + //TODO: execute event here |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | protected static $isInitialized = false; |
| 33 | 33 | |
| 34 | - public static function init () { |
|
| 34 | + public static function init() { |
|
| 35 | 35 | if (Cache::getCache()->contains("events", "events")) { |
| 36 | 36 | self::$events = Cache::getCache()->get("events", "events"); |
| 37 | 37 | } else { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | self::$isInitialized = true; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public static function throwEvent ($name, $params = array()) { |
|
| 63 | + public static function throwEvent($name, $params = array()) { |
|
| 64 | 64 | if (!is_array($params)) { |
| 65 | 65 | throw new IllegalArgumentException("second parameter params has to be an array."); |
| 66 | 66 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - protected static function executeEvent ($row, $params) { |
|
| 81 | + protected static function executeEvent($row, $params) { |
|
| 82 | 82 | //TODO: execute event here |
| 83 | 83 | } |
| 84 | 84 | |
@@ -11,79 +11,79 @@ |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | public static function isModRewriteAvailable () { |
| 14 | - if (function_exists("apache_get_modules")) { |
|
| 15 | - if (in_array('mod_rewrite',apache_get_modules())) { |
|
| 16 | - return true; |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - return false; |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - return false; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public static function startsWith ($haystack, $needle) : bool { |
|
| 26 | - //https://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php |
|
| 27 | - |
|
| 28 | - $length = strlen($needle); |
|
| 29 | - return (substr($haystack, 0, $length) === $needle); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - public static function endsWith ($haystack, $needle) : bool { |
|
| 33 | - $length = strlen($needle); |
|
| 34 | - |
|
| 35 | - return $length === 0 || (substr($haystack, -$length) === $needle); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * get IP address of client browser |
|
| 40 | - * |
|
| 41 | - * @return IPv4 / IPv6 address (up to 45 characters) |
|
| 42 | - */ |
|
| 43 | - public static function getClientIP () : string { |
|
| 44 | - //https://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php |
|
| 45 | - |
|
| 46 | - $ip = ""; |
|
| 47 | - |
|
| 48 | - if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 49 | - $ip = $_SERVER['HTTP_CLIENT_IP']; |
|
| 50 | - } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 51 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 52 | - } else { |
|
| 53 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return $ip; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public static function strEqs (string $str1, string $str2) : bool { |
|
| 60 | - return strcmp($str1, $str2) === 0; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Generate a random string, using a cryptographically secure |
|
| 65 | - * pseudorandom number generator (random_int) |
|
| 66 | - * |
|
| 67 | - * For PHP 7, random_int is a PHP core function |
|
| 68 | - * For PHP 5.x, depends on https://github.com/paragonie/random_compat |
|
| 69 | - * |
|
| 70 | - * @param int $length How many characters do we want? |
|
| 71 | - * @param string $keyspace A string of all possible characters |
|
| 72 | - * to select from |
|
| 73 | - * |
|
| 74 | - * @link https://stackoverflow.com/questions/4356289/php-random-string-generator/31107425#31107425 |
|
| 75 | - * |
|
| 76 | - * @return string |
|
| 77 | - */ |
|
| 78 | - public static function randomString(int $length, string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') : string { |
|
| 79 | - $str = ''; |
|
| 80 | - $max = mb_strlen($keyspace, '8bit') - 1; |
|
| 81 | - |
|
| 82 | - for ($i = 0; $i < $length; ++$i) { |
|
| 83 | - $str .= $keyspace[random_int(0, $max)]; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - return $str; |
|
| 87 | - } |
|
| 14 | + if (function_exists("apache_get_modules")) { |
|
| 15 | + if (in_array('mod_rewrite',apache_get_modules())) { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + return false; |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + return false; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public static function startsWith ($haystack, $needle) : bool { |
|
| 26 | + //https://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php |
|
| 27 | + |
|
| 28 | + $length = strlen($needle); |
|
| 29 | + return (substr($haystack, 0, $length) === $needle); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + public static function endsWith ($haystack, $needle) : bool { |
|
| 33 | + $length = strlen($needle); |
|
| 34 | + |
|
| 35 | + return $length === 0 || (substr($haystack, -$length) === $needle); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * get IP address of client browser |
|
| 40 | + * |
|
| 41 | + * @return IPv4 / IPv6 address (up to 45 characters) |
|
| 42 | + */ |
|
| 43 | + public static function getClientIP () : string { |
|
| 44 | + //https://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php |
|
| 45 | + |
|
| 46 | + $ip = ""; |
|
| 47 | + |
|
| 48 | + if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 49 | + $ip = $_SERVER['HTTP_CLIENT_IP']; |
|
| 50 | + } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 51 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 52 | + } else { |
|
| 53 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return $ip; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public static function strEqs (string $str1, string $str2) : bool { |
|
| 60 | + return strcmp($str1, $str2) === 0; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Generate a random string, using a cryptographically secure |
|
| 65 | + * pseudorandom number generator (random_int) |
|
| 66 | + * |
|
| 67 | + * For PHP 7, random_int is a PHP core function |
|
| 68 | + * For PHP 5.x, depends on https://github.com/paragonie/random_compat |
|
| 69 | + * |
|
| 70 | + * @param int $length How many characters do we want? |
|
| 71 | + * @param string $keyspace A string of all possible characters |
|
| 72 | + * to select from |
|
| 73 | + * |
|
| 74 | + * @link https://stackoverflow.com/questions/4356289/php-random-string-generator/31107425#31107425 |
|
| 75 | + * |
|
| 76 | + * @return string |
|
| 77 | + */ |
|
| 78 | + public static function randomString(int $length, string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') : string { |
|
| 79 | + $str = ''; |
|
| 80 | + $max = mb_strlen($keyspace, '8bit') - 1; |
|
| 81 | + |
|
| 82 | + for ($i = 0; $i < $length; ++$i) { |
|
| 83 | + $str .= $keyspace[random_int(0, $max)]; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + return $str; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | } |
@@ -2,17 +2,17 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class PHPUtils { |
| 4 | 4 | |
| 5 | - public static function isMemcacheAvailable () { |
|
| 5 | + public static function isMemcacheAvailable() { |
|
| 6 | 6 | return class_exists('Memcache'); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | - public static function isMemcachedAvailable () { |
|
| 9 | + public static function isMemcachedAvailable() { |
|
| 10 | 10 | return class_exists('Memcached'); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - public static function isModRewriteAvailable () { |
|
| 13 | + public static function isModRewriteAvailable() { |
|
| 14 | 14 | if (function_exists("apache_get_modules")) { |
| 15 | - if (in_array('mod_rewrite',apache_get_modules())) { |
|
| 15 | + if (in_array('mod_rewrite', apache_get_modules())) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | return false; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public static function startsWith ($haystack, $needle) : bool { |
|
| 25 | + public static function startsWith($haystack, $needle) : bool { |
|
| 26 | 26 | //https://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php |
| 27 | 27 | |
| 28 | 28 | $length = strlen($needle); |
| 29 | 29 | return (substr($haystack, 0, $length) === $needle); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public static function endsWith ($haystack, $needle) : bool { |
|
| 32 | + public static function endsWith($haystack, $needle) : bool { |
|
| 33 | 33 | $length = strlen($needle); |
| 34 | 34 | |
| 35 | 35 | return $length === 0 || (substr($haystack, -$length) === $needle); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return IPv4 / IPv6 address (up to 45 characters) |
| 42 | 42 | */ |
| 43 | - public static function getClientIP () : string { |
|
| 43 | + public static function getClientIP() : string { |
|
| 44 | 44 | //https://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php |
| 45 | 45 | |
| 46 | 46 | $ip = ""; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | return $ip; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - public static function strEqs (string $str1, string $str2) : bool { |
|
| 59 | + public static function strEqs(string $str1, string $str2) : bool { |
|
| 60 | 60 | return strcmp($str1, $str2) === 0; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (PHP_MAJOR_VERSION < 7) { |
| 20 | - echo "CMS is required PHP 7.0.0 or greater! Please install PHP 7 (current version: " . PHP_VERSION . ")."; |
|
| 21 | - ob_flush(); |
|
| 22 | - exit; |
|
| 20 | + echo "CMS is required PHP 7.0.0 or greater! Please install PHP 7 (current version: " . PHP_VERSION . ")."; |
|
| 21 | + ob_flush(); |
|
| 22 | + exit; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | register_shutdown_function(function () { |
| 26 | - //flush gzip cache |
|
| 27 | - ob_end_flush(); |
|
| 26 | + //flush gzip cache |
|
| 27 | + ob_end_flush(); |
|
| 28 | 28 | }); |
| 29 | 29 | |
| 30 | 30 | //define some constants |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | //load pre-loaded classes, if option is enabled |
| 55 | 55 | if (OPTION_PRELOAD_CLASSES) { |
| 56 | - AutoLoaderCache::load(); |
|
| 56 | + AutoLoaderCache::load(); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | //initialize cache |
@@ -77,20 +77,20 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | //check for maintenance mode |
| 79 | 79 | if (Settings::get("maintenance_mode_enabled", false) == true) { |
| 80 | - $html = Settings::get("maintenance_text", "Maintenance mode enabled!"); |
|
| 81 | - |
|
| 82 | - //throw event |
|
| 83 | - Events::throwEvent("maintenance_html", array( |
|
| 84 | - 'html' => &$html |
|
| 85 | - )); |
|
| 86 | - |
|
| 87 | - if (file_exists(ROOT_PATH . "maintenance.html")) { |
|
| 88 | - echo file_get_contents(ROOT_PATH . "maintenance.html"); |
|
| 89 | - } else if (file_exists(ROOT_PATH . "setup/maintenance.html")) { |
|
| 90 | - echo file_get_contents(ROOT_PATH . "setup/maintenance.html"); |
|
| 91 | - } else { |
|
| 92 | - echo $html; |
|
| 93 | - } |
|
| 80 | + $html = Settings::get("maintenance_text", "Maintenance mode enabled!"); |
|
| 81 | + |
|
| 82 | + //throw event |
|
| 83 | + Events::throwEvent("maintenance_html", array( |
|
| 84 | + 'html' => &$html |
|
| 85 | + )); |
|
| 86 | + |
|
| 87 | + if (file_exists(ROOT_PATH . "maintenance.html")) { |
|
| 88 | + echo file_get_contents(ROOT_PATH . "maintenance.html"); |
|
| 89 | + } else if (file_exists(ROOT_PATH . "setup/maintenance.html")) { |
|
| 90 | + echo file_get_contents(ROOT_PATH . "setup/maintenance.html"); |
|
| 91 | + } else { |
|
| 92 | + echo $html; |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /*set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) { |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | exit; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -register_shutdown_function(function () { |
|
| 25 | +register_shutdown_function(function() { |
|
| 26 | 26 | //flush gzip cache |
| 27 | 27 | ob_end_flush(); |
| 28 | 28 | }); |
@@ -27,9 +27,9 @@ |
||
| 27 | 27 | |
| 28 | 28 | interface Validator_Base { |
| 29 | 29 | |
| 30 | - public function isValide ($value) : bool; |
|
| 30 | + public function isValide ($value) : bool; |
|
| 31 | 31 | |
| 32 | - public function validate ($value); |
|
| 32 | + public function validate ($value); |
|
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | |
@@ -27,9 +27,9 @@ |
||
| 27 | 27 | |
| 28 | 28 | interface Validator_Base { |
| 29 | 29 | |
| 30 | - public function isValide ($value) : bool; |
|
| 30 | + public function isValide($value) : bool; |
|
| 31 | 31 | |
| 32 | - public function validate ($value); |
|
| 32 | + public function validate($value); |
|
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | |