@@ -367,7 +367,8 @@ |
||
| 367 | 367 | /** |
| 368 | 368 | * All of the profile options as defined in profile.subs or via an addon |
| 369 | 369 | */ |
| 370 | -function template_profile_options() { |
|
| 370 | +function template_profile_options() |
|
| 371 | +{ |
|
| 371 | 372 | global $context; |
| 372 | 373 | |
| 373 | 374 | if (empty($context['profile_fields'])) |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * We need this template in order to look at ignored boards |
| 17 | 17 | */ |
| 18 | -function template_ProfileOptions_init() |
|
| 18 | +function template_ProfileOptions_init () |
|
| 19 | 19 | { |
| 20 | 20 | global $context, $txt; |
| 21 | 21 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * Template for showing all the buddies of the current user. |
| 35 | 35 | */ |
| 36 | -function template_editBuddies() |
|
| 36 | +function template_editBuddies () |
|
| 37 | 37 | { |
| 38 | 38 | global $context, $txt; |
| 39 | 39 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | /** |
| 158 | 158 | * Template for showing the ignore list of the current user. |
| 159 | 159 | */ |
| 160 | -function template_editIgnoreList() |
|
| 160 | +function template_editIgnoreList () |
|
| 161 | 161 | { |
| 162 | 162 | global $context, $txt; |
| 163 | 163 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @uses ParseError |
| 267 | 267 | */ |
| 268 | -function template_edit_options() |
|
| 268 | +function template_edit_options () |
|
| 269 | 269 | { |
| 270 | 270 | global $context, $txt; |
| 271 | 271 | |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | /** |
| 358 | 358 | * All of the profile options as defined in profile.subs or via an addon |
| 359 | 359 | */ |
| 360 | -function template_profile_options() { |
|
| 360 | +function template_profile_options () { |
|
| 361 | 361 | global $context; |
| 362 | 362 | |
| 363 | 363 | if (empty($context['profile_fields'])) |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | * |
| 503 | 503 | * @param string $lastItem |
| 504 | 504 | */ |
| 505 | -function template_custom_profile_options($lastItem = '') |
|
| 505 | +function template_custom_profile_options ($lastItem = '') |
|
| 506 | 506 | { |
| 507 | 507 | global $context; |
| 508 | 508 | |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | /** |
| 541 | 541 | * Personal Message settings. |
| 542 | 542 | */ |
| 543 | -function template_profile_pm_settings() |
|
| 543 | +function template_profile_pm_settings () |
|
| 544 | 544 | { |
| 545 | 545 | global $context, $modSettings, $txt; |
| 546 | 546 | |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | /** |
| 603 | 603 | * Template for showing theme settings. Note: template_options() actually adds the theme specific options. |
| 604 | 604 | */ |
| 605 | -function template_profile_theme_settings() |
|
| 605 | +function template_profile_theme_settings () |
|
| 606 | 606 | { |
| 607 | 607 | global $context, $modSettings, $txt; |
| 608 | 608 | |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | /** |
| 765 | 765 | * Template for setting up how and what you want to be notified about |
| 766 | 766 | */ |
| 767 | -function template_action_notification() |
|
| 767 | +function template_action_notification () |
|
| 768 | 768 | { |
| 769 | 769 | global $context, $txt, $modSettings; |
| 770 | 770 | |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | * Template for showing which boards you have subscribed to |
| 894 | 894 | * and allowing for modification. |
| 895 | 895 | */ |
| 896 | -function template_board_notification_list() |
|
| 896 | +function template_board_notification_list () |
|
| 897 | 897 | { |
| 898 | 898 | template_show_list('board_notification_list'); |
| 899 | 899 | } |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | * Template for showing which topics you have subscribed to |
| 903 | 903 | * and allowing for modification. |
| 904 | 904 | */ |
| 905 | -function template_topic_notification_list() |
|
| 905 | +function template_topic_notification_list () |
|
| 906 | 906 | { |
| 907 | 907 | template_show_list('topic_notification_list'); |
| 908 | 908 | } |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | /** |
| 911 | 911 | * Template for choosing group membership. |
| 912 | 912 | */ |
| 913 | -function template_groupMembership() |
|
| 913 | +function template_groupMembership () |
|
| 914 | 914 | { |
| 915 | 915 | global $context, $txt; |
| 916 | 916 | |
@@ -1089,7 +1089,7 @@ discard block |
||
| 1089 | 1089 | /** |
| 1090 | 1090 | * Display a list of boards so a user can choose to ignore some |
| 1091 | 1091 | */ |
| 1092 | -function template_ignoreboards() |
|
| 1092 | +function template_ignoreboards () |
|
| 1093 | 1093 | { |
| 1094 | 1094 | global $txt; |
| 1095 | 1095 | |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | /** |
| 1118 | 1118 | * Display a load of drop down selectors for allowing the user to change group. |
| 1119 | 1119 | */ |
| 1120 | -function template_profile_group_manage() |
|
| 1120 | +function template_profile_group_manage () |
|
| 1121 | 1121 | { |
| 1122 | 1122 | global $context, $txt; |
| 1123 | 1123 | |
@@ -1174,7 +1174,7 @@ discard block |
||
| 1174 | 1174 | /** |
| 1175 | 1175 | * Callback function for entering a birth date! |
| 1176 | 1176 | */ |
| 1177 | -function template_profile_birthdate() |
|
| 1177 | +function template_profile_birthdate () |
|
| 1178 | 1178 | { |
| 1179 | 1179 | global $txt, $context; |
| 1180 | 1180 | |
@@ -1194,7 +1194,7 @@ discard block |
||
| 1194 | 1194 | /** |
| 1195 | 1195 | * Show the signature editing box. |
| 1196 | 1196 | */ |
| 1197 | -function template_profile_signature_modify() |
|
| 1197 | +function template_profile_signature_modify () |
|
| 1198 | 1198 | { |
| 1199 | 1199 | global $txt, $context; |
| 1200 | 1200 | |
@@ -1256,7 +1256,7 @@ discard block |
||
| 1256 | 1256 | /** |
| 1257 | 1257 | * Interface to select an avatar in profile. |
| 1258 | 1258 | */ |
| 1259 | -function template_profile_avatar_select() |
|
| 1259 | +function template_profile_avatar_select () |
|
| 1260 | 1260 | { |
| 1261 | 1261 | global $context, $txt, $modSettings; |
| 1262 | 1262 | |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | /** |
| 1386 | 1386 | * Callback for modifying karma. |
| 1387 | 1387 | */ |
| 1388 | -function template_profile_karma_modify() |
|
| 1388 | +function template_profile_karma_modify () |
|
| 1389 | 1389 | { |
| 1390 | 1390 | global $context, $modSettings, $txt; |
| 1391 | 1391 | |
@@ -1403,7 +1403,7 @@ discard block |
||
| 1403 | 1403 | /** |
| 1404 | 1404 | * Select the time format!. |
| 1405 | 1405 | */ |
| 1406 | -function template_profile_timeformat_modify() |
|
| 1406 | +function template_profile_timeformat_modify () |
|
| 1407 | 1407 | { |
| 1408 | 1408 | global $context, $txt; |
| 1409 | 1409 | |
@@ -1435,7 +1435,7 @@ discard block |
||
| 1435 | 1435 | /** |
| 1436 | 1436 | * Time offset. |
| 1437 | 1437 | */ |
| 1438 | -function template_profile_timeoffset_modify() |
|
| 1438 | +function template_profile_timeoffset_modify () |
|
| 1439 | 1439 | { |
| 1440 | 1440 | global $txt, $context; |
| 1441 | 1441 | |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | /** |
| 1453 | 1453 | * Button to allow the member to pick a theme. |
| 1454 | 1454 | */ |
| 1455 | -function template_profile_theme_pick() |
|
| 1455 | +function template_profile_theme_pick () |
|
| 1456 | 1456 | { |
| 1457 | 1457 | global $txt, $context; |
| 1458 | 1458 | |
@@ -1468,7 +1468,7 @@ discard block |
||
| 1468 | 1468 | /** |
| 1469 | 1469 | * Smiley set picker. |
| 1470 | 1470 | */ |
| 1471 | -function template_profile_smiley_pick() |
|
| 1471 | +function template_profile_smiley_pick () |
|
| 1472 | 1472 | { |
| 1473 | 1473 | global $txt, $context, $modSettings, $settings; |
| 1474 | 1474 | |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | /** |
| 1495 | 1495 | * Interface to allow the member to change the way they login to the forum. |
| 1496 | 1496 | */ |
| 1497 | -function template_authentication_method() |
|
| 1497 | +function template_authentication_method () |
|
| 1498 | 1498 | { |
| 1499 | 1499 | global $context, $modSettings, $txt; |
| 1500 | 1500 | |
@@ -1562,7 +1562,7 @@ discard block |
||
| 1562 | 1562 | /** |
| 1563 | 1563 | * This template allows for the selection of different themes. |
| 1564 | 1564 | */ |
| 1565 | -function template_pick() |
|
| 1565 | +function template_pick () |
|
| 1566 | 1566 | { |
| 1567 | 1567 | global $context, $scripturl, $txt; |
| 1568 | 1568 | |
@@ -42,396 +42,396 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | class ClassLoader |
| 44 | 44 | { |
| 45 | - // PSR-4 |
|
| 46 | - private $prefixLengthsPsr4 = array(); |
|
| 47 | - private $prefixDirsPsr4 = array(); |
|
| 48 | - private $fallbackDirsPsr4 = array(); |
|
| 49 | - |
|
| 50 | - // PSR-0 |
|
| 51 | - private $prefixesPsr0 = array(); |
|
| 52 | - private $fallbackDirsPsr0 = array(); |
|
| 53 | - |
|
| 54 | - private $useIncludePath = false; |
|
| 55 | - private $classMap = array(); |
|
| 56 | - private $classMapAuthoritative = false; |
|
| 57 | - private $missingClasses = array(); |
|
| 58 | - private $apcuPrefix; |
|
| 59 | - |
|
| 60 | - public function getPrefixes() |
|
| 61 | - { |
|
| 62 | - if (!empty($this->prefixesPsr0)) { |
|
| 63 | - return call_user_func_array('array_merge', $this->prefixesPsr0); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - return array(); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public function getPrefixesPsr4() |
|
| 70 | - { |
|
| 71 | - return $this->prefixDirsPsr4; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function getFallbackDirs() |
|
| 75 | - { |
|
| 76 | - return $this->fallbackDirsPsr0; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - public function getFallbackDirsPsr4() |
|
| 80 | - { |
|
| 81 | - return $this->fallbackDirsPsr4; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - public function getClassMap() |
|
| 85 | - { |
|
| 86 | - return $this->classMap; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @param array $classMap Class to filename map |
|
| 91 | - */ |
|
| 92 | - public function addClassMap(array $classMap) |
|
| 93 | - { |
|
| 94 | - if ($this->classMap) { |
|
| 95 | - $this->classMap = array_merge($this->classMap, $classMap); |
|
| 96 | - } else { |
|
| 97 | - $this->classMap = $classMap; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Registers a set of PSR-0 directories for a given prefix, either |
|
| 103 | - * appending or prepending to the ones previously set for this prefix. |
|
| 104 | - * |
|
| 105 | - * @param string $prefix The prefix |
|
| 106 | - * @param array|string $paths The PSR-0 root directories |
|
| 107 | - * @param bool $prepend Whether to prepend the directories |
|
| 108 | - */ |
|
| 109 | - public function add($prefix, $paths, $prepend = false) |
|
| 110 | - { |
|
| 111 | - if (!$prefix) { |
|
| 112 | - if ($prepend) { |
|
| 113 | - $this->fallbackDirsPsr0 = array_merge( |
|
| 114 | - (array) $paths, |
|
| 115 | - $this->fallbackDirsPsr0 |
|
| 116 | - ); |
|
| 117 | - } else { |
|
| 118 | - $this->fallbackDirsPsr0 = array_merge( |
|
| 119 | - $this->fallbackDirsPsr0, |
|
| 120 | - (array) $paths |
|
| 121 | - ); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $first = $prefix[0]; |
|
| 128 | - if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 129 | - $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
|
| 130 | - |
|
| 131 | - return; |
|
| 132 | - } |
|
| 133 | - if ($prepend) { |
|
| 134 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
| 135 | - (array) $paths, |
|
| 136 | - $this->prefixesPsr0[$first][$prefix] |
|
| 137 | - ); |
|
| 138 | - } else { |
|
| 139 | - $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
| 140 | - $this->prefixesPsr0[$first][$prefix], |
|
| 141 | - (array) $paths |
|
| 142 | - ); |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Registers a set of PSR-4 directories for a given namespace, either |
|
| 148 | - * appending or prepending to the ones previously set for this namespace. |
|
| 149 | - * |
|
| 150 | - * @param string $prefix The prefix/namespace, with trailing '\\' |
|
| 151 | - * @param array|string $paths The PSR-4 base directories |
|
| 152 | - * @param bool $prepend Whether to prepend the directories |
|
| 153 | - * |
|
| 154 | - * @throws \InvalidArgumentException |
|
| 155 | - */ |
|
| 156 | - public function addPsr4($prefix, $paths, $prepend = false) |
|
| 157 | - { |
|
| 158 | - if (!$prefix) { |
|
| 159 | - // Register directories for the root namespace. |
|
| 160 | - if ($prepend) { |
|
| 161 | - $this->fallbackDirsPsr4 = array_merge( |
|
| 162 | - (array) $paths, |
|
| 163 | - $this->fallbackDirsPsr4 |
|
| 164 | - ); |
|
| 165 | - } else { |
|
| 166 | - $this->fallbackDirsPsr4 = array_merge( |
|
| 167 | - $this->fallbackDirsPsr4, |
|
| 168 | - (array) $paths |
|
| 169 | - ); |
|
| 170 | - } |
|
| 171 | - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
| 172 | - // Register directories for a new namespace. |
|
| 173 | - $length = strlen($prefix); |
|
| 174 | - if ('\\' !== $prefix[$length - 1]) { |
|
| 175 | - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
| 176 | - } |
|
| 177 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
| 178 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
| 179 | - } elseif ($prepend) { |
|
| 180 | - // Prepend directories for an already registered namespace. |
|
| 181 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
| 182 | - (array) $paths, |
|
| 183 | - $this->prefixDirsPsr4[$prefix] |
|
| 184 | - ); |
|
| 185 | - } else { |
|
| 186 | - // Append directories for an already registered namespace. |
|
| 187 | - $this->prefixDirsPsr4[$prefix] = array_merge( |
|
| 188 | - $this->prefixDirsPsr4[$prefix], |
|
| 189 | - (array) $paths |
|
| 190 | - ); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Registers a set of PSR-0 directories for a given prefix, |
|
| 196 | - * replacing any others previously set for this prefix. |
|
| 197 | - * |
|
| 198 | - * @param string $prefix The prefix |
|
| 199 | - * @param array|string $paths The PSR-0 base directories |
|
| 200 | - */ |
|
| 201 | - public function set($prefix, $paths) |
|
| 202 | - { |
|
| 203 | - if (!$prefix) { |
|
| 204 | - $this->fallbackDirsPsr0 = (array) $paths; |
|
| 205 | - } else { |
|
| 206 | - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Registers a set of PSR-4 directories for a given namespace, |
|
| 212 | - * replacing any others previously set for this namespace. |
|
| 213 | - * |
|
| 214 | - * @param string $prefix The prefix/namespace, with trailing '\\' |
|
| 215 | - * @param array|string $paths The PSR-4 base directories |
|
| 216 | - * |
|
| 217 | - * @throws \InvalidArgumentException |
|
| 218 | - */ |
|
| 219 | - public function setPsr4($prefix, $paths) |
|
| 220 | - { |
|
| 221 | - if (!$prefix) { |
|
| 222 | - $this->fallbackDirsPsr4 = (array) $paths; |
|
| 223 | - } else { |
|
| 224 | - $length = strlen($prefix); |
|
| 225 | - if ('\\' !== $prefix[$length - 1]) { |
|
| 226 | - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
| 227 | - } |
|
| 228 | - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
| 229 | - $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * Turns on searching the include path for class files. |
|
| 235 | - * |
|
| 236 | - * @param bool $useIncludePath |
|
| 237 | - */ |
|
| 238 | - public function setUseIncludePath($useIncludePath) |
|
| 239 | - { |
|
| 240 | - $this->useIncludePath = $useIncludePath; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Can be used to check if the autoloader uses the include path to check |
|
| 245 | - * for classes. |
|
| 246 | - * |
|
| 247 | - * @return bool |
|
| 248 | - */ |
|
| 249 | - public function getUseIncludePath() |
|
| 250 | - { |
|
| 251 | - return $this->useIncludePath; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * Turns off searching the prefix and fallback directories for classes |
|
| 256 | - * that have not been registered with the class map. |
|
| 257 | - * |
|
| 258 | - * @param bool $classMapAuthoritative |
|
| 259 | - */ |
|
| 260 | - public function setClassMapAuthoritative($classMapAuthoritative) |
|
| 261 | - { |
|
| 262 | - $this->classMapAuthoritative = $classMapAuthoritative; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * Should class lookup fail if not found in the current class map? |
|
| 267 | - * |
|
| 268 | - * @return bool |
|
| 269 | - */ |
|
| 270 | - public function isClassMapAuthoritative() |
|
| 271 | - { |
|
| 272 | - return $this->classMapAuthoritative; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. |
|
| 277 | - * |
|
| 278 | - * @param string|null $apcuPrefix |
|
| 279 | - */ |
|
| 280 | - public function setApcuPrefix($apcuPrefix) |
|
| 281 | - { |
|
| 282 | - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * The APCu prefix in use, or null if APCu caching is not enabled. |
|
| 287 | - * |
|
| 288 | - * @return string|null |
|
| 289 | - */ |
|
| 290 | - public function getApcuPrefix() |
|
| 291 | - { |
|
| 292 | - return $this->apcuPrefix; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * Registers this instance as an autoloader. |
|
| 297 | - * |
|
| 298 | - * @param bool $prepend Whether to prepend the autoloader or not |
|
| 299 | - */ |
|
| 300 | - public function register($prepend = false) |
|
| 301 | - { |
|
| 302 | - spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * Unregisters this instance as an autoloader. |
|
| 307 | - */ |
|
| 308 | - public function unregister() |
|
| 309 | - { |
|
| 310 | - spl_autoload_unregister(array($this, 'loadClass')); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * Loads the given class or interface. |
|
| 315 | - * |
|
| 316 | - * @param string $class The name of the class |
|
| 317 | - * @return bool|null True if loaded, null otherwise |
|
| 318 | - */ |
|
| 319 | - public function loadClass($class) |
|
| 320 | - { |
|
| 321 | - if ($file = $this->findFile($class)) { |
|
| 322 | - includeFile($file); |
|
| 323 | - |
|
| 324 | - return true; |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * Finds the path to the file where the class is defined. |
|
| 330 | - * |
|
| 331 | - * @param string $class The name of the class |
|
| 332 | - * |
|
| 333 | - * @return string|false The path if found, false otherwise |
|
| 334 | - */ |
|
| 335 | - public function findFile($class) |
|
| 336 | - { |
|
| 337 | - // class map lookup |
|
| 338 | - if (isset($this->classMap[$class])) { |
|
| 339 | - return $this->classMap[$class]; |
|
| 340 | - } |
|
| 341 | - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
|
| 342 | - return false; |
|
| 343 | - } |
|
| 344 | - if (null !== $this->apcuPrefix) { |
|
| 345 | - $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
| 346 | - if ($hit) { |
|
| 347 | - return $file; |
|
| 348 | - } |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - $file = $this->findFileWithExtension($class, '.php'); |
|
| 352 | - |
|
| 353 | - // Search for Hack files if we are running on HHVM |
|
| 354 | - if (false === $file && defined('HHVM_VERSION')) { |
|
| 355 | - $file = $this->findFileWithExtension($class, '.hh'); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - if (null !== $this->apcuPrefix) { |
|
| 359 | - apcu_add($this->apcuPrefix.$class, $file); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - if (false === $file) { |
|
| 363 | - // Remember that this class does not exist. |
|
| 364 | - $this->missingClasses[$class] = true; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - return $file; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - private function findFileWithExtension($class, $ext) |
|
| 371 | - { |
|
| 372 | - // PSR-4 lookup |
|
| 373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 374 | - |
|
| 375 | - $first = $class[0]; |
|
| 376 | - if (isset($this->prefixLengthsPsr4[$first])) { |
|
| 377 | - $subPath = $class; |
|
| 378 | - while (false !== $lastPos = strrpos($subPath, '\\')) { |
|
| 379 | - $subPath = substr($subPath, 0, $lastPos); |
|
| 380 | - $search = $subPath . '\\'; |
|
| 381 | - if (isset($this->prefixDirsPsr4[$search])) { |
|
| 382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | - foreach ($this->prefixDirsPsr4[$search] as $dir) { |
|
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 385 | - return $file; |
|
| 386 | - } |
|
| 387 | - } |
|
| 388 | - } |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - // PSR-4 fallback dirs |
|
| 393 | - foreach ($this->fallbackDirsPsr4 as $dir) { |
|
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 395 | - return $file; |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - // PSR-0 lookup |
|
| 400 | - if (false !== $pos = strrpos($class, '\\')) { |
|
| 401 | - // namespaced class name |
|
| 402 | - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) |
|
| 403 | - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
|
| 404 | - } else { |
|
| 405 | - // PEAR-like class name |
|
| 406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - if (isset($this->prefixesPsr0[$first])) { |
|
| 410 | - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
|
| 411 | - if (0 === strpos($class, $prefix)) { |
|
| 412 | - foreach ($dirs as $dir) { |
|
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 414 | - return $file; |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - } |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - // PSR-0 fallback dirs |
|
| 422 | - foreach ($this->fallbackDirsPsr0 as $dir) { |
|
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 424 | - return $file; |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - // PSR-0 include paths. |
|
| 429 | - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { |
|
| 430 | - return $file; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - return false; |
|
| 434 | - } |
|
| 45 | + // PSR-4 |
|
| 46 | + private $prefixLengthsPsr4 = array(); |
|
| 47 | + private $prefixDirsPsr4 = array(); |
|
| 48 | + private $fallbackDirsPsr4 = array(); |
|
| 49 | + |
|
| 50 | + // PSR-0 |
|
| 51 | + private $prefixesPsr0 = array(); |
|
| 52 | + private $fallbackDirsPsr0 = array(); |
|
| 53 | + |
|
| 54 | + private $useIncludePath = false; |
|
| 55 | + private $classMap = array(); |
|
| 56 | + private $classMapAuthoritative = false; |
|
| 57 | + private $missingClasses = array(); |
|
| 58 | + private $apcuPrefix; |
|
| 59 | + |
|
| 60 | + public function getPrefixes() |
|
| 61 | + { |
|
| 62 | + if (!empty($this->prefixesPsr0)) { |
|
| 63 | + return call_user_func_array('array_merge', $this->prefixesPsr0); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + return array(); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public function getPrefixesPsr4() |
|
| 70 | + { |
|
| 71 | + return $this->prefixDirsPsr4; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function getFallbackDirs() |
|
| 75 | + { |
|
| 76 | + return $this->fallbackDirsPsr0; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + public function getFallbackDirsPsr4() |
|
| 80 | + { |
|
| 81 | + return $this->fallbackDirsPsr4; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + public function getClassMap() |
|
| 85 | + { |
|
| 86 | + return $this->classMap; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @param array $classMap Class to filename map |
|
| 91 | + */ |
|
| 92 | + public function addClassMap(array $classMap) |
|
| 93 | + { |
|
| 94 | + if ($this->classMap) { |
|
| 95 | + $this->classMap = array_merge($this->classMap, $classMap); |
|
| 96 | + } else { |
|
| 97 | + $this->classMap = $classMap; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Registers a set of PSR-0 directories for a given prefix, either |
|
| 103 | + * appending or prepending to the ones previously set for this prefix. |
|
| 104 | + * |
|
| 105 | + * @param string $prefix The prefix |
|
| 106 | + * @param array|string $paths The PSR-0 root directories |
|
| 107 | + * @param bool $prepend Whether to prepend the directories |
|
| 108 | + */ |
|
| 109 | + public function add($prefix, $paths, $prepend = false) |
|
| 110 | + { |
|
| 111 | + if (!$prefix) { |
|
| 112 | + if ($prepend) { |
|
| 113 | + $this->fallbackDirsPsr0 = array_merge( |
|
| 114 | + (array) $paths, |
|
| 115 | + $this->fallbackDirsPsr0 |
|
| 116 | + ); |
|
| 117 | + } else { |
|
| 118 | + $this->fallbackDirsPsr0 = array_merge( |
|
| 119 | + $this->fallbackDirsPsr0, |
|
| 120 | + (array) $paths |
|
| 121 | + ); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $first = $prefix[0]; |
|
| 128 | + if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 129 | + $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
|
| 130 | + |
|
| 131 | + return; |
|
| 132 | + } |
|
| 133 | + if ($prepend) { |
|
| 134 | + $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
| 135 | + (array) $paths, |
|
| 136 | + $this->prefixesPsr0[$first][$prefix] |
|
| 137 | + ); |
|
| 138 | + } else { |
|
| 139 | + $this->prefixesPsr0[$first][$prefix] = array_merge( |
|
| 140 | + $this->prefixesPsr0[$first][$prefix], |
|
| 141 | + (array) $paths |
|
| 142 | + ); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Registers a set of PSR-4 directories for a given namespace, either |
|
| 148 | + * appending or prepending to the ones previously set for this namespace. |
|
| 149 | + * |
|
| 150 | + * @param string $prefix The prefix/namespace, with trailing '\\' |
|
| 151 | + * @param array|string $paths The PSR-4 base directories |
|
| 152 | + * @param bool $prepend Whether to prepend the directories |
|
| 153 | + * |
|
| 154 | + * @throws \InvalidArgumentException |
|
| 155 | + */ |
|
| 156 | + public function addPsr4($prefix, $paths, $prepend = false) |
|
| 157 | + { |
|
| 158 | + if (!$prefix) { |
|
| 159 | + // Register directories for the root namespace. |
|
| 160 | + if ($prepend) { |
|
| 161 | + $this->fallbackDirsPsr4 = array_merge( |
|
| 162 | + (array) $paths, |
|
| 163 | + $this->fallbackDirsPsr4 |
|
| 164 | + ); |
|
| 165 | + } else { |
|
| 166 | + $this->fallbackDirsPsr4 = array_merge( |
|
| 167 | + $this->fallbackDirsPsr4, |
|
| 168 | + (array) $paths |
|
| 169 | + ); |
|
| 170 | + } |
|
| 171 | + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
| 172 | + // Register directories for a new namespace. |
|
| 173 | + $length = strlen($prefix); |
|
| 174 | + if ('\\' !== $prefix[$length - 1]) { |
|
| 175 | + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
| 176 | + } |
|
| 177 | + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
| 178 | + $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
| 179 | + } elseif ($prepend) { |
|
| 180 | + // Prepend directories for an already registered namespace. |
|
| 181 | + $this->prefixDirsPsr4[$prefix] = array_merge( |
|
| 182 | + (array) $paths, |
|
| 183 | + $this->prefixDirsPsr4[$prefix] |
|
| 184 | + ); |
|
| 185 | + } else { |
|
| 186 | + // Append directories for an already registered namespace. |
|
| 187 | + $this->prefixDirsPsr4[$prefix] = array_merge( |
|
| 188 | + $this->prefixDirsPsr4[$prefix], |
|
| 189 | + (array) $paths |
|
| 190 | + ); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Registers a set of PSR-0 directories for a given prefix, |
|
| 196 | + * replacing any others previously set for this prefix. |
|
| 197 | + * |
|
| 198 | + * @param string $prefix The prefix |
|
| 199 | + * @param array|string $paths The PSR-0 base directories |
|
| 200 | + */ |
|
| 201 | + public function set($prefix, $paths) |
|
| 202 | + { |
|
| 203 | + if (!$prefix) { |
|
| 204 | + $this->fallbackDirsPsr0 = (array) $paths; |
|
| 205 | + } else { |
|
| 206 | + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Registers a set of PSR-4 directories for a given namespace, |
|
| 212 | + * replacing any others previously set for this namespace. |
|
| 213 | + * |
|
| 214 | + * @param string $prefix The prefix/namespace, with trailing '\\' |
|
| 215 | + * @param array|string $paths The PSR-4 base directories |
|
| 216 | + * |
|
| 217 | + * @throws \InvalidArgumentException |
|
| 218 | + */ |
|
| 219 | + public function setPsr4($prefix, $paths) |
|
| 220 | + { |
|
| 221 | + if (!$prefix) { |
|
| 222 | + $this->fallbackDirsPsr4 = (array) $paths; |
|
| 223 | + } else { |
|
| 224 | + $length = strlen($prefix); |
|
| 225 | + if ('\\' !== $prefix[$length - 1]) { |
|
| 226 | + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
|
| 227 | + } |
|
| 228 | + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
|
| 229 | + $this->prefixDirsPsr4[$prefix] = (array) $paths; |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * Turns on searching the include path for class files. |
|
| 235 | + * |
|
| 236 | + * @param bool $useIncludePath |
|
| 237 | + */ |
|
| 238 | + public function setUseIncludePath($useIncludePath) |
|
| 239 | + { |
|
| 240 | + $this->useIncludePath = $useIncludePath; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Can be used to check if the autoloader uses the include path to check |
|
| 245 | + * for classes. |
|
| 246 | + * |
|
| 247 | + * @return bool |
|
| 248 | + */ |
|
| 249 | + public function getUseIncludePath() |
|
| 250 | + { |
|
| 251 | + return $this->useIncludePath; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Turns off searching the prefix and fallback directories for classes |
|
| 256 | + * that have not been registered with the class map. |
|
| 257 | + * |
|
| 258 | + * @param bool $classMapAuthoritative |
|
| 259 | + */ |
|
| 260 | + public function setClassMapAuthoritative($classMapAuthoritative) |
|
| 261 | + { |
|
| 262 | + $this->classMapAuthoritative = $classMapAuthoritative; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * Should class lookup fail if not found in the current class map? |
|
| 267 | + * |
|
| 268 | + * @return bool |
|
| 269 | + */ |
|
| 270 | + public function isClassMapAuthoritative() |
|
| 271 | + { |
|
| 272 | + return $this->classMapAuthoritative; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. |
|
| 277 | + * |
|
| 278 | + * @param string|null $apcuPrefix |
|
| 279 | + */ |
|
| 280 | + public function setApcuPrefix($apcuPrefix) |
|
| 281 | + { |
|
| 282 | + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * The APCu prefix in use, or null if APCu caching is not enabled. |
|
| 287 | + * |
|
| 288 | + * @return string|null |
|
| 289 | + */ |
|
| 290 | + public function getApcuPrefix() |
|
| 291 | + { |
|
| 292 | + return $this->apcuPrefix; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * Registers this instance as an autoloader. |
|
| 297 | + * |
|
| 298 | + * @param bool $prepend Whether to prepend the autoloader or not |
|
| 299 | + */ |
|
| 300 | + public function register($prepend = false) |
|
| 301 | + { |
|
| 302 | + spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * Unregisters this instance as an autoloader. |
|
| 307 | + */ |
|
| 308 | + public function unregister() |
|
| 309 | + { |
|
| 310 | + spl_autoload_unregister(array($this, 'loadClass')); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * Loads the given class or interface. |
|
| 315 | + * |
|
| 316 | + * @param string $class The name of the class |
|
| 317 | + * @return bool|null True if loaded, null otherwise |
|
| 318 | + */ |
|
| 319 | + public function loadClass($class) |
|
| 320 | + { |
|
| 321 | + if ($file = $this->findFile($class)) { |
|
| 322 | + includeFile($file); |
|
| 323 | + |
|
| 324 | + return true; |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * Finds the path to the file where the class is defined. |
|
| 330 | + * |
|
| 331 | + * @param string $class The name of the class |
|
| 332 | + * |
|
| 333 | + * @return string|false The path if found, false otherwise |
|
| 334 | + */ |
|
| 335 | + public function findFile($class) |
|
| 336 | + { |
|
| 337 | + // class map lookup |
|
| 338 | + if (isset($this->classMap[$class])) { |
|
| 339 | + return $this->classMap[$class]; |
|
| 340 | + } |
|
| 341 | + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
|
| 342 | + return false; |
|
| 343 | + } |
|
| 344 | + if (null !== $this->apcuPrefix) { |
|
| 345 | + $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
| 346 | + if ($hit) { |
|
| 347 | + return $file; |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + $file = $this->findFileWithExtension($class, '.php'); |
|
| 352 | + |
|
| 353 | + // Search for Hack files if we are running on HHVM |
|
| 354 | + if (false === $file && defined('HHVM_VERSION')) { |
|
| 355 | + $file = $this->findFileWithExtension($class, '.hh'); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + if (null !== $this->apcuPrefix) { |
|
| 359 | + apcu_add($this->apcuPrefix.$class, $file); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + if (false === $file) { |
|
| 363 | + // Remember that this class does not exist. |
|
| 364 | + $this->missingClasses[$class] = true; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + return $file; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + private function findFileWithExtension($class, $ext) |
|
| 371 | + { |
|
| 372 | + // PSR-4 lookup |
|
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 374 | + |
|
| 375 | + $first = $class[0]; |
|
| 376 | + if (isset($this->prefixLengthsPsr4[$first])) { |
|
| 377 | + $subPath = $class; |
|
| 378 | + while (false !== $lastPos = strrpos($subPath, '\\')) { |
|
| 379 | + $subPath = substr($subPath, 0, $lastPos); |
|
| 380 | + $search = $subPath . '\\'; |
|
| 381 | + if (isset($this->prefixDirsPsr4[$search])) { |
|
| 382 | + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | + foreach ($this->prefixDirsPsr4[$search] as $dir) { |
|
| 384 | + if (file_exists($file = $dir . $pathEnd)) { |
|
| 385 | + return $file; |
|
| 386 | + } |
|
| 387 | + } |
|
| 388 | + } |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + // PSR-4 fallback dirs |
|
| 393 | + foreach ($this->fallbackDirsPsr4 as $dir) { |
|
| 394 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 395 | + return $file; |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + // PSR-0 lookup |
|
| 400 | + if (false !== $pos = strrpos($class, '\\')) { |
|
| 401 | + // namespaced class name |
|
| 402 | + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) |
|
| 403 | + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
|
| 404 | + } else { |
|
| 405 | + // PEAR-like class name |
|
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + if (isset($this->prefixesPsr0[$first])) { |
|
| 410 | + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
|
| 411 | + if (0 === strpos($class, $prefix)) { |
|
| 412 | + foreach ($dirs as $dir) { |
|
| 413 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 414 | + return $file; |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + // PSR-0 fallback dirs |
|
| 422 | + foreach ($this->fallbackDirsPsr0 as $dir) { |
|
| 423 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 424 | + return $file; |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + // PSR-0 include paths. |
|
| 429 | + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { |
|
| 430 | + return $file; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + return false; |
|
| 434 | + } |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -441,5 +441,5 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | function includeFile($file) |
| 443 | 443 | { |
| 444 | - include $file; |
|
| 444 | + include $file; |
|
| 445 | 445 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | private $missingClasses = array(); |
| 58 | 58 | private $apcuPrefix; |
| 59 | 59 | |
| 60 | - public function getPrefixes() |
|
| 60 | + public function getPrefixes () |
|
| 61 | 61 | { |
| 62 | 62 | if (!empty($this->prefixesPsr0)) { |
| 63 | 63 | return call_user_func_array('array_merge', $this->prefixesPsr0); |
@@ -66,22 +66,22 @@ discard block |
||
| 66 | 66 | return array(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function getPrefixesPsr4() |
|
| 69 | + public function getPrefixesPsr4 () |
|
| 70 | 70 | { |
| 71 | 71 | return $this->prefixDirsPsr4; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function getFallbackDirs() |
|
| 74 | + public function getFallbackDirs () |
|
| 75 | 75 | { |
| 76 | 76 | return $this->fallbackDirsPsr0; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function getFallbackDirsPsr4() |
|
| 79 | + public function getFallbackDirsPsr4 () |
|
| 80 | 80 | { |
| 81 | 81 | return $this->fallbackDirsPsr4; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public function getClassMap() |
|
| 84 | + public function getClassMap () |
|
| 85 | 85 | { |
| 86 | 86 | return $this->classMap; |
| 87 | 87 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | /** |
| 90 | 90 | * @param array $classMap Class to filename map |
| 91 | 91 | */ |
| 92 | - public function addClassMap(array $classMap) |
|
| 92 | + public function addClassMap (array $classMap) |
|
| 93 | 93 | { |
| 94 | 94 | if ($this->classMap) { |
| 95 | 95 | $this->classMap = array_merge($this->classMap, $classMap); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param array|string $paths The PSR-0 root directories |
| 107 | 107 | * @param bool $prepend Whether to prepend the directories |
| 108 | 108 | */ |
| 109 | - public function add($prefix, $paths, $prepend = false) |
|
| 109 | + public function add ($prefix, $paths, $prepend = false) |
|
| 110 | 110 | { |
| 111 | 111 | if (!$prefix) { |
| 112 | 112 | if ($prepend) { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @throws \InvalidArgumentException |
| 155 | 155 | */ |
| 156 | - public function addPsr4($prefix, $paths, $prepend = false) |
|
| 156 | + public function addPsr4 ($prefix, $paths, $prepend = false) |
|
| 157 | 157 | { |
| 158 | 158 | if (!$prefix) { |
| 159 | 159 | // Register directories for the root namespace. |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @param string $prefix The prefix |
| 199 | 199 | * @param array|string $paths The PSR-0 base directories |
| 200 | 200 | */ |
| 201 | - public function set($prefix, $paths) |
|
| 201 | + public function set ($prefix, $paths) |
|
| 202 | 202 | { |
| 203 | 203 | if (!$prefix) { |
| 204 | 204 | $this->fallbackDirsPsr0 = (array) $paths; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @throws \InvalidArgumentException |
| 218 | 218 | */ |
| 219 | - public function setPsr4($prefix, $paths) |
|
| 219 | + public function setPsr4 ($prefix, $paths) |
|
| 220 | 220 | { |
| 221 | 221 | if (!$prefix) { |
| 222 | 222 | $this->fallbackDirsPsr4 = (array) $paths; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @param bool $useIncludePath |
| 237 | 237 | */ |
| 238 | - public function setUseIncludePath($useIncludePath) |
|
| 238 | + public function setUseIncludePath ($useIncludePath) |
|
| 239 | 239 | { |
| 240 | 240 | $this->useIncludePath = $useIncludePath; |
| 241 | 241 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @return bool |
| 248 | 248 | */ |
| 249 | - public function getUseIncludePath() |
|
| 249 | + public function getUseIncludePath () |
|
| 250 | 250 | { |
| 251 | 251 | return $this->useIncludePath; |
| 252 | 252 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @param bool $classMapAuthoritative |
| 259 | 259 | */ |
| 260 | - public function setClassMapAuthoritative($classMapAuthoritative) |
|
| 260 | + public function setClassMapAuthoritative ($classMapAuthoritative) |
|
| 261 | 261 | { |
| 262 | 262 | $this->classMapAuthoritative = $classMapAuthoritative; |
| 263 | 263 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @return bool |
| 269 | 269 | */ |
| 270 | - public function isClassMapAuthoritative() |
|
| 270 | + public function isClassMapAuthoritative () |
|
| 271 | 271 | { |
| 272 | 272 | return $this->classMapAuthoritative; |
| 273 | 273 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * |
| 278 | 278 | * @param string|null $apcuPrefix |
| 279 | 279 | */ |
| 280 | - public function setApcuPrefix($apcuPrefix) |
|
| 280 | + public function setApcuPrefix ($apcuPrefix) |
|
| 281 | 281 | { |
| 282 | 282 | $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; |
| 283 | 283 | } |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @return string|null |
| 289 | 289 | */ |
| 290 | - public function getApcuPrefix() |
|
| 290 | + public function getApcuPrefix () |
|
| 291 | 291 | { |
| 292 | 292 | return $this->apcuPrefix; |
| 293 | 293 | } |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * |
| 298 | 298 | * @param bool $prepend Whether to prepend the autoloader or not |
| 299 | 299 | */ |
| 300 | - public function register($prepend = false) |
|
| 300 | + public function register ($prepend = false) |
|
| 301 | 301 | { |
| 302 | 302 | spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
| 303 | 303 | } |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | /** |
| 306 | 306 | * Unregisters this instance as an autoloader. |
| 307 | 307 | */ |
| 308 | - public function unregister() |
|
| 308 | + public function unregister () |
|
| 309 | 309 | { |
| 310 | 310 | spl_autoload_unregister(array($this, 'loadClass')); |
| 311 | 311 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @param string $class The name of the class |
| 317 | 317 | * @return bool|null True if loaded, null otherwise |
| 318 | 318 | */ |
| 319 | - public function loadClass($class) |
|
| 319 | + public function loadClass ($class) |
|
| 320 | 320 | { |
| 321 | 321 | if ($file = $this->findFile($class)) { |
| 322 | 322 | includeFile($file); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | * |
| 333 | 333 | * @return string|false The path if found, false otherwise |
| 334 | 334 | */ |
| 335 | - public function findFile($class) |
|
| 335 | + public function findFile ($class) |
|
| 336 | 336 | { |
| 337 | 337 | // class map lookup |
| 338 | 338 | if (isset($this->classMap[$class])) { |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | return false; |
| 343 | 343 | } |
| 344 | 344 | if (null !== $this->apcuPrefix) { |
| 345 | - $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
| 345 | + $file = apcu_fetch($this->apcuPrefix . $class, $hit); |
|
| 346 | 346 | if ($hit) { |
| 347 | 347 | return $file; |
| 348 | 348 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | if (null !== $this->apcuPrefix) { |
| 359 | - apcu_add($this->apcuPrefix.$class, $file); |
|
| 359 | + apcu_add($this->apcuPrefix . $class, $file); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | if (false === $file) { |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | return $file; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - private function findFileWithExtension($class, $ext) |
|
| 370 | + private function findFileWithExtension ($class, $ext) |
|
| 371 | 371 | { |
| 372 | 372 | // PSR-4 lookup |
| 373 | 373 | $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * Prevents access to $this/self from included files. |
| 441 | 441 | */ |
| 442 | -function includeFile($file) |
|
| 442 | +function includeFile ($file) |
|
| 443 | 443 | { |
| 444 | 444 | include $file; |
| 445 | 445 | } |
@@ -59,7 +59,8 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function getPrefixes() |
| 61 | 61 | { |
| 62 | - if (!empty($this->prefixesPsr0)) { |
|
| 62 | + if (!empty($this->prefixesPsr0)) |
|
| 63 | + { |
|
| 63 | 64 | return call_user_func_array('array_merge', $this->prefixesPsr0); |
| 64 | 65 | } |
| 65 | 66 | |
@@ -91,9 +92,12 @@ discard block |
||
| 91 | 92 | */ |
| 92 | 93 | public function addClassMap(array $classMap) |
| 93 | 94 | { |
| 94 | - if ($this->classMap) { |
|
| 95 | + if ($this->classMap) |
|
| 96 | + { |
|
| 95 | 97 | $this->classMap = array_merge($this->classMap, $classMap); |
| 96 | - } else { |
|
| 98 | + } |
|
| 99 | + else |
|
| 100 | + { |
|
| 97 | 101 | $this->classMap = $classMap; |
| 98 | 102 | } |
| 99 | 103 | } |
@@ -108,13 +112,17 @@ discard block |
||
| 108 | 112 | */ |
| 109 | 113 | public function add($prefix, $paths, $prepend = false) |
| 110 | 114 | { |
| 111 | - if (!$prefix) { |
|
| 112 | - if ($prepend) { |
|
| 115 | + if (!$prefix) |
|
| 116 | + { |
|
| 117 | + if ($prepend) |
|
| 118 | + { |
|
| 113 | 119 | $this->fallbackDirsPsr0 = array_merge( |
| 114 | 120 | (array) $paths, |
| 115 | 121 | $this->fallbackDirsPsr0 |
| 116 | 122 | ); |
| 117 | - } else { |
|
| 123 | + } |
|
| 124 | + else |
|
| 125 | + { |
|
| 118 | 126 | $this->fallbackDirsPsr0 = array_merge( |
| 119 | 127 | $this->fallbackDirsPsr0, |
| 120 | 128 | (array) $paths |
@@ -125,17 +133,21 @@ discard block |
||
| 125 | 133 | } |
| 126 | 134 | |
| 127 | 135 | $first = $prefix[0]; |
| 128 | - if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 136 | + if (!isset($this->prefixesPsr0[$first][$prefix])) |
|
| 137 | + { |
|
| 129 | 138 | $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
| 130 | 139 | |
| 131 | 140 | return; |
| 132 | 141 | } |
| 133 | - if ($prepend) { |
|
| 142 | + if ($prepend) |
|
| 143 | + { |
|
| 134 | 144 | $this->prefixesPsr0[$first][$prefix] = array_merge( |
| 135 | 145 | (array) $paths, |
| 136 | 146 | $this->prefixesPsr0[$first][$prefix] |
| 137 | 147 | ); |
| 138 | - } else { |
|
| 148 | + } |
|
| 149 | + else |
|
| 150 | + { |
|
| 139 | 151 | $this->prefixesPsr0[$first][$prefix] = array_merge( |
| 140 | 152 | $this->prefixesPsr0[$first][$prefix], |
| 141 | 153 | (array) $paths |
@@ -155,34 +167,45 @@ discard block |
||
| 155 | 167 | */ |
| 156 | 168 | public function addPsr4($prefix, $paths, $prepend = false) |
| 157 | 169 | { |
| 158 | - if (!$prefix) { |
|
| 170 | + if (!$prefix) |
|
| 171 | + { |
|
| 159 | 172 | // Register directories for the root namespace. |
| 160 | - if ($prepend) { |
|
| 173 | + if ($prepend) |
|
| 174 | + { |
|
| 161 | 175 | $this->fallbackDirsPsr4 = array_merge( |
| 162 | 176 | (array) $paths, |
| 163 | 177 | $this->fallbackDirsPsr4 |
| 164 | 178 | ); |
| 165 | - } else { |
|
| 179 | + } |
|
| 180 | + else |
|
| 181 | + { |
|
| 166 | 182 | $this->fallbackDirsPsr4 = array_merge( |
| 167 | 183 | $this->fallbackDirsPsr4, |
| 168 | 184 | (array) $paths |
| 169 | 185 | ); |
| 170 | 186 | } |
| 171 | - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
| 187 | + } |
|
| 188 | + elseif (!isset($this->prefixDirsPsr4[$prefix])) |
|
| 189 | + { |
|
| 172 | 190 | // Register directories for a new namespace. |
| 173 | 191 | $length = strlen($prefix); |
| 174 | - if ('\\' !== $prefix[$length - 1]) { |
|
| 192 | + if ('\\' !== $prefix[$length - 1]) |
|
| 193 | + { |
|
| 175 | 194 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
| 176 | 195 | } |
| 177 | 196 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
| 178 | 197 | $this->prefixDirsPsr4[$prefix] = (array) $paths; |
| 179 | - } elseif ($prepend) { |
|
| 198 | + } |
|
| 199 | + elseif ($prepend) |
|
| 200 | + { |
|
| 180 | 201 | // Prepend directories for an already registered namespace. |
| 181 | 202 | $this->prefixDirsPsr4[$prefix] = array_merge( |
| 182 | 203 | (array) $paths, |
| 183 | 204 | $this->prefixDirsPsr4[$prefix] |
| 184 | 205 | ); |
| 185 | - } else { |
|
| 206 | + } |
|
| 207 | + else |
|
| 208 | + { |
|
| 186 | 209 | // Append directories for an already registered namespace. |
| 187 | 210 | $this->prefixDirsPsr4[$prefix] = array_merge( |
| 188 | 211 | $this->prefixDirsPsr4[$prefix], |
@@ -200,9 +223,12 @@ discard block |
||
| 200 | 223 | */ |
| 201 | 224 | public function set($prefix, $paths) |
| 202 | 225 | { |
| 203 | - if (!$prefix) { |
|
| 226 | + if (!$prefix) |
|
| 227 | + { |
|
| 204 | 228 | $this->fallbackDirsPsr0 = (array) $paths; |
| 205 | - } else { |
|
| 229 | + } |
|
| 230 | + else |
|
| 231 | + { |
|
| 206 | 232 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
| 207 | 233 | } |
| 208 | 234 | } |
@@ -218,11 +244,15 @@ discard block |
||
| 218 | 244 | */ |
| 219 | 245 | public function setPsr4($prefix, $paths) |
| 220 | 246 | { |
| 221 | - if (!$prefix) { |
|
| 247 | + if (!$prefix) |
|
| 248 | + { |
|
| 222 | 249 | $this->fallbackDirsPsr4 = (array) $paths; |
| 223 | - } else { |
|
| 250 | + } |
|
| 251 | + else |
|
| 252 | + { |
|
| 224 | 253 | $length = strlen($prefix); |
| 225 | - if ('\\' !== $prefix[$length - 1]) { |
|
| 254 | + if ('\\' !== $prefix[$length - 1]) |
|
| 255 | + { |
|
| 226 | 256 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
| 227 | 257 | } |
| 228 | 258 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
@@ -318,7 +348,8 @@ discard block |
||
| 318 | 348 | */ |
| 319 | 349 | public function loadClass($class) |
| 320 | 350 | { |
| 321 | - if ($file = $this->findFile($class)) { |
|
| 351 | + if ($file = $this->findFile($class)) |
|
| 352 | + { |
|
| 322 | 353 | includeFile($file); |
| 323 | 354 | |
| 324 | 355 | return true; |
@@ -335,15 +366,19 @@ discard block |
||
| 335 | 366 | public function findFile($class) |
| 336 | 367 | { |
| 337 | 368 | // class map lookup |
| 338 | - if (isset($this->classMap[$class])) { |
|
| 369 | + if (isset($this->classMap[$class])) |
|
| 370 | + { |
|
| 339 | 371 | return $this->classMap[$class]; |
| 340 | 372 | } |
| 341 | - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
|
| 373 | + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) |
|
| 374 | + { |
|
| 342 | 375 | return false; |
| 343 | 376 | } |
| 344 | - if (null !== $this->apcuPrefix) { |
|
| 377 | + if (null !== $this->apcuPrefix) |
|
| 378 | + { |
|
| 345 | 379 | $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
| 346 | - if ($hit) { |
|
| 380 | + if ($hit) |
|
| 381 | + { |
|
| 347 | 382 | return $file; |
| 348 | 383 | } |
| 349 | 384 | } |
@@ -351,15 +386,18 @@ discard block |
||
| 351 | 386 | $file = $this->findFileWithExtension($class, '.php'); |
| 352 | 387 | |
| 353 | 388 | // Search for Hack files if we are running on HHVM |
| 354 | - if (false === $file && defined('HHVM_VERSION')) { |
|
| 389 | + if (false === $file && defined('HHVM_VERSION')) |
|
| 390 | + { |
|
| 355 | 391 | $file = $this->findFileWithExtension($class, '.hh'); |
| 356 | 392 | } |
| 357 | 393 | |
| 358 | - if (null !== $this->apcuPrefix) { |
|
| 394 | + if (null !== $this->apcuPrefix) |
|
| 395 | + { |
|
| 359 | 396 | apcu_add($this->apcuPrefix.$class, $file); |
| 360 | 397 | } |
| 361 | 398 | |
| 362 | - if (false === $file) { |
|
| 399 | + if (false === $file) |
|
| 400 | + { |
|
| 363 | 401 | // Remember that this class does not exist. |
| 364 | 402 | $this->missingClasses[$class] = true; |
| 365 | 403 | } |
@@ -373,15 +411,20 @@ discard block |
||
| 373 | 411 | $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
| 374 | 412 | |
| 375 | 413 | $first = $class[0]; |
| 376 | - if (isset($this->prefixLengthsPsr4[$first])) { |
|
| 414 | + if (isset($this->prefixLengthsPsr4[$first])) |
|
| 415 | + { |
|
| 377 | 416 | $subPath = $class; |
| 378 | - while (false !== $lastPos = strrpos($subPath, '\\')) { |
|
| 417 | + while (false !== $lastPos = strrpos($subPath, '\\')) |
|
| 418 | + { |
|
| 379 | 419 | $subPath = substr($subPath, 0, $lastPos); |
| 380 | 420 | $search = $subPath . '\\'; |
| 381 | - if (isset($this->prefixDirsPsr4[$search])) { |
|
| 421 | + if (isset($this->prefixDirsPsr4[$search])) |
|
| 422 | + { |
|
| 382 | 423 | $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
| 383 | - foreach ($this->prefixDirsPsr4[$search] as $dir) { |
|
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 424 | + foreach ($this->prefixDirsPsr4[$search] as $dir) |
|
| 425 | + { |
|
| 426 | + if (file_exists($file = $dir . $pathEnd)) |
|
| 427 | + { |
|
| 385 | 428 | return $file; |
| 386 | 429 | } |
| 387 | 430 | } |
@@ -390,27 +433,37 @@ discard block |
||
| 390 | 433 | } |
| 391 | 434 | |
| 392 | 435 | // PSR-4 fallback dirs |
| 393 | - foreach ($this->fallbackDirsPsr4 as $dir) { |
|
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 436 | + foreach ($this->fallbackDirsPsr4 as $dir) |
|
| 437 | + { |
|
| 438 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) |
|
| 439 | + { |
|
| 395 | 440 | return $file; |
| 396 | 441 | } |
| 397 | 442 | } |
| 398 | 443 | |
| 399 | 444 | // PSR-0 lookup |
| 400 | - if (false !== $pos = strrpos($class, '\\')) { |
|
| 445 | + if (false !== $pos = strrpos($class, '\\')) |
|
| 446 | + { |
|
| 401 | 447 | // namespaced class name |
| 402 | 448 | $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) |
| 403 | 449 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 404 | - } else { |
|
| 450 | + } |
|
| 451 | + else |
|
| 452 | + { |
|
| 405 | 453 | // PEAR-like class name |
| 406 | 454 | $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
| 407 | 455 | } |
| 408 | 456 | |
| 409 | - if (isset($this->prefixesPsr0[$first])) { |
|
| 410 | - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
|
| 411 | - if (0 === strpos($class, $prefix)) { |
|
| 412 | - foreach ($dirs as $dir) { |
|
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 457 | + if (isset($this->prefixesPsr0[$first])) |
|
| 458 | + { |
|
| 459 | + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) |
|
| 460 | + { |
|
| 461 | + if (0 === strpos($class, $prefix)) |
|
| 462 | + { |
|
| 463 | + foreach ($dirs as $dir) |
|
| 464 | + { |
|
| 465 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) |
|
| 466 | + { |
|
| 414 | 467 | return $file; |
| 415 | 468 | } |
| 416 | 469 | } |
@@ -419,14 +472,17 @@ discard block |
||
| 419 | 472 | } |
| 420 | 473 | |
| 421 | 474 | // PSR-0 fallback dirs |
| 422 | - foreach ($this->fallbackDirsPsr0 as $dir) { |
|
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 475 | + foreach ($this->fallbackDirsPsr0 as $dir) |
|
| 476 | + { |
|
| 477 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) |
|
| 478 | + { |
|
| 424 | 479 | return $file; |
| 425 | 480 | } |
| 426 | 481 | } |
| 427 | 482 | |
| 428 | 483 | // PSR-0 include paths. |
| 429 | - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { |
|
| 484 | + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) |
|
| 485 | + { |
|
| 430 | 486 | return $file; |
| 431 | 487 | } |
| 432 | 488 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * - Makes sure, regardless of php.ini, everything has slashes. |
| 32 | 32 | * - Uses Request parseRequest() to clean and set up variables like $board or $_REQUEST'start']. |
| 33 | 33 | */ |
| 34 | -function cleanRequest() |
|
| 34 | +function cleanRequest () |
|
| 35 | 35 | { |
| 36 | 36 | // Make sure REMOTE_ADDR, other IPs, and the like are parsed |
| 37 | 37 | $req = Request::instance(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string The escaped string |
| 54 | 54 | */ |
| 55 | -function JavaScriptEscape($string) |
|
| 55 | +function JavaScriptEscape ($string) |
|
| 56 | 56 | { |
| 57 | 57 | global $scripturl; |
| 58 | 58 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @return string The modified output buffer |
| 87 | 87 | */ |
| 88 | -function ob_sessrewrite($buffer) |
|
| 88 | +function ob_sessrewrite ($buffer) |
|
| 89 | 89 | { |
| 90 | 90 | global $scripturl; |
| 91 | 91 | |
@@ -1730,10 +1730,13 @@ |
||
| 1730 | 1730 | if ($result[0] === 127 // Valid Response |
| 1731 | 1731 | && ($result[3] & 3 || $result[3] & 5) // Listed as Suspicious + Harvester || Suspicious + Comment Spammer |
| 1732 | 1732 | && $result[2] >= $modSettings['badbehavior_httpbl_threat'] // Level |
| 1733 | - && $result[1] <= $modSettings['badbehavior_httpbl_maxage']) // Age |
|
| 1733 | + && $result[1] <= $modSettings['badbehavior_httpbl_maxage']) |
|
| 1734 | + { |
|
| 1735 | + // Age |
|
| 1734 | 1736 | { |
| 1735 | 1737 | return true; |
| 1736 | 1738 | } |
| 1739 | + } |
|
| 1737 | 1740 | } |
| 1738 | 1741 | |
| 1739 | 1742 | return false; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return bool|string |
| 44 | 44 | */ |
| 45 | -function validateSession($type = 'admin') |
|
| 45 | +function validateSession ($type = 'admin') |
|
| 46 | 46 | { |
| 47 | 47 | global $modSettings; |
| 48 | 48 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @return bool |
| 159 | 159 | */ |
| 160 | -function checkPassword($type, $hash = false) |
|
| 160 | +function checkPassword ($type, $hash = false) |
|
| 161 | 161 | { |
| 162 | 162 | $password = $_POST[$type . ($hash ? '_hash_pass' : '_pass')]; |
| 163 | 163 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @return bool |
| 191 | 191 | * @throws \ElkArte\Exceptions\Exception |
| 192 | 192 | */ |
| 193 | -function is_not_guest($message = '', $is_fatal = true) |
|
| 193 | +function is_not_guest ($message = '', $is_fatal = true) |
|
| 194 | 194 | { |
| 195 | 195 | global $txt, $context, $scripturl; |
| 196 | 196 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * @throws \ElkArte\Exceptions\Exception |
| 272 | 272 | */ |
| 273 | -function is_not_banned($forceCheck = false) |
|
| 273 | +function is_not_banned ($forceCheck = false) |
|
| 274 | 274 | { |
| 275 | 275 | global $txt, $modSettings, $cookiename; |
| 276 | 276 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | (' . implode(' OR ', $ban_query) . ')', |
| 354 | 354 | $ban_query_vars |
| 355 | 355 | )->fetch_callback( |
| 356 | - function ($row) use ($restrictions, &$flag_is_activated) { |
|
| 356 | + function($row) use ($restrictions, &$flag_is_activated) { |
|
| 357 | 357 | // Store every type of ban that applies to you in your session. |
| 358 | 358 | foreach ($restrictions as $restriction) |
| 359 | 359 | { |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | 'current_time' => time(), |
| 416 | 416 | ) |
| 417 | 417 | )->fetch_callback( |
| 418 | - function ($row) { |
|
| 418 | + function($row) { |
|
| 419 | 419 | $_SESSION['ban']['cannot_access']['ids'][] = $row['id_ban']; |
| 420 | 420 | $_SESSION['ban']['cannot_access']['reason'] = $row['reason']; |
| 421 | 421 | } |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * @event integrate_warn_permissions Allows changing of permissions for users on warning moderate |
| 507 | 507 | * @package Bans |
| 508 | 508 | */ |
| 509 | -function banPermissions() |
|
| 509 | +function banPermissions () |
|
| 510 | 510 | { |
| 511 | 511 | global $modSettings, $context; |
| 512 | 512 | |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | * @param string|null $email = null |
| 615 | 615 | * @package Bans |
| 616 | 616 | */ |
| 617 | -function log_ban($ban_ids = array(), $email = null) |
|
| 617 | +function log_ban ($ban_ids = array(), $email = null) |
|
| 618 | 618 | { |
| 619 | 619 | $db = database(); |
| 620 | 620 | |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | * @throws \ElkArte\Exceptions\Exception |
| 671 | 671 | * @package Bans |
| 672 | 672 | */ |
| 673 | -function isBannedEmail($email, $restriction, $error) |
|
| 673 | +function isBannedEmail ($email, $restriction, $error) |
|
| 674 | 674 | { |
| 675 | 675 | global $txt; |
| 676 | 676 | |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | 'now' => time(), |
| 702 | 702 | ) |
| 703 | 703 | )->fetch_callback( |
| 704 | - function ($row) use (&$ban_ids, &$ban_reason, $restriction) { |
|
| 704 | + function($row) use (&$ban_ids, &$ban_reason, $restriction) { |
|
| 705 | 705 | if (!empty($row['cannot_access'])) |
| 706 | 706 | { |
| 707 | 707 | $_SESSION['ban']['cannot_access']['ids'][] = $row['id_ban']; |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | * |
| 751 | 751 | * @return string the error message if is_fatal is false. |
| 752 | 752 | */ |
| 753 | -function checkSession($type = 'post', $from_action = '', $is_fatal = true) |
|
| 753 | +function checkSession ($type = 'post', $from_action = '', $is_fatal = true) |
|
| 754 | 754 | { |
| 755 | 755 | global $modSettings, $boardurl; |
| 756 | 756 | |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | * |
| 894 | 894 | * @return string[] array of token var, time, csrf, token |
| 895 | 895 | */ |
| 896 | -function createToken($action, $type = 'post') |
|
| 896 | +function createToken ($action, $type = 'post') |
|
| 897 | 897 | { |
| 898 | 898 | global $context; |
| 899 | 899 | |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | * @return bool|string except for $action == 'login' where the token is returned |
| 935 | 935 | * @throws \ElkArte\Exceptions\Exception token_verify_fail |
| 936 | 936 | */ |
| 937 | -function validateToken($action, $type = 'post', $reset = true, $fatal = true) |
|
| 937 | +function validateToken ($action, $type = 'post', $reset = true, $fatal = true) |
|
| 938 | 938 | { |
| 939 | 939 | $type = ($type === 'get' || $type === 'request') ? $type : 'post'; |
| 940 | 940 | $token_index = $type . '-' . $action; |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | * @param bool $complete = false |
| 1014 | 1014 | * @param string $suffix = false |
| 1015 | 1015 | */ |
| 1016 | -function cleanTokens($complete = false, $suffix = '') |
|
| 1016 | +function cleanTokens ($complete = false, $suffix = '') |
|
| 1017 | 1017 | { |
| 1018 | 1018 | // We appreciate cleaning up after yourselves. |
| 1019 | 1019 | if (!isset($_SESSION['token'])) |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | * @return bool |
| 1058 | 1058 | * @throws \ElkArte\Exceptions\Exception error_form_already_submitted |
| 1059 | 1059 | */ |
| 1060 | -function checkSubmitOnce($action, $is_fatal = false) |
|
| 1060 | +function checkSubmitOnce ($action, $is_fatal = false) |
|
| 1061 | 1061 | { |
| 1062 | 1062 | global $context; |
| 1063 | 1063 | |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | * |
| 1124 | 1124 | * @return bool if the user can do the permission |
| 1125 | 1125 | */ |
| 1126 | -function allowedTo($permission, $boards = null) |
|
| 1126 | +function allowedTo ($permission, $boards = null) |
|
| 1127 | 1127 | { |
| 1128 | 1128 | $db = database(); |
| 1129 | 1129 | |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | * |
| 1226 | 1226 | * @throws \ElkArte\Exceptions\Exception cannot_xyz where xyz is the permission |
| 1227 | 1227 | */ |
| 1228 | -function isAllowedTo($permission, $boards = null) |
|
| 1228 | +function isAllowedTo ($permission, $boards = null) |
|
| 1229 | 1229 | { |
| 1230 | 1230 | global $txt; |
| 1231 | 1231 | |
@@ -1294,7 +1294,7 @@ discard block |
||
| 1294 | 1294 | * @return array |
| 1295 | 1295 | * @throws \ElkArte\Exceptions\Exception |
| 1296 | 1296 | */ |
| 1297 | -function boardsAllowedTo($permissions, $check_access = true, $simple = true) |
|
| 1297 | +function boardsAllowedTo ($permissions, $check_access = true, $simple = true) |
|
| 1298 | 1298 | { |
| 1299 | 1299 | $db = database(); |
| 1300 | 1300 | |
@@ -1345,7 +1345,7 @@ discard block |
||
| 1345 | 1345 | 'permissions' => $permissions, |
| 1346 | 1346 | ) |
| 1347 | 1347 | )->fetch_callback( |
| 1348 | - function ($row) use ($simple, &$deny_boards, &$boards) { |
|
| 1348 | + function($row) use ($simple, &$deny_boards, &$boards) { |
|
| 1349 | 1349 | if ($simple) |
| 1350 | 1350 | { |
| 1351 | 1351 | if (empty($row['add_deny'])) |
@@ -1411,7 +1411,7 @@ discard block |
||
| 1411 | 1411 | * |
| 1412 | 1412 | * @return string (yes, yes_permission_override, no_through_forum, no) |
| 1413 | 1413 | */ |
| 1414 | -function showEmailAddress($userProfile_hideEmail, $userProfile_id) |
|
| 1414 | +function showEmailAddress ($userProfile_hideEmail, $userProfile_id) |
|
| 1415 | 1415 | { |
| 1416 | 1416 | // Should this user's email address be shown? |
| 1417 | 1417 | // If you're guest: no. |
@@ -1459,7 +1459,7 @@ discard block |
||
| 1459 | 1459 | * @return bool|int|mixed |
| 1460 | 1460 | * @throws \ElkArte\Exceptions\Exception |
| 1461 | 1461 | */ |
| 1462 | -function spamProtection($error_type, $fatal = true) |
|
| 1462 | +function spamProtection ($error_type, $fatal = true) |
|
| 1463 | 1463 | { |
| 1464 | 1464 | global $modSettings; |
| 1465 | 1465 | |
@@ -1534,7 +1534,7 @@ discard block |
||
| 1534 | 1534 | * |
| 1535 | 1535 | * @return string[]|string|bool on success error string if anything fails |
| 1536 | 1536 | */ |
| 1537 | -function secureDirectory($path, $allow_localhost = false, $files = '*') |
|
| 1537 | +function secureDirectory ($path, $allow_localhost = false, $files = '*') |
|
| 1538 | 1538 | { |
| 1539 | 1539 | if (empty($path)) |
| 1540 | 1540 | { |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | |
| 1551 | 1551 | // How deep is this from our boarddir |
| 1552 | 1552 | $tree = explode(DIRECTORY_SEPARATOR, $path); |
| 1553 | - $root = explode(DIRECTORY_SEPARATOR,BOARDDIR); |
|
| 1553 | + $root = explode(DIRECTORY_SEPARATOR, BOARDDIR); |
|
| 1554 | 1554 | $count = max(count($tree) - count($root), 0); |
| 1555 | 1555 | |
| 1556 | 1556 | $errors = array(); |
@@ -1649,7 +1649,7 @@ discard block |
||
| 1649 | 1649 | * |
| 1650 | 1650 | * @return string A SQL condition |
| 1651 | 1651 | */ |
| 1652 | -function constructBanQueryIP($fullip) |
|
| 1652 | +function constructBanQueryIP ($fullip) |
|
| 1653 | 1653 | { |
| 1654 | 1654 | // First attempt a IPv6 address. |
| 1655 | 1655 | if (isValidIPv6($fullip)) |
@@ -1696,7 +1696,7 @@ discard block |
||
| 1696 | 1696 | * |
| 1697 | 1697 | * @return bool true if bad, false otherwise |
| 1698 | 1698 | */ |
| 1699 | -function runBadBehavior() |
|
| 1699 | +function runBadBehavior () |
|
| 1700 | 1700 | { |
| 1701 | 1701 | global $modSettings; |
| 1702 | 1702 | |
@@ -1757,7 +1757,7 @@ discard block |
||
| 1757 | 1757 | * |
| 1758 | 1758 | * @throws \ElkArte\Exceptions\Exception no_access |
| 1759 | 1759 | */ |
| 1760 | -function validatePasswordFlood($id_member, $password_flood_value = false, $was_correct = false) |
|
| 1760 | +function validatePasswordFlood ($id_member, $password_flood_value = false, $was_correct = false) |
|
| 1761 | 1761 | { |
| 1762 | 1762 | global $cookiename; |
| 1763 | 1763 | |
@@ -1818,7 +1818,7 @@ discard block |
||
| 1818 | 1818 | * |
| 1819 | 1819 | * @param string|null $override the frame option, defaults to deny. |
| 1820 | 1820 | */ |
| 1821 | -function frameOptionsHeader($override = null) |
|
| 1821 | +function frameOptionsHeader ($override = null) |
|
| 1822 | 1822 | { |
| 1823 | 1823 | global $modSettings; |
| 1824 | 1824 | |
@@ -1857,7 +1857,7 @@ discard block |
||
| 1857 | 1857 | * |
| 1858 | 1858 | * @param bool|null $override |
| 1859 | 1859 | */ |
| 1860 | -function securityOptionsHeader($override = null) |
|
| 1860 | +function securityOptionsHeader ($override = null) |
|
| 1861 | 1861 | { |
| 1862 | 1862 | if ($override !== true) |
| 1863 | 1863 | { |
@@ -1870,7 +1870,7 @@ discard block |
||
| 1870 | 1870 | /** |
| 1871 | 1871 | * Stop some browsers pre fetching activity to reduce server load |
| 1872 | 1872 | */ |
| 1873 | -function stop_prefetching() |
|
| 1873 | +function stop_prefetching () |
|
| 1874 | 1874 | { |
| 1875 | 1875 | if ((isset($_SERVER['HTTP_PURPOSE']) && $_SERVER['HTTP_PURPOSE'] === 'prefetch') |
| 1876 | 1876 | || (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] === 'prefetch')) |
@@ -1889,7 +1889,7 @@ discard block |
||
| 1889 | 1889 | * |
| 1890 | 1890 | * @return bool |
| 1891 | 1891 | */ |
| 1892 | -function isAdminSessionActive() |
|
| 1892 | +function isAdminSessionActive () |
|
| 1893 | 1893 | { |
| 1894 | 1894 | global $modSettings; |
| 1895 | 1895 | |
@@ -1907,7 +1907,7 @@ discard block |
||
| 1907 | 1907 | * |
| 1908 | 1908 | * @return bool |
| 1909 | 1909 | */ |
| 1910 | -function checkSecurityFiles() |
|
| 1910 | +function checkSecurityFiles () |
|
| 1911 | 1911 | { |
| 1912 | 1912 | global $txt, $context; |
| 1913 | 1913 | |
@@ -1943,7 +1943,7 @@ discard block |
||
| 1943 | 1943 | * @param bool $match_board - If true tries to match board|topic in the URL as well |
| 1944 | 1944 | * @return bool |
| 1945 | 1945 | */ |
| 1946 | -function validLoginUrl($url, $match_board = false) |
|
| 1946 | +function validLoginUrl ($url, $match_board = false) |
|
| 1947 | 1947 | { |
| 1948 | 1948 | if (empty($url)) |
| 1949 | 1949 | { |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return \ElkArte\Database\QueryInterface |
| 27 | 27 | */ |
| 28 | -function elk_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array(), $db_type = 'mysql') |
|
| 28 | +function elk_db_initiate ($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array(), $db_type = 'mysql') |
|
| 29 | 29 | { |
| 30 | 30 | return database(false); |
| 31 | 31 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @return \ElkArte\Database\QueryInterface |
| 42 | 42 | * @throws \Exception |
| 43 | 43 | */ |
| 44 | -function database($fatal = true, $force = false) |
|
| 44 | +function database ($fatal = true, $force = false) |
|
| 45 | 45 | { |
| 46 | 46 | static $db = null; |
| 47 | 47 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return \ElkArte\Database\AbstractTable |
| 92 | 92 | */ |
| 93 | -function db_table($db = null, $fatal = false) |
|
| 93 | +function db_table ($db = null, $fatal = false) |
|
| 94 | 94 | { |
| 95 | 95 | global $db_prefix, $db_type; |
| 96 | 96 | static $db_table = null; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @return \ElkArte\Database\AbstractSearch |
| 132 | 132 | */ |
| 133 | -function db_search() |
|
| 133 | +function db_search () |
|
| 134 | 134 | { |
| 135 | 135 | global $db_type; |
| 136 | 136 | static $db_search = null; |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * Attempt to start the session, unless it already has been. |
| 29 | 29 | */ |
| 30 | -function loadSession() |
|
| 30 | +function loadSession () |
|
| 31 | 31 | { |
| 32 | 32 | global $modSettings, $boardurl, $context; |
| 33 | 33 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param bool $force = false |
| 25 | 25 | */ |
| 26 | -function writeLog($force = false) |
|
| 26 | +function writeLog ($force = false) |
|
| 27 | 27 | { |
| 28 | 28 | global $context, $modSettings, $settings, $topic, $board; |
| 29 | 29 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * - Attempts to use the backup file first, to store the last database error |
| 153 | 153 | * - only updates db_last_error.txt if the first was successful. |
| 154 | 154 | */ |
| 155 | -function logLastDatabaseError() |
|
| 155 | +function logLastDatabaseError () |
|
| 156 | 156 | { |
| 157 | 157 | // Make a note of the last modified time in case someone does this before us |
| 158 | 158 | $last_db_error_change = @filemtime(BOARDDIR . '/db_last_error.txt'); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return bool|array |
| 201 | 201 | */ |
| 202 | -function trackStats($stats = array()) |
|
| 202 | +function trackStats ($stats = array()) |
|
| 203 | 203 | { |
| 204 | 204 | global $modSettings; |
| 205 | 205 | static $cache_stats = array(); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @example logAction('remove', array('starter' => $id_member_started)); |
| 267 | 267 | * |
| 268 | 268 | */ |
| 269 | -function logAction($action, $extra = array(), $log_type = 'moderate') |
|
| 269 | +function logAction ($action, $extra = array(), $log_type = 'moderate') |
|
| 270 | 270 | { |
| 271 | 271 | // Set up the array and pass through to logActions |
| 272 | 272 | return logActions(array( |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @return int the last logged ID |
| 297 | 297 | */ |
| 298 | -function logActions($logs) |
|
| 298 | +function logActions ($logs) |
|
| 299 | 299 | { |
| 300 | 300 | global $modSettings; |
| 301 | 301 | |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | switch ($type) |
| 350 | 350 | { |
| 351 | - case 'posts': |
|
| 352 | - $db->fetchQuery(' |
|
| 351 | + case 'posts': |
|
| 352 | + $db->fetchQuery(' |
|
| 353 | 353 | SELECT |
| 354 | 354 | /*!40001 SQL_NO_CACHE */ m.id_board, COUNT(*) AS real_num_posts |
| 355 | 355 | FROM {db_prefix}messages AS m |
@@ -357,29 +357,29 @@ discard block |
||
| 357 | 357 | AND m.id_topic <= {int:id_topic_max} |
| 358 | 358 | AND m.approved = {int:is_approved} |
| 359 | 359 | GROUP BY m.id_board', |
| 360 | - array( |
|
| 361 | - 'id_topic_min' => $start, |
|
| 362 | - 'id_topic_max' => $start + $increment, |
|
| 363 | - 'is_approved' => 1, |
|
| 364 | - ) |
|
| 365 | - )->fetch_callback( |
|
| 366 | - function ($row) use ($db) { |
|
| 367 | - $db->query('', ' |
|
| 360 | + array( |
|
| 361 | + 'id_topic_min' => $start, |
|
| 362 | + 'id_topic_max' => $start + $increment, |
|
| 363 | + 'is_approved' => 1, |
|
| 364 | + ) |
|
| 365 | + )->fetch_callback( |
|
| 366 | + function ($row) use ($db) { |
|
| 367 | + $db->query('', ' |
|
| 368 | 368 | UPDATE {db_prefix}boards |
| 369 | 369 | SET |
| 370 | 370 | num_posts = num_posts + {int:real_num_posts} |
| 371 | 371 | WHERE id_board = {int:id_board}', |
| 372 | - array( |
|
| 373 | - 'id_board' => $row['id_board'], |
|
| 374 | - 'real_num_posts' => $row['real_num_posts'], |
|
| 375 | - ) |
|
| 376 | - ); |
|
| 377 | - } |
|
| 378 | - ); |
|
| 379 | - break; |
|
| 372 | + array( |
|
| 373 | + 'id_board' => $row['id_board'], |
|
| 374 | + 'real_num_posts' => $row['real_num_posts'], |
|
| 375 | + ) |
|
| 376 | + ); |
|
| 377 | + } |
|
| 378 | + ); |
|
| 379 | + break; |
|
| 380 | 380 | |
| 381 | - case 'topics': |
|
| 382 | - $db->fetchQuery(' |
|
| 381 | + case 'topics': |
|
| 382 | + $db->fetchQuery(' |
|
| 383 | 383 | SELECT |
| 384 | 384 | /*!40001 SQL_NO_CACHE */ t.id_board, COUNT(*) AS real_num_topics |
| 385 | 385 | FROM {db_prefix}topics AS t |
@@ -387,29 +387,29 @@ discard block |
||
| 387 | 387 | AND t.id_topic > {int:id_topic_min} |
| 388 | 388 | AND t.id_topic <= {int:id_topic_max} |
| 389 | 389 | GROUP BY t.id_board', |
| 390 | - array( |
|
| 391 | - 'is_approved' => 1, |
|
| 392 | - 'id_topic_min' => $start, |
|
| 393 | - 'id_topic_max' => $start + $increment, |
|
| 394 | - ) |
|
| 395 | - )->fetch_callback( |
|
| 396 | - function ($row) use ($db) { |
|
| 397 | - $db->query('', ' |
|
| 390 | + array( |
|
| 391 | + 'is_approved' => 1, |
|
| 392 | + 'id_topic_min' => $start, |
|
| 393 | + 'id_topic_max' => $start + $increment, |
|
| 394 | + ) |
|
| 395 | + )->fetch_callback( |
|
| 396 | + function ($row) use ($db) { |
|
| 397 | + $db->query('', ' |
|
| 398 | 398 | UPDATE {db_prefix}boards |
| 399 | 399 | SET |
| 400 | 400 | num_topics = num_topics + {int:real_num_topics} |
| 401 | 401 | WHERE id_board = {int:id_board}', |
| 402 | - array( |
|
| 403 | - 'id_board' => $row['id_board'], |
|
| 404 | - 'real_num_topics' => $row['real_num_topics'], |
|
| 405 | - ) |
|
| 406 | - ); |
|
| 407 | - } |
|
| 408 | - ); |
|
| 409 | - break; |
|
| 402 | + array( |
|
| 403 | + 'id_board' => $row['id_board'], |
|
| 404 | + 'real_num_topics' => $row['real_num_topics'], |
|
| 405 | + ) |
|
| 406 | + ); |
|
| 407 | + } |
|
| 408 | + ); |
|
| 409 | + break; |
|
| 410 | 410 | |
| 411 | - case 'unapproved_posts': |
|
| 412 | - $db->fetchQuery(' |
|
| 411 | + case 'unapproved_posts': |
|
| 412 | + $db->fetchQuery(' |
|
| 413 | 413 | SELECT |
| 414 | 414 | /*!40001 SQL_NO_CACHE */ m.id_board, COUNT(*) AS real_unapproved_posts |
| 415 | 415 | FROM {db_prefix}messages AS m |
@@ -417,28 +417,28 @@ discard block |
||
| 417 | 417 | AND m.id_topic <= {int:id_topic_max} |
| 418 | 418 | AND m.approved = {int:is_approved} |
| 419 | 419 | GROUP BY m.id_board', |
| 420 | - array( |
|
| 421 | - 'id_topic_min' => $start, |
|
| 422 | - 'id_topic_max' => $start + $increment, |
|
| 423 | - 'is_approved' => 0, |
|
| 424 | - ) |
|
| 425 | - )->fetch_callback( |
|
| 426 | - function ($row) use ($db) { |
|
| 427 | - $db->query('', ' |
|
| 420 | + array( |
|
| 421 | + 'id_topic_min' => $start, |
|
| 422 | + 'id_topic_max' => $start + $increment, |
|
| 423 | + 'is_approved' => 0, |
|
| 424 | + ) |
|
| 425 | + )->fetch_callback( |
|
| 426 | + function ($row) use ($db) { |
|
| 427 | + $db->query('', ' |
|
| 428 | 428 | UPDATE {db_prefix}boards |
| 429 | 429 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
| 430 | 430 | WHERE id_board = {int:id_board}', |
| 431 | - array( |
|
| 432 | - 'id_board' => $row['id_board'], |
|
| 433 | - 'unapproved_posts' => $row['real_unapproved_posts'], |
|
| 434 | - ) |
|
| 435 | - ); |
|
| 436 | - } |
|
| 437 | - ); |
|
| 438 | - break; |
|
| 431 | + array( |
|
| 432 | + 'id_board' => $row['id_board'], |
|
| 433 | + 'unapproved_posts' => $row['real_unapproved_posts'], |
|
| 434 | + ) |
|
| 435 | + ); |
|
| 436 | + } |
|
| 437 | + ); |
|
| 438 | + break; |
|
| 439 | 439 | |
| 440 | - case 'unapproved_topics': |
|
| 441 | - $db->fetchQuery(' |
|
| 440 | + case 'unapproved_topics': |
|
| 441 | + $db->fetchQuery(' |
|
| 442 | 442 | SELECT |
| 443 | 443 | /*!40001 SQL_NO_CACHE */ t.id_board, COUNT(*) AS real_unapproved_topics |
| 444 | 444 | FROM {db_prefix}topics AS t |
@@ -446,28 +446,28 @@ discard block |
||
| 446 | 446 | AND t.id_topic > {int:id_topic_min} |
| 447 | 447 | AND t.id_topic <= {int:id_topic_max} |
| 448 | 448 | GROUP BY t.id_board', |
| 449 | - array( |
|
| 450 | - 'is_approved' => 0, |
|
| 451 | - 'id_topic_min' => $start, |
|
| 452 | - 'id_topic_max' => $start + $increment, |
|
| 453 | - ) |
|
| 454 | - )->fetch_callback( |
|
| 455 | - function ($row) use ($db) { |
|
| 456 | - $db->query('', ' |
|
| 449 | + array( |
|
| 450 | + 'is_approved' => 0, |
|
| 451 | + 'id_topic_min' => $start, |
|
| 452 | + 'id_topic_max' => $start + $increment, |
|
| 453 | + ) |
|
| 454 | + )->fetch_callback( |
|
| 455 | + function ($row) use ($db) { |
|
| 456 | + $db->query('', ' |
|
| 457 | 457 | UPDATE {db_prefix}boards |
| 458 | 458 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
| 459 | 459 | WHERE id_board = {int:id_board}', |
| 460 | - array( |
|
| 461 | - 'id_board' => $row['id_board'], |
|
| 462 | - 'real_unapproved_topics' => $row['real_unapproved_topics'], |
|
| 463 | - ) |
|
| 464 | - ); |
|
| 465 | - } |
|
| 466 | - ); |
|
| 467 | - break; |
|
| 460 | + array( |
|
| 461 | + 'id_board' => $row['id_board'], |
|
| 462 | + 'real_unapproved_topics' => $row['real_unapproved_topics'], |
|
| 463 | + ) |
|
| 464 | + ); |
|
| 465 | + } |
|
| 466 | + ); |
|
| 467 | + break; |
|
| 468 | 468 | |
| 469 | - default: |
|
| 470 | - trigger_error('updateBoardsCounter(): Invalid counter type \'' . $type . '\'', E_USER_NOTICE); |
|
| 469 | + default: |
|
| 470 | + trigger_error('updateBoardsCounter(): Invalid counter type \'' . $type . '\'', E_USER_NOTICE); |
|
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @return int |
| 21 | 21 | * @package Maintenance |
| 22 | 22 | */ |
| 23 | -function countMessages() |
|
| 23 | +function countMessages () |
|
| 24 | 24 | { |
| 25 | 25 | $db = database(); |
| 26 | 26 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @package Maintenance |
| 43 | 43 | */ |
| 44 | -function flushLogTables() |
|
| 44 | +function flushLogTables () |
|
| 45 | 45 | { |
| 46 | 46 | $db = database(); |
| 47 | 47 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @return array |
| 78 | 78 | * @package Maintenance |
| 79 | 79 | */ |
| 80 | -function getMessageTableColumns() |
|
| 80 | +function getMessageTableColumns () |
|
| 81 | 81 | { |
| 82 | 82 | $table = db_table(); |
| 83 | 83 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @package Maintenance |
| 92 | 92 | */ |
| 93 | -function fetchBodyType() |
|
| 93 | +function fetchBodyType () |
|
| 94 | 94 | { |
| 95 | 95 | $table = db_table(); |
| 96 | 96 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @param string $type |
| 113 | 113 | * @package Maintenance |
| 114 | 114 | */ |
| 115 | -function resizeMessageTableBody($type) |
|
| 115 | +function resizeMessageTableBody ($type) |
|
| 116 | 116 | { |
| 117 | 117 | $table = db_table(); |
| 118 | 118 | $table->change_column('{db_prefix}messages', 'body', array('type' => $type)); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @package Maintenance |
| 129 | 129 | * |
| 130 | 130 | */ |
| 131 | -function detectExceedingMessages($start, $increment) |
|
| 131 | +function detectExceedingMessages ($start, $increment) |
|
| 132 | 132 | { |
| 133 | 133 | $db = database(); |
| 134 | 134 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | 'increment' => $increment - 1, |
| 144 | 144 | ) |
| 145 | 145 | )->fetch_callback( |
| 146 | - function ($row) { |
|
| 146 | + function($row) { |
|
| 147 | 147 | return $row['id_msg']; |
| 148 | 148 | } |
| 149 | 149 | ); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @return array |
| 160 | 160 | * @package Maintenance |
| 161 | 161 | */ |
| 162 | -function getExceedingMessages($msg) |
|
| 162 | +function getExceedingMessages ($msg) |
|
| 163 | 163 | { |
| 164 | 164 | global $scripturl; |
| 165 | 165 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | 'messages' => $msg, |
| 175 | 175 | ) |
| 176 | 176 | )->fetch_callback( |
| 177 | - function ($row) use ($scripturl) { |
|
| 177 | + function($row) use ($scripturl) { |
|
| 178 | 178 | return '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
| 179 | 179 | } |
| 180 | 180 | ); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @return array |
| 189 | 189 | * @package Maintenance |
| 190 | 190 | */ |
| 191 | -function getElkTables() |
|
| 191 | +function getElkTables () |
|
| 192 | 192 | { |
| 193 | 193 | global $db_prefix; |
| 194 | 194 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * @return int |
| 216 | 216 | * @package Maintenance |
| 217 | 217 | */ |
| 218 | -function getMaxTopicID() |
|
| 218 | +function getMaxTopicID () |
|
| 219 | 219 | { |
| 220 | 220 | $db = database(); |
| 221 | 221 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * @param int $increment |
| 239 | 239 | * @package Maintenance |
| 240 | 240 | */ |
| 241 | -function recountApprovedMessages($start, $increment) |
|
| 241 | +function recountApprovedMessages ($start, $increment) |
|
| 242 | 242 | { |
| 243 | 243 | $db = database(); |
| 244 | 244 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | 'max_id' => $start + $increment, |
| 260 | 260 | ) |
| 261 | 261 | )->fetch_callback( |
| 262 | - function ($row) { |
|
| 262 | + function($row) { |
|
| 263 | 263 | setTopicAttribute($row['id_topic'], array('num_replies' => $row['real_num_replies'])); |
| 264 | 264 | } |
| 265 | 265 | ); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param int $increment |
| 273 | 273 | * @package Maintenance |
| 274 | 274 | */ |
| 275 | -function recountUnapprovedMessages($start, $increment) |
|
| 275 | +function recountUnapprovedMessages ($start, $increment) |
|
| 276 | 276 | { |
| 277 | 277 | $db = database(); |
| 278 | 278 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | 'max_id' => $start + $increment, |
| 294 | 294 | ) |
| 295 | 295 | )->fetch_callback( |
| 296 | - function ($row) { |
|
| 296 | + function($row) { |
|
| 297 | 297 | setTopicAttribute($row['id_topic'], array('unapproved_posts' => $row['real_unapproved_posts'])); |
| 298 | 298 | } |
| 299 | 299 | ); |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @package Maintenance |
| 312 | 312 | * |
| 313 | 313 | */ |
| 314 | -function resetBoardsCounter($column) |
|
| 314 | +function resetBoardsCounter ($column) |
|
| 315 | 315 | { |
| 316 | 316 | $db = database(); |
| 317 | 317 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @param int $increment |
| 343 | 343 | * @package Maintenance |
| 344 | 344 | */ |
| 345 | -function updateBoardsCounter($type, $start, $increment) |
|
| 345 | +function updateBoardsCounter ($type, $start, $increment) |
|
| 346 | 346 | { |
| 347 | 347 | $db = database(); |
| 348 | 348 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | 'is_approved' => 1, |
| 364 | 364 | ) |
| 365 | 365 | )->fetch_callback( |
| 366 | - function ($row) use ($db) { |
|
| 366 | + function($row) use ($db) { |
|
| 367 | 367 | $db->query('', ' |
| 368 | 368 | UPDATE {db_prefix}boards |
| 369 | 369 | SET |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | 'id_topic_max' => $start + $increment, |
| 394 | 394 | ) |
| 395 | 395 | )->fetch_callback( |
| 396 | - function ($row) use ($db) { |
|
| 396 | + function($row) use ($db) { |
|
| 397 | 397 | $db->query('', ' |
| 398 | 398 | UPDATE {db_prefix}boards |
| 399 | 399 | SET |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | 'is_approved' => 0, |
| 424 | 424 | ) |
| 425 | 425 | )->fetch_callback( |
| 426 | - function ($row) use ($db) { |
|
| 426 | + function($row) use ($db) { |
|
| 427 | 427 | $db->query('', ' |
| 428 | 428 | UPDATE {db_prefix}boards |
| 429 | 429 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | 'id_topic_max' => $start + $increment, |
| 453 | 453 | ) |
| 454 | 454 | )->fetch_callback( |
| 455 | - function ($row) use ($db) { |
|
| 455 | + function($row) use ($db) { |
|
| 456 | 456 | $db->query('', ' |
| 457 | 457 | UPDATE {db_prefix}boards |
| 458 | 458 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | * |
| 477 | 477 | * @package Maintenance |
| 478 | 478 | */ |
| 479 | -function updatePersonalMessagesCounter() |
|
| 479 | +function updatePersonalMessagesCounter () |
|
| 480 | 480 | { |
| 481 | 481 | $db = database(); |
| 482 | 482 | |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | 'is_not_deleted' => 0, |
| 495 | 495 | ) |
| 496 | 496 | )->fetch_callback( |
| 497 | - function ($row) { |
|
| 497 | + function($row) { |
|
| 498 | 498 | updateMemberData($row['id_member'], array('personal_messages' => $row['real_num'])); |
| 499 | 499 | } |
| 500 | 500 | ); |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | 'is_not_read' => 0, |
| 513 | 513 | ) |
| 514 | 514 | )->fetch_callback( |
| 515 | - function ($row) { |
|
| 515 | + function($row) { |
|
| 516 | 516 | updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
| 517 | 517 | } |
| 518 | 518 | ); |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | * @param int $increment |
| 526 | 526 | * @package Maintenance |
| 527 | 527 | */ |
| 528 | -function updateMessagesBoardID($start, $increment) |
|
| 528 | +function updateMessagesBoardID ($start, $increment) |
|
| 529 | 529 | { |
| 530 | 530 | $db = database(); |
| 531 | 531 | |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | 'id_msg_max' => $start + $increment, |
| 543 | 543 | ) |
| 544 | 544 | )->fetch_callback( |
| 545 | - function ($row) use (&$boards) { |
|
| 545 | + function($row) use (&$boards) { |
|
| 546 | 546 | $boards[$row['id_board']][] = $row['id_msg']; |
| 547 | 547 | } |
| 548 | 548 | ); |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | * |
| 567 | 567 | * @package Maintenance |
| 568 | 568 | */ |
| 569 | -function updateBoardsLastMessage() |
|
| 569 | +function updateBoardsLastMessage () |
|
| 570 | 570 | { |
| 571 | 571 | $db = database(); |
| 572 | 572 | |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | 'is_approved' => 1, |
| 583 | 583 | ) |
| 584 | 584 | )->fetch_callback( |
| 585 | - function ($row) use (&$realBoardCounts) { |
|
| 585 | + function($row) use (&$realBoardCounts) { |
|
| 586 | 586 | $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
| 587 | 587 | } |
| 588 | 588 | ); |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | FROM {db_prefix}boards', |
| 595 | 595 | array() |
| 596 | 596 | )->fetch_callback( |
| 597 | - function ($row) use (&$resort_me, $realBoardCounts) { |
|
| 597 | + function($row) use (&$resort_me, $realBoardCounts) { |
|
| 598 | 598 | $row['local_last_msg'] = $realBoardCounts[$row['id_board']] ?? 0; |
| 599 | 599 | $resort_me[$row['child_level']][] = $row; |
| 600 | 600 | } |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | * @return int |
| 652 | 652 | * @package Maintenance |
| 653 | 653 | */ |
| 654 | -function countTopicsFromBoard($id_board) |
|
| 654 | +function countTopicsFromBoard ($id_board) |
|
| 655 | 655 | { |
| 656 | 656 | $db = database(); |
| 657 | 657 | |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | * @return int[] |
| 679 | 679 | * @package Maintenance |
| 680 | 680 | */ |
| 681 | -function getTopicsToMove($id_board) |
|
| 681 | +function getTopicsToMove ($id_board) |
|
| 682 | 682 | { |
| 683 | 683 | $db = database(); |
| 684 | 684 | |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | 'id_board' => $id_board, |
| 694 | 694 | ) |
| 695 | 695 | )->fetch_callback( |
| 696 | - function ($row) { |
|
| 696 | + function($row) { |
|
| 697 | 697 | return $row['id_topic']; |
| 698 | 698 | } |
| 699 | 699 | ); |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | * @return int |
| 706 | 706 | * @package Maintenance |
| 707 | 707 | */ |
| 708 | -function countContributors() |
|
| 708 | +function countContributors () |
|
| 709 | 709 | { |
| 710 | 710 | $db = database(); |
| 711 | 711 | |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | * @return int |
| 735 | 735 | * @package Maintenance |
| 736 | 736 | */ |
| 737 | -function updateMembersPostCount($start, $increment) |
|
| 737 | +function updateMembersPostCount ($start, $increment) |
|
| 738 | 738 | { |
| 739 | 739 | global $modSettings; |
| 740 | 740 | |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | * |
| 775 | 775 | * @package Maintenance |
| 776 | 776 | */ |
| 777 | -function updateZeroPostMembers() |
|
| 777 | +function updateZeroPostMembers () |
|
| 778 | 778 | { |
| 779 | 779 | global $modSettings; |
| 780 | 780 | |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | 'recycle' => $modSettings['recycle_board'] |
| 805 | 805 | ) |
| 806 | 806 | )->fetch_callback( |
| 807 | - function ($row) { |
|
| 807 | + function($row) { |
|
| 808 | 808 | // Set the post count to zero for any delinquents we may have found |
| 809 | 809 | return $row['id_member']; |
| 810 | 810 | } |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | * @return array |
| 827 | 827 | * @package Maintenance |
| 828 | 828 | */ |
| 829 | -function purgeMembers($type, $groups, $time_limit) |
|
| 829 | +function purgeMembers ($type, $groups, $time_limit) |
|
| 830 | 830 | { |
| 831 | 831 | $db = database(); |
| 832 | 832 | |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | FROM {db_prefix}membergroups', |
| 851 | 851 | array() |
| 852 | 852 | )->fetch_callback( |
| 853 | - function ($row) use (&$where, &$where_vars, $groups) { |
|
| 853 | + function($row) use (&$where, &$where_vars, $groups) { |
|
| 854 | 854 | // Avoid this one? |
| 855 | 855 | if (!in_array($row['id_group'], $groups)) |
| 856 | 856 | { |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | WHERE ' . $where, |
| 887 | 887 | $where_vars |
| 888 | 888 | )->fetch_callback( |
| 889 | - function ($row) use (&$members, $groups) { |
|
| 889 | + function($row) use (&$members, $groups) { |
|
| 890 | 890 | if (!$row['is_mod'] || !in_array(3, $groups)) |
| 891 | 891 | { |
| 892 | 892 | $members[] = $row['id_member']; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $string |
| 22 | 22 | * @return string |
| 23 | 23 | */ |
| 24 | -function utf8_strtolower($string) |
|
| 24 | +function utf8_strtolower ($string) |
|
| 25 | 25 | { |
| 26 | 26 | static $case_folding = array( |
| 27 | 27 | 'A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @param string $string |
| 290 | 290 | * @return string |
| 291 | 291 | */ |
| 292 | -function utf8_strtoupper($string) |
|
| 292 | +function utf8_strtoupper ($string) |
|
| 293 | 293 | { |
| 294 | 294 | static $case_folding = array( |
| 295 | 295 | 'a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D', |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | /** |
| 554 | 554 | * Fixes corrupted serialized strings after a character set conversion. |
| 555 | 555 | */ |
| 556 | -function fix_serialized_columns() |
|
| 556 | +function fix_serialized_columns () |
|
| 557 | 557 | { |
| 558 | 558 | $db = database(); |
| 559 | 559 | |