Index: trunk/phase3/includes/Skin.php |
— | — | @@ -8,28 +8,11 @@ |
9 | 9 | * @subpackage Skins |
10 | 10 | */ |
11 | 11 | |
12 | | -# See skin.txt |
13 | | -require_once( 'Linker.php' ); |
14 | | -require_once( 'Image.php' ); |
15 | | - |
16 | 12 | # Get a list of available skins |
17 | 13 | # Build using the regular expression '^(.*).php$' |
18 | 14 | # Array keys are all lower case, array value keep the case used by filename |
19 | 15 | # |
20 | 16 | |
21 | | -$skinDir = dir( $wgStyleDirectory ); |
22 | | - |
23 | | -# while code from www.php.net |
24 | | -while (false !== ($file = $skinDir->read())) { |
25 | | - // Skip non-PHP files, hidden files, and '.dep' includes |
26 | | - if(preg_match('/^([^.]*)\.php$/',$file, $matches)) { |
27 | | - $aSkin = $matches[1]; |
28 | | - $wgValidSkinNames[strtolower($aSkin)] = $aSkin; |
29 | | - } |
30 | | -} |
31 | | -$skinDir->close(); |
32 | | -unset($matches); |
33 | | - |
34 | 17 | /** |
35 | 18 | * The main skin class that provide methods and properties for all other skins. |
36 | 19 | * This base class is also the "Standard" skin. |
— | — | @@ -55,9 +38,35 @@ |
56 | 39 | */ |
57 | 40 | function getSkinNames() { |
58 | 41 | global $wgValidSkinNames; |
| 42 | + if (!is_array($wgValidSkinNames)) { |
| 43 | + Skin::initializeSkinNames(); |
| 44 | + } |
59 | 45 | return $wgValidSkinNames; |
60 | 46 | } |
61 | 47 | |
| 48 | + /** |
| 49 | + * Initializes set of available skins. |
| 50 | + * @return array of strings - skin names |
| 51 | + * @static |
| 52 | + */ |
| 53 | + |
| 54 | + function initializeSkinNames() { |
| 55 | + global $wgStyleDirectory, $wgValidSkinNames; |
| 56 | + $skinDir = dir( $wgStyleDirectory ); |
| 57 | + |
| 58 | + # while code from www.php.net |
| 59 | + while (false !== ($file = $skinDir->read())) { |
| 60 | + // Skip non-PHP files, hidden files, and '.dep' includes |
| 61 | + if(preg_match('/^([^.]*)\.php$/',$file, $matches)) { |
| 62 | + $aSkin = $matches[1]; |
| 63 | + $wgValidSkinNames[strtolower($aSkin)] = $aSkin; |
| 64 | + } |
| 65 | + } |
| 66 | + $skinDir->close(); |
| 67 | + unset($matches); |
| 68 | + |
| 69 | + } |
| 70 | + |
62 | 71 | /** |
63 | 72 | * Normalize a skin preference value to a form that can be loaded. |
64 | 73 | * If a skin can't be found, it will fall back to the configured |
— | — | @@ -745,7 +754,7 @@ |
746 | 755 | $s = ''; |
747 | 756 | if ( $wgUser->isAnon() ) { |
748 | 757 | if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) { |
749 | | - $n = wfGetIP(); |
| 758 | + $n = ProxyTools::getIP(); |
750 | 759 | |
751 | 760 | $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), |
752 | 761 | $wgLang->getNsText( NS_TALK ) ); |
— | — | @@ -896,8 +905,7 @@ |
897 | 906 | } |
898 | 907 | |
899 | 908 | if (isset($wgMaxCredits) && $wgMaxCredits != 0) { |
900 | | - require_once('Credits.php'); |
901 | | - $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); |
| 909 | + $s .= ' ' . Credits::getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); |
902 | 910 | } else { |
903 | 911 | $s .= $this->lastModified(); |
904 | 912 | } |
— | — | @@ -1015,7 +1023,6 @@ |
1016 | 1024 | */ |
1017 | 1025 | function specialPagesList() { |
1018 | 1026 | global $wgUser, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights; |
1019 | | - require_once('SpecialPage.php'); |
1020 | 1027 | $a = array(); |
1021 | 1028 | $pages = SpecialPage::getPages(); |
1022 | 1029 | |
Index: trunk/phase3/includes/LoadBalancer.php |
— | — | @@ -7,7 +7,6 @@ |
8 | 8 | /** |
9 | 9 | * Depends on the database object |
10 | 10 | */ |
11 | | -require_once( 'Database.php' ); |
12 | 11 | |
13 | 12 | # Valid database indexes |
14 | 13 | # Operation-based indexes |
— | — | @@ -440,12 +439,14 @@ |
441 | 440 | } |
442 | 441 | |
443 | 442 | extract( $server ); |
| 443 | + |
444 | 444 | # Get class for this database type |
445 | | - $class = 'Database' . ucfirst( $type ); |
446 | | - if ( !class_exists( $class ) ) { |
447 | | - require_once( "$class.php" ); |
| 445 | + if ($type != 'mysql' ) { |
| 446 | + $class = 'Database' . ucfirst( $type ); |
| 447 | + } else { |
| 448 | + $class = 'Database'; |
448 | 449 | } |
449 | | - |
| 450 | + |
450 | 451 | # Create object |
451 | 452 | $db = new $class( $host, $user, $password, $dbname, 1, $flags ); |
452 | 453 | $db->setLBInfo( $server ); |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -725,7 +725,7 @@ |
726 | 726 | $this->summary = ''; |
727 | 727 | if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI ) |
728 | 728 | $this->textbox1 = wfMsgWeirdKey ( $this->mArticle->mTitle->getText() ) ; |
729 | | - wfProxyCheck(); |
| 729 | + ProxyTools::proxyCheck(); |
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
— | — | @@ -1118,7 +1118,6 @@ |
1119 | 1119 | $wgOut->addHTML( "<input type=\"hidden\" name=\"wpAutoSummary\" value=\"$autosumm\" />\n" ); |
1120 | 1120 | |
1121 | 1121 | if ( $this->isConflict ) { |
1122 | | - require_once( "DifferenceEngine.php" ); |
1123 | 1122 | $wgOut->addWikiText( '==' . wfMsg( "yourdiff" ) . '==' ); |
1124 | 1123 | |
1125 | 1124 | $de = new DifferenceEngine( $this->mTitle ); |
— | — | @@ -1618,7 +1617,6 @@ |
1619 | 1618 | * @return string HTML |
1620 | 1619 | */ |
1621 | 1620 | function getDiff() { |
1622 | | - require_once( 'DifferenceEngine.php' ); |
1623 | 1621 | $oldtext = $this->mArticle->fetchContent(); |
1624 | 1622 | $newtext = $this->mArticle->replaceSection( |
1625 | 1623 | $this->section, $this->textbox1, $this->summary, $this->edittime ); |
Index: trunk/phase3/includes/Math.php |
— | — | @@ -248,15 +248,13 @@ |
249 | 249 | wfDebug( "TeX: getHashPath, hash is: $this->hash, path is: $path\n" ); |
250 | 250 | return $path; |
251 | 251 | } |
252 | | - |
253 | | - |
| 252 | + |
| 253 | + static function renderMath ( $tex ) { |
| 254 | + global $wgUser; |
| 255 | + $math = new MathRenderer( $tex ); |
| 256 | + $math->setOutputMode( $wgUser->getOption('math')); |
| 257 | + return $math->render(); |
| 258 | + } |
254 | 259 | } |
255 | 260 | |
256 | | -function renderMath( $tex ) { |
257 | | - global $wgUser; |
258 | | - $math = new MathRenderer( $tex ); |
259 | | - $math->setOutputMode( $wgUser->getOption('math')); |
260 | | - return $math->render(); |
261 | | -} |
262 | | - |
263 | 261 | ?> |
Index: trunk/phase3/includes/PageHistory.php |
— | — | @@ -576,9 +576,6 @@ |
577 | 577 | * @param string $type |
578 | 578 | */ |
579 | 579 | function feed( $type ) { |
580 | | - require_once 'Feed.php'; |
581 | | - require_once 'SpecialRecentchanges.php'; |
582 | | - |
583 | 580 | global $wgFeedClasses; |
584 | 581 | if( !isset( $wgFeedClasses[$type] ) ) { |
585 | 582 | global $wgOut; |
Index: trunk/phase3/includes/SpecialPreferences.php |
— | — | @@ -444,7 +444,7 @@ |
445 | 445 | * @access private |
446 | 446 | */ |
447 | 447 | function mainPrefsForm( $status , $message = '' ) { |
448 | | - global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames; |
| 448 | + global $wgUser, $wgOut, $wgLang, $wgContLang; |
449 | 449 | global $wgAllowRealName, $wgImageLimits, $wgThumbLimits; |
450 | 450 | global $wgDisableLangConversion; |
451 | 451 | global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits; |
— | — | @@ -723,7 +723,7 @@ |
724 | 724 | $previewtext = wfMsg('skinpreview'); |
725 | 725 | # Only show members of $wgValidSkinNames rather than |
726 | 726 | # $skinNames (skins is all skin names from Language.php) |
727 | | - foreach ($wgValidSkinNames as $skinkey => $skinname ) { |
| 727 | + foreach (Skin::getSkinNames() as $skinkey => $skinname ) { |
728 | 728 | if ( in_array( $skinkey, $wgSkipSkins ) ) { |
729 | 729 | continue; |
730 | 730 | } |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -15,6 +15,10 @@ |
16 | 16 | * @subpackage SpecialPage |
17 | 17 | */ |
18 | 18 | |
| 19 | +/** |
| 20 | + * @todo put all global specialpages stuff into class |
| 21 | + */ |
| 22 | +global $wgSpecialPages, $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication; |
19 | 23 | |
20 | 24 | /** |
21 | 25 | * @access private |
Index: trunk/phase3/includes/DatabasePostgreSQL.php |
— | — | @@ -14,11 +14,6 @@ |
15 | 15 | */ |
16 | 16 | |
17 | 17 | /** |
18 | | - * Depends on database |
19 | | - */ |
20 | | -require_once( 'Database.php' ); |
21 | | - |
22 | | -/** |
23 | 18 | * |
24 | 19 | * @package MediaWiki |
25 | 20 | */ |
Index: trunk/phase3/includes/AjaxDispatcher.php |
— | — | @@ -1,18 +1,5 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -//$wgRequestTime = microtime(); |
5 | | - |
6 | | -// unset( $IP ); |
7 | | -// @ini_set( 'allow_url_fopen', 0 ); # For security... |
8 | | - |
9 | | -# Valid web server entry point, enable includes. |
10 | | -# Please don't move this line to includes/Defines.php. This line essentially defines |
11 | | -# a valid entry point. If you put it in includes/Defines.php, then any script that includes |
12 | | -# it becomes an entry point, thereby defeating its purpose. |
13 | | -// define( 'MEDIAWIKI', true ); |
14 | | -// require_once( './includes/Defines.php' ); |
15 | | -// require_once( './LocalSettings.php' ); |
16 | | -// require_once( 'includes/Setup.php' ); |
17 | 4 | require_once( 'AjaxFunctions.php' ); |
18 | 5 | |
19 | 6 | if ( ! $wgUseAjax ) { |
Index: trunk/phase3/includes/SearchMySQL.php |
— | — | @@ -24,9 +24,6 @@ |
25 | 25 | * @subpackage Search |
26 | 26 | */ |
27 | 27 | |
28 | | -/** */ |
29 | | -require_once( 'SearchEngine.php' ); |
30 | | - |
31 | 28 | /** @package MediaWiki */ |
32 | 29 | class SearchMySQL extends SearchEngine { |
33 | 30 | /** |
Index: trunk/phase3/includes/Parser.php |
— | — | @@ -6,11 +6,6 @@ |
7 | 7 | * @subpackage Parser |
8 | 8 | */ |
9 | 9 | |
10 | | -/** */ |
11 | | -require_once( 'Sanitizer.php' ); |
12 | | -require_once( 'HttpFunctions.php' ); |
13 | | -require_once( 'ImageGallery.php' ); |
14 | | - |
15 | 10 | /** |
16 | 11 | * Update this version number when the ParserOutput format |
17 | 12 | * changes in an incompatible way, so the parser cache |
— | — | @@ -452,7 +447,7 @@ |
453 | 448 | $output = wfEscapeHTMLTagsOnly( $content ); |
454 | 449 | break; |
455 | 450 | case 'math': |
456 | | - $output = renderMath( $content ); |
| 451 | + $output = MathRenderer::renderMath( $content ); |
457 | 452 | break; |
458 | 453 | case 'pre': |
459 | 454 | // Backwards-compatibility hack |
— | — | @@ -2972,7 +2967,7 @@ |
2973 | 2968 | } |
2974 | 2969 | } |
2975 | 2970 | |
2976 | | - $text = wfGetHTTP($url); |
| 2971 | + $text = HttpFunctions::getHTTP($url); |
2977 | 2972 | if (!$text) |
2978 | 2973 | return wfMsg('scarytranscludefailed', $url); |
2979 | 2974 | |
Index: trunk/phase3/includes/Revision.php |
— | — | @@ -4,10 +4,6 @@ |
5 | 5 | * @todo document |
6 | 6 | */ |
7 | 7 | |
8 | | -/** */ |
9 | | -require_once( 'Database.php' ); |
10 | | -require_once( 'Article.php' ); |
11 | | - |
12 | 8 | /** @+ */ |
13 | 9 | define( 'MW_REV_DELETED_TEXT', 1 ); |
14 | 10 | define( 'MW_REV_DELETED_COMMENT', 2 ); |
— | — | @@ -514,7 +510,6 @@ |
515 | 511 | wfProfileOut( $fname ); |
516 | 512 | return false; |
517 | 513 | } |
518 | | - require_once('ExternalStore.php'); |
519 | 514 | $text=ExternalStore::fetchFromURL($url); |
520 | 515 | } |
521 | 516 | |
— | — | @@ -604,7 +599,6 @@ |
605 | 600 | } else { |
606 | 601 | $store = $wgDefaultExternalStore; |
607 | 602 | } |
608 | | - require_once('ExternalStore.php'); |
609 | 603 | // Store and get the URL |
610 | 604 | $data = ExternalStore::insert( $store, $data ); |
611 | 605 | if ( !$data ) { |
Index: trunk/phase3/includes/CacheManager.php |
— | — | @@ -6,11 +6,6 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | | - * We need the title class |
11 | | - */ |
12 | | -require_once( 'Title.php' ); |
13 | | - |
14 | | -/** |
15 | 10 | * Handles talking to the file cache, putting stuff in and taking it back out. |
16 | 11 | * Mostly called from Article.php, also from DatabaseFunctions.php for the |
17 | 12 | * emergency abort/fallback to cache. |
Index: trunk/phase3/includes/UpdateClasses.php |
— | — | @@ -5,13 +5,4 @@ |
6 | 6 | * @package MediaWiki |
7 | 7 | */ |
8 | 8 | |
9 | | -/** |
10 | | - * |
11 | | - */ |
12 | | - |
13 | | -require_once( 'SiteStatsUpdate.php' ); |
14 | | -require_once( 'LinksUpdate.php' ); |
15 | | -require_once( 'SearchUpdate.php' ); |
16 | | -require_once( 'SquidUpdate.php' ); |
17 | | - |
18 | 9 | ?> |
\ No newline at end of file |
Index: trunk/phase3/includes/HistoryBlob.php |
— | — | @@ -167,18 +167,7 @@ |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | | - |
172 | 171 | /** |
173 | | - * One-step cache variable to hold base blobs; operations that |
174 | | - * pull multiple revisions may often pull multiple times from |
175 | | - * the same blob. By keeping the last-used one open, we avoid |
176 | | - * redundant unserialization and decompression overhead. |
177 | | - */ |
178 | | -global $wgBlobCache; |
179 | | -$wgBlobCache = array(); |
180 | | - |
181 | | - |
182 | | -/** |
183 | 172 | * @package MediaWiki |
184 | 173 | */ |
185 | 174 | class HistoryBlobStub { |
— | — | @@ -215,6 +204,15 @@ |
216 | 205 | function getText() { |
217 | 206 | $fname = 'HistoryBlob::getText'; |
218 | 207 | global $wgBlobCache; |
| 208 | + /** |
| 209 | + * One-step cache variable to hold base blobs; operations that |
| 210 | + * pull multiple revisions may often pull multiple times from |
| 211 | + * the same blob. By keeping the last-used one open, we avoid |
| 212 | + * redundant unserialization and decompression overhead. |
| 213 | + */ |
| 214 | + if (!is_array($wgBlobCache)) { |
| 215 | + $wgBlobCache = array(); |
| 216 | + } |
219 | 217 | if( isset( $wgBlobCache[$this->mOldId] ) ) { |
220 | 218 | $obj = $wgBlobCache[$this->mOldId]; |
221 | 219 | } else { |
— | — | @@ -231,7 +229,6 @@ |
232 | 230 | wfProfileOut( $fname ); |
233 | 231 | return false; |
234 | 232 | } |
235 | | - require_once('ExternalStore.php'); |
236 | 233 | $row->old_text=ExternalStore::fetchFromUrl($url); |
237 | 234 | |
238 | 235 | } |
Index: trunk/phase3/includes/CategoryPage.php |
— | — | @@ -10,9 +10,6 @@ |
11 | 11 | die( -1 ); |
12 | 12 | |
13 | 13 | global $wgCategoryMagicGallery; |
14 | | -if( $wgCategoryMagicGallery ) |
15 | | - /** */ |
16 | | - require_once('ImageGallery.php'); |
17 | 14 | |
18 | 15 | /** |
19 | 16 | * @package MediaWiki |
Index: trunk/phase3/includes/SpecialBlockme.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | { |
14 | 14 | global $wgBlockOpenProxies, $wgOut, $wgProxyKey; |
15 | 15 | |
16 | | - $ip = wfGetIP(); |
| 16 | + $ip = ProxyTools::getIP(); |
17 | 17 | |
18 | 18 | if ( !$wgBlockOpenProxies || $_REQUEST['ip'] != md5( $ip . $wgProxyKey ) ) { |
19 | 19 | $wgOut->addWikiText( wfMsg( "disabled" ) ); |
Index: trunk/phase3/includes/User.php |
— | — | @@ -5,11 +5,6 @@ |
6 | 6 | * @package MediaWiki |
7 | 7 | */ |
8 | 8 | |
9 | | -/** |
10 | | - * |
11 | | - */ |
12 | | -require_once( 'WatchedItem.php' ); |
13 | | - |
14 | 9 | # Number of characters in user_token field |
15 | 10 | define( 'USER_TOKEN_LENGTH', 32 ); |
16 | 11 | |
— | — | @@ -433,7 +428,7 @@ |
434 | 429 | wfDebug( "$fname: checking...\n" ); |
435 | 430 | |
436 | 431 | $this->mBlockedby = 0; |
437 | | - $ip = wfGetIP(); |
| 432 | + $ip = ProxyTools::getIP(); |
438 | 433 | |
439 | 434 | # User/IP blocking |
440 | 435 | $block = new Block(); |
— | — | @@ -454,7 +449,7 @@ |
455 | 450 | if ( !$this->isAllowed('proxyunbannable') && !in_array( $ip, $wgProxyWhitelist ) ) { |
456 | 451 | |
457 | 452 | # Local list |
458 | | - if ( wfIsLocallyBlockedProxy( $ip ) ) { |
| 453 | + if ( ProxyTools::isLocallyBlockedProxy( $ip ) ) { |
459 | 454 | $this->mBlockedby = wfMsg( 'proxyblocker' ); |
460 | 455 | $this->mBlockreason = wfMsg( 'proxyblockreason' ); |
461 | 456 | } |
— | — | @@ -538,7 +533,7 @@ |
539 | 534 | $limits = $wgRateLimits[$action]; |
540 | 535 | $keys = array(); |
541 | 536 | $id = $this->getId(); |
542 | | - $ip = wfGetIP(); |
| 537 | + $ip = ProxyTools::getIP(); |
543 | 538 | |
544 | 539 | if( isset( $limits['anon'] ) && $id == 0 ) { |
545 | 540 | $keys["$wgDBname:limiter:$action:anon"] = $limits['anon']; |
— | — | @@ -790,7 +785,7 @@ |
791 | 786 | function getName() { |
792 | 787 | $this->loadFromDatabase(); |
793 | 788 | if ( $this->mName === false ) { |
794 | | - $this->mName = wfGetIP(); |
| 789 | + $this->mName = ProxyTools::getIP(); |
795 | 790 | } |
796 | 791 | return $this->mName; |
797 | 792 | } |
— | — | @@ -1526,7 +1521,7 @@ |
1527 | 1522 | } |
1528 | 1523 | |
1529 | 1524 | # Check if this IP address is already blocked |
1530 | | - $ipblock = Block::newFromDB( wfGetIP() ); |
| 1525 | + $ipblock = Block::newFromDB( ProxyTools::getIP() ); |
1531 | 1526 | if ( $ipblock->isValid() ) { |
1532 | 1527 | # If the user is already blocked. Then check if the autoblock would |
1533 | 1528 | # excede the user block. If it would excede, then do nothing, else |
— | — | @@ -1541,8 +1536,8 @@ |
1542 | 1537 | } |
1543 | 1538 | |
1544 | 1539 | # Make a new block object with the desired properties |
1545 | | - wfDebug( "Autoblocking {$this->mName}@" . wfGetIP() . "\n" ); |
1546 | | - $ipblock->mAddress = wfGetIP(); |
| 1540 | + wfDebug( "Autoblocking {$this->mName}@" . ProxyTools::getIP() . "\n" ); |
| 1541 | + $ipblock->mAddress = ProxyTools::getIP(); |
1547 | 1542 | $ipblock->mUser = 0; |
1548 | 1543 | $ipblock->mBy = $userblock->mBy; |
1549 | 1544 | $ipblock->mReason = wfMsg( 'autoblocker', $this->getName(), $userblock->mReason ); |
— | — | @@ -1762,7 +1757,7 @@ |
1763 | 1758 | $url = $this->confirmationTokenUrl( $expiration ); |
1764 | 1759 | return $this->sendMail( wfMsg( 'confirmemail_subject' ), |
1765 | 1760 | wfMsg( 'confirmemail_body', |
1766 | | - wfGetIP(), |
| 1761 | + ProxyTools::getIP(), |
1767 | 1762 | $this->getName(), |
1768 | 1763 | $url, |
1769 | 1764 | $wgContLang->timeanddate( $expiration, false ) ) ); |
Index: trunk/phase3/includes/DifferenceEngine.php |
— | — | @@ -5,9 +5,6 @@ |
6 | 6 | * @subpackage DifferenceEngine |
7 | 7 | */ |
8 | 8 | |
9 | | -/** */ |
10 | | -require_once( 'Revision.php' ); |
11 | | - |
12 | 9 | define( 'MAX_DIFF_LINE', 10000 ); |
13 | 10 | define( 'MAX_DIFF_XREF_LENGTH', 10000 ); |
14 | 11 | |
Index: trunk/phase3/includes/Export.php |
— | — | @@ -22,9 +22,6 @@ |
23 | 23 | * @subpackage SpecialPage |
24 | 24 | */ |
25 | 25 | |
26 | | -/** */ |
27 | | -require_once( 'Revision.php' ); |
28 | | - |
29 | 26 | define( 'MW_EXPORT_FULL', 0 ); |
30 | 27 | define( 'MW_EXPORT_CURRENT', 1 ); |
31 | 28 | |
Index: trunk/phase3/includes/RecentChange.php |
— | — | @@ -205,7 +205,7 @@ |
206 | 206 | } |
207 | 207 | |
208 | 208 | if ( !$ip ) { |
209 | | - $ip = wfGetIP(); |
| 209 | + $ip = ProxyTools::getIP(); |
210 | 210 | if ( !$ip ) { |
211 | 211 | $ip = ''; |
212 | 212 | } |
— | — | @@ -249,7 +249,7 @@ |
250 | 250 | $ip='', $size = 0, $newId = 0 ) |
251 | 251 | { |
252 | 252 | if ( !$ip ) { |
253 | | - $ip = wfGetIP(); |
| 253 | + $ip = ProxyTools::getIP(); |
254 | 254 | if ( !$ip ) { |
255 | 255 | $ip = ''; |
256 | 256 | } |
— | — | @@ -294,7 +294,7 @@ |
295 | 295 | /*static*/ function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false ) |
296 | 296 | { |
297 | 297 | if ( !$ip ) { |
298 | | - $ip = wfGetIP(); |
| 298 | + $ip = ProxyTools::getIP(); |
299 | 299 | if ( !$ip ) { |
300 | 300 | $ip = ''; |
301 | 301 | } |
— | — | @@ -344,7 +344,7 @@ |
345 | 345 | $type, $action, $target, $logComment, $params ) |
346 | 346 | { |
347 | 347 | if ( !$ip ) { |
348 | | - $ip = wfGetIP(); |
| 348 | + $ip = ProxyTools::getIP(); |
349 | 349 | if ( !$ip ) { |
350 | 350 | $ip = ''; |
351 | 351 | } |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -22,13 +22,14 @@ |
23 | 23 | die( -1 ); |
24 | 24 | } |
25 | 25 | |
| 26 | +require('AutoLoader.php'); |
| 27 | + |
26 | 28 | if( !isset( $wgProfiling ) ) |
27 | 29 | $wgProfiling = false; |
28 | 30 | |
29 | 31 | if ( function_exists( 'wfProfileIn' ) ) { |
30 | 32 | /* nada, everything should be done already */ |
31 | 33 | } elseif ( $wgProfiling and (0 == rand() % $wgProfileSampleRate ) ) { |
32 | | - require_once( 'Profiling.php' ); |
33 | 34 | $wgProfiling = true; |
34 | 35 | if ($wgProfilerType == "") { |
35 | 36 | $wgProfiler = new Profiler(); |
— | — | @@ -48,29 +49,8 @@ |
49 | 50 | require_once( 'GlobalFunctions.php' ); |
50 | 51 | require_once( 'Hooks.php' ); |
51 | 52 | require_once( 'Namespace.php' ); |
52 | | -require_once( 'User.php' ); |
53 | | -require_once( 'Skin.php' ); |
54 | | -require_once( 'OutputPage.php' ); |
55 | | -require_once( 'LinkCache.php' ); |
56 | | -require_once( 'LinkBatch.php' ); |
57 | | -require_once( 'Title.php' ); |
58 | | -require_once( 'Article.php' ); |
59 | 53 | require_once( 'MagicWord.php' ); |
60 | | -require_once( 'Block.php' ); |
61 | | -require_once( 'MessageCache.php' ); |
62 | | -require_once( 'Parser.php' ); |
63 | | -require_once( 'ParserCache.php' ); |
64 | | -require_once( 'WebRequest.php' ); |
65 | | -require_once( 'LoadBalancer.php' ); |
66 | | -require_once( 'HistoryBlob.php' ); |
67 | | -require_once( 'ProxyTools.php' ); |
68 | | -require_once( 'ObjectCache.php' ); |
69 | | -require_once( 'WikiError.php' ); |
70 | | -require_once( 'SpecialPage.php' ); |
71 | 54 | |
72 | | -if ( $wgUseDynamicDates ) { |
73 | | - require_once( 'DateFormatter.php' ); |
74 | | -} |
75 | 55 | |
76 | 56 | wfProfileOut( $fname.'-includes' ); |
77 | 57 | wfProfileIn( $fname.'-misc1' ); |
— | — | @@ -108,9 +88,9 @@ |
109 | 89 | wfProfileOut( $fname.'-misc1' ); |
110 | 90 | wfProfileIn( $fname.'-memcached' ); |
111 | 91 | |
112 | | -$wgMemc =& wfGetMainCache(); |
113 | | -$messageMemc =& wfGetMessageCacheStorage(); |
114 | | -$parserMemc =& wfGetParserCacheStorage(); |
| 92 | +$wgMemc =& ObjectCacheManager::getMainCache(); |
| 93 | +$messageMemc =& ObjectCacheManager::getMessageCache(); |
| 94 | +$parserMemc =& ObjectCacheManager::getParserCache(); |
115 | 95 | |
116 | 96 | wfDebug( 'Main cache: ' . get_class( $wgMemc ) . |
117 | 97 | "\nMessage cache: " . get_class( $messageMemc ) . |
— | — | @@ -208,7 +188,6 @@ |
209 | 189 | } |
210 | 190 | |
211 | 191 | if( !is_object( $wgAuth ) ) { |
212 | | - require_once( 'AuthPlugin.php' ); |
213 | 192 | $wgAuth = new AuthPlugin(); |
214 | 193 | } |
215 | 194 | |
— | — | @@ -296,7 +275,6 @@ |
297 | 276 | $wgMwRedir =& MagicWord::get( MAG_REDIRECT ); |
298 | 277 | |
299 | 278 | if ( $wgUseXMLparser ) { |
300 | | - require_once( 'ParserXML.php' ); |
301 | 279 | $wgParser = new ParserXML(); |
302 | 280 | } else { |
303 | 281 | $wgParser = new Parser(); |
Index: trunk/phase3/includes/QueryPage.php |
— | — | @@ -5,11 +5,6 @@ |
6 | 6 | */ |
7 | 7 | |
8 | 8 | /** |
9 | | - * |
10 | | - */ |
11 | | -require_once 'Feed.php'; |
12 | | - |
13 | | -/** |
14 | 9 | * List of query page classes and their associated special pages, for periodic update purposes |
15 | 10 | */ |
16 | 11 | global $wgQueryPages; // not redundant |
Index: trunk/phase3/includes/MessageCache.php |
— | — | @@ -5,9 +5,6 @@ |
6 | 6 | * @subpackage Cache |
7 | 7 | */ |
8 | 8 | |
9 | | -/** */ |
10 | | -require_once( 'Revision.php' ); |
11 | | - |
12 | 9 | /** |
13 | 10 | * |
14 | 11 | */ |
Index: trunk/phase3/includes/SpecialRecentchanges.php |
— | — | @@ -6,13 +6,6 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | | - * |
11 | | - */ |
12 | | -require_once( 'Feed.php' ); |
13 | | -require_once( 'ChangesList.php' ); |
14 | | -require_once( 'Revision.php' ); |
15 | | - |
16 | | -/** |
17 | 10 | * Constructor |
18 | 11 | */ |
19 | 12 | function wfSpecialRecentchanges( $par, $specialPage ) { |
Index: trunk/phase3/includes/SpecialUpload.php |
— | — | @@ -9,8 +9,6 @@ |
10 | 10 | * |
11 | 11 | */ |
12 | 12 | require_once 'Image.php'; |
13 | | -require_once 'MacBinary.php'; |
14 | | -require_once 'Licenses.php'; |
15 | 13 | /** |
16 | 14 | * Entry point |
17 | 15 | */ |
Index: trunk/phase3/includes/RawPage.php |
— | — | @@ -10,9 +10,6 @@ |
11 | 11 | * @package MediaWiki |
12 | 12 | */ |
13 | 13 | |
14 | | -/** */ |
15 | | -require_once( 'Revision.php' ); |
16 | | - |
17 | 14 | /** |
18 | 15 | * @todo document |
19 | 16 | * @package MediaWiki |
Index: trunk/phase3/includes/ObjectCache.php |
— | — | @@ -33,93 +33,91 @@ |
34 | 34 | global $wgCaches; |
35 | 35 | $wgCaches = array(); |
36 | 36 | |
37 | | -/** @todo document */ |
38 | | -function &wfGetCache( $inputType ) { |
39 | | - global $wgCaches, $wgMemCachedServers, $wgMemCachedDebug, $wgMemCachedPersistent; |
40 | | - $cache = false; |
| 37 | +class ObjectCacheManager { |
| 38 | + /* @static */ |
| 39 | + function getCache( $inputType ) { |
| 40 | + global $wgCaches, $wgMemCachedServers, $wgMemCachedDebug, $wgMemCachedPersistent; |
| 41 | + $cache = false; |
41 | 42 | |
42 | | - if ( $inputType == CACHE_ANYTHING ) { |
43 | | - reset( $wgCaches ); |
44 | | - $type = key( $wgCaches ); |
45 | | - if ( $type === false || $type === CACHE_NONE ) { |
46 | | - $type = CACHE_DB; |
| 43 | + if ( $inputType == CACHE_ANYTHING ) { |
| 44 | + reset( $wgCaches ); |
| 45 | + $type = key( $wgCaches ); |
| 46 | + if ( $type === false || $type === CACHE_NONE ) { |
| 47 | + $type = CACHE_DB; |
| 48 | + } |
| 49 | + } else { |
| 50 | + $type = $inputType; |
47 | 51 | } |
48 | | - } else { |
49 | | - $type = $inputType; |
50 | | - } |
51 | 52 | |
52 | | - if ( $type == CACHE_MEMCACHED ) { |
53 | | - if ( !array_key_exists( CACHE_MEMCACHED, $wgCaches ) ){ |
54 | | - require_once( 'memcached-client.php' ); |
55 | | - |
56 | | - if (!class_exists("MemcachedClientforWiki")) { |
57 | | - class MemCachedClientforWiki extends memcached { |
58 | | - function _debugprint( $text ) { |
59 | | - wfDebug( "memcached: $text\n" ); |
60 | | - } |
| 53 | + if ( $type == CACHE_MEMCACHED ) { |
| 54 | + if ( !array_key_exists( CACHE_MEMCACHED, $wgCaches ) ){ |
| 55 | + $wgCaches[CACHE_DB] = new MemCachedClientforWiki( |
| 56 | + array('persistant' => $wgMemCachedPersistent, 'compress_threshold' => 1500 ) ); |
| 57 | + $cache =& $wgCaches[CACHE_DB]; |
| 58 | + $cache->set_servers( $wgMemCachedServers ); |
| 59 | + $cache->set_debug( $wgMemCachedDebug ); |
| 60 | + } |
| 61 | + } elseif ( $type == CACHE_ACCEL ) { |
| 62 | + if ( !array_key_exists( CACHE_ACCEL, $wgCaches ) ) { |
| 63 | + if ( function_exists( 'eaccelerator_get' ) ) { |
| 64 | + $wgCaches[CACHE_ACCEL] = new eAccelBagOStuff; |
| 65 | + } elseif ( function_exists( 'apc_fetch') ) { |
| 66 | + $wgCaches[CACHE_ACCEL] = new APCBagOStuff; |
| 67 | + } elseif ( function_exists( 'mmcache_get' ) ) { |
| 68 | + $wgCaches[CACHE_ACCEL] = new TurckBagOStuff; |
| 69 | + } else { |
| 70 | + $wgCaches[CACHE_ACCEL] = false; |
61 | 71 | } |
62 | 72 | } |
| 73 | + if ( $wgCaches[CACHE_ACCEL] !== false ) { |
| 74 | + $cache =& $wgCaches[CACHE_ACCEL]; |
| 75 | + } |
| 76 | + } |
63 | 77 | |
64 | | - $wgCaches[CACHE_DB] = new MemCachedClientforWiki( |
65 | | - array('persistant' => $wgMemCachedPersistent, 'compress_threshold' => 1500 ) ); |
| 78 | + if ( $type == CACHE_DB || ( $inputType == CACHE_ANYTHING && $cache === false ) ) { |
| 79 | + if ( !array_key_exists( CACHE_DB, $wgCaches ) ) { |
| 80 | + $wgCaches[CACHE_DB] = new MediaWikiBagOStuff('objectcache'); |
| 81 | + } |
66 | 82 | $cache =& $wgCaches[CACHE_DB]; |
67 | | - $cache->set_servers( $wgMemCachedServers ); |
68 | | - $cache->set_debug( $wgMemCachedDebug ); |
69 | 83 | } |
70 | | - } elseif ( $type == CACHE_ACCEL ) { |
71 | | - if ( !array_key_exists( CACHE_ACCEL, $wgCaches ) ) { |
72 | | - if ( function_exists( 'eaccelerator_get' ) ) { |
73 | | - require_once( 'BagOStuff.php' ); |
74 | | - $wgCaches[CACHE_ACCEL] = new eAccelBagOStuff; |
75 | | - } elseif ( function_exists( 'apc_fetch') ) { |
76 | | - require_once( 'BagOStuff.php' ); |
77 | | - $wgCaches[CACHE_ACCEL] = new APCBagOStuff; |
78 | | - } elseif ( function_exists( 'mmcache_get' ) ) { |
79 | | - require_once( 'BagOStuff.php' ); |
80 | | - $wgCaches[CACHE_ACCEL] = new TurckBagOStuff; |
81 | | - } else { |
82 | | - $wgCaches[CACHE_ACCEL] = false; |
| 84 | + |
| 85 | + if ( $cache === false ) { |
| 86 | + if ( !array_key_exists( CACHE_NONE, $wgCaches ) ) { |
| 87 | + $wgCaches[CACHE_NONE] = new FakeMemCachedClient; |
83 | 88 | } |
| 89 | + $cache =& $wgCaches[CACHE_NONE]; |
84 | 90 | } |
85 | | - if ( $wgCaches[CACHE_ACCEL] !== false ) { |
86 | | - $cache =& $wgCaches[CACHE_ACCEL]; |
87 | | - } |
88 | | - } |
89 | 91 | |
90 | | - if ( $type == CACHE_DB || ( $inputType == CACHE_ANYTHING && $cache === false ) ) { |
91 | | - if ( !array_key_exists( CACHE_DB, $wgCaches ) ) { |
92 | | - require_once( 'BagOStuff.php' ); |
93 | | - $wgCaches[CACHE_DB] = new MediaWikiBagOStuff('objectcache'); |
94 | | - } |
95 | | - $cache =& $wgCaches[CACHE_DB]; |
| 92 | + return $cache; |
96 | 93 | } |
97 | | - |
98 | | - if ( $cache === false ) { |
99 | | - if ( !array_key_exists( CACHE_NONE, $wgCaches ) ) { |
100 | | - $wgCaches[CACHE_NONE] = new FakeMemCachedClient; |
101 | | - } |
102 | | - $cache =& $wgCaches[CACHE_NONE]; |
| 94 | + |
| 95 | + /** @static */ |
| 96 | + function &getMainCache() { |
| 97 | + global $wgMainCacheType; |
| 98 | + $ret =& ObjectCacheManager::getCache( $wgMainCacheType ); |
| 99 | + return $ret; |
103 | 100 | } |
104 | 101 | |
105 | | - return $cache; |
| 102 | + /** @static */ |
| 103 | + function &getMessageCache() { |
| 104 | + global $wgMessageCacheType; |
| 105 | + $ret =& ObjectCacheManager::getCache( $wgMessageCacheType ); |
| 106 | + return $ret; |
| 107 | + } |
| 108 | + |
| 109 | + /** @static */ |
| 110 | + function &getParserCache() { |
| 111 | + global $wgParserCacheType; |
| 112 | + $ret =& ObjectCacheManager::getCache( $wgParserCacheType ); |
| 113 | + return $ret; |
| 114 | + } |
| 115 | + |
106 | 116 | } |
107 | 117 | |
108 | | -function &wfGetMainCache() { |
109 | | - global $wgMainCacheType; |
110 | | - $ret =& wfGetCache( $wgMainCacheType ); |
111 | | - return $ret; |
| 118 | +class MemCachedClientforWiki extends memcached { |
| 119 | + function _debugprint( $text ) { |
| 120 | + wfDebug( "memcached: $text\n" ); |
| 121 | + } |
112 | 122 | } |
113 | 123 | |
114 | | -function &wfGetMessageCacheStorage() { |
115 | | - global $wgMessageCacheType; |
116 | | - $ret =& wfGetCache( $wgMessageCacheType ); |
117 | | - return $ret; |
118 | | -} |
119 | | - |
120 | | -function &wfGetParserCacheStorage() { |
121 | | - global $wgParserCacheType; |
122 | | - $ret =& wfGetCache( $wgParserCacheType ); |
123 | | - return $ret; |
124 | | -} |
125 | | - |
126 | 124 | ?> |
Index: trunk/phase3/includes/SearchEngine.php |
— | — | @@ -195,10 +195,8 @@ |
196 | 196 | $class = $wgSearchType; |
197 | 197 | } elseif( $wgDBtype == 'mysql' ) { |
198 | 198 | $class = 'SearchMySQL4'; |
199 | | - require_once( 'SearchMySQL4.php' ); |
200 | 199 | } else if ( $wgDBtype == 'PostgreSQL' ) { |
201 | 200 | $class = 'SearchTsearch2'; |
202 | | - require_once( 'SearchTsearch2.php' ); |
203 | 201 | } else { |
204 | 202 | $class = 'SearchEngineDummy'; |
205 | 203 | } |
Index: trunk/phase3/includes/SearchTsearch2.php |
— | — | @@ -23,9 +23,6 @@ |
24 | 24 | * @subpackage Search |
25 | 25 | */ |
26 | 26 | |
27 | | -/** */ |
28 | | -require_once( 'SearchEngine.php' ); |
29 | | - |
30 | 27 | /** |
31 | 28 | * @todo document |
32 | 29 | * @package MediaWiki |
Index: trunk/phase3/includes/ProxyTools.php |
— | — | @@ -4,230 +4,228 @@ |
5 | 5 | * @package MediaWiki |
6 | 6 | */ |
7 | 7 | |
8 | | -function wfGetForwardedFor() { |
9 | | - if( function_exists( 'apache_request_headers' ) ) { |
10 | | - // More reliable than $_SERVER due to case and -/_ folding |
11 | | - $set = apache_request_headers(); |
12 | | - $index = 'X-Forwarded-For'; |
13 | | - } else { |
14 | | - // Subject to spoofing with headers like X_Forwarded_For |
15 | | - $set = $_SERVER; |
16 | | - $index = 'HTTP_X_FORWARDED_FOR'; |
| 8 | +class ProxyTools { |
| 9 | + function getForwardedFor() { |
| 10 | + if( function_exists( 'apache_request_headers' ) ) { |
| 11 | + // More reliable than $_SERVER due to case and -/_ folding |
| 12 | + $set = apache_request_headers(); |
| 13 | + $index = 'X-Forwarded-For'; |
| 14 | + } else { |
| 15 | + // Subject to spoofing with headers like X_Forwarded_For |
| 16 | + $set = $_SERVER; |
| 17 | + $index = 'HTTP_X_FORWARDED_FOR'; |
| 18 | + } |
| 19 | + if( isset( $set[$index] ) ) { |
| 20 | + return $set[$index]; |
| 21 | + } else { |
| 22 | + return null; |
| 23 | + } |
17 | 24 | } |
18 | | - if( isset( $set[$index] ) ) { |
19 | | - return $set[$index]; |
20 | | - } else { |
21 | | - return null; |
22 | | - } |
23 | | -} |
24 | 25 | |
25 | | -/** Work out the IP address based on various globals */ |
26 | | -function wfGetIP() { |
27 | | - global $wgSquidServers, $wgSquidServersNoPurge, $wgIP; |
| 26 | + /** Work out the IP address based on various globals */ |
| 27 | + function getIP() { |
| 28 | + global $wgSquidServers, $wgSquidServersNoPurge, $wgIP; |
28 | 29 | |
29 | | - # Return cached result |
30 | | - if ( !empty( $wgIP ) ) { |
31 | | - return $wgIP; |
32 | | - } |
| 30 | + # Return cached result |
| 31 | + if ( !empty( $wgIP ) ) { |
| 32 | + return $wgIP; |
| 33 | + } |
33 | 34 | |
34 | | - /* collect the originating ips */ |
35 | | - # Client connecting to this webserver |
36 | | - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
37 | | - $ipchain = array( $_SERVER['REMOTE_ADDR'] ); |
38 | | - } else { |
39 | | - # Running on CLI? |
40 | | - $ipchain = array( '127.0.0.1' ); |
41 | | - } |
42 | | - $ip = $ipchain[0]; |
43 | | - |
44 | | - # Get list of trusted proxies |
45 | | - # Flipped for quicker access |
46 | | - $trustedProxies = array_flip( array_merge( $wgSquidServers, $wgSquidServersNoPurge ) ); |
47 | | - if ( count( $trustedProxies ) ) { |
48 | | - # Append XFF on to $ipchain |
49 | | - $forwardedFor = wfGetForwardedFor(); |
50 | | - if ( isset( $forwardedFor ) ) { |
51 | | - $xff = array_map( 'trim', explode( ',', $forwardedFor ) ); |
52 | | - $xff = array_reverse( $xff ); |
53 | | - $ipchain = array_merge( $ipchain, $xff ); |
| 35 | + /* collect the originating ips */ |
| 36 | + # Client connecting to this webserver |
| 37 | + if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
| 38 | + $ipchain = array( $_SERVER['REMOTE_ADDR'] ); |
| 39 | + } else { |
| 40 | + # Running on CLI? |
| 41 | + $ipchain = array( '127.0.0.1' ); |
54 | 42 | } |
55 | | - # Step through XFF list and find the last address in the list which is a trusted server |
56 | | - # Set $ip to the IP address given by that trusted server, unless the address is not sensible (e.g. private) |
57 | | - foreach ( $ipchain as $i => $curIP ) { |
58 | | - if ( array_key_exists( $curIP, $trustedProxies ) ) { |
59 | | - if ( isset( $ipchain[$i + 1] ) && wfIsIPPublic( $ipchain[$i + 1] ) ) { |
60 | | - $ip = $ipchain[$i + 1]; |
| 43 | + $ip = $ipchain[0]; |
| 44 | + |
| 45 | + # Get list of trusted proxies |
| 46 | + # Flipped for quicker access |
| 47 | + $trustedProxies = array_flip( array_merge( $wgSquidServers, $wgSquidServersNoPurge ) ); |
| 48 | + if ( count( $trustedProxies ) ) { |
| 49 | + # Append XFF on to $ipchain |
| 50 | + $forwardedFor = ProxyTools::getForwardedFor(); |
| 51 | + if ( isset( $forwardedFor ) ) { |
| 52 | + $xff = array_map( 'trim', explode( ',', $forwardedFor ) ); |
| 53 | + $xff = array_reverse( $xff ); |
| 54 | + $ipchain = array_merge( $ipchain, $xff ); |
| 55 | + } |
| 56 | + # Step through XFF list and find the last address in the list which is a trusted server |
| 57 | + # Set $ip to the IP address given by that trusted server, unless the address is not sensible (e.g. private) |
| 58 | + foreach ( $ipchain as $i => $curIP ) { |
| 59 | + if ( array_key_exists( $curIP, $trustedProxies ) ) { |
| 60 | + if ( isset( $ipchain[$i + 1] ) && ProxyTools::isIPPublic( $ipchain[$i + 1] ) ) { |
| 61 | + $ip = $ipchain[$i + 1]; |
| 62 | + } |
| 63 | + } else { |
| 64 | + break; |
61 | 65 | } |
62 | | - } else { |
63 | | - break; |
64 | 66 | } |
65 | 67 | } |
66 | | - } |
67 | 68 | |
68 | | - wfDebug( "IP: $ip\n" ); |
69 | | - $wgIP = $ip; |
70 | | - return $ip; |
71 | | -} |
72 | | - |
73 | | -/** |
74 | | - * Given an IP address in dotted-quad notation, returns an unsigned integer. |
75 | | - * Like ip2long() except that it actually works and has a consistent error return value. |
76 | | - */ |
77 | | -function wfIP2Unsigned( $ip ) { |
78 | | - $n = ip2long( $ip ); |
79 | | - if ( $n == -1 || $n === false ) { # Return value on error depends on PHP version |
80 | | - $n = false; |
81 | | - } elseif ( $n < 0 ) { |
82 | | - $n += pow( 2, 32 ); |
| 69 | + wfDebug( "IP: $ip\n" ); |
| 70 | + $wgIP = $ip; |
| 71 | + return $ip; |
83 | 72 | } |
84 | | - return $n; |
85 | | -} |
86 | 73 | |
87 | | -/** |
88 | | - * Return a zero-padded hexadecimal representation of an IP address |
89 | | - */ |
90 | | -function wfIP2Hex( $ip ) { |
91 | | - $n = wfIP2Unsigned( $ip ); |
92 | | - if ( $n !== false ) { |
93 | | - $n = sprintf( '%08X', $n ); |
| 74 | + /** |
| 75 | + * Given an IP address in dotted-quad notation, returns an unsigned integer. |
| 76 | + * Like ip2long() except that it actually works and has a consistent error return value. |
| 77 | + */ |
| 78 | + function IP2Unsigned( $ip ) { |
| 79 | + $n = ip2long( $ip ); |
| 80 | + if ( $n == -1 || $n === false ) { # Return value on error depends on PHP version |
| 81 | + $n = false; |
| 82 | + } elseif ( $n < 0 ) { |
| 83 | + $n += pow( 2, 32 ); |
| 84 | + } |
| 85 | + return $n; |
94 | 86 | } |
95 | | - return $n; |
96 | | -} |
97 | 87 | |
98 | | -/** |
99 | | - * Determine if an IP address really is an IP address, and if it is public, |
100 | | - * i.e. not RFC 1918 or similar |
101 | | - */ |
102 | | -function wfIsIPPublic( $ip ) { |
103 | | - $n = wfIP2Unsigned( $ip ); |
104 | | - if ( !$n ) { |
105 | | - return false; |
| 88 | + /** |
| 89 | + * Return a zero-padded hexadecimal representation of an IP address |
| 90 | + */ |
| 91 | + function IP2Hex( $ip ) { |
| 92 | + $n = ProxyTools::IP2Unsigned( $ip ); |
| 93 | + if ( $n !== false ) { |
| 94 | + $n = sprintf( '%08X', $n ); |
| 95 | + } |
| 96 | + return $n; |
106 | 97 | } |
107 | | - |
108 | | - // ip2long accepts incomplete addresses, as well as some addresses |
109 | | - // followed by garbage characters. Check that it's really valid. |
110 | | - if( $ip != long2ip( $n ) ) { |
111 | | - return false; |
112 | | - } |
113 | 98 | |
114 | | - static $privateRanges = false; |
115 | | - if ( !$privateRanges ) { |
116 | | - $privateRanges = array( |
117 | | - array( '10.0.0.0', '10.255.255.255' ), # RFC 1918 (private) |
118 | | - array( '172.16.0.0', '172.31.255.255' ), # " |
119 | | - array( '192.168.0.0', '192.168.255.255' ), # " |
120 | | - array( '0.0.0.0', '0.255.255.255' ), # this network |
121 | | - array( '127.0.0.0', '127.255.255.255' ), # loopback |
122 | | - ); |
123 | | - } |
124 | | - |
125 | | - foreach ( $privateRanges as $r ) { |
126 | | - $start = wfIP2Unsigned( $r[0] ); |
127 | | - $end = wfIP2Unsigned( $r[1] ); |
128 | | - if ( $n >= $start && $n <= $end ) { |
| 99 | + /** |
| 100 | + * Determine if an IP address really is an IP address, and if it is public, |
| 101 | + * i.e. not RFC 1918 or similar |
| 102 | + */ |
| 103 | + function isIPPublic( $ip ) { |
| 104 | + $n = ProxyTools::IP2Unsigned( $ip ); |
| 105 | + if ( !$n ) { |
129 | 106 | return false; |
130 | 107 | } |
131 | | - } |
132 | | - return true; |
133 | | -} |
| 108 | + |
| 109 | + // ip2long accepts incomplete addresses, as well as some addresses |
| 110 | + // followed by garbage characters. Check that it's really valid. |
| 111 | + if( $ip != long2ip( $n ) ) { |
| 112 | + return false; |
| 113 | + } |
134 | 114 | |
135 | | -/** |
136 | | - * Forks processes to scan the originating IP for an open proxy server |
137 | | - * MemCached can be used to skip IPs that have already been scanned |
138 | | - */ |
139 | | -function wfProxyCheck() { |
140 | | - global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath; |
141 | | - global $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry; |
142 | | - global $wgProxyKey; |
| 115 | + static $privateRanges = false; |
| 116 | + if ( !$privateRanges ) { |
| 117 | + $privateRanges = array( |
| 118 | + array( '10.0.0.0', '10.255.255.255' ), # RFC 1918 (private) |
| 119 | + array( '172.16.0.0', '172.31.255.255' ), # " |
| 120 | + array( '192.168.0.0', '192.168.255.255' ), # " |
| 121 | + array( '0.0.0.0', '0.255.255.255' ), # this network |
| 122 | + array( '127.0.0.0', '127.255.255.255' ), # loopback |
| 123 | + ); |
| 124 | + } |
143 | 125 | |
144 | | - if ( !$wgBlockOpenProxies ) { |
145 | | - return; |
| 126 | + foreach ( $privateRanges as $r ) { |
| 127 | + $start = ProxyTools::IP2Unsigned( $r[0] ); |
| 128 | + $end = ProxyTools::IP2Unsigned( $r[1] ); |
| 129 | + if ( $n >= $start && $n <= $end ) { |
| 130 | + return false; |
| 131 | + } |
| 132 | + } |
| 133 | + return true; |
146 | 134 | } |
147 | 135 | |
148 | | - $ip = wfGetIP(); |
| 136 | + /** |
| 137 | + * Forks processes to scan the originating IP for an open proxy server |
| 138 | + * MemCached can be used to skip IPs that have already been scanned |
| 139 | + */ |
| 140 | + function proxyCheck() { |
| 141 | + global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath; |
| 142 | + global $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry; |
| 143 | + global $wgProxyKey; |
149 | 144 | |
150 | | - # Get MemCached key |
151 | | - $skip = false; |
152 | | - if ( $wgUseMemCached ) { |
153 | | - $mcKey = "$wgDBname:proxy:ip:$ip"; |
154 | | - $mcValue = $wgMemc->get( $mcKey ); |
155 | | - if ( $mcValue ) { |
156 | | - $skip = true; |
| 145 | + if ( !$wgBlockOpenProxies ) { |
| 146 | + return; |
157 | 147 | } |
158 | | - } |
159 | 148 | |
160 | | - # Fork the processes |
161 | | - if ( !$skip ) { |
162 | | - $title = Title::makeTitle( NS_SPECIAL, 'Blockme' ); |
163 | | - $iphash = md5( $ip . $wgProxyKey ); |
164 | | - $url = $title->getFullURL( 'ip='.$iphash ); |
| 149 | + $ip = ProxyTools::getIP(); |
165 | 150 | |
166 | | - foreach ( $wgProxyPorts as $port ) { |
167 | | - $params = implode( ' ', array( |
168 | | - escapeshellarg( $wgProxyScriptPath ), |
169 | | - escapeshellarg( $ip ), |
170 | | - escapeshellarg( $port ), |
171 | | - escapeshellarg( $url ) |
172 | | - )); |
173 | | - exec( "php $params &>/dev/null &" ); |
174 | | - } |
175 | | - # Set MemCached key |
| 151 | + # Get MemCached key |
| 152 | + $skip = false; |
176 | 153 | if ( $wgUseMemCached ) { |
177 | | - $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry ); |
| 154 | + $mcKey = "$wgDBname:proxy:ip:$ip"; |
| 155 | + $mcValue = $wgMemc->get( $mcKey ); |
| 156 | + if ( $mcValue ) { |
| 157 | + $skip = true; |
| 158 | + } |
178 | 159 | } |
179 | | - } |
180 | | -} |
181 | 160 | |
182 | | -/** |
183 | | - * Convert a network specification in CIDR notation to an integer network and a number of bits |
184 | | - */ |
185 | | -function wfParseCIDR( $range ) { |
186 | | - $parts = explode( '/', $range, 2 ); |
187 | | - if ( count( $parts ) != 2 ) { |
188 | | - return array( false, false ); |
189 | | - } |
190 | | - $network = wfIP2Unsigned( $parts[0] ); |
191 | | - if ( $network !== false && is_numeric( $parts[1] ) && $parts[1] >= 0 && $parts[1] <= 32 ) { |
192 | | - $bits = $parts[1]; |
193 | | - } else { |
194 | | - $network = false; |
195 | | - $bits = false; |
196 | | - } |
197 | | - return array( $network, $bits ); |
198 | | -} |
| 161 | + # Fork the processes |
| 162 | + if ( !$skip ) { |
| 163 | + $title = Title::makeTitle( NS_SPECIAL, 'Blockme' ); |
| 164 | + $iphash = md5( $ip . $wgProxyKey ); |
| 165 | + $url = $title->getFullURL( 'ip='.$iphash ); |
199 | 166 | |
200 | | -/** |
201 | | - * Check if an IP address is in the local proxy list |
202 | | - */ |
203 | | -function wfIsLocallyBlockedProxy( $ip ) { |
204 | | - global $wgProxyList; |
205 | | - $fname = 'wfIsLocallyBlockedProxy'; |
206 | | - |
207 | | - if ( !$wgProxyList ) { |
208 | | - return false; |
| 167 | + foreach ( $wgProxyPorts as $port ) { |
| 168 | + $params = implode( ' ', array( |
| 169 | + escapeshellarg( $wgProxyScriptPath ), |
| 170 | + escapeshellarg( $ip ), |
| 171 | + escapeshellarg( $port ), |
| 172 | + escapeshellarg( $url ) |
| 173 | + )); |
| 174 | + exec( "php $params &>/dev/null &" ); |
| 175 | + } |
| 176 | + # Set MemCached key |
| 177 | + if ( $wgUseMemCached ) { |
| 178 | + $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry ); |
| 179 | + } |
| 180 | + } |
209 | 181 | } |
210 | | - wfProfileIn( $fname ); |
211 | 182 | |
212 | | - if ( !is_array( $wgProxyList ) ) { |
213 | | - # Load from the specified file |
214 | | - $wgProxyList = array_map( 'trim', file( $wgProxyList ) ); |
| 183 | + /** |
| 184 | + * Convert a network specification in CIDR notation to an integer network and a number of bits |
| 185 | + */ |
| 186 | + function parseCIDR( $range ) { |
| 187 | + $parts = explode( '/', $range, 2 ); |
| 188 | + if ( count( $parts ) != 2 ) { |
| 189 | + return array( false, false ); |
| 190 | + } |
| 191 | + $network = ProxyTools::IP2Unsigned( $parts[0] ); |
| 192 | + if ( $network !== false && is_numeric( $parts[1] ) && $parts[1] >= 0 && $parts[1] <= 32 ) { |
| 193 | + $bits = $parts[1]; |
| 194 | + } else { |
| 195 | + $network = false; |
| 196 | + $bits = false; |
| 197 | + } |
| 198 | + return array( $network, $bits ); |
215 | 199 | } |
216 | 200 | |
217 | | - if ( !is_array( $wgProxyList ) ) { |
218 | | - $ret = false; |
219 | | - } elseif ( array_search( $ip, $wgProxyList ) !== false ) { |
220 | | - $ret = true; |
221 | | - } elseif ( array_key_exists( $ip, $wgProxyList ) ) { |
222 | | - # Old-style flipped proxy list |
223 | | - $ret = true; |
224 | | - } else { |
225 | | - $ret = false; |
226 | | - } |
227 | | - wfProfileOut( $fname ); |
228 | | - return $ret; |
229 | | -} |
| 201 | + /** |
| 202 | + * Check if an IP address is in the local proxy list |
| 203 | + */ |
| 204 | + function isLocallyBlockedProxy( $ip ) { |
| 205 | + global $wgProxyList; |
| 206 | + $fname = 'ProxyTools::isLocallyBlockedProxy'; |
230 | 207 | |
| 208 | + if ( !$wgProxyList ) { |
| 209 | + return false; |
| 210 | + } |
| 211 | + wfProfileIn( $fname ); |
231 | 212 | |
| 213 | + if ( !is_array( $wgProxyList ) ) { |
| 214 | + # Load from the specified file |
| 215 | + $wgProxyList = array_map( 'trim', file( $wgProxyList ) ); |
| 216 | + } |
232 | 217 | |
233 | | - |
| 218 | + if ( !is_array( $wgProxyList ) ) { |
| 219 | + $ret = false; |
| 220 | + } elseif ( array_search( $ip, $wgProxyList ) !== false ) { |
| 221 | + $ret = true; |
| 222 | + } elseif ( array_key_exists( $ip, $wgProxyList ) ) { |
| 223 | + # Old-style flipped proxy list |
| 224 | + $ret = true; |
| 225 | + } else { |
| 226 | + $ret = false; |
| 227 | + } |
| 228 | + wfProfileOut( $fname ); |
| 229 | + return $ret; |
| 230 | + } |
| 231 | +} |
234 | 232 | ?> |
Index: trunk/phase3/includes/ExternalStoreDB.php |
— | — | @@ -6,9 +6,7 @@ |
7 | 7 | * DB accessable external objects |
8 | 8 | * |
9 | 9 | */ |
10 | | -require_once( 'LoadBalancer.php' ); |
11 | 10 | |
12 | | - |
13 | 11 | /** @package MediaWiki */ |
14 | 12 | |
15 | 13 | /** |
Index: trunk/phase3/includes/Credits.php |
— | — | @@ -24,164 +24,165 @@ |
25 | 25 | /** |
26 | 26 | * This is largely cadged from PageHistory::history |
27 | 27 | */ |
28 | | -function showCreditsPage($article) { |
29 | | - global $wgOut; |
| 28 | +class Credits { |
| 29 | + function showCreditsPage($article) { |
| 30 | + global $wgOut; |
30 | 31 | |
31 | | - $fname = 'showCreditsPage'; |
| 32 | + $fname = 'Credits::showCreditsPage'; |
32 | 33 | |
33 | | - wfProfileIn( $fname ); |
| 34 | + wfProfileIn( $fname ); |
34 | 35 | |
35 | | - $wgOut->setPageTitle( $article->mTitle->getPrefixedText() ); |
36 | | - $wgOut->setSubtitle( wfMsg( 'creditspage' ) ); |
37 | | - $wgOut->setArticleFlag( false ); |
38 | | - $wgOut->setArticleRelated( true ); |
39 | | - $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
| 36 | + $wgOut->setPageTitle( $article->mTitle->getPrefixedText() ); |
| 37 | + $wgOut->setSubtitle( wfMsg( 'creditspage' ) ); |
| 38 | + $wgOut->setArticleFlag( false ); |
| 39 | + $wgOut->setArticleRelated( true ); |
| 40 | + $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
40 | 41 | |
41 | | - if( $article->mTitle->getArticleID() == 0 ) { |
42 | | - $s = wfMsg( 'nocredits' ); |
43 | | - } else { |
44 | | - $s = getCredits($article, -1); |
45 | | - } |
| 42 | + if( $article->mTitle->getArticleID() == 0 ) { |
| 43 | + $s = wfMsg( 'nocredits' ); |
| 44 | + } else { |
| 45 | + $s = Credits::getCredits($article, -1); |
| 46 | + } |
46 | 47 | |
47 | | - $wgOut->addHTML( $s ); |
| 48 | + $wgOut->addHTML( $s ); |
48 | 49 | |
49 | | - wfProfileOut( $fname ); |
50 | | -} |
| 50 | + wfProfileOut( $fname ); |
| 51 | + } |
51 | 52 | |
52 | | -function getCredits($article, $cnt, $showIfMax=true) { |
53 | | - $fname = 'getCredits'; |
54 | | - wfProfileIn( $fname ); |
55 | | - $s = ''; |
| 53 | + function getCredits($article, $cnt, $showIfMax=true) { |
| 54 | + $fname = 'Credits::getCredits'; |
| 55 | + wfProfileIn( $fname ); |
| 56 | + $s = ''; |
56 | 57 | |
57 | | - if (isset($cnt) && $cnt != 0) { |
58 | | - $s = getAuthorCredits($article); |
59 | | - if ($cnt > 1 || $cnt < 0) { |
60 | | - $s .= ' ' . getContributorCredits($article, $cnt - 1, $showIfMax); |
| 58 | + if (isset($cnt) && $cnt != 0) { |
| 59 | + $s = Credits::getAuthorCredits($article); |
| 60 | + if ($cnt > 1 || $cnt < 0) { |
| 61 | + $s .= ' ' . Credits::getContributorCredits($article, $cnt - 1, $showIfMax); |
| 62 | + } |
61 | 63 | } |
| 64 | + |
| 65 | + wfProfileOut( $fname ); |
| 66 | + return $s; |
62 | 67 | } |
63 | 68 | |
64 | | - wfProfileOut( $fname ); |
65 | | - return $s; |
66 | | -} |
| 69 | + /** |
| 70 | + * |
| 71 | + */ |
| 72 | + function getAuthorCredits($article) { |
| 73 | + global $wgLang, $wgAllowRealName; |
67 | 74 | |
68 | | -/** |
69 | | - * |
70 | | - */ |
71 | | -function getAuthorCredits($article) { |
72 | | - global $wgLang, $wgAllowRealName; |
| 75 | + $last_author = $article->getUser(); |
73 | 76 | |
74 | | - $last_author = $article->getUser(); |
| 77 | + if ($last_author == 0) { |
| 78 | + $author_credit = wfMsg('anonymous'); |
| 79 | + } else { |
| 80 | + if($wgAllowRealName) { $real_name = User::whoIsReal($last_author); } |
| 81 | + $user_name = User::whoIs($last_author); |
75 | 82 | |
76 | | - if ($last_author == 0) { |
77 | | - $author_credit = wfMsg('anonymous'); |
78 | | - } else { |
79 | | - if($wgAllowRealName) { $real_name = User::whoIsReal($last_author); } |
80 | | - $user_name = User::whoIs($last_author); |
| 83 | + if (!empty($real_name)) { |
| 84 | + $author_credit = Credits::creditLink($user_name, $real_name); |
| 85 | + } else { |
| 86 | + $author_credit = wfMsg('siteuser', Credits::creditLink($user_name)); |
| 87 | + } |
| 88 | + } |
81 | 89 | |
82 | | - if (!empty($real_name)) { |
83 | | - $author_credit = creditLink($user_name, $real_name); |
| 90 | + $timestamp = $article->getTimestamp(); |
| 91 | + if ($timestamp) { |
| 92 | + $d = $wgLang->timeanddate($article->getTimestamp(), true); |
84 | 93 | } else { |
85 | | - $author_credit = wfMsg('siteuser', creditLink($user_name)); |
| 94 | + $d = ''; |
86 | 95 | } |
| 96 | + return wfMsg('lastmodifiedby', $d, $author_credit); |
87 | 97 | } |
88 | 98 | |
89 | | - $timestamp = $article->getTimestamp(); |
90 | | - if ($timestamp) { |
91 | | - $d = $wgLang->timeanddate($article->getTimestamp(), true); |
92 | | - } else { |
93 | | - $d = ''; |
94 | | - } |
95 | | - return wfMsg('lastmodifiedby', $d, $author_credit); |
96 | | -} |
| 99 | + /** |
| 100 | + * |
| 101 | + */ |
| 102 | + function getContributorCredits($article, $cnt, $showIfMax) { |
97 | 103 | |
98 | | -/** |
99 | | - * |
100 | | - */ |
101 | | -function getContributorCredits($article, $cnt, $showIfMax) { |
| 104 | + global $wgLang, $wgAllowRealName; |
102 | 105 | |
103 | | - global $wgLang, $wgAllowRealName; |
| 106 | + $contributors = $article->getContributors(); |
104 | 107 | |
105 | | - $contributors = $article->getContributors(); |
| 108 | + $others_link = ''; |
106 | 109 | |
107 | | - $others_link = ''; |
| 110 | + # Hmm... too many to fit! |
108 | 111 | |
109 | | - # Hmm... too many to fit! |
110 | | - |
111 | | - if ($cnt > 0 && count($contributors) > $cnt) { |
112 | | - $others_link = creditOthersLink($article); |
113 | | - if (!$showIfMax) { |
114 | | - return wfMsg('othercontribs', $others_link); |
115 | | - } else { |
116 | | - $contributors = array_slice($contributors, 0, $cnt); |
| 112 | + if ($cnt > 0 && count($contributors) > $cnt) { |
| 113 | + $others_link = Credits::creditOthersLink($article); |
| 114 | + if (!$showIfMax) { |
| 115 | + return wfMsg('othercontribs', $others_link); |
| 116 | + } else { |
| 117 | + $contributors = array_slice($contributors, 0, $cnt); |
| 118 | + } |
117 | 119 | } |
118 | | - } |
119 | 120 | |
120 | | - $real_names = array(); |
121 | | - $user_names = array(); |
| 121 | + $real_names = array(); |
| 122 | + $user_names = array(); |
122 | 123 | |
123 | | - $anon = ''; |
| 124 | + $anon = ''; |
124 | 125 | |
125 | | - # Sift for real versus user names |
| 126 | + # Sift for real versus user names |
126 | 127 | |
127 | | - foreach ($contributors as $user_parts) { |
128 | | - if ($user_parts[0] != 0) { |
129 | | - if ($wgAllowRealName && !empty($user_parts[2])) { |
130 | | - $real_names[] = creditLink($user_parts[1], $user_parts[2]); |
| 128 | + foreach ($contributors as $user_parts) { |
| 129 | + if ($user_parts[0] != 0) { |
| 130 | + if ($wgAllowRealName && !empty($user_parts[2])) { |
| 131 | + $real_names[] = Credits::creditLink($user_parts[1], $user_parts[2]); |
| 132 | + } else { |
| 133 | + $user_names[] = Credits::creditLink($user_parts[1]); |
| 134 | + } |
131 | 135 | } else { |
132 | | - $user_names[] = creditLink($user_parts[1]); |
| 136 | + $anon = wfMsg('anonymous'); |
133 | 137 | } |
134 | | - } else { |
135 | | - $anon = wfMsg('anonymous'); |
136 | 138 | } |
137 | | - } |
138 | 139 | |
139 | | - # Two strings: real names, and user names |
| 140 | + # Two strings: real names, and user names |
140 | 141 | |
141 | | - $real = $wgLang->listToText($real_names); |
142 | | - $user = $wgLang->listToText($user_names); |
| 142 | + $real = $wgLang->listToText($real_names); |
| 143 | + $user = $wgLang->listToText($user_names); |
143 | 144 | |
144 | | - # "ThisSite user(s) A, B and C" |
| 145 | + # "ThisSite user(s) A, B and C" |
145 | 146 | |
146 | | - if (!empty($user)) { |
147 | | - $user = wfMsg('siteusers', $user); |
148 | | - } |
| 147 | + if (!empty($user)) { |
| 148 | + $user = wfMsg('siteusers', $user); |
| 149 | + } |
149 | 150 | |
150 | | - # This is the big list, all mooshed together. We sift for blank strings |
| 151 | + # This is the big list, all mooshed together. We sift for blank strings |
151 | 152 | |
152 | | - $fulllist = array(); |
| 153 | + $fulllist = array(); |
153 | 154 | |
154 | | - foreach (array($real, $user, $anon, $others_link) as $s) { |
155 | | - if (!empty($s)) { |
156 | | - array_push($fulllist, $s); |
| 155 | + foreach (array($real, $user, $anon, $others_link) as $s) { |
| 156 | + if (!empty($s)) { |
| 157 | + array_push($fulllist, $s); |
| 158 | + } |
157 | 159 | } |
158 | | - } |
159 | 160 | |
160 | | - # Make the list into text... |
| 161 | + # Make the list into text... |
161 | 162 | |
162 | | - $creds = $wgLang->listToText($fulllist); |
| 163 | + $creds = $wgLang->listToText($fulllist); |
163 | 164 | |
164 | | - # "Based on work by ..." |
| 165 | + # "Based on work by ..." |
165 | 166 | |
166 | | - return (empty($creds)) ? '' : wfMsg('othercontribs', $creds); |
167 | | -} |
| 167 | + return (empty($creds)) ? '' : wfMsg('othercontribs', $creds); |
| 168 | + } |
168 | 169 | |
169 | | -/** |
170 | | - * |
171 | | - */ |
172 | | -function creditLink($user_name, $link_text = '') { |
173 | | - global $wgUser, $wgContLang; |
174 | | - $skin = $wgUser->getSkin(); |
175 | | - return $skin->makeLink($wgContLang->getNsText(NS_USER) . ':' . $user_name, |
176 | | - htmlspecialchars( (empty($link_text)) ? $user_name : $link_text )); |
177 | | -} |
| 170 | + /** |
| 171 | + * |
| 172 | + */ |
| 173 | + function creditLink($user_name, $link_text = '') { |
| 174 | + global $wgUser, $wgContLang; |
| 175 | + $skin = $wgUser->getSkin(); |
| 176 | + return $skin->makeLink($wgContLang->getNsText(NS_USER) . ':' . $user_name, |
| 177 | + htmlspecialchars( (empty($link_text)) ? $user_name : $link_text )); |
| 178 | + } |
178 | 179 | |
179 | | -/** |
180 | | - * |
181 | | - */ |
182 | | -function creditOthersLink($article) { |
183 | | - global $wgUser; |
184 | | - $skin = $wgUser->getSkin(); |
185 | | - return $skin->makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), 'action=credits'); |
| 180 | + /** |
| 181 | + * |
| 182 | + */ |
| 183 | + function creditOthersLink($article) { |
| 184 | + global $wgUser; |
| 185 | + $skin = $wgUser->getSkin(); |
| 186 | + return $skin->makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), 'action=credits'); |
| 187 | + } |
186 | 188 | } |
187 | | - |
188 | 189 | ?> |
Index: trunk/phase3/includes/Database.php |
— | — | @@ -5,11 +5,6 @@ |
6 | 6 | * @package MediaWiki |
7 | 7 | */ |
8 | 8 | |
9 | | -/** |
10 | | - * Depends on the CacheManager |
11 | | - */ |
12 | | -require_once( 'CacheManager.php' ); |
13 | | - |
14 | 9 | /** See Database::makeList() */ |
15 | 10 | define( 'LIST_COMMA', 0 ); |
16 | 11 | define( 'LIST_AND', 1 ); |
Index: trunk/phase3/includes/SearchUpdate.php |
— | — | @@ -37,7 +37,6 @@ |
38 | 38 | $fname = 'SearchUpdate::doUpdate'; |
39 | 39 | wfProfileIn( $fname ); |
40 | 40 | |
41 | | - require_once( 'SearchEngine.php' ); |
42 | 41 | $search = SearchEngine::create(); |
43 | 42 | $lc = $search->legalSearchChars() . '&#;'; |
44 | 43 | |
Index: trunk/phase3/includes/AjaxFunctions.php |
— | — | @@ -3,8 +3,6 @@ |
4 | 4 | if( !defined( 'MEDIAWIKI' ) ) |
5 | 5 | die( -1 ); |
6 | 6 | |
7 | | -require_once('WebRequest.php'); |
8 | | - |
9 | 7 | /** |
10 | 8 | * Function converts an Javascript escaped string back into a string with |
11 | 9 | * specified charset (default is UTF-8). |
Index: trunk/phase3/includes/LogPage.php |
— | — | @@ -83,7 +83,6 @@ |
84 | 84 | $rcComment .= ': ' . $this->comment; |
85 | 85 | } |
86 | 86 | |
87 | | - require_once( 'RecentChange.php' ); |
88 | 87 | RecentChange::notifyLog( $now, $titleObj, $wgUser, $rcComment, '', |
89 | 88 | $this->type, $this->action, $this->target, $this->comment, $this->params ); |
90 | 89 | } |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -5,9 +5,6 @@ |
6 | 6 | * @package MediaWiki |
7 | 7 | */ |
8 | 8 | |
9 | | -/** */ |
10 | | -require_once( 'normal/UtfNormal.php' ); |
11 | | - |
12 | 9 | $wgTitleInterwikiCache = array(); |
13 | 10 | $wgTitleCache = array(); |
14 | 11 | |
— | — | @@ -334,7 +331,6 @@ |
335 | 332 | */ |
336 | 333 | /* static */ function indexTitle( $ns, $title ) { |
337 | 334 | global $wgContLang; |
338 | | - require_once( 'SearchEngine.php' ); |
339 | 335 | |
340 | 336 | $lc = SearchEngine::legalSearchChars() . '&#;'; |
341 | 337 | $t = $wgContLang->stripForSearch( $title ); |
— | — | @@ -1162,8 +1158,7 @@ |
1163 | 1159 | * Check that the corresponding skin exists |
1164 | 1160 | */ |
1165 | 1161 | function isValidCssJsSubpage() { |
1166 | | - global $wgValidSkinNames; |
1167 | | - return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), $wgValidSkinNames ) ); |
| 1162 | + return( $this->isCssJsSubpage() && array_key_exists( $this->getSkinFromCssJsSubpage(), Skin::getSkinNames() ) ); |
1168 | 1163 | } |
1169 | 1164 | /** |
1170 | 1165 | * Trim down a .css or .js subpage title to get the corresponding skin name |
Index: trunk/phase3/includes/Image.php |
— | — | @@ -12,9 +12,6 @@ |
13 | 13 | * extension=extensions/php_exif.dll |
14 | 14 | */ |
15 | 15 | |
16 | | -if ($wgShowEXIF) |
17 | | - require_once('Exif.php'); |
18 | | - |
19 | 16 | /** |
20 | 17 | * Bump this number when serialized cache records may be incompatible. |
21 | 18 | */ |
Index: trunk/phase3/includes/Profiling.php |
— | — | @@ -278,7 +278,6 @@ |
279 | 279 | } |
280 | 280 | } |
281 | 281 | $prof .= "\nTotal: $total\n\n"; |
282 | | - |
283 | 282 | return $prof; |
284 | 283 | } |
285 | 284 | |
— | — | @@ -322,7 +321,6 @@ |
323 | 322 | } else { |
324 | 323 | $pfhost = ''; |
325 | 324 | } |
326 | | - |
327 | 325 | $sql = "UPDATE $profiling "."SET pf_count=pf_count+{$eventCount}, "."pf_time=pf_time + {$timeSum} ". |
328 | 326 | "WHERE pf_name='{$encname}' AND pf_server='{$pfhost}'"; |
329 | 327 | $dbw->query($sql); |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -176,10 +176,8 @@ |
177 | 177 | |
178 | 178 | switch( $title->getNamespace() ) { |
179 | 179 | case NS_IMAGE: |
180 | | - require_once( 'includes/ImagePage.php' ); |
181 | 180 | return new ImagePage( $title ); |
182 | 181 | case NS_CATEGORY: |
183 | | - require_once( 'includes/CategoryPage.php' ); |
184 | 182 | return new CategoryPage( $title ); |
185 | 183 | default: |
186 | 184 | return new Article( $title ); |
— | — | @@ -284,8 +282,6 @@ |
285 | 283 | $n = intval( $wgJobRunRate ); |
286 | 284 | } |
287 | 285 | |
288 | | - require_once( 'JobQueue.php' ); |
289 | | - |
290 | 286 | while ( $n-- && false != ($job = Job::pop())) { |
291 | 287 | $output = $job->toString() . "\n"; |
292 | 288 | if ( !$job->run() ) { |
— | — | @@ -359,8 +355,7 @@ |
360 | 356 | } |
361 | 357 | break; |
362 | 358 | case 'credits': |
363 | | - require_once( 'includes/Credits.php' ); |
364 | | - showCreditsPage( $article ); |
| 359 | + Credits::showCreditsPage( $article ); |
365 | 360 | break; |
366 | 361 | case 'submit': |
367 | 362 | if( !$this->getVal( 'CommandLineMode' ) && !$request->checkSessionCookie() ) { |
— | — | @@ -375,11 +370,9 @@ |
376 | 371 | $oldid = $request->getVal( 'oldid' ); |
377 | 372 | if( !$this->getVal( 'UseExternalEditor' ) || $action=='submit' || $internal || |
378 | 373 | $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) { |
379 | | - require_once( 'includes/EditPage.php' ); |
380 | 374 | $editor = new EditPage( $article ); |
381 | 375 | $editor->submit(); |
382 | 376 | } elseif( $this->getVal( 'UseExternalEditor' ) && ( $external || $user->getOption( 'externaleditor' ) ) ) { |
383 | | - require_once( 'includes/ExternalEdit.php' ); |
384 | 377 | $mode = $request->getVal( 'mode' ); |
385 | 378 | $extedit = new ExternalEdit( $article, $mode ); |
386 | 379 | $extedit->edit(); |
— | — | @@ -389,12 +382,10 @@ |
390 | 383 | if( $_SERVER['REQUEST_URI'] == $title->getInternalURL( 'action=history' ) ) { |
391 | 384 | $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |
392 | 385 | } |
393 | | - require_once( 'includes/PageHistory.php' ); |
394 | 386 | $history = new PageHistory( $article ); |
395 | 387 | $history->history(); |
396 | 388 | break; |
397 | 389 | case 'raw': |
398 | | - require_once( 'includes/RawPage.php' ); |
399 | 390 | $raw = new RawPage( $article ); |
400 | 391 | $raw->view(); |
401 | 392 | break; |
Index: trunk/phase3/includes/HttpFunctions.php |
— | — | @@ -3,88 +3,89 @@ |
4 | 4 | * Various HTTP related functions |
5 | 5 | */ |
6 | 6 | |
7 | | -/** |
8 | | - * Get the contents of a file by HTTP |
9 | | - * |
10 | | - * if $timeout is 'default', $wgHTTPTimeout is used |
11 | | - */ |
12 | | -function wfGetHTTP( $url, $timeout = 'default' ) { |
13 | | - global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle; |
| 7 | +class HttpFunctions { |
| 8 | + /** |
| 9 | + * Get the contents of a file by HTTP |
| 10 | + * |
| 11 | + * if $timeout is 'default', $wgHTTPTimeout is used |
| 12 | + */ |
| 13 | + function getHTTP( $url, $timeout = 'default' ) { |
| 14 | + global $wgHTTPTimeout, $wgHTTPProxy, $wgVersion, $wgTitle; |
14 | 15 | |
15 | | - # Use curl if available |
16 | | - if ( function_exists( 'curl_init' ) ) { |
17 | | - $c = curl_init( $url ); |
18 | | - if ( wfIsLocalURL( $url ) ) { |
19 | | - curl_setopt( $c, CURLOPT_PROXY, 'localhost:80' ); |
20 | | - } else if ($wgHTTPProxy) { |
21 | | - curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy); |
22 | | - } |
| 16 | + # Use curl if available |
| 17 | + if ( function_exists( 'curl_init' ) ) { |
| 18 | + $c = curl_init( $url ); |
| 19 | + if ( HttpFunctions::isLocalURL( $url ) ) { |
| 20 | + curl_setopt( $c, CURLOPT_PROXY, 'localhost:80' ); |
| 21 | + } else if ($wgHTTPProxy) { |
| 22 | + curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy); |
| 23 | + } |
23 | 24 | |
24 | | - if ( $timeout == 'default' ) { |
25 | | - $timeout = $wgHTTPTimeout; |
26 | | - } |
27 | | - curl_setopt( $c, CURLOPT_TIMEOUT, $timeout ); |
28 | | - curl_setopt( $c, CURLOPT_USERAGENT, "MediaWiki/$wgVersion" ); |
| 25 | + if ( $timeout == 'default' ) { |
| 26 | + $timeout = $wgHTTPTimeout; |
| 27 | + } |
| 28 | + curl_setopt( $c, CURLOPT_TIMEOUT, $timeout ); |
| 29 | + curl_setopt( $c, CURLOPT_USERAGENT, "MediaWiki/$wgVersion" ); |
29 | 30 | |
30 | | - # Set the referer to $wgTitle, even in command-line mode |
31 | | - # This is useful for interwiki transclusion, where the foreign |
32 | | - # server wants to know what the referring page is. |
33 | | - # $_SERVER['REQUEST_URI'] gives a less reliable indication of the |
34 | | - # referring page. |
35 | | - if ( is_object( $wgTitle ) ) { |
36 | | - curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() ); |
37 | | - } |
| 31 | + # Set the referer to $wgTitle, even in command-line mode |
| 32 | + # This is useful for interwiki transclusion, where the foreign |
| 33 | + # server wants to know what the referring page is. |
| 34 | + # $_SERVER['REQUEST_URI'] gives a less reliable indication of the |
| 35 | + # referring page. |
| 36 | + if ( is_object( $wgTitle ) ) { |
| 37 | + curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() ); |
| 38 | + } |
38 | 39 | |
39 | | - ob_start(); |
40 | | - curl_exec( $c ); |
41 | | - $text = ob_get_contents(); |
42 | | - ob_end_clean(); |
| 40 | + ob_start(); |
| 41 | + curl_exec( $c ); |
| 42 | + $text = ob_get_contents(); |
| 43 | + ob_end_clean(); |
43 | 44 | |
44 | | - # Don't return the text of error messages, return false on error |
45 | | - if ( curl_getinfo( $c, CURLINFO_HTTP_CODE ) != 200 ) { |
46 | | - $text = false; |
| 45 | + # Don't return the text of error messages, return false on error |
| 46 | + if ( curl_getinfo( $c, CURLINFO_HTTP_CODE ) != 200 ) { |
| 47 | + $text = false; |
| 48 | + } |
| 49 | + curl_close( $c ); |
| 50 | + } else { |
| 51 | + # Otherwise use file_get_contents, or its compatibility function from GlobalFunctions.php |
| 52 | + # This may take 3 minutes to time out, and doesn't have local fetch capabilities |
| 53 | + $url_fopen = ini_set( 'allow_url_fopen', 1 ); |
| 54 | + $text = file_get_contents( $url ); |
| 55 | + ini_set( 'allow_url_fopen', $url_fopen ); |
47 | 56 | } |
48 | | - curl_close( $c ); |
49 | | - } else { |
50 | | - # Otherwise use file_get_contents, or its compatibility function from GlobalFunctions.php |
51 | | - # This may take 3 minutes to time out, and doesn't have local fetch capabilities |
52 | | - $url_fopen = ini_set( 'allow_url_fopen', 1 ); |
53 | | - $text = file_get_contents( $url ); |
54 | | - ini_set( 'allow_url_fopen', $url_fopen ); |
| 57 | + return $text; |
55 | 58 | } |
56 | | - return $text; |
57 | | -} |
58 | 59 | |
59 | | -/** |
60 | | - * Check if the URL can be served by localhost |
61 | | - */ |
62 | | -function wfIsLocalURL( $url ) { |
63 | | - global $wgCommandLineMode, $wgConf; |
64 | | - if ( $wgCommandLineMode ) { |
65 | | - return false; |
66 | | - } |
| 60 | + /** |
| 61 | + * Check if the URL can be served by localhost |
| 62 | + */ |
| 63 | + function isLocalURL( $url ) { |
| 64 | + global $wgCommandLineMode, $wgConf; |
| 65 | + if ( $wgCommandLineMode ) { |
| 66 | + return false; |
| 67 | + } |
67 | 68 | |
68 | | - // Extract host part |
69 | | - $matches = array(); |
70 | | - if ( preg_match( '!^http://([\w.-]+)[/:].*$!', $url, $matches ) ) { |
71 | | - $host = $matches[1]; |
72 | | - // Split up dotwise |
73 | | - $domainParts = explode( '.', $host ); |
74 | | - // Check if this domain or any superdomain is listed in $wgConf as a local virtual host |
75 | | - $domainParts = array_reverse( $domainParts ); |
76 | | - for ( $i = 0; $i < count( $domainParts ); $i++ ) { |
77 | | - $domainPart = $domainParts[$i]; |
78 | | - if ( $i == 0 ) { |
79 | | - $domain = $domainPart; |
80 | | - } else { |
81 | | - $domain = $domainPart . '.' . $domain; |
| 69 | + // Extract host part |
| 70 | + $matches = array(); |
| 71 | + if ( preg_match( '!^http://([\w.-]+)[/:].*$!', $url, $matches ) ) { |
| 72 | + $host = $matches[1]; |
| 73 | + // Split up dotwise |
| 74 | + $domainParts = explode( '.', $host ); |
| 75 | + // Check if this domain or any superdomain is listed in $wgConf as a local virtual host |
| 76 | + $domainParts = array_reverse( $domainParts ); |
| 77 | + for ( $i = 0; $i < count( $domainParts ); $i++ ) { |
| 78 | + $domainPart = $domainParts[$i]; |
| 79 | + if ( $i == 0 ) { |
| 80 | + $domain = $domainPart; |
| 81 | + } else { |
| 82 | + $domain = $domainPart . '.' . $domain; |
| 83 | + } |
| 84 | + if ( $wgConf->isLocalVHost( $domain ) ) { |
| 85 | + return true; |
| 86 | + } |
82 | 87 | } |
83 | | - if ( $wgConf->isLocalVHost( $domain ) ) { |
84 | | - return true; |
85 | | - } |
86 | 88 | } |
| 89 | + return false; |
87 | 90 | } |
88 | | - return false; |
89 | 91 | } |
90 | | - |
91 | 92 | ?> |
Index: trunk/phase3/includes/ParserXML.php |
— | — | @@ -5,9 +5,6 @@ |
6 | 6 | * @subpackage Experimental |
7 | 7 | */ |
8 | 8 | |
9 | | -/** */ |
10 | | -require_once ('Parser.php'); |
11 | | - |
12 | 9 | /** |
13 | 10 | * This should one day become the XML->(X)HTML parser |
14 | 11 | * Based on work by Jan Hidders and Magnus Manske |
Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -9,8 +9,6 @@ |
10 | 10 | if( !defined( 'MEDIAWIKI' ) ) |
11 | 11 | die( -1 ); |
12 | 12 | |
13 | | -require_once( 'Image.php' ); |
14 | | - |
15 | 13 | /** |
16 | 14 | * Special handling for image description pages |
17 | 15 | * @package MediaWiki |
— | — | @@ -309,9 +307,8 @@ |
310 | 308 | $wgOut->addHTML($sharedtext); |
311 | 309 | |
312 | 310 | if ($wgRepositoryBaseUrl && $wgFetchCommonsDescriptions) { |
313 | | - require_once("HttpFunctions.php"); |
314 | 311 | $ur = ini_set('allow_url_fopen', true); |
315 | | - $text = wfGetHTTP($url . '?action=render'); |
| 312 | + $text = HttpFunctions::getHTTP($url . '?action=render'); |
316 | 313 | ini_set('allow_url_fopen', $ur); |
317 | 314 | if ($text) |
318 | 315 | $this->mExtraDescription = $text; |
— | — | @@ -674,7 +671,6 @@ |
675 | 672 | } |
676 | 673 | |
677 | 674 | function blockedIPpage() { |
678 | | - require_once( 'EditPage.php' ); |
679 | 675 | $edit = new EditPage( $this ); |
680 | 676 | return $edit->blockedIPpage(); |
681 | 677 | } |
Index: trunk/phase3/includes/SearchMySQL4.php |
— | — | @@ -23,8 +23,6 @@ |
24 | 24 | * @subpackage Search |
25 | 25 | */ |
26 | 26 | |
27 | | -require_once( 'SearchMySQL.php' ); |
28 | | - |
29 | 27 | /** |
30 | 28 | * @package MediaWiki |
31 | 29 | * @subpackage Search |
Index: trunk/phase3/includes/LinksUpdate.php |
— | — | @@ -119,7 +119,6 @@ |
120 | 120 | if ( $this->mRecursive ) { |
121 | 121 | $tlto = $this->mTitle->getTemplateLinksTo(); |
122 | 122 | if ( count( $tlto ) ) { |
123 | | - require_once( 'JobQueue.php' ); |
124 | 123 | Job::queueLinksJobs( $tlto ); |
125 | 124 | } |
126 | 125 | } |
— | — | @@ -155,7 +154,6 @@ |
156 | 155 | if ( $this->mRecursive ) { |
157 | 156 | $tlto = $this->mTitle->getTemplateLinksTo(); |
158 | 157 | if ( count( $tlto ) ) { |
159 | | - require_once( 'JobQueue.php' ); |
160 | 158 | Job::queueLinksJobs( $tlto ); |
161 | 159 | } |
162 | 160 | } |
Index: trunk/phase3/includes/SpecialVersion.php |
— | — | @@ -190,7 +190,7 @@ |
191 | 191 | * @return string |
192 | 192 | */ |
193 | 193 | function IPInfo() { |
194 | | - $ip = str_replace( '--', ' - ', htmlspecialchars( wfGetIP() ) ); |
| 194 | + $ip = str_replace( '--', ' - ', htmlspecialchars( ProxyTools::getIP() ) ); |
195 | 195 | return "<!-- visited from $ip -->\n" . |
196 | 196 | "<span style='display:none'>visited from $ip</span>"; |
197 | 197 | } |
Index: trunk/phase3/includes/Block.php |
— | — | @@ -169,7 +169,7 @@ |
170 | 170 | { |
171 | 171 | $fname = 'Block::loadRange'; |
172 | 172 | |
173 | | - $iaddr = wfIP2Hex( $address ); |
| 173 | + $iaddr = ProxyTools::IP2Hex( $address ); |
174 | 174 | if ( $iaddr === false ) { |
175 | 175 | # Invalid address |
176 | 176 | return false; |
— | — | @@ -207,7 +207,7 @@ |
208 | 208 | * Determine if a given integer IPv4 address is in a given CIDR network |
209 | 209 | */ |
210 | 210 | function isAddressInRange( $addr, $range ) { |
211 | | - list( $network, $bits ) = wfParseCIDR( $range ); |
| 211 | + list( $network, $bits ) = ProxyTools::parseCIDR( $range ); |
212 | 212 | if ( $network !== false && $addr >> ( 32 - $bits ) == $network >> ( 32 - $bits ) ) { |
213 | 213 | return true; |
214 | 214 | } else { |
— | — | @@ -241,7 +241,7 @@ |
242 | 242 | $this->mRangeStart = ''; |
243 | 243 | $this->mRangeEnd = ''; |
244 | 244 | if ( $this->mUser == 0 ) { |
245 | | - list( $network, $bits ) = wfParseCIDR( $this->mAddress ); |
| 245 | + list( $network, $bits ) = ProxyTools::parseCIDR( $this->mAddress ); |
246 | 246 | if ( $network !== false ) { |
247 | 247 | $this->mRangeStart = sprintf( '%08X', $network ); |
248 | 248 | $this->mRangeEnd = sprintf( '%08X', $network + (1 << (32 - $bits)) - 1 ); |
— | — | @@ -431,7 +431,7 @@ |
432 | 432 | $parts = explode( '/', $range ); |
433 | 433 | if ( count( $parts ) == 2 ) { |
434 | 434 | $shift = 32 - $parts[1]; |
435 | | - $ipint = wfIP2Unsigned( $parts[0] ); |
| 435 | + $ipint = ProxyTools::IP2Unsigned( $parts[0] ); |
436 | 436 | $ipint = $ipint >> $shift << $shift; |
437 | 437 | $newip = long2ip( $ipint ); |
438 | 438 | $range = "$newip/{$parts[1]}"; |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -5,9 +5,6 @@ |
6 | 6 | * @package MediaWiki |
7 | 7 | */ |
8 | 8 | |
9 | | -if ( $wgUseTeX ) |
10 | | - require_once 'Math.php'; |
11 | | - |
12 | 9 | /** |
13 | 10 | * @todo document |
14 | 11 | * @package MediaWiki |
— | — | @@ -650,7 +647,7 @@ |
651 | 648 | |
652 | 649 | $id = $wgUser->blockedBy(); |
653 | 650 | $reason = $wgUser->blockedFor(); |
654 | | - $ip = wfGetIP(); |
| 651 | + $ip = ProxyTools::getIP(); |
655 | 652 | |
656 | 653 | if ( is_numeric( $id ) ) { |
657 | 654 | $name = User::whoIs( $id ); |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -343,8 +343,7 @@ |
344 | 344 | $this->credits = false; |
345 | 345 | |
346 | 346 | if (isset($wgMaxCredits) && $wgMaxCredits != 0) { |
347 | | - require_once("Credits.php"); |
348 | | - $this->credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); |
| 347 | + $this->credits = Credits::getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); |
349 | 348 | } else { |
350 | 349 | $tpl->set('lastmod', $this->lastModified()); |
351 | 350 | } |
Index: trunk/phase3/includes/ChangesList.php |
— | — | @@ -7,7 +7,6 @@ |
8 | 8 | * - recent changes |
9 | 9 | */ |
10 | 10 | |
11 | | -require_once("RecentChange.php"); |
12 | 11 | /** |
13 | 12 | * @todo document |
14 | 13 | * @package MediaWiki |
Index: trunk/phase3/includes/SpecialUserlogin.php |
— | — | @@ -210,7 +210,7 @@ |
211 | 211 | return false; |
212 | 212 | } |
213 | 213 | |
214 | | - $ip = wfGetIP(); |
| 214 | + $ip = ProxyTools::getIP(); |
215 | 215 | if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) && |
216 | 216 | $wgUser->inSorbsBlacklist( $ip ) ) |
217 | 217 | { |
— | — | @@ -416,7 +416,7 @@ |
417 | 417 | |
418 | 418 | $u->saveSettings(); |
419 | 419 | |
420 | | - $ip = wfGetIP(); |
| 420 | + $ip = ProxyTools::getIP(); |
421 | 421 | if ( '' == $ip ) { $ip = '(Unknown)'; } |
422 | 422 | |
423 | 423 | $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np, $wgServer . $wgScript ); |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -4,12 +4,6 @@ |
5 | 5 | * @package MediaWiki |
6 | 6 | */ |
7 | 7 | |
8 | | -/** |
9 | | - * Need the CacheManager to be loaded |
10 | | - */ |
11 | | -require_once( 'CacheManager.php' ); |
12 | | -require_once( 'Revision.php' ); |
13 | | - |
14 | 8 | $wgArticleCurContentFields = false; |
15 | 9 | $wgArticleOldContentFields = false; |
16 | 10 | |
— | — | @@ -762,7 +756,6 @@ |
763 | 757 | # diff page instead of the article. |
764 | 758 | |
765 | 759 | if ( !is_null( $diff ) ) { |
766 | | - require_once( 'DifferenceEngine.php' ); |
767 | 760 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
768 | 761 | |
769 | 762 | $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid ); |
— | — | @@ -1233,7 +1226,6 @@ |
1234 | 1227 | |
1235 | 1228 | Article::onArticleCreate( $this->mTitle ); |
1236 | 1229 | if(!$suppressRC) { |
1237 | | - require_once( 'RecentChange.php' ); |
1238 | 1230 | $rcid = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, 'default', |
1239 | 1231 | '', strlen( $text ), $revisionId ); |
1240 | 1232 | # Mark as patrolled if the user can and has the option set |
— | — | @@ -1440,7 +1432,6 @@ |
1441 | 1433 | $dbw->rollback(); |
1442 | 1434 | } else { |
1443 | 1435 | # Update recentchanges and purge cache and whatnot |
1444 | | - require_once( 'RecentChange.php' ); |
1445 | 1436 | $bot = (int)($wgUser->isBot() || $forceBot); |
1446 | 1437 | $rcid = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary, |
1447 | 1438 | $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, |
— | — | @@ -1564,7 +1555,6 @@ |
1565 | 1556 | $rcid = $wgRequest->getVal( 'rcid' ); |
1566 | 1557 | if ( !is_null ( $rcid ) ) { |
1567 | 1558 | if( wfRunHooks( 'MarkPatrolled', array( &$rcid, &$wgUser, false ) ) ) { |
1568 | | - require_once( 'RecentChange.php' ); |
1569 | 1559 | RecentChange::markPatrolled( $rcid ); |
1570 | 1560 | wfRunHooks( 'MarkPatrolledComplete', array( &$rcid, &$wgUser, false ) ); |
1571 | 1561 | $wgOut->setPagetitle( wfMsg( 'markedaspatrolled' ) ); |
— | — | @@ -1679,7 +1669,6 @@ |
1680 | 1670 | * action=protect handler |
1681 | 1671 | */ |
1682 | 1672 | function protect() { |
1683 | | - require_once 'ProtectionForm.php'; |
1684 | 1673 | $form = new ProtectionForm( $this ); |
1685 | 1674 | $form->show(); |
1686 | 1675 | } |
Index: trunk/phase3/includes/WebRequest.php |
— | — | @@ -117,7 +117,6 @@ |
118 | 118 | $data = $wgContLang->checkTitleEncoding( $data ); |
119 | 119 | } |
120 | 120 | } |
121 | | - require_once( 'normal/UtfNormal.php' ); |
122 | 121 | $data = $this->normalizeUnicode( $data ); |
123 | 122 | return $data; |
124 | 123 | } else { |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -27,8 +27,6 @@ |
28 | 28 | |
29 | 29 | |
30 | 30 | require_once( 'DatabaseFunctions.php' ); |
31 | | -require_once( 'UpdateClasses.php' ); |
32 | | -require_once( 'LogPage.php' ); |
33 | 31 | require_once( 'normal/UtfNormalUtil.php' ); |
34 | 32 | require_once( 'XmlFunctions.php' ); |
35 | 33 | |
— | — | @@ -1508,11 +1506,6 @@ |
1509 | 1507 | return $wgMimeMagic; |
1510 | 1508 | } |
1511 | 1509 | |
1512 | | - if (!class_exists("MimeMagic")) { |
1513 | | - #include on demand |
1514 | | - require_once("MimeMagic.php"); |
1515 | | - } |
1516 | | - |
1517 | 1510 | $wgMimeMagic= new MimeMagic(); |
1518 | 1511 | |
1519 | 1512 | return $wgMimeMagic; |
— | — | @@ -1861,4 +1854,27 @@ |
1862 | 1855 | } |
1863 | 1856 | } |
1864 | 1857 | |
| 1858 | +/***** DEPRECATED INTERFACES *******/ |
| 1859 | +function wfGetForwardedFor() { return ProxyTools::getForwardedFor(); } |
| 1860 | +function wfGetIP() { return ProxyTools::getIP(); } |
| 1861 | +function wfIP2Unsigned($ip) { return ProxyTools::IP2Unsigned($ip); } |
| 1862 | +function wfIP2Hex($ip) { return ProxyTools::IP2Hex($ip); } |
| 1863 | +function wfIsIPPublic($ip) { return ProxyTools::isIPPublic($ip); } |
| 1864 | +function wfProxyCheck() { return ProxyTools::proxyCheck(); } |
| 1865 | +function wfParseCIDR($range) { return ProxyTools::parseCIDR($range); } |
| 1866 | +function wfIsLocallyBlockedProxy($ip) { return ProxyTools::isLocallyBlockedProxy($ip); } |
| 1867 | + |
| 1868 | +function wfGetCache($type) { return ObjectCacheManager::getCache($type); } |
| 1869 | +function wfGetMainCache() { return ObjectCacheManager::getMainCache(); } |
| 1870 | +function wfGetMessageCacheStorage() { return ObjectCacheManager::getMessageCache(); } |
| 1871 | +function wfGetParserCacheStorage() { return ObjectCacheManager::getParserCache(); } |
| 1872 | + |
| 1873 | +function renderMath($tex) { return MathRenderer::renderMath($tex); } |
| 1874 | + |
| 1875 | +function showCreditsPage($article) { return Credits::showCreditsPage($article); } |
| 1876 | +function getCredits($article, $cnt, $showIfMax=true) { return Credits::getCredits($article,$cnt,$showIfMax); } |
| 1877 | + |
| 1878 | +function wfGetHTTP( $url, $timeout = 'default' ) { return HttpFunctions::getHTTP($url,$timeout); } |
| 1879 | +function wfIsLocalURL( $url ) { return HttpFunctions::isLocalURL($url); } |
| 1880 | + |
1865 | 1881 | ?> |
Index: trunk/phase3/includes/DatabaseOracle.php |
— | — | @@ -6,11 +6,6 @@ |
7 | 7 | * @package MediaWiki |
8 | 8 | */ |
9 | 9 | |
10 | | -/** |
11 | | - * Depends on database |
12 | | - */ |
13 | | -require_once( 'Database.php' ); |
14 | | - |
15 | 10 | class OracleBlob extends DBObject { |
16 | 11 | function isLOB() { |
17 | 12 | return true; |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -0,0 +1,219 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* This defines autoloading handler for whole MediaWiki framework */ |
| 5 | +function __autoload($class_name) { |
| 6 | + $classes = array( |
| 7 | + 'AjaxDispatcher' => 'AjaxDispatcher.php', |
| 8 | + 'AjaxCachePolicy' => 'AjaxFunctions.php', |
| 9 | + 'Article' => 'Article.php', |
| 10 | + 'AuthPlugin' => 'AuthPlugin.php', |
| 11 | + 'BagOStuff' => 'BagOStuff.php', |
| 12 | + 'HashBagOStuff' => 'BagOStuff.php', |
| 13 | + 'SqlBagOStuff' => 'BagOStuff.php', |
| 14 | + 'MediaWikiBagOStuff' => 'BagOStuff.php', |
| 15 | + 'TurckBagOStuff' => 'BagOStuff.php', |
| 16 | + 'APCBagOStuff' => 'BagOStuff.php', |
| 17 | + 'eAccelBagOStuff' => 'BagOStuff.php', |
| 18 | + 'Block' => 'Block.php', |
| 19 | + 'CacheManager' => 'CacheManager.php', |
| 20 | + 'CategoryPage' => 'CategoryPage.php', |
| 21 | + 'Categoryfinder' => 'Categoryfinder.php', |
| 22 | + 'RCCacheEntry' => 'ChangesList.php', |
| 23 | + 'ChangesList' => 'ChangesList.php', |
| 24 | + 'OldChangesList' => 'ChangesList.php', |
| 25 | + 'EnhancedChangesList' => 'ChangesList.php', |
| 26 | + 'DBObject' => 'Database.php', |
| 27 | + 'Database' => 'Database.php', |
| 28 | + 'DatabaseMysql' => 'Database.php', |
| 29 | + 'ResultWrapper' => 'Database.php', |
| 30 | + 'OracleBlob' => 'DatabaseOracle.php', |
| 31 | + 'DatabaseOracle' => 'DatabaseOracle.php', |
| 32 | + 'DatabasePgsql' => 'DatabasePostgreSQL.php', |
| 33 | + 'DatabasePostgreSQL' => 'DatabasePostgreSQL.php', |
| 34 | + 'DateFormatter' => 'DateFormatter.php', |
| 35 | + 'DifferenceEngine' => 'DifferenceEngine.php', |
| 36 | + '_DiffOp' => 'DifferenceEngine.php', |
| 37 | + '_DiffOp_Copy' => 'DifferenceEngine.php', |
| 38 | + '_DiffOp_Delete' => 'DifferenceEngine.php', |
| 39 | + '_DiffOp_Add' => 'DifferenceEngine.php', |
| 40 | + '_DiffOp_Change' => 'DifferenceEngine.php', |
| 41 | + '_DiffEngine' => 'DifferenceEngine.php', |
| 42 | + 'Diff' => 'DifferenceEngine.php', |
| 43 | + 'MappedDiff' => 'DifferenceEngine.php', |
| 44 | + 'DiffFormatter' => 'DifferenceEngine.php', |
| 45 | + '_HWLDF_WordAccumulator' => 'DifferenceEngine.php', |
| 46 | + 'WordLevelDiff' => 'DifferenceEngine.php', |
| 47 | + 'TableDiffFormatter' => 'DifferenceEngine.php', |
| 48 | + 'EditPage' => 'EditPage.php', |
| 49 | + 'Exif' => 'Exif.php', |
| 50 | + 'FormatExif' => 'Exif.php', |
| 51 | + 'WikiExporter' => 'Export.php', |
| 52 | + 'XmlDumpWriter' => 'Export.php', |
| 53 | + 'DumpOutput' => 'Export.php', |
| 54 | + 'DumpFileOutput' => 'Export.php', |
| 55 | + 'DumpPipeOutput' => 'Export.php', |
| 56 | + 'DumpGZipOutput' => 'Export.php', |
| 57 | + 'DumpBZip2Output' => 'Export.php', |
| 58 | + 'Dump7ZipOutput' => 'Export.php', |
| 59 | + 'DumpFilter' => 'Export.php', |
| 60 | + 'DumpNotalkFilter' => 'Export.php', |
| 61 | + 'DumpNamespaceFilter' => 'Export.php', |
| 62 | + 'DumpLatestFilter' => 'Export.php', |
| 63 | + 'DumpMultiWriter' => 'Export.php', |
| 64 | + 'ExternalEdit' => 'ExternalEdit.php', |
| 65 | + 'ExternalStore' => 'ExternalStore.php', |
| 66 | + 'ExternalStoreDB' => 'ExternalStoreDB.php', |
| 67 | + 'ExternalStoreHttp' => 'ExternalStoreHttp.php', |
| 68 | + 'FakeTitle' => 'FakeTitle.php', |
| 69 | + 'FeedItem' => 'Feed.php', |
| 70 | + 'ChannelFeed' => 'Feed.php', |
| 71 | + 'RSSFeed' => 'Feed.php', |
| 72 | + 'AtomFeed' => 'Feed.php', |
| 73 | + 'ReplacerCallback' => 'GlobalFunctions.php', |
| 74 | + 'Group' => 'Group.php', |
| 75 | + 'HTMLForm' => 'HTMLForm.php', |
| 76 | + 'HistoryBlob' => 'HistoryBlob.php', |
| 77 | + 'ConcatenatedGzipHistoryBlob' => 'HistoryBlob.php', |
| 78 | + 'HistoryBlobStub' => 'HistoryBlob.php', |
| 79 | + 'HistoryBlobCurStub' => 'HistoryBlob.php', |
| 80 | + 'Image' => 'Image.php', |
| 81 | + 'ThumbnailImage' => 'Image.php', |
| 82 | + 'ImageGallery' => 'ImageGallery.php', |
| 83 | + 'ImagePage' => 'ImagePage.php', |
| 84 | + 'ImageHistoryList' => 'ImagePage.php', |
| 85 | + 'ImageRemote' => 'ImageRemote.php', |
| 86 | + 'Job' => 'JobQueue.php', |
| 87 | + 'Licenses' => 'Licenses.php', |
| 88 | + 'License' => 'Licenses.php', |
| 89 | + 'LinkBatch' => 'LinkBatch.php', |
| 90 | + 'LinkCache' => 'LinkCache.php', |
| 91 | + 'LinkFilter' => 'LinkFilter.php', |
| 92 | + 'Linker' => 'Linker.php', |
| 93 | + 'LinksUpdate' => 'LinksUpdate.php', |
| 94 | + 'LoadBalancer' => 'LoadBalancer.php', |
| 95 | + 'LogPage' => 'LogPage.php', |
| 96 | + 'MacBinary' => 'MacBinary.php', |
| 97 | + 'MagicWord' => 'MagicWord.php', |
| 98 | + 'MathRenderer' => 'Math.php', |
| 99 | + 'MessageCache' => 'MessageCache.php', |
| 100 | + 'MimeMagic' => 'MimeMagic.php', |
| 101 | + 'Namespace' => 'Namespace.php', |
| 102 | + 'FakeMemCachedClient' => 'ObjectCache.php', |
| 103 | + 'ObjectCacheManager' => 'ObjectCache.php', |
| 104 | + 'MemCachedClientforWiki' => 'ObjectCache.php', |
| 105 | + 'OutputPage' => 'OutputPage.php', |
| 106 | + 'PageHistory' => 'PageHistory.php', |
| 107 | + 'Parser' => 'Parser.php', |
| 108 | + 'ParserOutput' => 'Parser.php', |
| 109 | + 'ParserOptions' => 'Parser.php', |
| 110 | + 'ParserCache' => 'ParserCache.php', |
| 111 | + 'element' => 'ParserXML.php', |
| 112 | + 'xml2php' => 'ParserXML.php', |
| 113 | + 'ParserXML' => 'ParserXML.php', |
| 114 | + 'ProfilerSimple' => 'ProfilerSimple.php', |
| 115 | + 'ProfilerSimpleUDP' => 'ProfilerSimpleUDP.php', |
| 116 | + 'Profiler' => 'Profiling.php', |
| 117 | + 'ProxyTools' => 'ProxyTools.php', |
| 118 | + 'ProtectionForm' => 'ProtectionForm.php', |
| 119 | + 'QueryPage' => 'QueryPage.php', |
| 120 | + 'PageQueryPage' => 'QueryPage.php', |
| 121 | + 'RawPage' => 'RawPage.php', |
| 122 | + 'RecentChange' => 'RecentChange.php', |
| 123 | + 'Revision' => 'Revision.php', |
| 124 | + 'Sanitizer' => 'Sanitizer.php', |
| 125 | + 'SearchEngine' => 'SearchEngine.php', |
| 126 | + 'SearchResultSet' => 'SearchEngine.php', |
| 127 | + 'SearchResult' => 'SearchEngine.php', |
| 128 | + 'SearchEngineDummy' => 'SearchEngine.php', |
| 129 | + 'SearchMySQL' => 'SearchMySQL.php', |
| 130 | + 'MySQLSearchResultSet' => 'SearchMySQL.php', |
| 131 | + 'SearchMySQL4' => 'SearchMySQL4.php', |
| 132 | + 'SearchTsearch2' => 'SearchTsearch2.php', |
| 133 | + 'SearchUpdate' => 'SearchUpdate.php', |
| 134 | + 'SearchUpdateMyISAM' => 'SearchUpdate.php', |
| 135 | + 'SiteConfiguration' => 'SiteConfiguration.php', |
| 136 | + 'SiteStatsUpdate' => 'SiteStatsUpdate.php', |
| 137 | + 'Skin' => 'Skin.php', |
| 138 | + 'MediaWiki_I18N' => 'SkinTemplate.php', |
| 139 | + 'SkinTemplate' => 'SkinTemplate.php', |
| 140 | + 'QuickTemplate' => 'SkinTemplate.php', |
| 141 | + 'SpecialAllpages' => 'SpecialAllpages.php', |
| 142 | + 'AncientPagesPage' => 'SpecialAncientpages.php', |
| 143 | + 'IPBlockForm' => 'SpecialBlockip.php', |
| 144 | + 'BookSourceList' => 'SpecialBooksources.php', |
| 145 | + 'BrokenRedirectsPage' => 'SpecialBrokenRedirects.php', |
| 146 | + 'CategoriesPage' => 'SpecialCategories.php', |
| 147 | + 'EmailConfirmation' => 'SpecialConfirmemail.php', |
| 148 | + 'contribs_finder' => 'SpecialContributions.php', |
| 149 | + 'DeadendPagesPage' => 'SpecialDeadendpages.php', |
| 150 | + 'DisambiguationsPage' => 'SpecialDisambiguations.php', |
| 151 | + 'DoubleRedirectsPage' => 'SpecialDoubleRedirects.php', |
| 152 | + 'EmailUserForm' => 'SpecialEmailuser.php', |
| 153 | + 'GroupsForm' => 'SpecialGroups.php', |
| 154 | + 'WikiRevision' => 'SpecialImport.php', |
| 155 | + 'WikiImporter' => 'SpecialImport.php', |
| 156 | + 'ImportStringSource' => 'SpecialImport.php', |
| 157 | + 'ImportStreamSource' => 'SpecialImport.php', |
| 158 | + 'IPUnblockForm' => 'SpecialIpblocklist.php', |
| 159 | + 'ListredirectsPage' => 'SpecialListredirects.php', |
| 160 | + 'ListUsersPage' => 'SpecialListusers.php', |
| 161 | + 'DBLockForm' => 'SpecialLockdb.php', |
| 162 | + 'LogReader' => 'SpecialLog.php', |
| 163 | + 'LogViewer' => 'SpecialLog.php', |
| 164 | + 'LonelyPagesPage' => 'SpecialLonelypages.php', |
| 165 | + 'LongPagesPage' => 'SpecialLongpages.php', |
| 166 | + 'MIMEsearchPage' => 'SpecialMIMEsearch.php', |
| 167 | + 'MostcategoriesPage' => 'SpecialMostcategories.php', |
| 168 | + 'MostimagesPage' => 'SpecialMostimages.php', |
| 169 | + 'MostlinkedPage' => 'SpecialMostlinked.php', |
| 170 | + 'MostlinkedCategoriesPage' => 'SpecialMostlinkedcategories.php', |
| 171 | + 'MostrevisionsPage' => 'SpecialMostrevisions.php', |
| 172 | + 'MovePageForm' => 'SpecialMovepage.php', |
| 173 | + 'NewPagesPage' => 'SpecialNewpages.php', |
| 174 | + 'SpecialPage' => 'SpecialPage.php', |
| 175 | + 'UnlistedSpecialPage' => 'SpecialPage.php', |
| 176 | + 'IncludableSpecialPage' => 'SpecialPage.php', |
| 177 | + 'PopularPagesPage' => 'SpecialPopularpages.php', |
| 178 | + 'PreferencesForm' => 'SpecialPreferences.php', |
| 179 | + 'SpecialPrefixindex' => 'SpecialPrefixindex.php', |
| 180 | + 'RevisionDeleteForm' => 'SpecialRevisiondelete.php', |
| 181 | + 'RevisionDeleter' => 'SpecialRevisiondelete.php', |
| 182 | + 'SpecialSearch' => 'SpecialSearch.php', |
| 183 | + 'ShortPagesPage' => 'SpecialShortpages.php', |
| 184 | + 'UncategorizedCategoriesPage' => 'SpecialUncategorizedcategories.php', |
| 185 | + 'UncategorizedPagesPage' => 'SpecialUncategorizedpages.php', |
| 186 | + 'PageArchive' => 'SpecialUndelete.php', |
| 187 | + 'UndeleteForm' => 'SpecialUndelete.php', |
| 188 | + 'DBUnlockForm' => 'SpecialUnlockdb.php', |
| 189 | + 'UnusedCategoriesPage' => 'SpecialUnusedcategories.php', |
| 190 | + 'UnusedimagesPage' => 'SpecialUnusedimages.php', |
| 191 | + 'UnusedtemplatesPage' => 'SpecialUnusedtemplates.php', |
| 192 | + 'UnwatchedpagesPage' => 'SpecialUnwatchedpages.php', |
| 193 | + 'UploadForm' => 'SpecialUpload.php', |
| 194 | + 'UploadFormMogile' => 'SpecialUploadMogile.php', |
| 195 | + 'LoginForm' => 'SpecialUserlogin.php', |
| 196 | + 'UserrightsForm' => 'SpecialUserrights.php', |
| 197 | + 'SpecialVersion' => 'SpecialVersion.php', |
| 198 | + 'WantedCategoriesPage' => 'SpecialWantedcategories.php', |
| 199 | + 'WantedPagesPage' => 'SpecialWantedpages.php', |
| 200 | + 'WhatLinksHerePage' => 'SpecialWhatlinkshere.php', |
| 201 | + 'SquidUpdate' => 'SquidUpdate.php', |
| 202 | + 'Title' => 'Title.php', |
| 203 | + 'User' => 'User.php', |
| 204 | + 'MailAddress' => 'UserMailer.php', |
| 205 | + 'EmailNotification' => 'UserMailer.php', |
| 206 | + 'WatchedItem' => 'WatchedItem.php', |
| 207 | + 'WebRequest' => 'WebRequest.php', |
| 208 | + 'FauxRequest' => 'WebRequest.php', |
| 209 | + 'MediaWiki' => 'Wiki.php', |
| 210 | + 'WikiError' => 'WikiError.php', |
| 211 | + 'WikiErrorMsg' => 'WikiError.php', |
| 212 | + 'WikiXmlError' => 'WikiError.php', |
| 213 | + 'ZhClient' => 'ZhClient.php', |
| 214 | + 'memcached' => 'memcached-client.php', |
| 215 | + 'UtfNormal' => 'normal/UtfNormal.php' |
| 216 | + ); |
| 217 | + require($classes[$class_name]); |
| 218 | +} |
| 219 | + |
| 220 | +?> |
\ No newline at end of file |