Deferred initialisation of $wgIP, because it's potentially slow, especially if and...
[lhc/web/wiklou.git] / includes / SpecialVersion.php
1 <?php
2 /**
3 * Give information about the version of MediaWiki, PHP, the DB and extensions
4 *
5 * @package MediaWiki
6 * @subpackage SpecialPage
7 *
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
10 */
11
12 /**
13 * constructor
14 */
15 function wfSpecialVersion() {
16 $version = new SpecialVersion;
17 $version->execute();
18 }
19
20 class SpecialVersion {
21 /**
22 * @var object
23 */
24 var $langObj;
25
26 /**
27 * Constructor
28 */
29 function SpecialVersion() {
30 // English motherfucker, do you speak it?
31 $this->langObj = setupLangObj( 'LanguageEn' );
32 $this->langObj->initEncoding();
33 }
34
35 function execute() {
36 global $wgOut;
37
38 $wgOut->setRobotpolicy( 'index,follow' );
39 $wgOut->addWikiText( $this->MediaWikiCredits() . $this->extensionCredits() );
40 $wgOut->addHTML( $this->IPInfo() );
41 }
42
43 function MediaWikiCredits() {
44 global $wgVersion;
45
46 $dbr =& wfGetDB( DB_SLAVE );
47
48 $ret =
49 "__NOTOC__
50 <div dir='ltr'>
51 This wiki is powered by '''[http://www.mediawiki.org/ MediaWiki]''',
52 copyright (C) 2001-2005 Magnus Manske, Brion Vibber, Lee Daniel Crocker,
53 Tim Starling, Erik Möller, and others.
54
55 MediaWiki is free software; you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
57 the Free Software Foundation; either version 2 of the License, or
58 (at your option) any later version.
59
60 MediaWiki is distributed in the hope that it will be useful,
61 but WITHOUT ANY WARRANTY; without even the implied warranty of
62 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63 GNU General Public License for more details.
64
65 You should have received [{{SERVER}}{{SCRIPTPATH}}/COPYING a copy of the GNU General Public License]
66 along with this program; if not, write to the Free Software
67 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
68 or [http://www.gnu.org/copyleft/gpl.html read it online]
69
70 * [http://www.mediawiki.org/ MediaWiki]: $wgVersion
71 * [http://www.php.net/ PHP]: " . phpversion() . " (" . php_sapi_name() . ")
72 * " . $dbr->getSoftwareLink() . ": " . $dbr->getServerVersion() . "
73 </div>";
74
75 return str_replace( "\t\t", '', $ret );
76 }
77
78 function extensionCredits() {
79 global $wgExtensionCredits, $wgExtensionFunctions, $wgSkinExtensionFunction;
80
81 if ( ! count( $wgExtensionCredits ) && ! count( $wgExtensionFunctions ) && ! count( $wgSkinExtensionFunction ) )
82 return '';
83
84 $extensionTypes = array(
85 'specialpage' => 'Special pages',
86 'parserhook' => 'Parser hooks',
87 'other' => 'Other',
88 );
89
90 $out = "\n* Extensions:\n";
91 foreach ( $extensionTypes as $type => $text ) {
92 if ( count( @$wgExtensionCredits[$type] ) ) {
93 $out .= "** $text:\n";
94 foreach ( $wgExtensionCredits[$type] as $extension ) {
95 wfSuppressWarnings();
96 $out .= $this->formatCredits(
97 $extension['name'],
98 $extension['version'],
99 $extension['author'],
100 $extension['url'],
101 $extension['description']
102 );
103 wfRestoreWarnings();
104 }
105 }
106 }
107
108 if ( count( $wgExtensionFunctions ) ) {
109 $out .= "** Extension functions:\n";
110 $out .= '***' . $this->langObj->listToText( $wgExtensionFunctions ) . "\n";
111 }
112
113 if ( count( $wgSkinExtensionFunction ) ) {
114 $out .= "** Skin extension functions:\n";
115 $out .= '***' . $this->langObj->listToText( $wgSkinExtensionFunction ) . "\n";
116 }
117
118 return $out;
119 }
120
121 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
122 $ret = '*** ';
123 if ( isset( $url ) )
124 $ret .= "[$url ";
125 $ret .= "''$name";
126 if ( isset( $version ) )
127 $ret .= " (version $version)";
128 $ret .= "''";
129 if ( isset( $url ) )
130 $ret .= ']';
131 if ( isset( $description ) )
132 $ret .= ', ' . $description;
133 if ( isset( $description ) && isset( $author ) )
134 $ret .= ', ';
135 if ( isset( $author ) )
136 $ret .= ' by ' . $this->langObj->listToText( (array)$author );
137
138 return "$ret\n";
139 }
140
141 function IPInfo() {
142
143 $ip = str_replace( '--', ' - - ', htmlspecialchars( wfGetIP() ) );
144 return "<!-- visited from $ip -->\n";
145 }
146 }
147 ?>