@@ -19,18 +19,24 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function __construct(string $url = '') { |
| 21 | 21 | |
| 22 | - if (false === ($url = parse_url($url))) return; |
|
| 22 | + if (false === ($url = parse_url($url))) { |
|
| 23 | + return; |
|
| 24 | + } |
|
| 23 | 25 | |
| 24 | 26 | # Parse path |
| 25 | 27 | |
| 26 | - if (isset($url['path'])) foreach (explode('/', $url['path']) as $part) { |
|
| 28 | + if (isset($url['path'])) { |
|
| 29 | + foreach (explode('/', $url['path']) as $part) { |
|
| 27 | 30 | |
| 28 | 31 | if ('' !== $part) $this->path[] = urldecode($part); |
| 29 | 32 | } |
| 33 | + } |
|
| 30 | 34 | |
| 31 | 35 | # Parse query |
| 32 | 36 | |
| 33 | - if (isset($url['query'])) parse_str($url['query'], $this->query); |
|
| 37 | + if (isset($url['query'])) { |
|
| 38 | + parse_str($url['query'], $this->query); |
|
| 39 | + } |
|
| 34 | 40 | } |
| 35 | 41 | |
| 36 | 42 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function getPath() : string { |
| 74 | 74 | |
| 75 | - return ('/' . implode('/', array_map('urlencode', $this->path))); |
|
| 75 | + return ('/'.implode('/', array_map('urlencode', $this->path))); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | public function getQuery() : string { |
| 83 | 83 | |
| 84 | - return (($query = http_build_query($this->query)) ? ('?' . $query) : ''); |
|
| 84 | + return (($query = http_build_query($this->query)) ? ('?'.$query) : ''); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | public function getString(bool $include_query = true) : string { |
| 110 | 110 | |
| 111 | - return ($this->getPath() . ($include_query ? $this->getQuery() : '')); |
|
| 111 | + return ($this->getPath().($include_query ? $this->getQuery() : '')); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -47,10 +47,10 @@ |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | - * Get a query attribute |
|
| 51 | - * |
|
| 52 | - * @return string|false : the value or false if the attribute does not exist |
|
| 53 | - */ |
|
| 50 | + * Get a query attribute |
|
| 51 | + * |
|
| 52 | + * @return string|false : the value or false if the attribute does not exist |
|
| 53 | + */ |
|
| 54 | 54 | |
| 55 | 55 | public function getAttribute(string $name) { |
| 56 | 56 | |
@@ -181,7 +181,7 @@ |
||
| 181 | 181 | |
| 182 | 182 | foreach ($this->fields as $field) { |
| 183 | 183 | |
| 184 | - $block->setBlock(('field_' . $field->getName()), $field->getBlock()); |
|
| 184 | + $block->setBlock(('field_'.$field->getName()), $field->getBlock()); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | private function addField(Form\Field $field) : bool { |
| 25 | 25 | |
| 26 | - if ($this->posted || ('' === ($key = $field->getKey()))) return false; |
|
| 26 | + if ($this->posted || ('' === ($key = $field->getKey()))) { |
|
| 27 | + return false; |
|
| 28 | + } |
|
| 27 | 29 | |
| 28 | 30 | $this->fields[$key] = $field; |
| 29 | 31 | |
@@ -38,7 +40,9 @@ discard block |
||
| 38 | 40 | |
| 39 | 41 | public function __construct(string $name = '') { |
| 40 | 42 | |
| 41 | - if (preg_match(REGEX_FORM_NAME, $name)) $this->name = $name; |
|
| 43 | + if (preg_match(REGEX_FORM_NAME, $name)) { |
|
| 44 | + $this->name = $name; |
|
| 45 | + } |
|
| 42 | 46 | } |
| 43 | 47 | |
| 44 | 48 | /** |
@@ -90,9 +94,15 @@ discard block |
||
| 90 | 94 | |
| 91 | 95 | foreach ($this->fields as $field) { |
| 92 | 96 | |
| 93 | - if (($field instanceof Form\Field\Checkbox) || $field->disabled) continue; |
|
| 97 | + if (($field instanceof Form\Field\Checkbox) || $field->disabled) { |
|
| 98 | + continue; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | - if (false !== Request::post($field->getName())) $check = true; else return false; |
|
| 101 | + if (false !== Request::post($field->getName())) { |
|
| 102 | + $check = true; |
|
| 103 | + } else { |
|
| 104 | + return false; |
|
| 105 | + } |
|
| 96 | 106 | } |
| 97 | 107 | |
| 98 | 108 | # ------------------------ |
@@ -108,7 +118,9 @@ discard block |
||
| 108 | 118 | |
| 109 | 119 | public function post() { |
| 110 | 120 | |
| 111 | - if ($this->posted || !$this->check()) return false; |
|
| 121 | + if ($this->posted || !$this->check()) { |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 112 | 124 | |
| 113 | 125 | $post = []; $errors = false; |
| 114 | 126 | |
@@ -116,7 +128,9 @@ discard block |
||
| 116 | 128 | |
| 117 | 129 | $field->post(); $post[$field->getKey()] = $field->getValue(); |
| 118 | 130 | |
| 119 | - if ($field->error) $errors = true; |
|
| 131 | + if ($field->error) { |
|
| 132 | + $errors = true; |
|
| 133 | + } |
|
| 120 | 134 | } |
| 121 | 135 | |
| 122 | 136 | $this->posted = true; $this->errors = $errors; |
@@ -53,7 +53,9 @@ |
||
| 53 | 53 | |
| 54 | 54 | $tag->setAttribute('type', 'checkbox'); |
| 55 | 55 | |
| 56 | - if ($this->value) $tag->setAttribute('checked', 'checked'); |
|
| 56 | + if ($this->value) { |
|
| 57 | + $tag->setAttribute('checked', 'checked'); |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | # ------------------------ |
| 59 | 61 | |
@@ -31,9 +31,9 @@ |
||
| 31 | 31 | |
| 32 | 32 | if (preg_match(REGEX_FORM_FIELD_KEY, $key)) { |
| 33 | 33 | |
| 34 | - $prefix = (('' !== $this->form->getName()) ? ($this->form->getName() . '_') : ''); |
|
| 34 | + $prefix = (('' !== $this->form->getName()) ? ($this->form->getName().'_') : ''); |
|
| 35 | 35 | |
| 36 | - $this->key = $key; $this->name = ($prefix . $key); $this->id = str_replace('_', '-', $this->name); |
|
| 36 | + $this->key = $key; $this->name = ($prefix.$key); $this->id = str_replace('_', '-', $this->name); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | # Set configuration |
@@ -57,11 +57,17 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | # Set appearance |
| 59 | 59 | |
| 60 | - if ($this->disabled) $data['disabled'] = 'disabled'; |
|
| 60 | + if ($this->disabled) { |
|
| 61 | + $data['disabled'] = 'disabled'; |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | - if ($this->required) $data['data-required'] = 'required'; |
|
| 64 | + if ($this->required) { |
|
| 65 | + $data['data-required'] = 'required'; |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | - if ($this->error) $data['data-error'] = 'error'; |
|
| 68 | + if ($this->error) { |
|
| 69 | + $data['data-error'] = 'error'; |
|
| 70 | + } |
|
| 65 | 71 | |
| 66 | 72 | # ------------------------ |
| 67 | 73 | |
@@ -76,7 +82,9 @@ discard block |
||
| 76 | 82 | |
| 77 | 83 | public function post() : bool { |
| 78 | 84 | |
| 79 | - if ($this->posted || $this->disabled || ('' === $this->key)) return false; |
|
| 85 | + if ($this->posted || $this->disabled || ('' === $this->key)) { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 80 | 88 | |
| 81 | 89 | $this->error = (!$this->setValue(Request::post($this->name)) && $this->required); |
| 82 | 90 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | if (($name === '.') || ($name === '..')) continue; |
| 25 | 25 | |
| 26 | - if (@$checker($dir_name . $name)) yield $name; |
|
| 26 | + if (@$checker($dir_name.$name)) yield $name; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | closedir($handler); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | foreach (array_diff($list, ['.', '..']) as $name) { |
| 95 | 95 | |
| 96 | - $name = ($dir_name . '/' . $name); |
|
| 96 | + $name = ($dir_name.'/'.$name); |
|
| 97 | 97 | |
| 98 | 98 | if (@is_dir($name)) self::removeDir($name, true); |
| 99 | 99 | |
@@ -21,9 +21,13 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | while (false !== ($name = readdir($handler))) { |
| 23 | 23 | |
| 24 | - if (($name === '.') || ($name === '..')) continue; |
|
| 24 | + if (($name === '.') || ($name === '..')) { |
|
| 25 | + continue; |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | - if (@$checker($dir_name . $name)) yield $name; |
|
| 28 | + if (@$checker($dir_name . $name)) { |
|
| 29 | + yield $name; |
|
| 30 | + } |
|
| 27 | 31 | } |
| 28 | 32 | |
| 29 | 33 | closedir($handler); |
@@ -38,7 +42,9 @@ discard block |
||
| 38 | 42 | |
| 39 | 43 | private static function getInfo(string $file_name, int $param, bool $check_exists = true) { |
| 40 | 44 | |
| 41 | - if ($check_exists && !self::isFile($file_name)) return false; |
|
| 45 | + if ($check_exists && !self::isFile($file_name)) { |
|
| 46 | + return false; |
|
| 47 | + } |
|
| 42 | 48 | |
| 43 | 49 | return pathinfo($file_name, $param); |
| 44 | 50 | } |
@@ -97,9 +103,11 @@ discard block |
||
| 97 | 103 | |
| 98 | 104 | $name = ($dir_name . '/' . $name); |
| 99 | 105 | |
| 100 | - if (@is_dir($name)) self::removeDir($name, true); |
|
| 101 | - |
|
| 102 | - else if (@is_file($name)) self::removeFile($name); |
|
| 106 | + if (@is_dir($name)) { |
|
| 107 | + self::removeDir($name, true); |
|
| 108 | + } else if (@is_file($name)) { |
|
| 109 | + self::removeFile($name); |
|
| 110 | + } |
|
| 103 | 111 | } |
| 104 | 112 | } |
| 105 | 113 | |
@@ -125,7 +133,9 @@ discard block |
||
| 125 | 133 | |
| 126 | 134 | public static function iterateDirs(string $dir_name) : Generator { |
| 127 | 135 | |
| 128 | - foreach (self::getList($dir_name, 'is_dir') as $name) yield $name; |
|
| 136 | + foreach (self::getList($dir_name, 'is_dir') as $name) { |
|
| 137 | + yield $name; |
|
| 138 | + } |
|
| 129 | 139 | } |
| 130 | 140 | |
| 131 | 141 | /** |
@@ -134,7 +144,9 @@ discard block |
||
| 134 | 144 | |
| 135 | 145 | public static function iterateFiles(string $dir_name) : Generator { |
| 136 | 146 | |
| 137 | - foreach (self::getList($dir_name, 'is_file') as $name) yield $name; |
|
| 147 | + foreach (self::getList($dir_name, 'is_file') as $name) { |
|
| 148 | + yield $name; |
|
| 149 | + } |
|
| 138 | 150 | } |
| 139 | 151 | |
| 140 | 152 | /** |
@@ -240,7 +252,9 @@ discard block |
||
| 240 | 252 | |
| 241 | 253 | public static function include(string $file_name) { |
| 242 | 254 | |
| 243 | - if ((strtolower(self::getExtension($file_name)) !== 'php')) return false; |
|
| 255 | + if ((strtolower(self::getExtension($file_name)) !== 'php')) { |
|
| 256 | + return false; |
|
| 257 | + } |
|
| 244 | 258 | |
| 245 | 259 | return @include $file_name; |
| 246 | 260 | } |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public static function load(string $file_name) { |
| 43 | 43 | |
| 44 | - if (false === ($contents = Explorer::getContents($file_name))) return null; |
|
| 44 | + if (false === ($contents = Explorer::getContents($file_name))) { |
|
| 45 | + return null; |
|
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | return self::parse($contents); |
| 47 | 49 | } |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | |
| 55 | 57 | public static function save(string $file_name, $value) { |
| 56 | 58 | |
| 57 | - if (false === ($value = self::stringify($value))) return false; |
|
| 59 | + if (false === ($value = self::stringify($value))) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | return Explorer::putContents($file_name, $value); |
| 60 | 64 | } |
@@ -2,16 +2,16 @@ |
||
| 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_ADDON_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 9 | -define('REGEX_LANGUAGE_NAME', '/^[a-z][a-z]-[A-Z][A-Z]$/'); |
|
| 10 | -define('REGEX_TEMPLATE_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 8 | +define('REGEX_ADDON_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 9 | +define('REGEX_LANGUAGE_NAME', '/^[a-z][a-z]-[A-Z][A-Z]$/'); |
|
| 10 | +define('REGEX_TEMPLATE_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 11 | 11 | |
| 12 | -define('REGEX_USER_AUTH_CODE', '/^[a-zA-Z0-9]{40}$/'); |
|
| 12 | +define('REGEX_USER_AUTH_CODE', '/^[a-zA-Z0-9]{40}$/'); |
|
| 13 | 13 | |
| 14 | -define('REGEX_USER_NAME', '/^(?!_)(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
| 15 | -define('REGEX_USER_PASSWORD', '/^.+$/'); |
|
| 14 | +define('REGEX_USER_NAME', '/^(?!_)(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
| 15 | +define('REGEX_USER_PASSWORD', '/^.+$/'); |
|
| 16 | 16 | |
| 17 | -define('REGEX_FILE_NAME', '/^[^\/?%*:|"<>\\\]+$/'); |
|
| 17 | +define('REGEX_FILE_NAME', '/^[^\/?%*:|"<>\\\]+$/'); |
|
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | # Handle form |
| 37 | 37 | |
| 38 | - if ($this->form->handle(new Controller)) Request::redirect(INSTALL_PATH . '/contact?submitted'); |
|
| 38 | + if ($this->form->handle(new Controller)) Request::redirect(INSTALL_PATH.'/contact?submitted'); |
|
| 39 | 39 | |
| 40 | 40 | # Display success message |
| 41 | 41 | |
@@ -35,11 +35,15 @@ |
||
| 35 | 35 | |
| 36 | 36 | # Handle form |
| 37 | 37 | |
| 38 | - if ($this->form->handle(new Controller)) Request::redirect(INSTALL_PATH . '/contact?submitted'); |
|
| 38 | + if ($this->form->handle(new Controller)) { |
|
| 39 | + Request::redirect(INSTALL_PATH . '/contact?submitted'); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | # Display success message |
| 41 | 43 | |
| 42 | - if (false !== Request::get('submitted')) Messages::set('success', Language::get('CONTACT_SUCCESS_SEND')); |
|
| 44 | + if (false !== Request::get('submitted')) { |
|
| 45 | + Messages::set('success', Language::get('CONTACT_SUCCESS_SEND')); |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | 48 | # ------------------------ |
| 45 | 49 | |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | |
| 27 | 27 | # Send mail |
| 28 | 28 | |
| 29 | - $to = Settings::get('system_email'); $subject = (Settings::get('site_title') . ' | Contact form message'); |
|
| 29 | + $to = Settings::get('system_email'); $subject = (Settings::get('site_title').' | Contact form message'); |
|
| 30 | 30 | |
| 31 | 31 | if (!Mailer::send($to, $name, $email, $email, $subject, $message)) return 'CONTACT_ERROR_SEND'; |
| 32 | 32 | |
@@ -20,15 +20,21 @@ |
||
| 20 | 20 | |
| 21 | 21 | # Validate values |
| 22 | 22 | |
| 23 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'CONTACT_ERROR_EMAIL_INVALID']; |
|
| 23 | + if (false === ($email = Validate::userEmail($email))) { |
|
| 24 | + return ['email', 'CONTACT_ERROR_EMAIL_INVALID']; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | - if (false === Security::checkCaptcha($captcha)) return ['captcha', 'CONTACT_ERROR_CAPTCHA_INCORRECT']; |
|
| 27 | + if (false === Security::checkCaptcha($captcha)) { |
|
| 28 | + return ['captcha', 'CONTACT_ERROR_CAPTCHA_INCORRECT']; |
|
| 29 | + } |
|
| 26 | 30 | |
| 27 | 31 | # Send mail |
| 28 | 32 | |
| 29 | 33 | $to = Settings::get('system_email'); $subject = (Settings::get('site_title') . ' | Contact form message'); |
| 30 | 34 | |
| 31 | - if (!Mailer::send($to, $name, $email, $email, $subject, $message)) return 'CONTACT_ERROR_SEND'; |
|
| 35 | + if (!Mailer::send($to, $name, $email, $email, $subject, $message)) { |
|
| 36 | + return 'CONTACT_ERROR_SEND'; |
|
| 37 | + } |
|
| 32 | 38 | |
| 33 | 39 | # ------------------------ |
| 34 | 40 | |