@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * initialize classloader (called only once / request) |
| 29 | 29 | */ |
| 30 | - public static function init () { |
|
| 30 | + public static function init() { |
|
| 31 | 31 | |
| 32 | 32 | //register autoloader |
| 33 | 33 | spl_autoload_register('cms_autoloader'); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public static function rebuildCache () { |
|
| 48 | + public static function rebuildCache() { |
|
| 49 | 49 | |
| 50 | 50 | require_once(ROOT_PATH . "system/core/classes/packages.php"); |
| 51 | 51 | |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | /** |
| 95 | 95 | * add classloader for specific namespace prefix |
| 96 | 96 | */ |
| 97 | - public static function addLoader (string $prefix, callable $func) { |
|
| 97 | + public static function addLoader(string $prefix, callable $func) { |
|
| 98 | 98 | $prefix = strtolower($prefix); |
| 99 | 99 | self::$namespace_autoloader[$prefix] = $func; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public static function removeLoader (string $prefix) { |
|
| 102 | + public static function removeLoader(string $prefix) { |
|
| 103 | 103 | $prefix = strtolower($prefix); |
| 104 | 104 | unset(self::$namespace_autoloader[$prefix]); |
| 105 | 105 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | /** |
| 110 | 110 | * autoload function |
| 111 | 111 | */ |
| 112 | -function cms_autoloader ($classname) { |
|
| 112 | +function cms_autoloader($classname) { |
|
| 113 | 113 | |
| 114 | 114 | ClassLoader::$loadedClasses++; |
| 115 | 115 | |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | * add classloader for specific namespace prefix |
| 96 | 96 | */ |
| 97 | 97 | public static function addLoader (string $prefix, callable $func) { |
| 98 | - $prefix = strtolower($prefix); |
|
| 99 | - self::$namespace_autoloader[$prefix] = $func; |
|
| 100 | - } |
|
| 98 | + $prefix = strtolower($prefix); |
|
| 99 | + self::$namespace_autoloader[$prefix] = $func; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - public static function removeLoader (string $prefix) { |
|
| 103 | - $prefix = strtolower($prefix); |
|
| 104 | - unset(self::$namespace_autoloader[$prefix]); |
|
| 105 | - } |
|
| 102 | + public static function removeLoader (string $prefix) { |
|
| 103 | + $prefix = strtolower($prefix); |
|
| 104 | + unset(self::$namespace_autoloader[$prefix]); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | |
@@ -122,66 +122,66 @@ discard block |
||
| 122 | 122 | require(ROOT_PATH . "system/core/classes/" . strtolower($classname) . ".php"); |
| 123 | 123 | return null; |
| 124 | 124 | } else if (file_exists(ROOT_PATH . "system/core/exception/" . strtolower($classname) . ".php")) { |
| 125 | - require(ROOT_PATH . "system/core/exception/" . strtolower($classname) . ".php"); |
|
| 126 | - return null; |
|
| 127 | - } else if (file_exists(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php")) { |
|
| 128 | - require(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php"); |
|
| 129 | - return null; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - //check, if class belongs to dwoo template engine |
|
| 125 | + require(ROOT_PATH . "system/core/exception/" . strtolower($classname) . ".php"); |
|
| 126 | + return null; |
|
| 127 | + } else if (file_exists(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php")) { |
|
| 128 | + require(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php"); |
|
| 129 | + return null; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + //check, if class belongs to dwoo template engine |
|
| 133 | 133 | if (PHPUtils::startsWith($classname, "Dwoo")) { |
| 134 | 134 | if (class_exists("DwooAutoloader", true)) { |
| 135 | 135 | DwooAutoloader::loadClass($classname); |
| 136 | 136 | return; |
| 137 | 137 | } else { |
| 138 | - echo "Could not load Dwoo template engine class " . $classname . "!"; |
|
| 138 | + echo "Could not load Dwoo template engine class " . $classname . "!"; |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | //check, if we have to use namespace classloading |
| 143 | - if (PHPUtils::containsStr($classname, "\\")) { |
|
| 144 | - //we have to use namespace classloading |
|
| 145 | - if (PHPUtils::startsWith($classname, "\\")) { |
|
| 146 | - //use normal class loading |
|
| 147 | - $classname = substr($classname, 1); |
|
| 148 | - } else { |
|
| 149 | - $array = explode("\\", strtolower($classname)); |
|
| 150 | - |
|
| 151 | - if ($array[0] === "plugin") { |
|
| 152 | - $array1 = array(); |
|
| 153 | - |
|
| 154 | - for ($i = 2; $i < count($array); $i++) { |
|
| 155 | - $array1[] = $array[$i]; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - $file_name = implode("/", $array1); |
|
| 159 | - |
|
| 160 | - //load plugin class |
|
| 161 | - $path = PLUGIN_PATH . $array[1] . "/classes/" . $file_name . ".php"; |
|
| 162 | - |
|
| 163 | - if (file_exists($path)) { |
|
| 164 | - require($path); |
|
| 165 | - } else { |
|
| 166 | - $expected_str = (DEBUG_MODE ? " (expected path: " . $path . ")" : ""); |
|
| 167 | - echo "Could not load plugin-class with namespace " . $classname . $expected_str . "!"; |
|
| 168 | - } |
|
| 169 | - } else { |
|
| 170 | - //check, if there is a classloader for this prefix |
|
| 171 | - if (isset(ClassLoader::$namespace_autoloader[$array[0]])) { |
|
| 172 | - //get function |
|
| 173 | - $func = ClassLoader::$namespace_autoloader[$array[0]]; |
|
| 174 | - |
|
| 175 | - //call func |
|
| 176 | - $func($classname); |
|
| 177 | - } else { |
|
| 178 | - throw new IllegalStateException("Cannot load namespace class '" . $classname . "' with unknown prefix '" . $array[0] . "'!"); |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - return; |
|
| 183 | - } |
|
| 184 | - } |
|
| 143 | + if (PHPUtils::containsStr($classname, "\\")) { |
|
| 144 | + //we have to use namespace classloading |
|
| 145 | + if (PHPUtils::startsWith($classname, "\\")) { |
|
| 146 | + //use normal class loading |
|
| 147 | + $classname = substr($classname, 1); |
|
| 148 | + } else { |
|
| 149 | + $array = explode("\\", strtolower($classname)); |
|
| 150 | + |
|
| 151 | + if ($array[0] === "plugin") { |
|
| 152 | + $array1 = array(); |
|
| 153 | + |
|
| 154 | + for ($i = 2; $i < count($array); $i++) { |
|
| 155 | + $array1[] = $array[$i]; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + $file_name = implode("/", $array1); |
|
| 159 | + |
|
| 160 | + //load plugin class |
|
| 161 | + $path = PLUGIN_PATH . $array[1] . "/classes/" . $file_name . ".php"; |
|
| 162 | + |
|
| 163 | + if (file_exists($path)) { |
|
| 164 | + require($path); |
|
| 165 | + } else { |
|
| 166 | + $expected_str = (DEBUG_MODE ? " (expected path: " . $path . ")" : ""); |
|
| 167 | + echo "Could not load plugin-class with namespace " . $classname . $expected_str . "!"; |
|
| 168 | + } |
|
| 169 | + } else { |
|
| 170 | + //check, if there is a classloader for this prefix |
|
| 171 | + if (isset(ClassLoader::$namespace_autoloader[$array[0]])) { |
|
| 172 | + //get function |
|
| 173 | + $func = ClassLoader::$namespace_autoloader[$array[0]]; |
|
| 174 | + |
|
| 175 | + //call func |
|
| 176 | + $func($classname); |
|
| 177 | + } else { |
|
| 178 | + throw new IllegalStateException("Cannot load namespace class '" . $classname . "' with unknown prefix '" . $array[0] . "'!"); |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + return; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | $array = explode("_", strtolower($classname)); |
| 187 | 187 | |
@@ -204,32 +204,32 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | } else if (sizeof($array) == 2) { |
| 207 | - if ($array[0] == "validator") { |
|
| 208 | - if (file_exists(ROOT_PATH . "system/core/validator/" . $array[1] . ".php")) { |
|
| 209 | - require(ROOT_PATH . "system/core/validator/" . $array[1] . ".php"); |
|
| 210 | - } else { |
|
| 211 | - echo "Could not load validator class " . $classname . "!"; |
|
| 212 | - } |
|
| 213 | - } else if ($array[0] == "datatype") { |
|
| 214 | - if (file_exists(ROOT_PATH . "system/core/datatype/" . $array[1] . ".php")) { |
|
| 215 | - require(ROOT_PATH . "system/core/datatype/" . $array[1] . ".php"); |
|
| 216 | - } else { |
|
| 217 | - echo "Could not load datatype class " . $classname . "!"; |
|
| 218 | - } |
|
| 219 | - } else if (strpos($classname, "Plugin")) { |
|
| 220 | - //dwoo tries several times to load a class - with and without namespace, so we hide this error message |
|
| 221 | - } else { |
|
| 222 | - echo "Could not load class " . $classname . ", unknown prefix '" . $array[0] . "'!"; |
|
| 207 | + if ($array[0] == "validator") { |
|
| 208 | + if (file_exists(ROOT_PATH . "system/core/validator/" . $array[1] . ".php")) { |
|
| 209 | + require(ROOT_PATH . "system/core/validator/" . $array[1] . ".php"); |
|
| 210 | + } else { |
|
| 211 | + echo "Could not load validator class " . $classname . "!"; |
|
| 212 | + } |
|
| 213 | + } else if ($array[0] == "datatype") { |
|
| 214 | + if (file_exists(ROOT_PATH . "system/core/datatype/" . $array[1] . ".php")) { |
|
| 215 | + require(ROOT_PATH . "system/core/datatype/" . $array[1] . ".php"); |
|
| 216 | + } else { |
|
| 217 | + echo "Could not load datatype class " . $classname . "!"; |
|
| 218 | + } |
|
| 219 | + } else if (strpos($classname, "Plugin")) { |
|
| 220 | + //dwoo tries several times to load a class - with and without namespace, so we hide this error message |
|
| 221 | + } else { |
|
| 222 | + echo "Could not load class " . $classname . ", unknown prefix '" . $array[0] . "'!"; |
|
| 223 | 223 | } |
| 224 | - } else if (sizeOf($array) == 1) { |
|
| 224 | + } else if (sizeOf($array) == 1) { |
|
| 225 | 225 | |
| 226 | 226 | if (file_exists(ROOT_PATH . "system/classes/" . strtolower($classname) . ".php")) { |
| 227 | 227 | include ROOT_PATH . "system/classes/" . strtolower($classname) . ".php"; |
| 228 | 228 | } else if (file_exists(ROOT_PATH . "system/libs/smarty/sysplugins/" . strtolower($classname) . "php")) { |
| 229 | 229 | require ROOT_PATH . "system/libs/smarty/sysplugins/" . strtolower($classname) . ".php"; |
| 230 | 230 | } else if (strpos($classname, "Plugin") !== FALSE) { |
| 231 | - //dwoo tries several times to load a class - with and without namespace, so we hide this error message |
|
| 232 | - } else { |
|
| 231 | + //dwoo tries several times to load a class - with and without namespace, so we hide this error message |
|
| 232 | + } else { |
|
| 233 | 233 | echo "Could not load class '" . $classname . "'' (array size 1)!"; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -29,71 +29,71 @@ |
||
| 29 | 29 | |
| 30 | 30 | class Event { |
| 31 | 31 | |
| 32 | - protected $row = null; |
|
| 32 | + protected $row = null; |
|
| 33 | 33 | |
| 34 | - public function __construct(array $row) { |
|
| 35 | - $this->row = $row; |
|
| 36 | - } |
|
| 34 | + public function __construct(array $row) { |
|
| 35 | + $this->row = $row; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function getID () : int { |
|
| 39 | - return $this->row['id']; |
|
| 40 | - } |
|
| 38 | + public function getID () : int { |
|
| 39 | + return $this->row['id']; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function getCalenderID () : int { |
|
| 43 | - return $this->row['calenderID']; |
|
| 44 | - } |
|
| 42 | + public function getCalenderID () : int { |
|
| 43 | + return $this->row['calenderID']; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function getTitle () : string { |
|
| 47 | - return utf8_encode($this->row['title']); |
|
| 48 | - } |
|
| 46 | + public function getTitle () : string { |
|
| 47 | + return utf8_encode($this->row['title']); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function getDescription () : string { |
|
| 51 | - return utf8_encode($this->row['description']); |
|
| 52 | - } |
|
| 50 | + public function getDescription () : string { |
|
| 51 | + return utf8_encode($this->row['description']); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function getPriceInfo () : string { |
|
| 55 | - return (isset($this->row['price_info']) ? $this->row['price_info'] : ""); |
|
| 56 | - } |
|
| 54 | + public function getPriceInfo () : string { |
|
| 55 | + return (isset($this->row['price_info']) ? $this->row['price_info'] : ""); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function hasImage () : bool { |
|
| 59 | - return $this->row['image'] !== "none"; |
|
| 60 | - } |
|
| 58 | + public function hasImage () : bool { |
|
| 59 | + return $this->row['image'] !== "none"; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function getImage () : string { |
|
| 63 | - return $this->row['image']; |
|
| 64 | - } |
|
| 62 | + public function getImage () : string { |
|
| 63 | + return $this->row['image']; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function isAllDay () : bool { |
|
| 67 | - return $this->row['all_day'] == 1; |
|
| 68 | - } |
|
| 66 | + public function isAllDay () : bool { |
|
| 67 | + return $this->row['all_day'] == 1; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function getFromTimestamp () : string { |
|
| 71 | - return $this->row['from_date']; |
|
| 72 | - } |
|
| 70 | + public function getFromTimestamp () : string { |
|
| 71 | + return $this->row['from_date']; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public function getToTimestamp () : string { |
|
| 75 | - return $this->row['to_date']; |
|
| 76 | - } |
|
| 74 | + public function getToTimestamp () : string { |
|
| 75 | + return $this->row['to_date']; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - public function getLocation () : string { |
|
| 79 | - return utf8_encode($this->row['location']); |
|
| 80 | - } |
|
| 78 | + public function getLocation () : string { |
|
| 79 | + return utf8_encode($this->row['location']); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - public function hasColor () : bool { |
|
| 83 | - return $this->row['color'] !== "none"; |
|
| 84 | - } |
|
| 82 | + public function hasColor () : bool { |
|
| 83 | + return $this->row['color'] !== "none"; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function getColor () : string { |
|
| 87 | - return $this->row['color']; |
|
| 88 | - } |
|
| 86 | + public function getColor () : string { |
|
| 87 | + return $this->row['color']; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - public function isActivated () : bool { |
|
| 91 | - return $this->row['activated'] == 1; |
|
| 92 | - } |
|
| 90 | + public function isActivated () : bool { |
|
| 91 | + return $this->row['activated'] == 1; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - public static function castEvent (Event $event) : Event { |
|
| 95 | - return $event; |
|
| 96 | - } |
|
| 94 | + public static function castEvent (Event $event) : Event { |
|
| 95 | + return $event; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | |
@@ -35,63 +35,63 @@ |
||
| 35 | 35 | $this->row = $row; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function getID () : int { |
|
| 38 | + public function getID() : int { |
|
| 39 | 39 | return $this->row['id']; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function getCalenderID () : int { |
|
| 42 | + public function getCalenderID() : int { |
|
| 43 | 43 | return $this->row['calenderID']; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function getTitle () : string { |
|
| 46 | + public function getTitle() : string { |
|
| 47 | 47 | return utf8_encode($this->row['title']); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function getDescription () : string { |
|
| 50 | + public function getDescription() : string { |
|
| 51 | 51 | return utf8_encode($this->row['description']); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public function getPriceInfo () : string { |
|
| 54 | + public function getPriceInfo() : string { |
|
| 55 | 55 | return (isset($this->row['price_info']) ? $this->row['price_info'] : ""); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function hasImage () : bool { |
|
| 58 | + public function hasImage() : bool { |
|
| 59 | 59 | return $this->row['image'] !== "none"; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function getImage () : string { |
|
| 62 | + public function getImage() : string { |
|
| 63 | 63 | return $this->row['image']; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function isAllDay () : bool { |
|
| 66 | + public function isAllDay() : bool { |
|
| 67 | 67 | return $this->row['all_day'] == 1; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function getFromTimestamp () : string { |
|
| 70 | + public function getFromTimestamp() : string { |
|
| 71 | 71 | return $this->row['from_date']; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function getToTimestamp () : string { |
|
| 74 | + public function getToTimestamp() : string { |
|
| 75 | 75 | return $this->row['to_date']; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function getLocation () : string { |
|
| 78 | + public function getLocation() : string { |
|
| 79 | 79 | return utf8_encode($this->row['location']); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function hasColor () : bool { |
|
| 82 | + public function hasColor() : bool { |
|
| 83 | 83 | return $this->row['color'] !== "none"; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function getColor () : string { |
|
| 86 | + public function getColor() : string { |
|
| 87 | 87 | return $this->row['color']; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function isActivated () : bool { |
|
| 90 | + public function isActivated() : bool { |
|
| 91 | 91 | return $this->row['activated'] == 1; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public static function castEvent (Event $event) : Event { |
|
| 94 | + public static function castEvent(Event $event) : Event { |
|
| 95 | 95 | return $event; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -16,16 +16,16 @@ |
||
| 16 | 16 | 'ssl' => false, |
| 17 | 17 | |
| 18 | 18 | 'auth' => true, |
| 19 | - 'user' => "uname",//ldap rdn or dn, |
|
| 19 | + 'user' => "uname", //ldap rdn or dn, |
|
| 20 | 20 | 'password' => "admin", |
| 21 | 21 | |
| 22 | 22 | // domain, for purposes of constructing $user |
| 23 | - 'ldap_usr_dom' => "",//e.q. @college.school.edu --> user "user1" => [email protected] |
|
| 23 | + 'ldap_usr_dom' => "", //e.q. @college.school.edu --> user "user1" => [email protected] |
|
| 24 | 24 | |
| 25 | 25 | // active directory DN (base location of ldap search) |
| 26 | - 'dn' => "",//$dn = "OU=Departments,DC=college,DC=school,DC=edu"; |
|
| 26 | + 'dn' => "", //$dn = "OU=Departments,DC=college,DC=school,DC=edu"; |
|
| 27 | 27 | |
| 28 | - 'readonly' => true,//only readonly access |
|
| 28 | + 'readonly' => true, //only readonly access |
|
| 29 | 29 | |
| 30 | 30 | //https://www.forumsys.com/tutorials/integration-how-to/ldap/api-identity-management-ldap-server/ |
| 31 | 31 | |
@@ -7,38 +7,38 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | $ldap_config = array( |
| 10 | - 'enabled' => false, |
|
| 10 | + 'enabled' => false, |
|
| 11 | 11 | |
| 12 | - // active directory server |
|
| 13 | - 'host' => "localhost", |
|
| 14 | - 'port' => 389, |
|
| 12 | + // active directory server |
|
| 13 | + 'host' => "localhost", |
|
| 14 | + 'port' => 389, |
|
| 15 | 15 | |
| 16 | - 'use_uri' => true, |
|
| 17 | - 'user_prefix' => "uid=", |
|
| 16 | + 'use_uri' => true, |
|
| 17 | + 'user_prefix' => "uid=", |
|
| 18 | 18 | |
| 19 | - 'ssl' => false, |
|
| 19 | + 'ssl' => false, |
|
| 20 | 20 | |
| 21 | - 'auth' => true, |
|
| 22 | - 'user' => "uname",//ldap rdn or dn, |
|
| 23 | - 'password' => "admin", |
|
| 21 | + 'auth' => true, |
|
| 22 | + 'user' => "uname",//ldap rdn or dn, |
|
| 23 | + 'password' => "admin", |
|
| 24 | 24 | |
| 25 | - // domain, for purposes of constructing $user |
|
| 26 | - 'ldap_usr_dom' => "",//e.q. @college.school.edu --> user "user1" => [email protected] |
|
| 25 | + // domain, for purposes of constructing $user |
|
| 26 | + 'ldap_usr_dom' => "",//e.q. @college.school.edu --> user "user1" => [email protected] |
|
| 27 | 27 | |
| 28 | - // active directory DN (base location of ldap search) |
|
| 29 | - 'dn' => "",//$dn = "OU=Departments,DC=college,DC=school,DC=edu"; |
|
| 28 | + // active directory DN (base location of ldap search) |
|
| 29 | + 'dn' => "",//$dn = "OU=Departments,DC=college,DC=school,DC=edu"; |
|
| 30 | 30 | |
| 31 | - 'readonly' => true,//only readonly access |
|
| 31 | + 'readonly' => true,//only readonly access |
|
| 32 | 32 | |
| 33 | - //https://www.forumsys.com/tutorials/integration-how-to/ldap/api-identity-management-ldap-server/ |
|
| 33 | + //https://www.forumsys.com/tutorials/integration-how-to/ldap/api-identity-management-ldap-server/ |
|
| 34 | 34 | |
| 35 | - //https://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/ |
|
| 35 | + //https://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/ |
|
| 36 | 36 | |
| 37 | - //ldap params |
|
| 38 | - 'params' => array( |
|
| 39 | - LDAP_OPT_PROTOCOL_VERSION => 3, |
|
| 40 | - LDAP_OPT_REFERRALS => 0 |
|
| 41 | - ), |
|
| 37 | + //ldap params |
|
| 38 | + 'params' => array( |
|
| 39 | + LDAP_OPT_PROTOCOL_VERSION => 3, |
|
| 40 | + LDAP_OPT_REFERRALS => 0 |
|
| 41 | + ), |
|
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | 44 | ?> |
@@ -27,15 +27,15 @@ |
||
| 27 | 27 | |
| 28 | 28 | interface IAuthentificator { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * check password of user and import user, if neccessary |
|
| 32 | - * |
|
| 33 | - * @param $username string name of user |
|
| 34 | - * @param $password string password of user |
|
| 35 | - * |
|
| 36 | - * @return userID or -1, if credentials are wrong |
|
| 37 | - */ |
|
| 38 | - public function checkPasswordAndImport (string $username, string $password) : int; |
|
| 30 | + /** |
|
| 31 | + * check password of user and import user, if neccessary |
|
| 32 | + * |
|
| 33 | + * @param $username string name of user |
|
| 34 | + * @param $password string password of user |
|
| 35 | + * |
|
| 36 | + * @return userID or -1, if credentials are wrong |
|
| 37 | + */ |
|
| 38 | + public function checkPasswordAndImport (string $username, string $password) : int; |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | * |
| 36 | 36 | * @return userID or -1, if credentials are wrong |
| 37 | 37 | */ |
| 38 | - public function checkPasswordAndImport (string $username, string $password) : int; |
|
| 38 | + public function checkPasswordAndImport(string $username, string $password) : int; |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
@@ -27,58 +27,58 @@ |
||
| 27 | 27 | |
| 28 | 28 | class LocalAuthentificator implements IAuthentificator { |
| 29 | 29 | |
| 30 | - public function __construct() { |
|
| 31 | - // |
|
| 32 | - } |
|
| 30 | + public function __construct() { |
|
| 31 | + // |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * check password of user and import user, if neccessary |
|
| 36 | - * |
|
| 37 | - * @param $username string name of user |
|
| 38 | - * @param $password string password of user |
|
| 39 | - * |
|
| 40 | - * @return userID or -1, if credentials are wrong |
|
| 41 | - */ |
|
| 42 | - public function checkPasswordAndImport(string $username, string $password) : int { |
|
| 43 | - $row = Database::getInstance()->getRow("SELECT * FROM `{praefix}user` WHERE `username` = :username AND `activated` = '1'; ", array( |
|
| 44 | - 'username' => &$username |
|
| 45 | - )); |
|
| 34 | + /** |
|
| 35 | + * check password of user and import user, if neccessary |
|
| 36 | + * |
|
| 37 | + * @param $username string name of user |
|
| 38 | + * @param $password string password of user |
|
| 39 | + * |
|
| 40 | + * @return userID or -1, if credentials are wrong |
|
| 41 | + */ |
|
| 42 | + public function checkPasswordAndImport(string $username, string $password) : int { |
|
| 43 | + $row = Database::getInstance()->getRow("SELECT * FROM `{praefix}user` WHERE `username` = :username AND `activated` = '1'; ", array( |
|
| 44 | + 'username' => &$username |
|
| 45 | + )); |
|
| 46 | 46 | |
| 47 | - if (!$row) { |
|
| 48 | - //user doesnt exists |
|
| 49 | - return -1; |
|
| 50 | - } |
|
| 47 | + if (!$row) { |
|
| 48 | + //user doesnt exists |
|
| 49 | + return -1; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - //get salt |
|
| 53 | - $salt = $row['salt']; |
|
| 52 | + //get salt |
|
| 53 | + $salt = $row['salt']; |
|
| 54 | 54 | |
| 55 | - //add salt to password |
|
| 56 | - $password .= $salt; |
|
| 55 | + //add salt to password |
|
| 56 | + $password .= $salt; |
|
| 57 | 57 | |
| 58 | - //verify password |
|
| 59 | - if (password_verify($password, $row['password'])) { |
|
| 60 | - //correct password |
|
| 58 | + //verify password |
|
| 59 | + if (password_verify($password, $row['password'])) { |
|
| 60 | + //correct password |
|
| 61 | 61 | |
| 62 | - //check, if a newer password algorithmus is available --> rehash required |
|
| 63 | - if (password_needs_rehash($row['password'], PASSWORD_DEFAULT)) { |
|
| 64 | - //rehash password |
|
| 65 | - $new_hash = self::hashPassword($password, $salt); |
|
| 62 | + //check, if a newer password algorithmus is available --> rehash required |
|
| 63 | + if (password_needs_rehash($row['password'], PASSWORD_DEFAULT)) { |
|
| 64 | + //rehash password |
|
| 65 | + $new_hash = self::hashPassword($password, $salt); |
|
| 66 | 66 | |
| 67 | - //update password in database |
|
| 68 | - Database::getInstance()->execute("UPDATE `{praefix}user` SET `password` = :password WHERE `userID` = :userID; ", array( |
|
| 69 | - 'password' => $new_hash, |
|
| 70 | - 'userID' => array( |
|
| 71 | - 'type' => PDO::PARAM_INT, |
|
| 72 | - 'value' => $row['userID'] |
|
| 73 | - ) |
|
| 74 | - )); |
|
| 75 | - } |
|
| 67 | + //update password in database |
|
| 68 | + Database::getInstance()->execute("UPDATE `{praefix}user` SET `password` = :password WHERE `userID` = :userID; ", array( |
|
| 69 | + 'password' => $new_hash, |
|
| 70 | + 'userID' => array( |
|
| 71 | + 'type' => PDO::PARAM_INT, |
|
| 72 | + 'value' => $row['userID'] |
|
| 73 | + ) |
|
| 74 | + )); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - return $row['userID']; |
|
| 78 | - } else { |
|
| 79 | - return -1; |
|
| 80 | - } |
|
| 81 | - } |
|
| 77 | + return $row['userID']; |
|
| 78 | + } else { |
|
| 79 | + return -1; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
@@ -27,49 +27,49 @@ |
||
| 27 | 27 | |
| 28 | 28 | class SettingsInstaller extends PluginInstaller_Plugin { |
| 29 | 29 | |
| 30 | - public function install(Plugin $plugin, array $install_json): bool { |
|
| 31 | - if (isset($install_json['set-settings'])) { |
|
| 32 | - $prefs = new Preferences("plugin_" . $plugin->getName() . "_uninstall"); |
|
| 30 | + public function install(Plugin $plugin, array $install_json): bool { |
|
| 31 | + if (isset($install_json['set-settings'])) { |
|
| 32 | + $prefs = new Preferences("plugin_" . $plugin->getName() . "_uninstall"); |
|
| 33 | 33 | |
| 34 | - foreach ($install_json['set-settings'] as $key=>$value) { |
|
| 35 | - if (Settings::contains($key)) { |
|
| 36 | - //backup old value |
|
| 37 | - $old_value = Settings::get($key); |
|
| 38 | - $prefs->put($key, $old_value); |
|
| 39 | - } else { |
|
| 40 | - $prefs->put($key, null); |
|
| 41 | - } |
|
| 34 | + foreach ($install_json['set-settings'] as $key=>$value) { |
|
| 35 | + if (Settings::contains($key)) { |
|
| 36 | + //backup old value |
|
| 37 | + $old_value = Settings::get($key); |
|
| 38 | + $prefs->put($key, $old_value); |
|
| 39 | + } else { |
|
| 40 | + $prefs->put($key, null); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - //set new value |
|
| 44 | - Settings::set($key, $value); |
|
| 45 | - } |
|
| 43 | + //set new value |
|
| 44 | + Settings::set($key, $value); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $prefs->save(); |
|
| 48 | - } |
|
| 47 | + $prefs->save(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return true; |
|
| 51 | - } |
|
| 50 | + return true; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function uninstall(Plugin $plugin, array $install_json): bool { |
|
| 54 | - //restore old values |
|
| 53 | + public function uninstall(Plugin $plugin, array $install_json): bool { |
|
| 54 | + //restore old values |
|
| 55 | 55 | |
| 56 | - $prefs = new Preferences("plugin_" . $plugin->getName() . "_uninstall"); |
|
| 56 | + $prefs = new Preferences("plugin_" . $plugin->getName() . "_uninstall"); |
|
| 57 | 57 | |
| 58 | - foreach ($prefs->listAll() as $key=>$value) { |
|
| 59 | - if ($value != null) { |
|
| 60 | - Settings::set($key, $value); |
|
| 61 | - } |
|
| 62 | - } |
|
| 58 | + foreach ($prefs->listAll() as $key=>$value) { |
|
| 59 | + if ($value != null) { |
|
| 60 | + Settings::set($key, $value); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - //clear preferences |
|
| 65 | - $prefs->clearAll(); |
|
| 64 | + //clear preferences |
|
| 65 | + $prefs->clearAll(); |
|
| 66 | 66 | |
| 67 | - return true; |
|
| 68 | - } |
|
| 67 | + return true; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function upgrade(Plugin $plugin, array $install_json): bool { |
|
| 71 | - return $this->install($plugin, $install_json); |
|
| 72 | - } |
|
| 70 | + public function upgrade(Plugin $plugin, array $install_json): bool { |
|
| 71 | + return $this->install($plugin, $install_json); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | } |
| 75 | 75 | |
@@ -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 | } else { |
| 109 | 109 | echo "Debug Mode is disabled. You can enable it in config/config.php file.<br />"; |
| 110 | 110 | } |
@@ -160,15 +160,15 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - public function listAllDrivers () { |
|
| 163 | + public function listAllDrivers() { |
|
| 164 | 164 | return $this->conn->getAvailableDrivers(); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function quote ($str) : string { |
|
| 167 | + public function quote($str) : string { |
|
| 168 | 168 | return $this->conn->quote($str); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - protected function getQuery ($sql, bool $allow_information_schema = false) { |
|
| 171 | + protected function getQuery($sql, bool $allow_information_schema = false) { |
|
| 172 | 172 | /** |
| 173 | 173 | * check, if sql query contains comments |
| 174 | 174 | * |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | return $this->queries; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - public function beginTransaction () { |
|
| 317 | + public function beginTransaction() { |
|
| 318 | 318 | $this->conn->beginTransaction(); |
| 319 | 319 | } |
| 320 | 320 | |
@@ -55,12 +55,12 @@ 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 | //throw exception |
| 58 | - $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 58 | + $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 59 | 59 | |
| 60 | 60 | if (DEBUG_MODE) { |
| 61 | - //$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 62 | - //$this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); |
|
| 63 | - } |
|
| 61 | + //$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
|
| 62 | + //$this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); |
|
| 63 | + } |
|
| 64 | 64 | } catch (PDOException $e) { |
| 65 | 65 | echo "Couldnt connect to database!"; |
| 66 | 66 | echo $e->getTraceAsString(); |
@@ -106,18 +106,18 @@ discard block |
||
| 106 | 106 | $res = $stmt->execute(); |
| 107 | 107 | |
| 108 | 108 | if (!$res) { |
| 109 | - if (DEBUG_MODE) { |
|
| 110 | - echo "SQL Query: " + $sql; |
|
| 111 | - } else { |
|
| 112 | - echo "Debug Mode is disabled. You can enable it in config/config.php file.<br />"; |
|
| 113 | - } |
|
| 109 | + if (DEBUG_MODE) { |
|
| 110 | + echo "SQL Query: " + $sql; |
|
| 111 | + } else { |
|
| 112 | + echo "Debug Mode is disabled. You can enable it in config/config.php file.<br />"; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | //TODO: throw exception instead |
| 116 | 116 | |
| 117 | 117 | print_r($stmt->errorInfo()); |
| 118 | 118 | |
| 119 | - flush(); |
|
| 120 | - ob_end_flush(); |
|
| 119 | + flush(); |
|
| 120 | + ob_end_flush(); |
|
| 121 | 121 | exit; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | exit; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - print_r($e); |
|
| 132 | + print_r($e); |
|
| 133 | 133 | |
| 134 | 134 | echo "<br /><br /><b>Query</b>: " . $sql . ", parameters: "; |
| 135 | 135 | var_dump($params); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | exit; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - print_r($e); |
|
| 151 | + print_r($e); |
|
| 152 | 152 | |
| 153 | 153 | echo "<br /><br /><b>Query</b>: " . $sql . ", parameters: "; |
| 154 | 154 | var_dump($params); |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $sql = str_replace("{DBPRAEFIX}", $this->praefix, $sql); |
| 214 | 214 | $sql = str_replace("{praefix}", $this->praefix, $sql); |
| 215 | - $sql = str_replace("{prefix}", $this->praefix, $sql); |
|
| 216 | - $sql = str_replace("{PREFIX}", $this->praefix, $sql); |
|
| 215 | + $sql = str_replace("{prefix}", $this->praefix, $sql); |
|
| 216 | + $sql = str_replace("{PREFIX}", $this->praefix, $sql); |
|
| 217 | 217 | return str_replace("{PRAEFIX}", $this->praefix, $sql); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | $res = $stmt->execute(); |
| 262 | 262 | |
| 263 | 263 | if (!$res) { |
| 264 | - if (DEBUG_MODE) { |
|
| 265 | - echo "SQL Query: " . $sql . "<br />"; |
|
| 266 | - var_dump($params); |
|
| 267 | - } |
|
| 264 | + if (DEBUG_MODE) { |
|
| 265 | + echo "SQL Query: " . $sql . "<br />"; |
|
| 266 | + var_dump($params); |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | 269 | throw new PDOException("PDOException while getRow(): " . ($this->getErrorInfo())[3] . "\n" . ($stmt->errorInfo())[2] . ""); |
| 270 | 270 | } |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); |
| 303 | 303 | |
| 304 | 304 | if ($rows === FALSE) { |
| 305 | - //failure, http://php.net/manual/de/pdostatement.fetchall.php |
|
| 306 | - throw new PDOException("Failure while listRows(): " . print_r($this->getErrorInfo(), true)); |
|
| 307 | - } |
|
| 305 | + //failure, http://php.net/manual/de/pdostatement.fetchall.php |
|
| 306 | + throw new PDOException("Failure while listRows(): " . print_r($this->getErrorInfo(), true)); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | 309 | return $rows; |
| 310 | 310 | } |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - public function lastInsertId(): int { |
|
| 354 | - return $this->conn->lastInsertId(); |
|
| 355 | - } |
|
| 353 | + public function lastInsertId(): int { |
|
| 354 | + return $this->conn->lastInsertId(); |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | 357 | public function listQueryHistory() : array { |
| 358 | 358 | return self::$query_history; |
@@ -27,106 +27,106 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Preferences { |
| 29 | 29 | |
| 30 | - protected $area = ""; |
|
| 31 | - protected $prefs = array(); |
|
| 32 | - protected $changed_prefs = array(); |
|
| 30 | + protected $area = ""; |
|
| 31 | + protected $prefs = array(); |
|
| 32 | + protected $changed_prefs = array(); |
|
| 33 | 33 | |
| 34 | - public function __construct(string $area) { |
|
| 35 | - $area = strtolower($area); |
|
| 34 | + public function __construct(string $area) { |
|
| 35 | + $area = strtolower($area); |
|
| 36 | 36 | |
| 37 | - if (!PHPUtils::startsWith($area, "plugin_") && !PHPUtils::startsWith($area, "style_")) { |
|
| 38 | - throw new IllegalArgumentException("preferences area name should start with 'plugin_' or 'style_'´."); |
|
| 39 | - } |
|
| 37 | + if (!PHPUtils::startsWith($area, "plugin_") && !PHPUtils::startsWith($area, "style_")) { |
|
| 38 | + throw new IllegalArgumentException("preferences area name should start with 'plugin_' or 'style_'´."); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $this->area = $area; |
|
| 41 | + $this->area = $area; |
|
| 42 | 42 | |
| 43 | - if (Cache::contains("preferences", "preferences-" . $area)) { |
|
| 44 | - $this->prefs = Cache::get("preferences", "preferences-" . $area); |
|
| 45 | - } else { |
|
| 46 | - $rows = Database::getInstance()->listRows("SELECT * FROM `{praefix}preferences` WHERE `area` = :area; ", array('area' => $area)); |
|
| 43 | + if (Cache::contains("preferences", "preferences-" . $area)) { |
|
| 44 | + $this->prefs = Cache::get("preferences", "preferences-" . $area); |
|
| 45 | + } else { |
|
| 46 | + $rows = Database::getInstance()->listRows("SELECT * FROM `{praefix}preferences` WHERE `area` = :area; ", array('area' => $area)); |
|
| 47 | 47 | |
| 48 | - foreach ($rows as $row) { |
|
| 49 | - $this->prefs[$row['key']] = unserialize($row['value']); |
|
| 50 | - } |
|
| 48 | + foreach ($rows as $row) { |
|
| 49 | + $this->prefs[$row['key']] = unserialize($row['value']); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - //cache preferences |
|
| 53 | - Cache::put("preferences", "preferences-" . $area, $this->prefs); |
|
| 54 | - } |
|
| 55 | - } |
|
| 52 | + //cache preferences |
|
| 53 | + Cache::put("preferences", "preferences-" . $area, $this->prefs); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function contains (string $key) : bool { |
|
| 58 | - return isset($this->prefs[$key]); |
|
| 59 | - } |
|
| 57 | + public function contains (string $key) : bool { |
|
| 58 | + return isset($this->prefs[$key]); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function get (string $key, $default = null) { |
|
| 62 | - if (!isset($this->prefs[$key])) { |
|
| 63 | - return $default; |
|
| 64 | - } |
|
| 61 | + public function get (string $key, $default = null) { |
|
| 62 | + if (!isset($this->prefs[$key])) { |
|
| 63 | + return $default; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return $this->prefs[$key]; |
|
| 67 | - } |
|
| 66 | + return $this->prefs[$key]; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - public function put (string $key, $value, bool $auto_save = false) { |
|
| 70 | - $contains_key = $this->contains($key); |
|
| 69 | + public function put (string $key, $value, bool $auto_save = false) { |
|
| 70 | + $contains_key = $this->contains($key); |
|
| 71 | 71 | |
| 72 | - $this->prefs[$key] = $value; |
|
| 72 | + $this->prefs[$key] = $value; |
|
| 73 | 73 | |
| 74 | - if ($auto_save) { |
|
| 75 | - //update database |
|
| 76 | - Database::getInstance()->execute("INSERT INTO `{praefix}preferences` ( |
|
| 74 | + if ($auto_save) { |
|
| 75 | + //update database |
|
| 76 | + Database::getInstance()->execute("INSERT INTO `{praefix}preferences` ( |
|
| 77 | 77 | `key`, `area`, `value` |
| 78 | 78 | ) VALUES ( |
| 79 | 79 | :key, :area, :value |
| 80 | 80 | ) ON DUPLICATE KEY UPDATE `value` = :value; ", array( |
| 81 | - 'key' => $key, |
|
| 82 | - 'area' => $this->area, |
|
| 83 | - 'value' => serialize($value) |
|
| 84 | - )); |
|
| 85 | - } else { |
|
| 86 | - $this->changed_prefs[$key] = $contains_key; |
|
| 87 | - } |
|
| 88 | - } |
|
| 81 | + 'key' => $key, |
|
| 82 | + 'area' => $this->area, |
|
| 83 | + 'value' => serialize($value) |
|
| 84 | + )); |
|
| 85 | + } else { |
|
| 86 | + $this->changed_prefs[$key] = $contains_key; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - public function listAll () : array { |
|
| 91 | - return $this->prefs; |
|
| 92 | - } |
|
| 90 | + public function listAll () : array { |
|
| 91 | + return $this->prefs; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - public function clearAll () { |
|
| 95 | - //delete from database |
|
| 96 | - Database::getInstance()->execute("DELETE FROM `{praefix}preferences` WHERE `area` = :area; ", array('area' => $this->area)); |
|
| 94 | + public function clearAll () { |
|
| 95 | + //delete from database |
|
| 96 | + Database::getInstance()->execute("DELETE FROM `{praefix}preferences` WHERE `area` = :area; ", array('area' => $this->area)); |
|
| 97 | 97 | |
| 98 | - $this->prefs = array(); |
|
| 99 | - $this->changed_prefs = array(); |
|
| 98 | + $this->prefs = array(); |
|
| 99 | + $this->changed_prefs = array(); |
|
| 100 | 100 | |
| 101 | - //clear cache |
|
| 102 | - Cache::clear("preferences", "preferences-" . $this->area); |
|
| 103 | - } |
|
| 101 | + //clear cache |
|
| 102 | + Cache::clear("preferences", "preferences-" . $this->area); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * write all values to database |
|
| 107 | - */ |
|
| 108 | - public function save () { |
|
| 109 | - $lines = array(); |
|
| 110 | - $values = array(); |
|
| 105 | + /** |
|
| 106 | + * write all values to database |
|
| 107 | + */ |
|
| 108 | + public function save () { |
|
| 109 | + $lines = array(); |
|
| 110 | + $values = array(); |
|
| 111 | 111 | |
| 112 | - $values['area'] = $this->area; |
|
| 112 | + $values['area'] = $this->area; |
|
| 113 | 113 | |
| 114 | - $i = 1; |
|
| 114 | + $i = 1; |
|
| 115 | 115 | |
| 116 | - foreach ($this->changed_prefs as $key=>$contains_key) { |
|
| 117 | - $lines[] = "(:key" . $i . ", :area, :value" . $i . ")"; |
|
| 118 | - $values['key' . $i] = $key; |
|
| 119 | - $values['value' . $i] = serialize($this->prefs[$key]); |
|
| 116 | + foreach ($this->changed_prefs as $key=>$contains_key) { |
|
| 117 | + $lines[] = "(:key" . $i . ", :area, :value" . $i . ")"; |
|
| 118 | + $values['key' . $i] = $key; |
|
| 119 | + $values['value' . $i] = serialize($this->prefs[$key]); |
|
| 120 | 120 | |
| 121 | - $i++; |
|
| 122 | - } |
|
| 121 | + $i++; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - $lines_str = implode(",\r\n", $lines); |
|
| 124 | + $lines_str = implode(",\r\n", $lines); |
|
| 125 | 125 | |
| 126 | - Database::getInstance()->execute("INSERT INTO `{praefix}preferences` ( |
|
| 126 | + Database::getInstance()->execute("INSERT INTO `{praefix}preferences` ( |
|
| 127 | 127 | `key`, `area`, `value` |
| 128 | 128 | ) VALUES " . $lines_str . " ON DUPLICATE KEY UPDATE `value` = VALUES(value); ", $values); |
| 129 | - } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function contains (string $key) : bool { |
|
| 57 | + public function contains(string $key) : bool { |
|
| 58 | 58 | return isset($this->prefs[$key]); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - public function get (string $key, $default = null) { |
|
| 61 | + public function get(string $key, $default = null) { |
|
| 62 | 62 | if (!isset($this->prefs[$key])) { |
| 63 | 63 | return $default; |
| 64 | 64 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | return $this->prefs[$key]; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function put (string $key, $value, bool $auto_save = false) { |
|
| 69 | + public function put(string $key, $value, bool $auto_save = false) { |
|
| 70 | 70 | $contains_key = $this->contains($key); |
| 71 | 71 | |
| 72 | 72 | $this->prefs[$key] = $value; |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function listAll () : array { |
|
| 90 | + public function listAll() : array { |
|
| 91 | 91 | return $this->prefs; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function clearAll () { |
|
| 94 | + public function clearAll() { |
|
| 95 | 95 | //delete from database |
| 96 | 96 | Database::getInstance()->execute("DELETE FROM `{praefix}preferences` WHERE `area` = :area; ", array('area' => $this->area)); |
| 97 | 97 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | /** |
| 106 | 106 | * write all values to database |
| 107 | 107 | */ |
| 108 | - public function save () { |
|
| 108 | + public function save() { |
|
| 109 | 109 | $lines = array(); |
| 110 | 110 | $values = array(); |
| 111 | 111 | |
@@ -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 | flush(); |
| 28 | 28 | @ob_end_flush(); |
@@ -17,18 +17,18 @@ 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 | - flush(); |
|
| 28 | - @ob_end_flush(); |
|
| 26 | + //flush gzip cache |
|
| 27 | + flush(); |
|
| 28 | + @ob_end_flush(); |
|
| 29 | 29 | |
| 30 | - //throw event, for example to write logs to file |
|
| 31 | - @Events::throwEvent("shutdown_function"); |
|
| 30 | + //throw event, for example to write logs to file |
|
| 31 | + @Events::throwEvent("shutdown_function"); |
|
| 32 | 32 | }); |
| 33 | 33 | |
| 34 | 34 | //define some constants |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | //check, if cache directory is writable |
| 43 | 43 | if (!file_exists(CACHE_PATH)) { |
| 44 | - echo "Error! cache directory doesnt exists!"; |
|
| 45 | - exit; |
|
| 44 | + echo "Error! cache directory doesnt exists!"; |
|
| 45 | + exit; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | if (!is_writable(CACHE_PATH)) { |
| 49 | - echo "Error! directory isnt writable!"; |
|
| 50 | - exit; |
|
| 49 | + echo "Error! directory isnt writable!"; |
|
| 50 | + exit; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | //set default charset to UTF-8 |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | //load pre-loaded classes, if option is enabled |
| 71 | 71 | if (OPTION_PRELOAD_CLASSES) { |
| 72 | - AutoLoaderCache::load(); |
|
| 72 | + AutoLoaderCache::load(); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | //initialize cache |
@@ -101,29 +101,29 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | //check, if allow_url_fopen is enabled |
| 103 | 103 | if (!PHPUtils::isUrlfopenEnabled() && !PHPUtils::isCurlAvailable()) { |
| 104 | - echo "CMS requires PHP option 'allow_url_fopen' enabled OR extension 'curl', change your php.ini or hosting settings to enable this option!"; |
|
| 105 | - ob_flush(); |
|
| 106 | - exit; |
|
| 104 | + echo "CMS requires PHP option 'allow_url_fopen' enabled OR extension 'curl', change your php.ini or hosting settings to enable this option!"; |
|
| 105 | + ob_flush(); |
|
| 106 | + exit; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | Events::throwEvent("init_security"); |
| 110 | 110 | |
| 111 | 111 | //check for maintenance mode |
| 112 | 112 | if (Settings::get("maintenance_mode_enabled", false) == true) { |
| 113 | - $html = Settings::get("maintenance_text", "Maintenance mode enabled!"); |
|
| 114 | - |
|
| 115 | - //throw event |
|
| 116 | - Events::throwEvent("maintenance_html", array( |
|
| 117 | - 'html' => &$html |
|
| 118 | - )); |
|
| 119 | - |
|
| 120 | - if (file_exists(ROOT_PATH . "maintenance.html")) { |
|
| 121 | - echo file_get_contents(ROOT_PATH . "maintenance.html"); |
|
| 122 | - } else if (file_exists(ROOT_PATH . "setup/maintenance.html")) { |
|
| 123 | - echo file_get_contents(ROOT_PATH . "setup/maintenance.html"); |
|
| 124 | - } else { |
|
| 125 | - echo $html; |
|
| 126 | - } |
|
| 113 | + $html = Settings::get("maintenance_text", "Maintenance mode enabled!"); |
|
| 114 | + |
|
| 115 | + //throw event |
|
| 116 | + Events::throwEvent("maintenance_html", array( |
|
| 117 | + 'html' => &$html |
|
| 118 | + )); |
|
| 119 | + |
|
| 120 | + if (file_exists(ROOT_PATH . "maintenance.html")) { |
|
| 121 | + echo file_get_contents(ROOT_PATH . "maintenance.html"); |
|
| 122 | + } else if (file_exists(ROOT_PATH . "setup/maintenance.html")) { |
|
| 123 | + echo file_get_contents(ROOT_PATH . "setup/maintenance.html"); |
|
| 124 | + } else { |
|
| 125 | + echo $html; |
|
| 126 | + } |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | //initialize logging |