@@ -58,6 +58,10 @@ |
||
| 58 | 58 | self::command('install', false, $path); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | + /** |
|
| 62 | + * @param string $command |
|
| 63 | + * @param string $path |
|
| 64 | + */ |
|
| 61 | 65 | static function command($command, $needOutput = true, $path = null) |
| 62 | 66 | { |
| 63 | 67 | include_once 'composer/vendor/autoload.php'; |
@@ -216,6 +216,7 @@ |
||
| 216 | 216 | * @param $number Integer Число на основе которого нужно сформировать окончание |
| 217 | 217 | * @param $endingsArray Array Массив слов или окончаний для чисел (1, 4, 5), |
| 218 | 218 | * например array('яблоко', 'яблока', 'яблок') |
| 219 | + * @param string[] $endingArray |
|
| 219 | 220 | * @return String |
| 220 | 221 | */ |
| 221 | 222 | static function getNumEnding($number, $endingArray) |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | static function uriParse($uri) |
| 39 | 39 | { |
| 40 | 40 | $answerPos = strpos($uri, '?'); |
| 41 | - $params = array_slice(explode('/', substr($uri, 0, $answerPos ? $answerPos : strlen($uri) )), 1); |
|
| 41 | + $params = array_slice(explode('/', substr($uri, 0, $answerPos ? $answerPos : strlen($uri))), 1); |
|
| 42 | 42 | |
| 43 | 43 | foreach ($params as $key => $param) { |
| 44 | 44 | if ($param != '') { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | static function resizeImage($img_path, $max_width = 1000, $max_height = 1000, $crop = false, $pos = 'center') |
| 86 | 86 | { |
| 87 | 87 | ini_set("gd.jpeg_ignore_warning", 1); |
| 88 | - list( $img_width, $img_height, $img_type, $img_tag ) = getimagesize($img_path); |
|
| 88 | + list($img_width, $img_height, $img_type, $img_tag) = getimagesize($img_path); |
|
| 89 | 89 | switch ($img_type) { |
| 90 | 90 | case 1: |
| 91 | 91 | $img_type = 'gif'; |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | if ($crop === true || $crop == 'q') { |
| 110 | 110 | if ($img_width > $img_height) { |
| 111 | - $imgX = floor(( $img_width - $img_height ) / 2); |
|
| 111 | + $imgX = floor(($img_width - $img_height) / 2); |
|
| 112 | 112 | $imgY = 0; |
| 113 | 113 | $img_width = $img_height; |
| 114 | 114 | $new_width = $max_width; |
| 115 | 115 | $new_height = $max_height; |
| 116 | 116 | } else { |
| 117 | 117 | $imgX = 0; |
| 118 | - $imgY = floor(( $img_height - $img_width ) / 2); |
|
| 118 | + $imgY = floor(($img_height - $img_width) / 2); |
|
| 119 | 119 | $img_height = $img_width; |
| 120 | 120 | $new_width = $max_width; |
| 121 | 121 | $new_height = $max_height; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $new_width = $max_width; |
| 137 | 137 | $new_height = $max_height; |
| 138 | 138 | //Находим начальные координаты (центрируем новое изображение) |
| 139 | - $imgX = (int) (($ow / 2) - ($img_width / 2) ); |
|
| 139 | + $imgX = (int) (($ow / 2) - ($img_width / 2)); |
|
| 140 | 140 | if ($pos == 'center') { |
| 141 | 141 | $imgY = (int) (($oh / 2) - ($img_height / 2)); |
| 142 | 142 | } else { |
@@ -58,8 +58,9 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | static function createDir($path) |
| 60 | 60 | { |
| 61 | - if (file_exists($path)) |
|
| 62 | - return true; |
|
| 61 | + if (file_exists($path)) { |
|
| 62 | + return true; |
|
| 63 | + } |
|
| 63 | 64 | |
| 64 | 65 | $path = explode('/', $path); |
| 65 | 66 | $cur = ''; |
@@ -101,10 +102,11 @@ discard block |
||
| 101 | 102 | $imagecreatefromX = "imagecreatefrom{$img_type}"; |
| 102 | 103 | $src_res = $imagecreatefromX($img_path); |
| 103 | 104 | |
| 104 | - if ($img_width / $max_width > $img_height / $max_height) |
|
| 105 | - $separator = $img_width / $max_width; |
|
| 106 | - else |
|
| 107 | - $separator = $img_height / $max_height; |
|
| 105 | + if ($img_width / $max_width > $img_height / $max_height) { |
|
| 106 | + $separator = $img_width / $max_width; |
|
| 107 | + } else { |
|
| 108 | + $separator = $img_height / $max_height; |
|
| 109 | + } |
|
| 108 | 110 | |
| 109 | 111 | if ($crop === true || $crop == 'q') { |
| 110 | 112 | if ($img_width > $img_height) { |
@@ -29,6 +29,9 @@ discard block |
||
| 29 | 29 | public $params = []; |
| 30 | 30 | public $distinct = false; |
| 31 | 31 | |
| 32 | + /** |
|
| 33 | + * @param $instance |
|
| 34 | + */ |
|
| 32 | 35 | function __construct($instance = null) |
| 33 | 36 | { |
| 34 | 37 | if (!$instance) { |
@@ -47,6 +50,9 @@ discard block |
||
| 47 | 50 | return $this->curInstance->pdo->lastInsertId(); |
| 48 | 51 | } |
| 49 | 52 | |
| 53 | + /** |
|
| 54 | + * @param string $table |
|
| 55 | + */ |
|
| 50 | 56 | public function select($table) |
| 51 | 57 | { |
| 52 | 58 | $this->operation = 'SELECT'; |
@@ -288,7 +288,7 @@ |
||
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | $update = implode(',', $updates); |
| 291 | - $query .=" SET {$update}"; |
|
| 291 | + $query .= " SET {$update}"; |
|
| 292 | 292 | case 'SELECT': |
| 293 | 293 | case 'DELETE': |
| 294 | 294 | $this->buildWhere($this->where); |
@@ -126,12 +126,14 @@ discard block |
||
| 126 | 126 | if (!is_array($order)) { |
| 127 | 127 | $this->order[] = "{$order} {$type}"; |
| 128 | 128 | } else { |
| 129 | - foreach ($order as $item) |
|
| 130 | - if (!is_array($item)) { |
|
| 129 | + foreach ($order as $item) { |
|
| 130 | + if (!is_array($item)) { |
|
| 131 | 131 | call_user_func_array(array($this, 'order'), $order); |
| 132 | + } |
|
| 132 | 133 | break; |
| 133 | - } else |
|
| 134 | - $this->order($item); |
|
| 134 | + } else { |
|
| 135 | + $this->order($item); |
|
| 136 | + } |
|
| 135 | 137 | } |
| 136 | 138 | } |
| 137 | 139 | |
@@ -140,8 +142,9 @@ discard block |
||
| 140 | 142 | $start = intval($start); |
| 141 | 143 | $len = intval($len); |
| 142 | 144 | $this->limit = "LIMIT {$start}"; |
| 143 | - if ($len !== 0) |
|
| 144 | - $this->limit .= ",{$len}"; |
|
| 145 | + if ($len !== 0) { |
|
| 146 | + $this->limit .= ",{$len}"; |
|
| 147 | + } |
|
| 145 | 148 | } |
| 146 | 149 | |
| 147 | 150 | public function buildJoin($table, $where = false, $type = 'LEFT', $alias = '') |
@@ -154,10 +157,12 @@ discard block |
||
| 154 | 157 | } |
| 155 | 158 | } else { |
| 156 | 159 | $join .= " {$type} JOIN {$this->curInstance->table_prefix}{$table}"; |
| 157 | - if ($alias) |
|
| 158 | - $join .= " AS `{$alias}`"; |
|
| 159 | - if ($where) |
|
| 160 | - $join .= " ON {$where}"; |
|
| 160 | + if ($alias) { |
|
| 161 | + $join .= " AS `{$alias}`"; |
|
| 162 | + } |
|
| 163 | + if ($where) { |
|
| 164 | + $join .= " ON {$where}"; |
|
| 165 | + } |
|
| 161 | 166 | } |
| 162 | 167 | return $join; |
| 163 | 168 | } |
@@ -177,31 +182,33 @@ discard block |
||
| 177 | 182 | $operation = '='; |
| 178 | 183 | } |
| 179 | 184 | |
| 180 | - if ($concatenation === false) |
|
| 181 | - $concatenation = 'AND'; |
|
| 182 | - elseif ($concatenation === true) |
|
| 183 | - $concatenation = ''; |
|
| 185 | + if ($concatenation === false) { |
|
| 186 | + $concatenation = 'AND'; |
|
| 187 | + } elseif ($concatenation === true) { |
|
| 188 | + $concatenation = ''; |
|
| 189 | + } |
|
| 184 | 190 | |
| 185 | - if ($this->whereString == NULL) |
|
| 186 | - $this->whereString = ' WHERE '; |
|
| 191 | + if ($this->whereString == NULL) { |
|
| 192 | + $this->whereString = ' WHERE '; |
|
| 193 | + } |
|
| 187 | 194 | |
| 188 | 195 | if (stristr($operation, 'IN') || stristr($operation, 'NOT IN')) { |
| 189 | - if (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) |
|
| 190 | - $value = "({$value})"; |
|
| 191 | - elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) |
|
| 192 | - $value = "\"{$value}\""; |
|
| 193 | - } |
|
| 194 | - elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
| 196 | + if (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
| 197 | + $value = "({$value})"; |
|
| 198 | + } elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
| 199 | + $value = "\"{$value}\""; |
|
| 200 | + } |
|
| 201 | + } elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
| 195 | 202 | $this->params[] = $value; |
| 196 | 203 | $value = "?"; |
| 197 | 204 | } |
| 198 | 205 | |
| 199 | - if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') |
|
| 200 | - $this->whereString .= " {$where} {$operation} {$value} "; |
|
| 201 | - else |
|
| 202 | - $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
| 203 | - } |
|
| 204 | - else { |
|
| 206 | + if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') { |
|
| 207 | + $this->whereString .= " {$where} {$operation} {$value} "; |
|
| 208 | + } else { |
|
| 209 | + $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
| 210 | + } |
|
| 211 | + } else { |
|
| 205 | 212 | $i = -1; |
| 206 | 213 | while (isset($where[++$i])) { |
| 207 | 214 | $item = $where[$i]; |
@@ -216,28 +223,32 @@ discard block |
||
| 216 | 223 | $this->whereString .= "{$concatenation} "; |
| 217 | 224 | } |
| 218 | 225 | |
| 219 | - if ($this->whereString != NULL) |
|
| 220 | - $this->whereString .= '('; |
|
| 221 | - else |
|
| 222 | - $this->whereString = 'WHERE ('; |
|
| 226 | + if ($this->whereString != NULL) { |
|
| 227 | + $this->whereString .= '('; |
|
| 228 | + } else { |
|
| 229 | + $this->whereString = 'WHERE ('; |
|
| 230 | + } |
|
| 223 | 231 | } |
| 224 | 232 | |
| 225 | 233 | if (!is_array($item)) { |
| 226 | 234 | call_user_func_array(array($this, 'buildWhere'), $where); |
| 227 | 235 | break; |
| 228 | 236 | } else { |
| 229 | - if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') |
|
| 230 | - if (!isset($item[3])) |
|
| 237 | + if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') { |
|
| 238 | + if (!isset($item[3])) |
|
| 231 | 239 | $concatenation = 'AND'; |
| 232 | - else |
|
| 233 | - $concatenation = $item[3]; |
|
| 234 | - elseif (substr($this->whereString, -1, 1) != '(') |
|
| 235 | - $this->whereString = 'WHERE '; |
|
| 240 | + } else { |
|
| 241 | + $concatenation = $item[3]; |
|
| 242 | + } |
|
| 243 | + elseif (substr($this->whereString, -1, 1) != '(') { |
|
| 244 | + $this->whereString = 'WHERE '; |
|
| 245 | + } |
|
| 236 | 246 | |
| 237 | 247 | $this->buildWhere($item); |
| 238 | 248 | } |
| 239 | - if (!isset($where[$i + 1]) && isset($where[$i - 1])) |
|
| 240 | - $this->whereString .= ') '; |
|
| 249 | + if (!isset($where[$i + 1]) && isset($where[$i - 1])) { |
|
| 250 | + $this->whereString .= ') '; |
|
| 251 | + } |
|
| 241 | 252 | } |
| 242 | 253 | } |
| 243 | 254 | } |
@@ -45,6 +45,10 @@ |
||
| 45 | 45 | return $modelCols; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | + /** |
|
| 49 | + * @param string $colPrefix |
|
| 50 | + * @param string $tableName |
|
| 51 | + */ |
|
| 48 | 52 | function parseColsForTable($cols, $colPrefix, $tableName) |
| 49 | 53 | { |
| 50 | 54 | |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | |
| 26 | 26 | function parseColsForModel($cols = []) |
| 27 | 27 | { |
| 28 | - $modelCols = [ 'labels' => [], 'cols' => [], 'relations' => []]; |
|
| 28 | + $modelCols = ['labels' => [], 'cols' => [], 'relations' => []]; |
|
| 29 | 29 | foreach ($cols as $col) { |
| 30 | 30 | $modelCols['labels'][$col['code']] = $col['label']; |
| 31 | 31 | $colType = !empty($col['type']['primary']) ? $col['type']['primary'] : $col['type']; |
@@ -23,6 +23,9 @@ |
||
| 23 | 23 | public $attributes = []; |
| 24 | 24 | public $indexCol = null; |
| 25 | 25 | |
| 26 | + /** |
|
| 27 | + * @param string[] $cols |
|
| 28 | + */ |
|
| 26 | 29 | function setCols($cols) |
| 27 | 30 | { |
| 28 | 31 | $this->cols = $cols; |
@@ -92,6 +92,9 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | + /** |
|
| 96 | + * @param string $user_mail |
|
| 97 | + */ |
|
| 95 | 98 | function passre($user_mail) |
| 96 | 99 | { |
| 97 | 100 | $user = $this->get($user_mail, 'mail'); |
@@ -312,6 +315,9 @@ discard block |
||
| 312 | 315 | return $user->id; |
| 313 | 316 | } |
| 314 | 317 | |
| 318 | + /** |
|
| 319 | + * @param string $pass |
|
| 320 | + */ |
|
| 315 | 321 | function hashpass($pass) |
| 316 | 322 | { |
| 317 | 323 | return password_hash($pass, PASSWORD_DEFAULT); |
@@ -296,7 +296,7 @@ |
||
| 296 | 296 | $to = $user_mail; |
| 297 | 297 | $subject = 'Регистрация на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME); |
| 298 | 298 | $text = 'Вы были зарегистрированы на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME) . '<br />для входа используйте ваш почтовый ящик в качестве логина и пароль: ' . $pass; |
| 299 | - $text .='<br />'; |
|
| 299 | + $text .= '<br />'; |
|
| 300 | 300 | $text .= '<br />'; |
| 301 | 301 | $text .= 'Для активации вашего аккаунта перейдите по ссылке <a href = "http://' . INJI_DOMAIN_NAME . '/users/activation/' . $user->id . '/' . $user->activation . '">http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/users/activation/' . $user->id . '/' . $user->activation . '</a>'; |
| 302 | 302 | Tools::sendMail($from, $to, $subject, $text); |
@@ -189,17 +189,20 @@ |
||
| 189 | 189 | |
| 190 | 190 | public function get($idn = false, $ltype = 'id') |
| 191 | 191 | { |
| 192 | - if (!$idn) |
|
| 193 | - return false; |
|
| 192 | + if (!$idn) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 194 | 195 | |
| 195 | - if (is_numeric($idn) && $ltype != 'login') |
|
| 196 | - $user = Users\User::get($idn, 'id'); |
|
| 197 | - elseif ($ltype == 'login') |
|
| 198 | - $user = Users\User::get($idn, 'login'); |
|
| 199 | - else |
|
| 200 | - $user = Users\User::get($idn, 'mail'); |
|
| 201 | - if (!$user) |
|
| 202 | - return []; |
|
| 196 | + if (is_numeric($idn) && $ltype != 'login') { |
|
| 197 | + $user = Users\User::get($idn, 'id'); |
|
| 198 | + } elseif ($ltype == 'login') { |
|
| 199 | + $user = Users\User::get($idn, 'login'); |
|
| 200 | + } else { |
|
| 201 | + $user = Users\User::get($idn, 'mail'); |
|
| 202 | + } |
|
| 203 | + if (!$user) { |
|
| 204 | + return []; |
|
| 205 | + } |
|
| 203 | 206 | |
| 204 | 207 | return $user; |
| 205 | 208 | } |
@@ -147,6 +147,9 @@ discard block |
||
| 147 | 147 | return $result[1]; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | + /** |
|
| 151 | + * @param string $source |
|
| 152 | + */ |
|
| 150 | 153 | function parseSource($source) |
| 151 | 154 | { |
| 152 | 155 | $tags = $this->parseRaw($source); |
@@ -190,6 +193,9 @@ discard block |
||
| 190 | 193 | return substr($source, ( $pos + strlen($rawTag) + 2)); |
| 191 | 194 | } |
| 192 | 195 | |
| 196 | + /** |
|
| 197 | + * @param string $type |
|
| 198 | + */ |
|
| 193 | 199 | function getHref($type, $params) |
| 194 | 200 | { |
| 195 | 201 | $href = ''; |
@@ -531,6 +537,9 @@ discard block |
||
| 531 | 537 | echo round(( microtime(true) - INJI_TIME_START), 4); |
| 532 | 538 | } |
| 533 | 539 | |
| 540 | + /** |
|
| 541 | + * @param string $type |
|
| 542 | + */ |
|
| 534 | 543 | function customAsset($type, $asset, $lib = false) |
| 535 | 544 | { |
| 536 | 545 | if (!$lib) { |
@@ -549,6 +558,9 @@ discard block |
||
| 549 | 558 | } |
| 550 | 559 | } |
| 551 | 560 | |
| 561 | + /** |
|
| 562 | + * @param string $lineParams |
|
| 563 | + */ |
|
| 552 | 564 | function widget($_widgetName, $_params = [], $lineParams = null) |
| 553 | 565 | { |
| 554 | 566 | $_paths = $this->getWidgetPaths($_widgetName); |
@@ -140,8 +140,9 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | private function parseRaw($source) |
| 142 | 142 | { |
| 143 | - if (!$source) |
|
| 144 | - return []; |
|
| 143 | + if (!$source) { |
|
| 144 | + return []; |
|
| 145 | + } |
|
| 145 | 146 | |
| 146 | 147 | preg_match_all("|{([^}]+)}|", $source, $result); |
| 147 | 148 | return $result[1]; |
@@ -327,10 +328,11 @@ discard block |
||
| 327 | 328 | $this->ResolveCssHref($css, $type, $hrefs); |
| 328 | 329 | continue; |
| 329 | 330 | } |
| 330 | - if (strpos($css, '//') !== false) |
|
| 331 | - $href = $css; |
|
| 332 | - else |
|
| 333 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 331 | + if (strpos($css, '//') !== false) { |
|
| 332 | + $href = $css; |
|
| 333 | + } else { |
|
| 334 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 335 | + } |
|
| 334 | 336 | $hrefs[$href] = $href; |
| 335 | 337 | } |
| 336 | 338 | break; |
@@ -340,10 +342,11 @@ discard block |
||
| 340 | 342 | $this->ResolveCssHref($css, $type, $hrefs); |
| 341 | 343 | continue; |
| 342 | 344 | } |
| 343 | - if (strpos($css, '://') !== false) |
|
| 344 | - $href = $css; |
|
| 345 | - else |
|
| 346 | - $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}"; |
|
| 345 | + if (strpos($css, '://') !== false) { |
|
| 346 | + $href = $css; |
|
| 347 | + } else { |
|
| 348 | + $href = $this->app->templatesPath . "/{$this->template->name}/css/{$css}"; |
|
| 349 | + } |
|
| 347 | 350 | $hrefs[$href] = $href; |
| 348 | 351 | } |
| 349 | 352 | break; |
@@ -353,10 +356,11 @@ discard block |
||
| 353 | 356 | $this->ResolveCssHref($css, $type, $hrefs); |
| 354 | 357 | continue; |
| 355 | 358 | } |
| 356 | - if (strpos($css, '//') !== false) |
|
| 357 | - $href = $css; |
|
| 358 | - else |
|
| 359 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 359 | + if (strpos($css, '//') !== false) { |
|
| 360 | + $href = $css; |
|
| 361 | + } else { |
|
| 362 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 363 | + } |
|
| 360 | 364 | $hrefs[$href] = $href; |
| 361 | 365 | } |
| 362 | 366 | break; |
@@ -410,8 +414,9 @@ discard block |
||
| 410 | 414 | $noParsedScripts = []; |
| 411 | 415 | foreach ($scripts as $script) { |
| 412 | 416 | if (is_string($script)) { |
| 413 | - if (!empty($urls[$script])) |
|
| 414 | - continue; |
|
| 417 | + if (!empty($urls[$script])) { |
|
| 418 | + continue; |
|
| 419 | + } |
|
| 415 | 420 | |
| 416 | 421 | $path = $this->app->staticLoader->parsePath($script); |
| 417 | 422 | if (file_exists($path)) { |
@@ -422,8 +427,9 @@ discard block |
||
| 422 | 427 | $noParsedScripts[$script] = $script; |
| 423 | 428 | } |
| 424 | 429 | } elseif (!empty($script['file'])) { |
| 425 | - if (!empty($urls[$script['file']])) |
|
| 426 | - continue; |
|
| 430 | + if (!empty($urls[$script['file']])) { |
|
| 431 | + continue; |
|
| 432 | + } |
|
| 427 | 433 | |
| 428 | 434 | $path = $this->app->staticLoader->parsePath($script['file']); |
| 429 | 435 | if (file_exists($path)) { |
@@ -482,12 +488,14 @@ discard block |
||
| 482 | 488 | $this->genScriptArray($js, $type, $resultArray); |
| 483 | 489 | continue; |
| 484 | 490 | } |
| 485 | - if (strpos($js, '//') !== false) |
|
| 486 | - $href = $js; |
|
| 487 | - else |
|
| 488 | - $href = $this->getHref('js', $js); |
|
| 489 | - if (!$href) |
|
| 490 | - continue; |
|
| 491 | + if (strpos($js, '//') !== false) { |
|
| 492 | + $href = $js; |
|
| 493 | + } else { |
|
| 494 | + $href = $this->getHref('js', $js); |
|
| 495 | + } |
|
| 496 | + if (!$href) { |
|
| 497 | + continue; |
|
| 498 | + } |
|
| 491 | 499 | |
| 492 | 500 | $resultArray[] = $href; |
| 493 | 501 | } |
@@ -498,10 +506,11 @@ discard block |
||
| 498 | 506 | $this->genScriptArray($js, $type, $resultArray); |
| 499 | 507 | continue; |
| 500 | 508 | } |
| 501 | - if (strpos($js, '//') !== false) |
|
| 502 | - $href = $js; |
|
| 503 | - else |
|
| 504 | - $href = $this->app->templatesPath . "/{$this->template->name}/js/{$js}"; |
|
| 509 | + if (strpos($js, '//') !== false) { |
|
| 510 | + $href = $js; |
|
| 511 | + } else { |
|
| 512 | + $href = $this->app->templatesPath . "/{$this->template->name}/js/{$js}"; |
|
| 513 | + } |
|
| 505 | 514 | $resultArray[] = $href; |
| 506 | 515 | } |
| 507 | 516 | break; |
@@ -517,8 +526,9 @@ discard block |
||
| 517 | 526 | $asset = []; |
| 518 | 527 | } |
| 519 | 528 | $asset['file'] = $this->getHref('js', $js); |
| 520 | - if (!$asset['file']) |
|
| 521 | - continue; |
|
| 529 | + if (!$asset['file']) { |
|
| 530 | + continue; |
|
| 531 | + } |
|
| 522 | 532 | $resultArray[] = $asset; |
| 523 | 533 | } |
| 524 | 534 | break; |
@@ -568,8 +578,9 @@ discard block |
||
| 568 | 578 | $paramArray = true; |
| 569 | 579 | } |
| 570 | 580 | } |
| 571 | - if (!$paramArray) |
|
| 572 | - $lineParams = ':' . implode(':', $_params); |
|
| 581 | + if (!$paramArray) { |
|
| 582 | + $lineParams = ':' . implode(':', $_params); |
|
| 583 | + } |
|
| 573 | 584 | } |
| 574 | 585 | } |
| 575 | 586 | echo "<!--start:{WIDGET:{$_widgetName}{$lineParams}}-->\n"; |
@@ -187,16 +187,16 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | $pos = strpos($source, $rawTag) - 1; |
| 189 | 189 | echo substr($source, 0, $pos); |
| 190 | - return substr($source, ( $pos + strlen($rawTag) + 2)); |
|
| 190 | + return substr($source, ($pos + strlen($rawTag) + 2)); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | public function getHref($type, $params) |
| 194 | 194 | { |
| 195 | 195 | $href = ''; |
| 196 | 196 | if (is_string($params)) { |
| 197 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params; |
|
| 197 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '') . $params; |
|
| 198 | 198 | } elseif (empty($params['template']) && !empty($params['file'])) { |
| 199 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $params['file']; |
|
| 199 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '') . $params['file']; |
|
| 200 | 200 | } elseif (!empty($params['template']) && !empty($params['file'])) { |
| 201 | 201 | $href = $this->app->templatesPath . "/{$this->template->name}/{$type}/{$params['file']}"; |
| 202 | 202 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | $this->checkNeedLibs(); |
| 257 | 257 | $this->parseCss(); |
| 258 | - echo "\n <script src='" . Statics::file(($this->app->type != 'app' ? '/' . $this->app->name : '' ) . "/static/system/js/Inji.js") . "'></script>"; |
|
| 258 | + echo "\n <script src='" . Statics::file(($this->app->type != 'app' ? '/' . $this->app->name : '') . "/static/system/js/Inji.js") . "'></script>"; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | public function parseCss() |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | if (file_exists($path)) { |
| 280 | 280 | $this->loadedCss[$href] = $href; |
| 281 | 281 | $urls[$href] = $path; |
| 282 | - $timeStr.=filemtime($path); |
|
| 282 | + $timeStr .= filemtime($path); |
|
| 283 | 283 | } else { |
| 284 | 284 | echo "\n <link href='{$href}' rel='stylesheet' type='text/css' />"; |
| 285 | 285 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | if (strpos($css, '//') !== false) |
| 331 | 331 | $href = $css; |
| 332 | 332 | else |
| 333 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 333 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '') . $css; |
|
| 334 | 334 | $hrefs[$href] = $href; |
| 335 | 335 | } |
| 336 | 336 | break; |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | if (strpos($css, '//') !== false) |
| 357 | 357 | $href = $css; |
| 358 | 358 | else |
| 359 | - $href = ($this->app->type != 'app' ? '/' . $this->app->name : '' ) . $css; |
|
| 359 | + $href = ($this->app->type != 'app' ? '/' . $this->app->name : '') . $css; |
|
| 360 | 360 | $hrefs[$href] = $href; |
| 361 | 361 | } |
| 362 | 362 | break; |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | if (file_exists($path)) { |
| 418 | 418 | $nativeUrl[$script] = $script; |
| 419 | 419 | $urls[$script] = $path; |
| 420 | - $timeStr.=filemtime($path); |
|
| 420 | + $timeStr .= filemtime($path); |
|
| 421 | 421 | } else { |
| 422 | 422 | $noParsedScripts[$script] = $script; |
| 423 | 423 | } |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | if (!empty($script['name'])) { |
| 433 | 433 | $onLoadModules[$script['name']] = $script['name']; |
| 434 | 434 | } |
| 435 | - $timeStr.=filemtime($path); |
|
| 435 | + $timeStr .= filemtime($path); |
|
| 436 | 436 | } else { |
| 437 | 437 | $noParsedScripts[$script] = $script; |
| 438 | 438 | } |
@@ -31,6 +31,9 @@ |
||
| 31 | 31 | return $return; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + /** |
|
| 35 | + * @param string $path |
|
| 36 | + */ |
|
| 34 | 37 | static function parseClass($path) |
| 35 | 38 | { |
| 36 | 39 | $code = file_get_contents($path); |
@@ -16,13 +16,13 @@ |
||
| 16 | 16 | if ($level == 0) |
| 17 | 17 | $return = "["; |
| 18 | 18 | foreach ($data as $key => $item) { |
| 19 | - $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "'{$key}' => "; |
|
| 19 | + $return .= "\n" . str_repeat(' ', ($level * 4 + 4)) . "'{$key}' => "; |
|
| 20 | 20 | if (!is_array($item)) |
| 21 | 21 | $return .= "'{$item}',"; |
| 22 | 22 | else { |
| 23 | 23 | $return .= "["; |
| 24 | 24 | $return .= rtrim(self::genArray($item, $level + 1), ','); |
| 25 | - $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "],"; |
|
| 25 | + $return .= "\n" . str_repeat(' ', ($level * 4 + 4)) . "],"; |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | if ($level == 0) |
@@ -13,20 +13,22 @@ |
||
| 13 | 13 | static function genArray($data, $level = 0) |
| 14 | 14 | { |
| 15 | 15 | $return = ''; |
| 16 | - if ($level == 0) |
|
| 17 | - $return = "["; |
|
| 16 | + if ($level == 0) { |
|
| 17 | + $return = "["; |
|
| 18 | + } |
|
| 18 | 19 | foreach ($data as $key => $item) { |
| 19 | 20 | $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "'{$key}' => "; |
| 20 | - if (!is_array($item)) |
|
| 21 | - $return .= "'{$item}',"; |
|
| 22 | - else { |
|
| 21 | + if (!is_array($item)) { |
|
| 22 | + $return .= "'{$item}',"; |
|
| 23 | + } else { |
|
| 23 | 24 | $return .= "["; |
| 24 | 25 | $return .= rtrim(self::genArray($item, $level + 1), ','); |
| 25 | 26 | $return .= "\n" . str_repeat(' ', ( $level * 4 + 4)) . "],"; |
| 26 | 27 | } |
| 27 | 28 | } |
| 28 | - if ($level == 0) |
|
| 29 | - $return = rtrim($return, ',') . "\n];"; |
|
| 29 | + if ($level == 0) { |
|
| 30 | + $return = rtrim($return, ',') . "\n];"; |
|
| 31 | + } |
|
| 30 | 32 | |
| 31 | 33 | return $return; |
| 32 | 34 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * the constructor |
| 90 | 90 | * |
| 91 | 91 | * @param array $options |
| 92 | - * @return boolean |
|
| 92 | + * @return boolean|null |
|
| 93 | 93 | * @since 0.5.2 |
| 94 | 94 | */ |
| 95 | 95 | public function __construct($options = false) |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | /** |
| 389 | 389 | * Use this method to get the last error ocurred |
| 390 | 390 | * @param void |
| 391 | - * @return string The last error, that occured |
|
| 391 | + * @return boolean The last error, that occured |
|
| 392 | 392 | */ |
| 393 | 393 | public function get_last_error() |
| 394 | 394 | { |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | /** |
| 399 | 399 | * The actual decoding algorithm |
| 400 | 400 | * @param string |
| 401 | - * @return mixed |
|
| 401 | + * @return false|string |
|
| 402 | 402 | */ |
| 403 | 403 | protected function _decode($encoded) |
| 404 | 404 | { |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | /** |
| 456 | 456 | * The actual encoding algorithm |
| 457 | 457 | * @param string |
| 458 | - * @return mixed |
|
| 458 | + * @return false|string |
|
| 459 | 459 | */ |
| 460 | 460 | protected function _encode($decoded) |
| 461 | 461 | { |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | * Decomposes a Hangul syllable |
| 676 | 676 | * (see http://www.unicode.org/unicode/reports/tr15/#Hangul |
| 677 | 677 | * @param integer 32bit UCS4 code point |
| 678 | - * @return array Either Hangul Syllable decomposed or original 32bit value as one value array |
|
| 678 | + * @return integer[] Either Hangul Syllable decomposed or original 32bit value as one value array |
|
| 679 | 679 | */ |
| 680 | 680 | protected function _hangul_decompose($char) |
| 681 | 681 | { |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | break; |
| 261 | 261 | case 'ucs4_string': |
| 262 | 262 | return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); |
| 263 | - break; |
|
| 263 | + break; |
|
| 264 | 264 | case 'ucs4_array': |
| 265 | 265 | return $this->_utf8_to_ucs4($return); |
| 266 | 266 | break; |
@@ -316,8 +316,8 @@ discard block |
||
| 316 | 316 | case 0x40: |
| 317 | 317 | // Neither email addresses nor URLs allowed in strict mode |
| 318 | 318 | if ($this->_strict_mode) { |
| 319 | - $this->_error('Neither email addresses nor URLs are allowed in strict mode.'); |
|
| 320 | - return false; |
|
| 319 | + $this->_error('Neither email addresses nor URLs are allowed in strict mode.'); |
|
| 320 | + return false; |
|
| 321 | 321 | } else { |
| 322 | 322 | // Skip first char |
| 323 | 323 | if ($k) { |
@@ -129,41 +129,41 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | foreach ($option as $k => $v) { |
| 131 | 131 | switch ($k) { |
| 132 | - case 'encoding': |
|
| 133 | - switch ($v) { |
|
| 134 | - case 'utf8': |
|
| 135 | - case 'ucs4_string': |
|
| 136 | - case 'ucs4_array': |
|
| 137 | - $this->_api_encoding = $v; |
|
| 132 | + case 'encoding': |
|
| 133 | + switch ($v) { |
|
| 134 | + case 'utf8': |
|
| 135 | + case 'ucs4_string': |
|
| 136 | + case 'ucs4_array': |
|
| 137 | + $this->_api_encoding = $v; |
|
| 138 | + break; |
|
| 139 | + default: |
|
| 140 | + $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k); |
|
| 141 | + return false; |
|
| 142 | + } |
|
| 143 | + break; |
|
| 144 | + case 'overlong': |
|
| 145 | + $this->_allow_overlong = ($v) ? true : false; |
|
| 146 | + break; |
|
| 147 | + case 'strict': |
|
| 148 | + $this->_strict_mode = ($v) ? true : false; |
|
| 149 | + break; |
|
| 150 | + case 'idn_version': |
|
| 151 | + if (in_array($v, array('2003', '2008'))) { |
|
| 152 | + $this->_idn_version = $v; |
|
| 153 | + } else { |
|
| 154 | + $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k); |
|
| 155 | + } |
|
| 156 | + break; |
|
| 157 | + case 'encode_german_sz': // Deprecated |
|
| 158 | + if (!$v) { |
|
| 159 | + self::$NP['replacemaps'][0xDF] = array(0x73, 0x73); |
|
| 160 | + } else { |
|
| 161 | + unset(self::$NP['replacemaps'][0xDF]); |
|
| 162 | + } |
|
| 138 | 163 | break; |
| 139 | 164 | default: |
| 140 | - $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k); |
|
| 165 | + $this->_error('Set Parameter: Unknown option '.$k); |
|
| 141 | 166 | return false; |
| 142 | - } |
|
| 143 | - break; |
|
| 144 | - case 'overlong': |
|
| 145 | - $this->_allow_overlong = ($v) ? true : false; |
|
| 146 | - break; |
|
| 147 | - case 'strict': |
|
| 148 | - $this->_strict_mode = ($v) ? true : false; |
|
| 149 | - break; |
|
| 150 | - case 'idn_version': |
|
| 151 | - if (in_array($v, array('2003', '2008'))) { |
|
| 152 | - $this->_idn_version = $v; |
|
| 153 | - } else { |
|
| 154 | - $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k); |
|
| 155 | - } |
|
| 156 | - break; |
|
| 157 | - case 'encode_german_sz': // Deprecated |
|
| 158 | - if (!$v) { |
|
| 159 | - self::$NP['replacemaps'][0xDF] = array(0x73, 0x73); |
|
| 160 | - } else { |
|
| 161 | - unset(self::$NP['replacemaps'][0xDF]); |
|
| 162 | - } |
|
| 163 | - break; |
|
| 164 | - default: |
|
| 165 | - $this->_error('Set Parameter: Unknown option '.$k); |
|
| 166 | - return false; |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | return true; |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | // Optionally set |
| 181 | 181 | if ($one_time_encoding) { |
| 182 | 182 | switch ($one_time_encoding) { |
| 183 | - case 'utf8': |
|
| 184 | - case 'ucs4_string': |
|
| 185 | - case 'ucs4_array': |
|
| 186 | - break; |
|
| 187 | - default: |
|
| 188 | - $this->_error('Unknown encoding '.$one_time_encoding); |
|
| 189 | - return false; |
|
| 183 | + case 'utf8': |
|
| 184 | + case 'ucs4_string': |
|
| 185 | + case 'ucs4_array': |
|
| 186 | + break; |
|
| 187 | + default: |
|
| 188 | + $this->_error('Unknown encoding '.$one_time_encoding); |
|
| 189 | + return false; |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | // Make sure to drop any newline characters around |
@@ -255,18 +255,18 @@ discard block |
||
| 255 | 255 | // The output is UTF-8 by default, other output formats need conversion here |
| 256 | 256 | // If one time encoding is given, use this, else the objects property |
| 257 | 257 | switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) { |
| 258 | - case 'utf8': |
|
| 259 | - return $return; |
|
| 260 | - break; |
|
| 261 | - case 'ucs4_string': |
|
| 262 | - return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); |
|
| 263 | - break; |
|
| 264 | - case 'ucs4_array': |
|
| 265 | - return $this->_utf8_to_ucs4($return); |
|
| 266 | - break; |
|
| 267 | - default: |
|
| 268 | - $this->_error('Unsupported output format'); |
|
| 269 | - return false; |
|
| 258 | + case 'utf8': |
|
| 259 | + return $return; |
|
| 260 | + break; |
|
| 261 | + case 'ucs4_string': |
|
| 262 | + return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); |
|
| 263 | + break; |
|
| 264 | + case 'ucs4_array': |
|
| 265 | + return $this->_utf8_to_ucs4($return); |
|
| 266 | + break; |
|
| 267 | + default: |
|
| 268 | + $this->_error('Unsupported output format'); |
|
| 269 | + return false; |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | |
@@ -281,16 +281,16 @@ discard block |
||
| 281 | 281 | // Forcing conversion of input to UCS4 array |
| 282 | 282 | // If one time encoding is given, use this, else the objects property |
| 283 | 283 | switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) { |
| 284 | - case 'utf8': |
|
| 285 | - $decoded = $this->_utf8_to_ucs4($decoded); |
|
| 286 | - break; |
|
| 287 | - case 'ucs4_string': |
|
| 288 | - $decoded = $this->_ucs4_string_to_ucs4($decoded); |
|
| 289 | - case 'ucs4_array': |
|
| 290 | - break; |
|
| 291 | - default: |
|
| 292 | - $this->_error('Unsupported input format: '.($one_time_encoding ? $one_time_encoding : $this->_api_encoding)); |
|
| 293 | - return false; |
|
| 284 | + case 'utf8': |
|
| 285 | + $decoded = $this->_utf8_to_ucs4($decoded); |
|
| 286 | + break; |
|
| 287 | + case 'ucs4_string': |
|
| 288 | + $decoded = $this->_ucs4_string_to_ucs4($decoded); |
|
| 289 | + case 'ucs4_array': |
|
| 290 | + break; |
|
| 291 | + default: |
|
| 292 | + $this->_error('Unsupported input format: '.($one_time_encoding ? $one_time_encoding : $this->_api_encoding)); |
|
| 293 | + return false; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // No input, no output, what else did you expect? |
@@ -303,35 +303,35 @@ discard block |
||
| 303 | 303 | foreach ($decoded as $k => $v) { |
| 304 | 304 | // Make sure to use just the plain dot |
| 305 | 305 | switch($v) { |
| 306 | - case 0x3002: |
|
| 307 | - case 0xFF0E: |
|
| 308 | - case 0xFF61: |
|
| 309 | - $decoded[$k] = 0x2E; |
|
| 310 | - // Right, no break here, the above are converted to dots anyway |
|
| 311 | - // Stumbling across an anchoring character |
|
| 312 | - case 0x2E: |
|
| 313 | - case 0x2F: |
|
| 314 | - case 0x3A: |
|
| 315 | - case 0x3F: |
|
| 316 | - case 0x40: |
|
| 317 | - // Neither email addresses nor URLs allowed in strict mode |
|
| 318 | - if ($this->_strict_mode) { |
|
| 319 | - $this->_error('Neither email addresses nor URLs are allowed in strict mode.'); |
|
| 320 | - return false; |
|
| 321 | - } else { |
|
| 322 | - // Skip first char |
|
| 323 | - if ($k) { |
|
| 324 | - $encoded = ''; |
|
| 325 | - $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k)-$last_begin))); |
|
| 326 | - if ($encoded) { |
|
| 327 | - $output .= $encoded; |
|
| 328 | - } else { |
|
| 329 | - $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k)-$last_begin))); |
|
| 306 | + case 0x3002: |
|
| 307 | + case 0xFF0E: |
|
| 308 | + case 0xFF61: |
|
| 309 | + $decoded[$k] = 0x2E; |
|
| 310 | + // Right, no break here, the above are converted to dots anyway |
|
| 311 | + // Stumbling across an anchoring character |
|
| 312 | + case 0x2E: |
|
| 313 | + case 0x2F: |
|
| 314 | + case 0x3A: |
|
| 315 | + case 0x3F: |
|
| 316 | + case 0x40: |
|
| 317 | + // Neither email addresses nor URLs allowed in strict mode |
|
| 318 | + if ($this->_strict_mode) { |
|
| 319 | + $this->_error('Neither email addresses nor URLs are allowed in strict mode.'); |
|
| 320 | + return false; |
|
| 321 | + } else { |
|
| 322 | + // Skip first char |
|
| 323 | + if ($k) { |
|
| 324 | + $encoded = ''; |
|
| 325 | + $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k)-$last_begin))); |
|
| 326 | + if ($encoded) { |
|
| 327 | + $output .= $encoded; |
|
| 328 | + } else { |
|
| 329 | + $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k)-$last_begin))); |
|
| 330 | + } |
|
| 331 | + $output .= chr($decoded[$k]); |
|
| 330 | 332 | } |
| 331 | - $output .= chr($decoded[$k]); |
|
| 333 | + $last_begin = $k + 1; |
|
| 332 | 334 | } |
| 333 | - $last_begin = $k + 1; |
|
| 334 | - } |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | // Catch the rest of the string |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | protected $_lcount = 19; |
| 73 | 73 | protected $_vcount = 21; |
| 74 | 74 | protected $_tcount = 28; |
| 75 | - protected $_ncount = 588; // _vcount * _tcount |
|
| 75 | + protected $_ncount = 588; // _vcount * _tcount |
|
| 76 | 76 | protected $_scount = 11172; // _lcount * _tcount * _vcount |
| 77 | 77 | protected $_error = false; |
| 78 | 78 | |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | // See {@link set_paramter()} for details of how to change the following |
| 82 | 82 | // settings from within your script / application |
| 83 | - protected $_api_encoding = 'utf8'; // Default input charset is UTF-8 |
|
| 84 | - protected $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden |
|
| 85 | - protected $_strict_mode = false; // Behave strict or not |
|
| 86 | - protected $_idn_version = 2003; // Can be either 2003 (old, default) or 2008 |
|
| 83 | + protected $_api_encoding = 'utf8'; // Default input charset is UTF-8 |
|
| 84 | + protected $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden |
|
| 85 | + protected $_strict_mode = false; // Behave strict or not |
|
| 86 | + protected $_idn_version = 2003; // Can be either 2003 (old, default) or 2008 |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * the constructor |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $this->_api_encoding = $v; |
| 138 | 138 | break; |
| 139 | 139 | default: |
| 140 | - $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k); |
|
| 140 | + $this->_error('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k); |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | break; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | if (in_array($v, array('2003', '2008'))) { |
| 152 | 152 | $this->_idn_version = $v; |
| 153 | 153 | } else { |
| 154 | - $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k); |
|
| 154 | + $this->_error('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k); |
|
| 155 | 155 | } |
| 156 | 156 | break; |
| 157 | 157 | case 'encode_german_sz': // Deprecated |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | break; |
| 164 | 164 | default: |
| 165 | - $this->_error('Set Parameter: Unknown option '.$k); |
|
| 165 | + $this->_error('Set Parameter: Unknown option ' . $k); |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | case 'ucs4_array': |
| 186 | 186 | break; |
| 187 | 187 | default: |
| 188 | - $this->_error('Unknown encoding '.$one_time_encoding); |
|
| 188 | + $this->_error('Unknown encoding ' . $one_time_encoding); |
|
| 189 | 189 | return false; |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | list ($email_pref, $input) = explode('@', $input, 2); |
| 204 | 204 | $arr = explode('.', $input); |
| 205 | 205 | foreach ($arr as $k => $v) { |
| 206 | - if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) { |
|
| 206 | + if (preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) { |
|
| 207 | 207 | $conv = $this->_decode($v); |
| 208 | 208 | if ($conv) $arr[$k] = $conv; |
| 209 | 209 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $input = join('.', $arr); |
| 212 | 212 | $arr = explode('.', $email_pref); |
| 213 | 213 | foreach ($arr as $k => $v) { |
| 214 | - if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) { |
|
| 214 | + if (preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) { |
|
| 215 | 215 | $conv = $this->_decode($v); |
| 216 | 216 | if ($conv) $arr[$k] = $conv; |
| 217 | 217 | } |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | $parsed['host'] = join('.', $arr); |
| 235 | 235 | $return = |
| 236 | - (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')) |
|
| 237 | - .(empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@') |
|
| 236 | + (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')) |
|
| 237 | + .(empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@') |
|
| 238 | 238 | .$parsed['host'] |
| 239 | - .(empty($parsed['port']) ? '' : ':'.$parsed['port']) |
|
| 239 | + .(empty($parsed['port']) ? '' : ':' . $parsed['port']) |
|
| 240 | 240 | .(empty($parsed['path']) ? '' : $parsed['path']) |
| 241 | - .(empty($parsed['query']) ? '' : '?'.$parsed['query']) |
|
| 242 | - .(empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']); |
|
| 241 | + .(empty($parsed['query']) ? '' : '?' . $parsed['query']) |
|
| 242 | + .(empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']); |
|
| 243 | 243 | } else { // parse_url seems to have failed, try without it |
| 244 | 244 | $arr = explode('.', $input); |
| 245 | 245 | foreach ($arr as $k => $v) { |
@@ -255,8 +255,7 @@ discard block |
||
| 255 | 255 | // The output is UTF-8 by default, other output formats need conversion here |
| 256 | 256 | // If one time encoding is given, use this, else the objects property |
| 257 | 257 | switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) { |
| 258 | - case 'utf8': |
|
| 259 | - return $return; |
|
| 258 | + case 'utf8' : return $return; |
|
| 260 | 259 | break; |
| 261 | 260 | case 'ucs4_string': |
| 262 | 261 | return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); |
@@ -281,15 +280,14 @@ discard block |
||
| 281 | 280 | // Forcing conversion of input to UCS4 array |
| 282 | 281 | // If one time encoding is given, use this, else the objects property |
| 283 | 282 | switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) { |
| 284 | - case 'utf8': |
|
| 285 | - $decoded = $this->_utf8_to_ucs4($decoded); |
|
| 283 | + case 'utf8' : $decoded = $this->_utf8_to_ucs4($decoded); |
|
| 286 | 284 | break; |
| 287 | 285 | case 'ucs4_string': |
| 288 | 286 | $decoded = $this->_ucs4_string_to_ucs4($decoded); |
| 289 | 287 | case 'ucs4_array': |
| 290 | 288 | break; |
| 291 | 289 | default: |
| 292 | - $this->_error('Unsupported input format: '.($one_time_encoding ? $one_time_encoding : $this->_api_encoding)); |
|
| 290 | + $this->_error('Unsupported input format: ' . ($one_time_encoding ? $one_time_encoding : $this->_api_encoding)); |
|
| 293 | 291 | return false; |
| 294 | 292 | } |
| 295 | 293 | |
@@ -302,7 +300,7 @@ discard block |
||
| 302 | 300 | $output = ''; |
| 303 | 301 | foreach ($decoded as $k => $v) { |
| 304 | 302 | // Make sure to use just the plain dot |
| 305 | - switch($v) { |
|
| 303 | + switch ($v) { |
|
| 306 | 304 | case 0x3002: |
| 307 | 305 | case 0xFF0E: |
| 308 | 306 | case 0xFF61: |
@@ -322,11 +320,11 @@ discard block |
||
| 322 | 320 | // Skip first char |
| 323 | 321 | if ($k) { |
| 324 | 322 | $encoded = ''; |
| 325 | - $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k)-$last_begin))); |
|
| 323 | + $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k) - $last_begin))); |
|
| 326 | 324 | if ($encoded) { |
| 327 | 325 | $output .= $encoded; |
| 328 | 326 | } else { |
| 329 | - $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k)-$last_begin))); |
|
| 327 | + $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k) - $last_begin))); |
|
| 330 | 328 | } |
| 331 | 329 | $output .= chr($decoded[$k]); |
| 332 | 330 | } |
@@ -338,11 +336,11 @@ discard block |
||
| 338 | 336 | if ($last_begin) { |
| 339 | 337 | $inp_len = sizeof($decoded); |
| 340 | 338 | $encoded = ''; |
| 341 | - $encoded = $this->_encode(array_slice($decoded, $last_begin, (($inp_len)-$last_begin))); |
|
| 339 | + $encoded = $this->_encode(array_slice($decoded, $last_begin, (($inp_len) - $last_begin))); |
|
| 342 | 340 | if ($encoded) { |
| 343 | 341 | $output .= $encoded; |
| 344 | 342 | } else { |
| 345 | - $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($inp_len)-$last_begin))); |
|
| 343 | + $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($inp_len) - $last_begin))); |
|
| 346 | 344 | } |
| 347 | 345 | return $output; |
| 348 | 346 | } else { |
@@ -375,13 +373,13 @@ discard block |
||
| 375 | 373 | } |
| 376 | 374 | $parsed['host'] = join('.', $arr); |
| 377 | 375 | $return = |
| 378 | - (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')) |
|
| 379 | - .(empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@') |
|
| 376 | + (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')) |
|
| 377 | + .(empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@') |
|
| 380 | 378 | .$parsed['host'] |
| 381 | - .(empty($parsed['port']) ? '' : ':'.$parsed['port']) |
|
| 379 | + .(empty($parsed['port']) ? '' : ':' . $parsed['port']) |
|
| 382 | 380 | .(empty($parsed['path']) ? '' : $parsed['path']) |
| 383 | - .(empty($parsed['query']) ? '' : '?'.$parsed['query']) |
|
| 384 | - .(empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']); |
|
| 381 | + .(empty($parsed['query']) ? '' : '?' . $parsed['query']) |
|
| 382 | + .(empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']); |
|
| 385 | 383 | return $return; |
| 386 | 384 | } |
| 387 | 385 | |
@@ -404,11 +402,11 @@ discard block |
||
| 404 | 402 | { |
| 405 | 403 | $decoded = array(); |
| 406 | 404 | // find the Punycode prefix |
| 407 | - if (!preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $encoded)) { |
|
| 405 | + if (!preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $encoded)) { |
|
| 408 | 406 | $this->_error('This is not a punycode string'); |
| 409 | 407 | return false; |
| 410 | 408 | } |
| 411 | - $encode_test = preg_replace('!^'.preg_quote($this->_punycode_prefix, '!').'!', '', $encoded); |
|
| 409 | + $encode_test = preg_replace('!^' . preg_quote($this->_punycode_prefix, '!') . '!', '', $encoded); |
|
| 412 | 410 | // If nothing left after removing the prefix, it is hopeless |
| 413 | 411 | if (!$encode_test) { |
| 414 | 412 | $this->_error('The given encoded string was empty'); |
@@ -431,11 +429,10 @@ discard block |
||
| 431 | 429 | $char = $this->_initial_n; |
| 432 | 430 | |
| 433 | 431 | for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) { |
| 434 | - for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) { |
|
| 432 | + for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) { |
|
| 435 | 433 | $digit = $this->_decode_digit($encoded{$enco_idx++}); |
| 436 | 434 | $idx += $digit * $w; |
| 437 | - $t = ($k <= $bias) ? $this->_tmin : |
|
| 438 | - (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias)); |
|
| 435 | + $t = ($k <= $bias) ? $this->_tmin : (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias)); |
|
| 439 | 436 | if ($digit < $t) break; |
| 440 | 437 | $w = (int) ($w * ($this->_base - $t)); |
| 441 | 438 | } |
@@ -500,7 +497,7 @@ discard block |
||
| 500 | 497 | if ($codecount == $deco_len) return $encoded; // All codepoints were basic ones |
| 501 | 498 | |
| 502 | 499 | // Start with the prefix; copy it to output |
| 503 | - $encoded = $this->_punycode_prefix.$encoded; |
|
| 500 | + $encoded = $this->_punycode_prefix . $encoded; |
|
| 504 | 501 | // If we have basic code points in output, add an hyphen to the end |
| 505 | 502 | if ($codecount) $encoded .= '-'; |
| 506 | 503 | // Now find and encode all non-basic code points |
@@ -525,14 +522,13 @@ discard block |
||
| 525 | 522 | $delta++; |
| 526 | 523 | } elseif ($decoded[$i] == $cur_code) { |
| 527 | 524 | for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) { |
| 528 | - $t = ($k <= $bias) ? $this->_tmin : |
|
| 529 | - (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias); |
|
| 525 | + $t = ($k <= $bias) ? $this->_tmin : (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias); |
|
| 530 | 526 | if ($q < $t) break; |
| 531 | 527 | $encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval() |
| 532 | 528 | $q = (int) (($q - $t) / ($this->_base - $t)); |
| 533 | 529 | } |
| 534 | 530 | $encoded .= $this->_encode_digit($q); |
| 535 | - $bias = $this->_adapt($delta, $codecount+1, $is_first); |
|
| 531 | + $bias = $this->_adapt($delta, $codecount + 1, $is_first); |
|
| 536 | 532 | $codecount++; |
| 537 | 533 | $delta = 0; |
| 538 | 534 | $is_first = false; |
@@ -610,12 +606,12 @@ discard block |
||
| 610 | 606 | if (in_array($v, self::$NP['map_nothing'])) continue; |
| 611 | 607 | // Try to find prohibited input |
| 612 | 608 | if (in_array($v, self::$NP['prohibit']) || in_array($v, self::$NP['general_prohibited'])) { |
| 613 | - $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v)); |
|
| 609 | + $this->_error('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v)); |
|
| 614 | 610 | return false; |
| 615 | 611 | } |
| 616 | 612 | foreach (self::$NP['prohibit_ranges'] as $range) { |
| 617 | 613 | if ($range[0] <= $v && $v <= $range[1]) { |
| 618 | - $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v)); |
|
| 614 | + $this->_error('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v)); |
|
| 619 | 615 | return false; |
| 620 | 616 | } |
| 621 | 617 | } |
@@ -654,13 +650,13 @@ discard block |
||
| 654 | 650 | if ($out) { |
| 655 | 651 | $output[$last_starter] = $out; |
| 656 | 652 | if (count($out) != $seq_len) { |
| 657 | - for ($j = $i+1; $j < $out_len; ++$j) $output[$j-1] = $output[$j]; |
|
| 653 | + for ($j = $i + 1; $j < $out_len; ++$j) $output[$j - 1] = $output[$j]; |
|
| 658 | 654 | unset($output[$out_len]); |
| 659 | 655 | } |
| 660 | 656 | // Rewind the for loop by one, since there can be more possible compositions |
| 661 | 657 | $i--; |
| 662 | 658 | $out_len--; |
| 663 | - $last_class = ($i == $last_starter) ? 0 : $this->_get_combining_class($output[$i-1]); |
|
| 659 | + $last_class = ($i == $last_starter) ? 0 : $this->_get_combining_class($output[$i - 1]); |
|
| 664 | 660 | continue; |
| 665 | 661 | } |
| 666 | 662 | } |
@@ -752,15 +748,15 @@ discard block |
||
| 752 | 748 | while ($swap) { |
| 753 | 749 | $swap = false; |
| 754 | 750 | $last = $this->_get_combining_class(intval($input[0])); |
| 755 | - for ($i = 0; $i < $size-1; ++$i) { |
|
| 756 | - $next = $this->_get_combining_class(intval($input[$i+1])); |
|
| 751 | + for ($i = 0; $i < $size - 1; ++$i) { |
|
| 752 | + $next = $this->_get_combining_class(intval($input[$i + 1])); |
|
| 757 | 753 | if ($next != 0 && $last > $next) { |
| 758 | 754 | // Move item leftward until it fits |
| 759 | 755 | for ($j = $i + 1; $j > 0; --$j) { |
| 760 | - if ($this->_get_combining_class(intval($input[$j-1])) <= $next) break; |
|
| 756 | + if ($this->_get_combining_class(intval($input[$j - 1])) <= $next) break; |
|
| 761 | 757 | $t = intval($input[$j]); |
| 762 | - $input[$j] = intval($input[$j-1]); |
|
| 763 | - $input[$j-1] = $t; |
|
| 758 | + $input[$j] = intval($input[$j - 1]); |
|
| 759 | + $input[$j - 1] = $t; |
|
| 764 | 760 | $swap = true; |
| 765 | 761 | } |
| 766 | 762 | // Reentering the loop looking at the old character again |
@@ -831,7 +827,7 @@ discard block |
||
| 831 | 827 | $output[$out_len] = $v; |
| 832 | 828 | ++$out_len; |
| 833 | 829 | if ('add' == $mode) { |
| 834 | - $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k); |
|
| 830 | + $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k); |
|
| 835 | 831 | return false; |
| 836 | 832 | } |
| 837 | 833 | continue; |
@@ -856,7 +852,7 @@ discard block |
||
| 856 | 852 | $next_byte = 4; |
| 857 | 853 | $v = ($v - 252) << 30; |
| 858 | 854 | } else { |
| 859 | - $this->_error('This might be UTF-8, but I don\'t understand it at byte '.$k); |
|
| 855 | + $this->_error('This might be UTF-8, but I don\'t understand it at byte ' . $k); |
|
| 860 | 856 | return false; |
| 861 | 857 | } |
| 862 | 858 | if ('add' == $mode) { |
@@ -869,7 +865,7 @@ discard block |
||
| 869 | 865 | if (!$this->_allow_overlong && $test == 'range') { |
| 870 | 866 | $test = 'none'; |
| 871 | 867 | if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) { |
| 872 | - $this->_error('Bogus UTF-8 character detected (out of legal range) at byte '.$k); |
|
| 868 | + $this->_error('Bogus UTF-8 character detected (out of legal range) at byte ' . $k); |
|
| 873 | 869 | return false; |
| 874 | 870 | } |
| 875 | 871 | } |
@@ -878,7 +874,7 @@ discard block |
||
| 878 | 874 | $output[($out_len - 1)] += $v; |
| 879 | 875 | --$next_byte; |
| 880 | 876 | } else { |
| 881 | - $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k); |
|
| 877 | + $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k); |
|
| 882 | 878 | return false; |
| 883 | 879 | } |
| 884 | 880 | if ($next_byte < 0) { |
@@ -902,13 +898,13 @@ discard block |
||
| 902 | 898 | if ($v < 128) { // 7bit are transferred literally |
| 903 | 899 | $output .= chr($v); |
| 904 | 900 | } elseif ($v < (1 << 11)) { // 2 bytes |
| 905 | - $output .= chr(192+($v >> 6)).chr(128+($v & 63)); |
|
| 901 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
| 906 | 902 | } elseif ($v < (1 << 16)) { // 3 bytes |
| 907 | - $output .= chr(224+($v >> 12)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63)); |
|
| 903 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
| 908 | 904 | } elseif ($v < (1 << 21)) { // 4 bytes |
| 909 | - $output .= chr(240+($v >> 18)).chr(128+(($v >> 12) & 63)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63)); |
|
| 905 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
| 910 | 906 | } else { |
| 911 | - $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k); |
|
| 907 | + $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte ' . $k); |
|
| 912 | 908 | return false; |
| 913 | 909 | } |
| 914 | 910 | } |
@@ -927,7 +923,7 @@ discard block |
||
| 927 | 923 | // Take array values and split output to 4 bytes per value |
| 928 | 924 | // The bit mask is 255, which reads &11111111 |
| 929 | 925 | foreach ($input as $v) { |
| 930 | - $output .= chr(($v >> 24) & 255).chr(($v >> 16) & 255).chr(($v >> 8) & 255).chr($v & 255); |
|
| 926 | + $output .= chr(($v >> 24) & 255) . chr(($v >> 16) & 255) . chr(($v >> 8) & 255) . chr($v & 255); |
|
| 931 | 927 | } |
| 932 | 928 | return $output; |
| 933 | 929 | } |
@@ -955,7 +951,7 @@ discard block |
||
| 955 | 951 | $out_len++; |
| 956 | 952 | $output[$out_len] = 0; |
| 957 | 953 | } |
| 958 | - $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) ); |
|
| 954 | + $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4))); |
|
| 959 | 955 | } |
| 960 | 956 | return $output; |
| 961 | 957 | } |
@@ -1017,13 +1013,12 @@ discard block |
||
| 1017 | 1013 | * @private array |
| 1018 | 1014 | * @since 0.5.2 |
| 1019 | 1015 | */ |
| 1020 | - protected static $NP = array |
|
| 1021 | - ('map_nothing' => array(0xAD, 0x34F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B, 0x200C |
|
| 1016 | + protected static $NP = array('map_nothing' => array(0xAD, 0x34F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B, 0x200C |
|
| 1022 | 1017 | ,0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07 |
| 1023 | 1018 | ,0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, 0xFEFF |
| 1024 | 1019 | ) |
| 1025 | 1020 | ,'general_prohibited' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 |
| 1026 | - ,20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 ,33, 34, 35, 36, 37, 38, 39, 40, 41, 42 |
|
| 1021 | + ,20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 |
|
| 1027 | 1022 | ,43, 44, 47, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96, 123, 124, 125, 126, 127, 0x3002 |
| 1028 | 1023 | ) |
| 1029 | 1024 | ,'prohibit' => array(0xA0, 0x340, 0x341, 0x6DD, 0x70F, 0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003 |
@@ -1035,7 +1030,7 @@ discard block |
||
| 1035 | 1030 | ,0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xE0001, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, 0x10FFFF |
| 1036 | 1031 | ) |
| 1037 | 1032 | ,'prohibit_ranges' => array(array(0x80, 0x9F), array(0x2060, 0x206F), array(0x1D173, 0x1D17A) |
| 1038 | - ,array(0xE000, 0xF8FF) ,array(0xF0000, 0xFFFFD), array(0x100000, 0x10FFFD) |
|
| 1033 | + ,array(0xE000, 0xF8FF), array(0xF0000, 0xFFFFD), array(0x100000, 0x10FFFD) |
|
| 1039 | 1034 | ,array(0xFDD0, 0xFDEF), array(0xD800, 0xDFFF), array(0x2FF0, 0x2FFB), array(0xE0020, 0xE007F) |
| 1040 | 1035 | ) |
| 1041 | 1036 | ,'replacemaps' => array(0x41 => array(0x61), 0x42 => array(0x62), 0x43 => array(0x63) |
@@ -1301,7 +1296,7 @@ discard block |
||
| 1301 | 1296 | ,0x2128 => array(0x7A), 0x212A => array(0x6B), 0x212B => array(0xE5) |
| 1302 | 1297 | ,0x212C => array(0x62), 0x212D => array(0x63), 0x2130 => array(0x65) |
| 1303 | 1298 | ,0x2131 => array(0x66), 0x2133 => array(0x6D), 0x213E => array(0x3B3) |
| 1304 | - ,0x213F => array(0x3C0), 0x2145 => array(0x64) ,0x2160 => array(0x2170) |
|
| 1299 | + ,0x213F => array(0x3C0), 0x2145 => array(0x64), 0x2160 => array(0x2170) |
|
| 1305 | 1300 | ,0x2161 => array(0x2171), 0x2162 => array(0x2172), 0x2163 => array(0x2173) |
| 1306 | 1301 | ,0x2164 => array(0x2174), 0x2165 => array(0x2175), 0x2166 => array(0x2176) |
| 1307 | 1302 | ,0x2167 => array(0x2177), 0x2168 => array(0x2178), 0x2169 => array(0x2179) |
@@ -1449,7 +1444,7 @@ discard block |
||
| 1449 | 1444 | ,0x1D5E5 => array(0x72), 0x1D5E6 => array(0x73), 0x1D5E7 => array(0x74) |
| 1450 | 1445 | ,0x1D5E8 => array(0x75), 0x1D5E9 => array(0x76), 0x1D5EA => array(0x77) |
| 1451 | 1446 | ,0x1D5EB => array(0x78), 0x1D5EC => array(0x79), 0x1D5ED => array(0x7A) |
| 1452 | - ,0x1D608 => array(0x61), 0x1D609 => array(0x62) ,0x1D60A => array(0x63) |
|
| 1447 | + ,0x1D608 => array(0x61), 0x1D609 => array(0x62), 0x1D60A => array(0x63) |
|
| 1453 | 1448 | ,0x1D60B => array(0x64), 0x1D60C => array(0x65), 0x1D60D => array(0x66) |
| 1454 | 1449 | ,0x1D60E => array(0x67), 0x1D60F => array(0x68), 0x1D610 => array(0x69) |
| 1455 | 1450 | ,0x1D611 => array(0x6A), 0x1D612 => array(0x6B), 0x1D613 => array(0x6C) |
@@ -1489,9 +1484,9 @@ discard block |
||
| 1489 | 1484 | ,0x1D6E9 => array(0x3B8), 0x1D6EA => array(0x3B9), 0x1D6EB => array(0x3BA) |
| 1490 | 1485 | ,0x1D6EC => array(0x3BB), 0x1D6ED => array(0x3BC), 0x1D6EE => array(0x3BD) |
| 1491 | 1486 | ,0x1D6EF => array(0x3BE), 0x1D6F0 => array(0x3BF), 0x1D6F1 => array(0x3C0) |
| 1492 | - ,0x1D6F2 => array(0x3C1), 0x1D6F3 => array(0x3B8) ,0x1D6F4 => array(0x3C3) |
|
| 1487 | + ,0x1D6F2 => array(0x3C1), 0x1D6F3 => array(0x3B8), 0x1D6F4 => array(0x3C3) |
|
| 1493 | 1488 | ,0x1D6F5 => array(0x3C4), 0x1D6F6 => array(0x3C5), 0x1D6F7 => array(0x3C6) |
| 1494 | - ,0x1D6F8 => array(0x3C7), 0x1D6F9 => array(0x3C8) ,0x1D6FA => array(0x3C9) |
|
| 1489 | + ,0x1D6F8 => array(0x3C7), 0x1D6F9 => array(0x3C8), 0x1D6FA => array(0x3C9) |
|
| 1495 | 1490 | ,0x1D70D => array(0x3C3), 0x1D71C => array(0x3B1), 0x1D71D => array(0x3B2) |
| 1496 | 1491 | ,0x1D71E => array(0x3B3), 0x1D71F => array(0x3B4), 0x1D720 => array(0x3B5) |
| 1497 | 1492 | ,0x1D721 => array(0x3B6), 0x1D722 => array(0x3B7), 0x1D723 => array(0x3B8) |
@@ -1531,18 +1526,18 @@ discard block |
||
| 1531 | 1526 | ,0x337A => array(0x69, 0x75), 0x33DE => array(0x76, 0x2215, 0x6D) |
| 1532 | 1527 | ,0x33DF => array(0x61, 0x2215, 0x6D) |
| 1533 | 1528 | ) |
| 1534 | - ,'norm_combcls' => array(0x334 => 1, 0x335 => 1, 0x336 => 1, 0x337 => 1 |
|
| 1535 | - ,0x338 => 1, 0x93C => 7, 0x9BC => 7, 0xA3C => 7, 0xABC => 7 |
|
| 1536 | - ,0xB3C => 7, 0xCBC => 7, 0x1037 => 7, 0x3099 => 8, 0x309A => 8 |
|
| 1537 | - ,0x94D => 9, 0x9CD => 9, 0xA4D => 9, 0xACD => 9, 0xB4D => 9 |
|
| 1538 | - ,0xBCD => 9, 0xC4D => 9, 0xCCD => 9, 0xD4D => 9, 0xDCA => 9 |
|
| 1539 | - ,0xE3A => 9, 0xF84 => 9, 0x1039 => 9, 0x1714 => 9, 0x1734 => 9 |
|
| 1540 | - ,0x17D2 => 9, 0x5B0 => 10, 0x5B1 => 11, 0x5B2 => 12, 0x5B3 => 13 |
|
| 1541 | - ,0x5B4 => 14, 0x5B5 => 15, 0x5B6 => 16, 0x5B7 => 17, 0x5B8 => 18 |
|
| 1542 | - ,0x5B9 => 19, 0x5BB => 20, 0x5Bc => 21, 0x5BD => 22, 0x5BF => 23 |
|
| 1543 | - ,0x5C1 => 24, 0x5C2 => 25, 0xFB1E => 26, 0x64B => 27, 0x64C => 28 |
|
| 1544 | - ,0x64D => 29, 0x64E => 30, 0x64F => 31, 0x650 => 32, 0x651 => 33 |
|
| 1545 | - ,0x652 => 34, 0x670 => 35, 0x711 => 36, 0xC55 => 84, 0xC56 => 91 |
|
| 1529 | + ,'norm_combcls' => array(0x334 => 1, 0x335 => 1, 0x336 => 1, 0x337 => 1 |
|
| 1530 | + ,0x338 => 1, 0x93C => 7, 0x9BC => 7, 0xA3C => 7, 0xABC => 7 |
|
| 1531 | + ,0xB3C => 7, 0xCBC => 7, 0x1037 => 7, 0x3099 => 8, 0x309A => 8 |
|
| 1532 | + ,0x94D => 9, 0x9CD => 9, 0xA4D => 9, 0xACD => 9, 0xB4D => 9 |
|
| 1533 | + ,0xBCD => 9, 0xC4D => 9, 0xCCD => 9, 0xD4D => 9, 0xDCA => 9 |
|
| 1534 | + ,0xE3A => 9, 0xF84 => 9, 0x1039 => 9, 0x1714 => 9, 0x1734 => 9 |
|
| 1535 | + ,0x17D2 => 9, 0x5B0 => 10, 0x5B1 => 11, 0x5B2 => 12, 0x5B3 => 13 |
|
| 1536 | + ,0x5B4 => 14, 0x5B5 => 15, 0x5B6 => 16, 0x5B7 => 17, 0x5B8 => 18 |
|
| 1537 | + ,0x5B9 => 19, 0x5BB => 20, 0x5Bc => 21, 0x5BD => 22, 0x5BF => 23 |
|
| 1538 | + ,0x5C1 => 24, 0x5C2 => 25, 0xFB1E => 26, 0x64B => 27, 0x64C => 28 |
|
| 1539 | + ,0x64D => 29, 0x64E => 30, 0x64F => 31, 0x650 => 32, 0x651 => 33 |
|
| 1540 | + ,0x652 => 34, 0x670 => 35, 0x711 => 36, 0xC55 => 84, 0xC56 => 91 |
|
| 1546 | 1541 | ,0xE38 => 103, 0xE39 => 103, 0xE48 => 107, 0xE49 => 107, 0xE4A => 107 |
| 1547 | 1542 | ,0xE4B => 107, 0xEB8 => 118, 0xEB9 => 118, 0xEC8 => 122, 0xEC9 => 122 |
| 1548 | 1543 | ,0xECA => 122, 0xECB => 122, 0xF71 => 129, 0xF72 => 130, 0xF7A => 130 |
@@ -205,7 +205,9 @@ discard block |
||
| 205 | 205 | foreach ($arr as $k => $v) { |
| 206 | 206 | if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) { |
| 207 | 207 | $conv = $this->_decode($v); |
| 208 | - if ($conv) $arr[$k] = $conv; |
|
| 208 | + if ($conv) { |
|
| 209 | + $arr[$k] = $conv; |
|
| 210 | + } |
|
| 209 | 211 | } |
| 210 | 212 | } |
| 211 | 213 | $input = join('.', $arr); |
@@ -213,7 +215,9 @@ discard block |
||
| 213 | 215 | foreach ($arr as $k => $v) { |
| 214 | 216 | if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) { |
| 215 | 217 | $conv = $this->_decode($v); |
| 216 | - if ($conv) $arr[$k] = $conv; |
|
| 218 | + if ($conv) { |
|
| 219 | + $arr[$k] = $conv; |
|
| 220 | + } |
|
| 217 | 221 | } |
| 218 | 222 | } |
| 219 | 223 | $email_pref = join('.', $arr); |
@@ -229,7 +233,9 @@ discard block |
||
| 229 | 233 | $arr = explode('.', $parsed['host']); |
| 230 | 234 | foreach ($arr as $k => $v) { |
| 231 | 235 | $conv = $this->_decode($v); |
| 232 | - if ($conv) $arr[$k] = $conv; |
|
| 236 | + if ($conv) { |
|
| 237 | + $arr[$k] = $conv; |
|
| 238 | + } |
|
| 233 | 239 | } |
| 234 | 240 | $parsed['host'] = join('.', $arr); |
| 235 | 241 | $return = |
@@ -250,7 +256,9 @@ discard block |
||
| 250 | 256 | } |
| 251 | 257 | } else { // Otherwise we consider it being a pure domain name string |
| 252 | 258 | $return = $this->_decode($input); |
| 253 | - if (!$return) $return = $input; |
|
| 259 | + if (!$return) { |
|
| 260 | + $return = $input; |
|
| 261 | + } |
|
| 254 | 262 | } |
| 255 | 263 | // The output is UTF-8 by default, other output formats need conversion here |
| 256 | 264 | // If one time encoding is given, use this, else the objects property |
@@ -294,7 +302,9 @@ discard block |
||
| 294 | 302 | } |
| 295 | 303 | |
| 296 | 304 | // No input, no output, what else did you expect? |
| 297 | - if (empty($decoded)) return ''; |
|
| 305 | + if (empty($decoded)) { |
|
| 306 | + return ''; |
|
| 307 | + } |
|
| 298 | 308 | |
| 299 | 309 | // Anchors for iteration |
| 300 | 310 | $last_begin = 0; |
@@ -371,7 +381,9 @@ discard block |
||
| 371 | 381 | $arr = explode('.', $parsed['host']); |
| 372 | 382 | foreach ($arr as $k => $v) { |
| 373 | 383 | $conv = $this->encode($v, 'utf8'); |
| 374 | - if ($conv) $arr[$k] = $conv; |
|
| 384 | + if ($conv) { |
|
| 385 | + $arr[$k] = $conv; |
|
| 386 | + } |
|
| 375 | 387 | } |
| 376 | 388 | $parsed['host'] = join('.', $arr); |
| 377 | 389 | $return = |
@@ -436,7 +448,9 @@ discard block |
||
| 436 | 448 | $idx += $digit * $w; |
| 437 | 449 | $t = ($k <= $bias) ? $this->_tmin : |
| 438 | 450 | (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias)); |
| 439 | - if ($digit < $t) break; |
|
| 451 | + if ($digit < $t) { |
|
| 452 | + break; |
|
| 453 | + } |
|
| 440 | 454 | $w = (int) ($w * ($this->_base - $t)); |
| 441 | 455 | } |
| 442 | 456 | $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first); |
@@ -445,7 +459,9 @@ discard block |
||
| 445 | 459 | $idx %= ($deco_len + 1); |
| 446 | 460 | if ($deco_len > 0) { |
| 447 | 461 | // Make room for the decoded char |
| 448 | - for ($i = $deco_len; $i > $idx; $i--) $decoded[$i] = $decoded[($i - 1)]; |
|
| 462 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
| 463 | + $decoded[$i] = $decoded[($i - 1)]; |
|
| 464 | + } |
|
| 449 | 465 | } |
| 450 | 466 | $decoded[$idx++] = $char; |
| 451 | 467 | } |
@@ -482,9 +498,15 @@ discard block |
||
| 482 | 498 | } |
| 483 | 499 | // Do NAMEPREP |
| 484 | 500 | $decoded = $this->_nameprep($decoded); |
| 485 | - if (!$decoded || !is_array($decoded)) return false; // NAMEPREP failed |
|
| 501 | + if (!$decoded || !is_array($decoded)) { |
|
| 502 | + return false; |
|
| 503 | + } |
|
| 504 | + // NAMEPREP failed |
|
| 486 | 505 | $deco_len = count($decoded); |
| 487 | - if (!$deco_len) return false; // Empty array |
|
| 506 | + if (!$deco_len) { |
|
| 507 | + return false; |
|
| 508 | + } |
|
| 509 | + // Empty array |
|
| 488 | 510 | $codecount = 0; // How many chars have been consumed |
| 489 | 511 | $encoded = ''; |
| 490 | 512 | // Copy all basic code points to output |
@@ -497,12 +519,17 @@ discard block |
||
| 497 | 519 | $codecount++; |
| 498 | 520 | } |
| 499 | 521 | } |
| 500 | - if ($codecount == $deco_len) return $encoded; // All codepoints were basic ones |
|
| 522 | + if ($codecount == $deco_len) { |
|
| 523 | + return $encoded; |
|
| 524 | + } |
|
| 525 | + // All codepoints were basic ones |
|
| 501 | 526 | |
| 502 | 527 | // Start with the prefix; copy it to output |
| 503 | 528 | $encoded = $this->_punycode_prefix.$encoded; |
| 504 | 529 | // If we have basic code points in output, add an hyphen to the end |
| 505 | - if ($codecount) $encoded .= '-'; |
|
| 530 | + if ($codecount) { |
|
| 531 | + $encoded .= '-'; |
|
| 532 | + } |
|
| 506 | 533 | // Now find and encode all non-basic code points |
| 507 | 534 | $is_first = true; |
| 508 | 535 | $cur_code = $this->_initial_n; |
@@ -527,7 +554,9 @@ discard block |
||
| 527 | 554 | for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) { |
| 528 | 555 | $t = ($k <= $bias) ? $this->_tmin : |
| 529 | 556 | (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias); |
| 530 | - if ($q < $t) break; |
|
| 557 | + if ($q < $t) { |
|
| 558 | + break; |
|
| 559 | + } |
|
| 531 | 560 | $encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval() |
| 532 | 561 | $q = (int) (($q - $t) / ($this->_base - $t)); |
| 533 | 562 | } |
@@ -607,7 +636,9 @@ discard block |
||
| 607 | 636 | // While mapping required chars we apply the cannonical ordering |
| 608 | 637 | foreach ($input as $v) { |
| 609 | 638 | // Map to nothing == skip that code point |
| 610 | - if (in_array($v, self::$NP['map_nothing'])) continue; |
|
| 639 | + if (in_array($v, self::$NP['map_nothing'])) { |
|
| 640 | + continue; |
|
| 641 | + } |
|
| 611 | 642 | // Try to find prohibited input |
| 612 | 643 | if (in_array($v, self::$NP['prohibit']) || in_array($v, self::$NP['general_prohibited'])) { |
| 613 | 644 | $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v)); |
@@ -654,7 +685,9 @@ discard block |
||
| 654 | 685 | if ($out) { |
| 655 | 686 | $output[$last_starter] = $out; |
| 656 | 687 | if (count($out) != $seq_len) { |
| 657 | - for ($j = $i+1; $j < $out_len; ++$j) $output[$j-1] = $output[$j]; |
|
| 688 | + for ($j = $i+1; $j < $out_len; ++$j) { |
|
| 689 | + $output[$j-1] = $output[$j]; |
|
| 690 | + } |
|
| 658 | 691 | unset($output[$out_len]); |
| 659 | 692 | } |
| 660 | 693 | // Rewind the for loop by one, since there can be more possible compositions |
@@ -665,7 +698,9 @@ discard block |
||
| 665 | 698 | } |
| 666 | 699 | } |
| 667 | 700 | // The current class is 0 |
| 668 | - if (!$class) $last_starter = $i; |
|
| 701 | + if (!$class) { |
|
| 702 | + $last_starter = $i; |
|
| 703 | + } |
|
| 669 | 704 | $last_class = $class; |
| 670 | 705 | } |
| 671 | 706 | return $output; |
@@ -680,12 +715,16 @@ discard block |
||
| 680 | 715 | protected function _hangul_decompose($char) |
| 681 | 716 | { |
| 682 | 717 | $sindex = (int) $char - $this->_sbase; |
| 683 | - if ($sindex < 0 || $sindex >= $this->_scount) return array($char); |
|
| 718 | + if ($sindex < 0 || $sindex >= $this->_scount) { |
|
| 719 | + return array($char); |
|
| 720 | + } |
|
| 684 | 721 | $result = array(); |
| 685 | 722 | $result[] = (int) $this->_lbase + $sindex / $this->_ncount; |
| 686 | 723 | $result[] = (int) $this->_vbase + ($sindex % $this->_ncount) / $this->_tcount; |
| 687 | 724 | $T = intval($this->_tbase + $sindex % $this->_tcount); |
| 688 | - if ($T != $this->_tbase) $result[] = $T; |
|
| 725 | + if ($T != $this->_tbase) { |
|
| 726 | + $result[] = $T; |
|
| 727 | + } |
|
| 689 | 728 | return $result; |
| 690 | 729 | } |
| 691 | 730 | /** |
@@ -697,7 +736,9 @@ discard block |
||
| 697 | 736 | protected function _hangul_compose($input) |
| 698 | 737 | { |
| 699 | 738 | $inp_len = count($input); |
| 700 | - if (!$inp_len) return array(); |
|
| 739 | + if (!$inp_len) { |
|
| 740 | + return array(); |
|
| 741 | + } |
|
| 701 | 742 | $result = array(); |
| 702 | 743 | $last = (int) $input[0]; |
| 703 | 744 | $result[] = $last; // copy first char from input to output |
@@ -757,7 +798,9 @@ discard block |
||
| 757 | 798 | if ($next != 0 && $last > $next) { |
| 758 | 799 | // Move item leftward until it fits |
| 759 | 800 | for ($j = $i + 1; $j > 0; --$j) { |
| 760 | - if ($this->_get_combining_class(intval($input[$j-1])) <= $next) break; |
|
| 801 | + if ($this->_get_combining_class(intval($input[$j-1])) <= $next) { |
|
| 802 | + break; |
|
| 803 | + } |
|
| 761 | 804 | $t = intval($input[$j]); |
| 762 | 805 | $input[$j] = intval($input[$j-1]); |
| 763 | 806 | $input[$j-1] = $t; |
@@ -784,8 +827,12 @@ discard block |
||
| 784 | 827 | return false; |
| 785 | 828 | } |
| 786 | 829 | foreach (self::$NP['replacemaps'] as $np_src => $np_target) { |
| 787 | - if ($np_target[0] != $input[0]) continue; |
|
| 788 | - if (count($np_target) != $inp_len) continue; |
|
| 830 | + if ($np_target[0] != $input[0]) { |
|
| 831 | + continue; |
|
| 832 | + } |
|
| 833 | + if (count($np_target) != $inp_len) { |
|
| 834 | + continue; |
|
| 835 | + } |
|
| 789 | 836 | $hit = false; |
| 790 | 837 | foreach ($input as $k2 => $v2) { |
| 791 | 838 | if ($v2 == $np_target[$k2]) { |
@@ -795,7 +842,9 @@ discard block |
||
| 795 | 842 | break; |
| 796 | 843 | } |
| 797 | 844 | } |
| 798 | - if ($hit) return $np_src; |
|
| 845 | + if ($hit) { |
|
| 846 | + return $np_src; |
|
| 847 | + } |
|
| 799 | 848 | } |
| 800 | 849 | return false; |
| 801 | 850 | } |
@@ -948,7 +997,9 @@ discard block |
||
| 948 | 997 | return false; |
| 949 | 998 | } |
| 950 | 999 | // Empty input - return empty output |
| 951 | - if (!$inp_len) return $output; |
|
| 1000 | + if (!$inp_len) { |
|
| 1001 | + return $output; |
|
| 1002 | + } |
|
| 952 | 1003 | for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) { |
| 953 | 1004 | // Increment output position every 4 input bytes |
| 954 | 1005 | if (!($i % 4)) { |