@@ -2,7 +2,11 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Utils { |
| 4 | 4 | |
| 5 | - use Modules\Informer, Utils\Messages, Explorer, Language, Request; |
|
| 5 | + use Modules\Informer; |
|
| 6 | + use Utils\Messages; |
|
| 7 | + use Explorer; |
|
| 8 | + use Language; |
|
| 9 | + use Request; |
|
| 6 | 10 | |
| 7 | 11 | abstract class Uploader { |
| 8 | 12 | |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | |
| 60 | 60 | # Check target file |
| 61 | 61 | |
| 62 | - $file_name = ($dir_name . '/' . basename($file['name'])); |
|
| 62 | + $file_name = ($dir_name.'/'.basename($file['name'])); |
|
| 63 | 63 | |
| 64 | 64 | if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) return 'UPLOADER_ERROR_EXISTS'; |
| 65 | 65 | |
@@ -10,19 +10,33 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | private static function translateError(int $error) { |
| 12 | 12 | |
| 13 | - if ($error === UPLOAD_ERR_INI_SIZE) return 'UPLOADER_ERROR_INI_SIZE'; |
|
| 13 | + if ($error === UPLOAD_ERR_INI_SIZE) { |
|
| 14 | + return 'UPLOADER_ERROR_INI_SIZE'; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | - if ($error === UPLOAD_ERR_FORM_SIZE) return 'UPLOADER_ERROR_FORM_SIZE'; |
|
| 17 | + if ($error === UPLOAD_ERR_FORM_SIZE) { |
|
| 18 | + return 'UPLOADER_ERROR_FORM_SIZE'; |
|
| 19 | + } |
|
| 16 | 20 | |
| 17 | - if ($error === UPLOAD_ERR_PARTIAL) return 'UPLOADER_ERROR_PARTIAL'; |
|
| 21 | + if ($error === UPLOAD_ERR_PARTIAL) { |
|
| 22 | + return 'UPLOADER_ERROR_PARTIAL'; |
|
| 23 | + } |
|
| 18 | 24 | |
| 19 | - if ($error === UPLOAD_ERR_NO_FILE) return 'UPLOADER_ERROR_NO_FILE'; |
|
| 25 | + if ($error === UPLOAD_ERR_NO_FILE) { |
|
| 26 | + return 'UPLOADER_ERROR_NO_FILE'; |
|
| 27 | + } |
|
| 20 | 28 | |
| 21 | - if ($error === UPLOAD_ERR_NO_TMP_DIR) return 'UPLOADER_ERROR_NO_TMP_DIR'; |
|
| 29 | + if ($error === UPLOAD_ERR_NO_TMP_DIR) { |
|
| 30 | + return 'UPLOADER_ERROR_NO_TMP_DIR'; |
|
| 31 | + } |
|
| 22 | 32 | |
| 23 | - if ($error === UPLOAD_ERR_CANT_WRITE) return 'UPLOADER_ERROR_CANT_WRITE'; |
|
| 33 | + if ($error === UPLOAD_ERR_CANT_WRITE) { |
|
| 34 | + return 'UPLOADER_ERROR_CANT_WRITE'; |
|
| 35 | + } |
|
| 24 | 36 | |
| 25 | - if ($error === UPLOAD_ERR_EXTENSION) return 'UPLOADER_ERROR_EXTENSION'; |
|
| 37 | + if ($error === UPLOAD_ERR_EXTENSION) { |
|
| 38 | + return 'UPLOADER_ERROR_EXTENSION'; |
|
| 39 | + } |
|
| 26 | 40 | |
| 27 | 41 | # ------------------------ |
| 28 | 42 | |
@@ -33,19 +47,27 @@ discard block |
||
| 33 | 47 | |
| 34 | 48 | public static function save(string $name, string $dir_name) { |
| 35 | 49 | |
| 36 | - if ((false === ($file = Request::file($name))) || !is_uploaded_file($file['tmp_name'])) return false; |
|
| 50 | + if ((false === ($file = Request::file($name))) || !is_uploaded_file($file['tmp_name'])) { |
|
| 51 | + return false; |
|
| 52 | + } |
|
| 37 | 53 | |
| 38 | 54 | # Check for demo mode |
| 39 | 55 | |
| 40 | - if (Informer::isDemoMode()) return 'DEMO_MODE_RESTRICTION'; |
|
| 56 | + if (Informer::isDemoMode()) { |
|
| 57 | + return 'DEMO_MODE_RESTRICTION'; |
|
| 58 | + } |
|
| 41 | 59 | |
| 42 | 60 | # Check for upload errors |
| 43 | 61 | |
| 44 | - if ($file['error'] !== UPLOAD_ERR_OK) return self::translateError($file['error']); |
|
| 62 | + if ($file['error'] !== UPLOAD_ERR_OK) { |
|
| 63 | + return self::translateError($file['error']); |
|
| 64 | + } |
|
| 45 | 65 | |
| 46 | 66 | # Check size |
| 47 | 67 | |
| 48 | - if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) return 'UPLOADER_ERROR_SIZE'; |
|
| 68 | + if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) { |
|
| 69 | + return 'UPLOADER_ERROR_SIZE'; |
|
| 70 | + } |
|
| 49 | 71 | |
| 50 | 72 | # Check file extension |
| 51 | 73 | |
@@ -53,21 +75,29 @@ discard block |
||
| 53 | 75 | |
| 54 | 76 | $extension = strtolower(Explorer::extension($file['name'], false)); |
| 55 | 77 | |
| 56 | - if (in_array($extension, $extensions, true)) return 'UPLOADER_ERROR_TYPE'; |
|
| 78 | + if (in_array($extension, $extensions, true)) { |
|
| 79 | + return 'UPLOADER_ERROR_TYPE'; |
|
| 80 | + } |
|
| 57 | 81 | |
| 58 | 82 | # Check target directory |
| 59 | 83 | |
| 60 | - if (!Explorer::isDir($dir_name)) return 'UPLOADER_ERROR_DIR'; |
|
| 84 | + if (!Explorer::isDir($dir_name)) { |
|
| 85 | + return 'UPLOADER_ERROR_DIR'; |
|
| 86 | + } |
|
| 61 | 87 | |
| 62 | 88 | # Check target file |
| 63 | 89 | |
| 64 | 90 | $file_name = ($dir_name . '/' . basename($file['name'])); |
| 65 | 91 | |
| 66 | - if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) return 'UPLOADER_ERROR_EXISTS'; |
|
| 92 | + if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) { |
|
| 93 | + return 'UPLOADER_ERROR_EXISTS'; |
|
| 94 | + } |
|
| 67 | 95 | |
| 68 | 96 | # Save uploaded file |
| 69 | 97 | |
| 70 | - if (!@move_uploaded_file($file['tmp_name'], $file_name)) return 'UPLOADER_ERROR_SAVE'; |
|
| 98 | + if (!@move_uploaded_file($file['tmp_name'], $file_name)) { |
|
| 99 | + return 'UPLOADER_ERROR_SAVE'; |
|
| 100 | + } |
|
| 71 | 101 | |
| 72 | 102 | # ------------------------ |
| 73 | 103 | |
@@ -2,7 +2,9 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | # Check PHP version |
| 4 | 4 | |
| 5 | -if (version_compare(PHP_VERSION, '7.0.0') < 0) exit('PHP version 7 or higher is required.'); |
|
| 5 | +if (version_compare(PHP_VERSION, '7.0.0') < 0) { |
|
| 6 | + exit('PHP version 7 or higher is required.'); |
|
| 7 | +} |
|
| 6 | 8 | |
| 7 | 9 | # Set error reporting |
| 8 | 10 | |
@@ -37,9 +39,11 @@ discard block |
||
| 37 | 39 | |
| 38 | 40 | # Require class file |
| 39 | 41 | |
| 40 | - if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) require_once $file_name; |
|
| 41 | - |
|
| 42 | - else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) require_once $file_name; |
|
| 42 | + if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) { |
|
| 43 | + require_once $file_name; |
|
| 44 | + } else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) { |
|
| 45 | + require_once $file_name; |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | 48 | # Check if class exists |
| 45 | 49 | |
@@ -50,5 +54,7 @@ discard block |
||
| 50 | 54 | |
| 51 | 55 | # Call autoload method |
| 52 | 56 | |
| 53 | - if (method_exists($class_name, '__autoload')) $class_name::__autoload(); |
|
| 54 | -}); |
|
| 57 | + if (method_exists($class_name, '__autoload')) { |
|
| 58 | + $class_name::__autoload(); |
|
| 59 | + } |
|
| 60 | + }); |
|
@@ -10,18 +10,18 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | # Define constants |
| 12 | 12 | |
| 13 | -define('DIR_ENGINE', (dirname(__FILE__) . '/')); |
|
| 13 | +define('DIR_ENGINE', (dirname(__FILE__).'/')); |
|
| 14 | 14 | |
| 15 | -define('DIR_WWW', (DIR_ENGINE . '../')); |
|
| 16 | -define('DIR_UPLOADS', (DIR_ENGINE . '../uploads/')); |
|
| 15 | +define('DIR_WWW', (DIR_ENGINE.'../')); |
|
| 16 | +define('DIR_UPLOADS', (DIR_ENGINE.'../uploads/')); |
|
| 17 | 17 | |
| 18 | 18 | # Require framework main file |
| 19 | 19 | |
| 20 | -require_once(DIR_ENGINE . 'Framework/Main.php'); |
|
| 20 | +require_once(DIR_ENGINE.'Framework/Main.php'); |
|
| 21 | 21 | |
| 22 | 22 | # Require system main file |
| 23 | 23 | |
| 24 | -require_once(DIR_ENGINE . 'System/Main.php'); |
|
| 24 | +require_once(DIR_ENGINE.'System/Main.php'); |
|
| 25 | 25 | |
| 26 | 26 | # Register classes autoloader |
| 27 | 27 | |
@@ -33,13 +33,13 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $system_classes = ['Frames', 'Handlers', 'Modules', 'Utils', 'Views', 'Dispatcher', 'Installer']; |
| 35 | 35 | |
| 36 | - $path = ((in_array($path[0], $system_classes, true) ? DIR_SYSTEM_CLASSES : DIR_CLASSES) . implode('/', $path)); |
|
| 36 | + $path = ((in_array($path[0], $system_classes, true) ? DIR_SYSTEM_CLASSES : DIR_CLASSES).implode('/', $path)); |
|
| 37 | 37 | |
| 38 | 38 | # Require class file |
| 39 | 39 | |
| 40 | - if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) require_once $file_name; |
|
| 40 | + if (@file_exists($file_name = ($path.'.php')) && @is_file($file_name)) require_once $file_name; |
|
| 41 | 41 | |
| 42 | - else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) require_once $file_name; |
|
| 42 | + else if (@file_exists($file_name = ($path.'/'.$last.'.php')) && @is_file($file_name)) require_once $file_name; |
|
| 43 | 43 | |
| 44 | 44 | # Check if class exists |
| 45 | 45 | |
@@ -2,7 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Modules\Entitizer\Form { |
| 4 | 4 | |
| 5 | - use Modules\Entitizer, Utils\Form; |
|
| 5 | + use Modules\Entitizer; |
|
| 6 | + use Utils\Form; |
|
| 6 | 7 | |
| 7 | 8 | class Widget extends Form { |
| 8 | 9 | |
@@ -49,9 +49,13 @@ |
||
| 49 | 49 | |
| 50 | 50 | public static function url(string $value) { |
| 51 | 51 | |
| 52 | - if (false === ($value = parent::url($value))) return false; |
|
| 52 | + if (false === ($value = parent::url($value))) { |
|
| 53 | + return false; |
|
| 54 | + } |
|
| 53 | 55 | |
| 54 | - if (!preg_match('/^https?:\/\//', $value)) return false; |
|
| 56 | + if (!preg_match('/^https?:\/\//', $value)) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 55 | 59 | |
| 56 | 60 | # ------------------------ |
| 57 | 61 | |
@@ -2,15 +2,15 @@ |
||
| 2 | 2 | |
| 3 | 3 | # Regular expressions |
| 4 | 4 | |
| 5 | -define('REGEX_MAP_ITEM_PATH', '/^[a-zA-Z0-9_\-\+\.\,\'\*\(\)\[\]:;!$%~]+$/'); |
|
| 6 | -define('REGEX_MAP_ITEM_HANDLER', '/^[A-Z][a-zA-Z0-9]*$/'); |
|
| 5 | +define('REGEX_MAP_ITEM_PATH', '/^[a-zA-Z0-9_\-\+\.\,\'\*\(\)\[\]:;!$%~]+$/'); |
|
| 6 | +define('REGEX_MAP_ITEM_HANDLER', '/^[A-Z][a-zA-Z0-9]*$/'); |
|
| 7 | 7 | |
| 8 | -define('REGEX_LANGUAGE_NAME', '/^[a-z][a-z]-[A-Z][A-Z]$/'); |
|
| 9 | -define('REGEX_TEMPLATE_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 8 | +define('REGEX_LANGUAGE_NAME', '/^[a-z][a-z]-[A-Z][A-Z]$/'); |
|
| 9 | +define('REGEX_TEMPLATE_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 10 | 10 | |
| 11 | -define('REGEX_USER_AUTH_CODE', '/^[a-zA-Z0-9]{40}$/'); |
|
| 11 | +define('REGEX_USER_AUTH_CODE', '/^[a-zA-Z0-9]{40}$/'); |
|
| 12 | 12 | |
| 13 | -define('REGEX_USER_NAME', '/^(?!_)(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
| 14 | -define('REGEX_USER_PASSWORD', '/^.+$/'); |
|
| 13 | +define('REGEX_USER_NAME', '/^(?!_)(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
| 14 | +define('REGEX_USER_PASSWORD', '/^.+$/'); |
|
| 15 | 15 | |
| 16 | -define('REGEX_FILE_NAME', '/^[^\/?%*:|"<>\\\]+$/'); |
|
| 16 | +define('REGEX_FILE_NAME', '/^[^\/?%*:|"<>\\\]+$/'); |
|
@@ -32,11 +32,15 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $file_name = ($dir_name . $name . '/Config.json'); |
| 34 | 34 | |
| 35 | - if (false === ($config = Explorer::json($file_name))) continue; |
|
| 35 | + if (false === ($config = Explorer::json($file_name))) { |
|
| 36 | + continue; |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | $config = Arr::select($config, self::$data); |
| 38 | 40 | |
| 39 | - if (!(self::valid($config['name']) && ($config['name'] === $name))) continue; |
|
| 41 | + if (!(self::valid($config['name']) && ($config['name'] === $name))) { |
|
| 42 | + continue; |
|
| 43 | + } |
|
| 40 | 44 | |
| 41 | 45 | $items[$name] = array_map('strval', $config); |
| 42 | 46 | } |
@@ -52,11 +56,19 @@ discard block |
||
| 52 | 56 | |
| 53 | 57 | $name = ''; $param = self::$param[self::$section]; |
| 54 | 58 | |
| 55 | - if (self::exists($name_cookie = Cookie::get($param))) $name = $name_cookie; |
|
| 59 | + if (self::exists($name_cookie = Cookie::get($param))) { |
|
| 60 | + $name = $name_cookie; |
|
| 61 | + } |
|
| 56 | 62 | |
| 57 | - if (self::exists($name_get = Request::get(self::$name))) $name = $name_get; |
|
| 63 | + if (self::exists($name_get = Request::get(self::$name))) { |
|
| 64 | + $name = $name_get; |
|
| 65 | + } |
|
| 58 | 66 | |
| 59 | - if ('' !== $name) Cookie::set($param, $name, self::$cookie_expires); else return false; |
|
| 67 | + if ('' !== $name) { |
|
| 68 | + Cookie::set($param, $name, self::$cookie_expires); |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 60 | 72 | |
| 61 | 73 | # ------------------------ |
| 62 | 74 | |
@@ -90,7 +102,9 @@ discard block |
||
| 90 | 102 | |
| 91 | 103 | $section = self::getSection($section); $dir_name = self::getDirName($section); |
| 92 | 104 | |
| 93 | - if (!Explorer::isDir($dir_name)) throw new Exception\General(self::$error_directory); |
|
| 105 | + if (!Explorer::isDir($dir_name)) { |
|
| 106 | + throw new Exception\General(self::$error_directory); |
|
| 107 | + } |
|
| 94 | 108 | |
| 95 | 109 | self::$section = $section; self::$dir_name = $dir_name; self::$items = self::getItems($dir_name); |
| 96 | 110 | |
@@ -98,11 +112,15 @@ discard block |
||
| 98 | 112 | |
| 99 | 113 | $primary = (self::exists(self::$default[$section]) ? self::$default[$section] : false); |
| 100 | 114 | |
| 101 | - if ($selectable && (false !== ($name = self::getUserDefined()))) $name_valid = true; |
|
| 102 | - |
|
| 103 | - else $name_valid = (self::exists($name = Settings::get($param)) || (false !== ($name = $primary))); |
|
| 115 | + if ($selectable && (false !== ($name = self::getUserDefined()))) { |
|
| 116 | + $name_valid = true; |
|
| 117 | + } else { |
|
| 118 | + $name_valid = (self::exists($name = Settings::get($param)) || (false !== ($name = $primary))); |
|
| 119 | + } |
|
| 104 | 120 | |
| 105 | - if (!($name_valid || (null !== ($name = key(self::$items))))) throw new Exception\General(self::$error_select); |
|
| 121 | + if (!($name_valid || (null !== ($name = key(self::$items))))) { |
|
| 122 | + throw new Exception\General(self::$error_select); |
|
| 123 | + } |
|
| 106 | 124 | |
| 107 | 125 | # ------------------------ |
| 108 | 126 | |
@@ -127,7 +145,9 @@ discard block |
||
| 127 | 145 | |
| 128 | 146 | public static function items(string $section = null) { |
| 129 | 147 | |
| 130 | - if (null === $section) return self::$items; |
|
| 148 | + if (null === $section) { |
|
| 149 | + return self::$items; |
|
| 150 | + } |
|
| 131 | 151 | |
| 132 | 152 | $section = self::getSection($section); $dir_name = self::getDirName($section); |
| 133 | 153 | |
@@ -152,7 +172,9 @@ discard block |
||
| 152 | 172 | |
| 153 | 173 | public static function path() { |
| 154 | 174 | |
| 155 | - if ('' === self::$active) return false; |
|
| 175 | + if ('' === self::$active) { |
|
| 176 | + return false; |
|
| 177 | + } |
|
| 156 | 178 | |
| 157 | 179 | return (self::$dir_name . self::$active . '/'); |
| 158 | 180 | } |
@@ -161,7 +183,9 @@ discard block |
||
| 161 | 183 | |
| 162 | 184 | public static function pathPrimary() { |
| 163 | 185 | |
| 164 | - if ('' === self::$primary) return false; |
|
| 186 | + if ('' === self::$primary) { |
|
| 187 | + return false; |
|
| 188 | + } |
|
| 165 | 189 | |
| 166 | 190 | return (self::$dir_name . self::$primary . '/'); |
| 167 | 191 | } |
@@ -170,9 +194,13 @@ discard block |
||
| 170 | 194 | |
| 171 | 195 | public static function data(string $name = null) { |
| 172 | 196 | |
| 173 | - if ('' === self::$active) return false; |
|
| 197 | + if ('' === self::$active) { |
|
| 198 | + return false; |
|
| 199 | + } |
|
| 174 | 200 | |
| 175 | - if (null === $name) return self::$items[self::$active]; |
|
| 201 | + if (null === $name) { |
|
| 202 | + return self::$items[self::$active]; |
|
| 203 | + } |
|
| 176 | 204 | |
| 177 | 205 | return (isset(self::$items[self::$active][$name]) ? self::$items[self::$active][$name] : false); |
| 178 | 206 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | private static function getDirName(string $section) { |
| 21 | 21 | |
| 22 | - return (self::$root_dir . (self::$separate ? ($section . '/') : '')); |
|
| 22 | + return (self::$root_dir.(self::$separate ? ($section.'/') : '')); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | # Get items |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | foreach (Explorer::listDirs($dir_name) as $name) { |
| 32 | 32 | |
| 33 | - $file_name = ($dir_name . $name . '/Config.json'); |
|
| 33 | + $file_name = ($dir_name.$name.'/Config.json'); |
|
| 34 | 34 | |
| 35 | 35 | if (false === ($config = Explorer::json($file_name))) continue; |
| 36 | 36 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | if ('' === self::$active) return false; |
| 156 | 156 | |
| 157 | - return (self::$dir_name . self::$active . '/'); |
|
| 157 | + return (self::$dir_name.self::$active.'/'); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | # Get primary extension path |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | if ('' === self::$primary) return false; |
| 165 | 165 | |
| 166 | - return (self::$dir_name . self::$primary . '/'); |
|
| 166 | + return (self::$dir_name.self::$primary.'/'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | # Get active extension data |
@@ -14,7 +14,9 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | $parts = preg_split('/\//', $string, 0, PREG_SPLIT_NO_EMPTY); |
| 16 | 16 | |
| 17 | - foreach ($parts as $name) if (!preg_match($regex, $name)) return false; |
|
| 17 | + foreach ($parts as $name) { |
|
| 18 | + if (!preg_match($regex, $name)) return false; |
|
| 19 | + } |
|
| 18 | 20 | |
| 19 | 21 | # ------------------------ |
| 20 | 22 | |
@@ -27,9 +29,13 @@ discard block |
||
| 27 | 29 | |
| 28 | 30 | $data = Arr::select($item, ['path', 'handler']); |
| 29 | 31 | |
| 30 | - if (false === ($path = $this->parseString($data['path'], REGEX_MAP_ITEM_PATH))) return; |
|
| 32 | + if (false === ($path = $this->parseString($data['path'], REGEX_MAP_ITEM_PATH))) { |
|
| 33 | + return; |
|
| 34 | + } |
|
| 31 | 35 | |
| 32 | - if (false === ($handler = $this->parseString($data['handler'], REGEX_MAP_ITEM_HANDLER))) return; |
|
| 36 | + if (false === ($handler = $this->parseString($data['handler'], REGEX_MAP_ITEM_HANDLER))) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 33 | 39 | |
| 34 | 40 | $this->map[] = ['path' => $path, 'handler' => implode('\\', $handler)]; |
| 35 | 41 | } |
@@ -40,16 +46,22 @@ discard block |
||
| 40 | 46 | |
| 41 | 47 | $file_name = (DIR_SYSTEM_DATA . 'Map.json'); |
| 42 | 48 | |
| 43 | - if (false === ($map = Explorer::json($file_name))) return; |
|
| 49 | + if (false === ($map = Explorer::json($file_name))) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 44 | 52 | |
| 45 | - foreach ($map as $item) if (is_array($item)) $this->parseItem($item); |
|
| 53 | + foreach ($map as $item) { |
|
| 54 | + if (is_array($item)) $this->parseItem($item); |
|
| 55 | + } |
|
| 46 | 56 | } |
| 47 | 57 | |
| 48 | 58 | # Get handler by url |
| 49 | 59 | |
| 50 | 60 | public function handler(Url $url) { |
| 51 | 61 | |
| 52 | - foreach ($this->map as $item) if ($item['path'] === $url->path()) return $item['handler']; |
|
| 62 | + foreach ($this->map as $item) { |
|
| 63 | + if ($item['path'] === $url->path()) return $item['handler']; |
|
| 64 | + } |
|
| 53 | 65 | |
| 54 | 66 | return false; |
| 55 | 67 | } |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | |
| 39 | 39 | public function __construct() { |
| 40 | 40 | |
| 41 | - $file_name = (DIR_SYSTEM_DATA . 'Map.json'); |
|
| 41 | + $file_name = (DIR_SYSTEM_DATA.'Map.json'); |
|
| 42 | 42 | |
| 43 | 43 | if (false === ($map = Explorer::json($file_name))) return; |
| 44 | 44 | |
@@ -18,12 +18,16 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | foreach (array_keys($this->database) as $key) { |
| 20 | 20 | |
| 21 | - if (is_scalar($value = Arr::get($data, ['database', $key]))) $this->database[$key] = strval($value); |
|
| 21 | + if (is_scalar($value = Arr::get($data, ['database', $key]))) { |
|
| 22 | + $this->database[$key] = strval($value); |
|
| 23 | + } |
|
| 22 | 24 | } |
| 23 | 25 | |
| 24 | 26 | # Parse installation details |
| 25 | 27 | |
| 26 | - if (is_numeric($time = Arr::get($data, ['time']))) $this->time = intval($time); |
|
| 28 | + if (is_numeric($time = Arr::get($data, ['time']))) { |
|
| 29 | + $this->time = intval($time); |
|
| 30 | + } |
|
| 27 | 31 | } |
| 28 | 32 | |
| 29 | 33 | # Constructor |
@@ -32,7 +36,9 @@ discard block |
||
| 32 | 36 | |
| 33 | 37 | $system_file = (DIR_SYSTEM_DATA . 'System.json'); |
| 34 | 38 | |
| 35 | - if (false !== ($data = Explorer::json($system_file))) $this->parse($data); |
|
| 39 | + if (false !== ($data = Explorer::json($system_file))) { |
|
| 40 | + $this->parse($data); |
|
| 41 | + } |
|
| 36 | 42 | } |
| 37 | 43 | } |
| 38 | 44 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function __construct() { |
| 32 | 32 | |
| 33 | - $system_file = (DIR_SYSTEM_DATA . 'System.json'); |
|
| 33 | + $system_file = (DIR_SYSTEM_DATA.'System.json'); |
|
| 34 | 34 | |
| 35 | 35 | if (false !== ($data = Explorer::json($system_file))) $this->parse($data); |
| 36 | 36 | } |
@@ -12,9 +12,13 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | while (false !== ($name = readdir($handler))) { |
| 14 | 14 | |
| 15 | - if (($name === '.') || ($name === '..')) continue; |
|
| 15 | + if (($name === '.') || ($name === '..')) { |
|
| 16 | + continue; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | - if ($dirs ? @is_dir($dir_name . $name) : @is_file($dir_name . $name)) yield $name; |
|
| 19 | + if ($dirs ? @is_dir($dir_name . $name) : @is_file($dir_name . $name)) { |
|
| 20 | + yield $name; |
|
| 21 | + } |
|
| 18 | 22 | } |
| 19 | 23 | |
| 20 | 24 | closedir($handler); |
@@ -25,7 +29,9 @@ discard block |
||
| 25 | 29 | |
| 26 | 30 | private static function getInfo(string $file_name, int $param, bool $check_exists = true) { |
| 27 | 31 | |
| 28 | - if ($check_exists && !self::isFile($file_name)) return false; |
|
| 32 | + if ($check_exists && !self::isFile($file_name)) { |
|
| 33 | + return false; |
|
| 34 | + } |
|
| 29 | 35 | |
| 30 | 36 | return pathinfo($file_name, $param); |
| 31 | 37 | } |
@@ -68,9 +74,11 @@ discard block |
||
| 68 | 74 | |
| 69 | 75 | $name = ($dir_name . '/' . $name); |
| 70 | 76 | |
| 71 | - if (@is_file($name)) self::removeFile($name); |
|
| 72 | - |
|
| 73 | - else if (@is_dir($name)) self::removeDir($name, true); |
|
| 77 | + if (@is_file($name)) { |
|
| 78 | + self::removeFile($name); |
|
| 79 | + } else if (@is_dir($name)) { |
|
| 80 | + self::removeDir($name, true); |
|
| 81 | + } |
|
| 74 | 82 | } |
| 75 | 83 | } |
| 76 | 84 | |
@@ -146,7 +154,9 @@ discard block |
||
| 146 | 154 | |
| 147 | 155 | public static function json(string $file_name) { |
| 148 | 156 | |
| 149 | - if ((strtolower(self::extension($file_name)) !== 'json')) return false; |
|
| 157 | + if ((strtolower(self::extension($file_name)) !== 'json')) { |
|
| 158 | + return false; |
|
| 159 | + } |
|
| 150 | 160 | |
| 151 | 161 | return (json_decode(@file_get_contents($file_name), true) ?? false); |
| 152 | 162 | } |
@@ -155,7 +165,9 @@ discard block |
||
| 155 | 165 | |
| 156 | 166 | public static function php(string $file_name) { |
| 157 | 167 | |
| 158 | - if ((strtolower(self::extension($file_name)) !== 'php')) return false; |
|
| 168 | + if ((strtolower(self::extension($file_name)) !== 'php')) { |
|
| 169 | + return false; |
|
| 170 | + } |
|
| 159 | 171 | |
| 160 | 172 | return include $file_name; |
| 161 | 173 | } |
@@ -164,7 +176,9 @@ discard block |
||
| 164 | 176 | |
| 165 | 177 | public static function xml(string $file_name) { |
| 166 | 178 | |
| 167 | - if ((strtolower(self::extension($file_name)) !== 'xml')) return false; |
|
| 179 | + if ((strtolower(self::extension($file_name)) !== 'xml')) { |
|
| 180 | + return false; |
|
| 181 | + } |
|
| 168 | 182 | |
| 169 | 183 | return @simplexml_load_file($file_name); |
| 170 | 184 | } |
@@ -173,7 +187,11 @@ discard block |
||
| 173 | 187 | |
| 174 | 188 | public static function save(string $file_name, string $contents, bool $force = false) { |
| 175 | 189 | |
| 176 | - if (self::isFile($file_name)) if (!$force) return false; else if (!@unlink($file_name)) return false; |
|
| 190 | + if (self::isFile($file_name)) { |
|
| 191 | + if (!$force) return false; |
|
| 192 | + } else if (!@unlink($file_name)) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 177 | 195 | |
| 178 | 196 | return @file_put_contents($file_name, $contents); |
| 179 | 197 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | if (($name === '.') || ($name === '..')) continue; |
| 16 | 16 | |
| 17 | - if ($dirs ? @is_dir($dir_name . $name) : @is_file($dir_name . $name)) yield $name; |
|
| 17 | + if ($dirs ? @is_dir($dir_name.$name) : @is_file($dir_name.$name)) yield $name; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | closedir($handler); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | foreach (array_diff($list, ['.', '..']) as $name) { |
| 68 | 68 | |
| 69 | - $name = ($dir_name . '/' . $name); |
|
| 69 | + $name = ($dir_name.'/'.$name); |
|
| 70 | 70 | |
| 71 | 71 | if (@is_file($name)) self::removeFile($name); |
| 72 | 72 | |