Remove errant string; now I look like a fscking noob
[lhc/web/wiklou.git] / includes / SpecialVersion.php
1 <?php
2 /**#@+
3 * Give information about the version of MediaWiki, PHP, server software, the DB and extensions
4 *
5 * @package MediaWiki
6 * @subpackage SpecialPage
7 *
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
10 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
11 */
12
13 /**
14 * constructor
15 */
16 function wfSpecialVersion() {
17 $version = new SpecialVersion;
18 $version->execute();
19 }
20
21 class SpecialVersion {
22 /**
23 * @var object
24 * @access private
25 */
26 var $langObj;
27
28 /**
29 * Constructor
30 */
31 function SpecialVersion() {
32 # Force to English language
33 $this->langObj = setupLangObj( 'LanguageEn' );
34 $this->langObj->initEncoding();
35 }
36
37 /**
38 * main()
39 */
40 function execute() {
41 global $wgOut;
42
43 $wgOut->addWikiText(
44 $this->MediaWikiCredits() .
45 $this->extensionCredits() .
46 $this->wgHooks()
47 );
48 $wgOut->addHTML( $this->IPInfo() );
49 }
50
51 /**#@+
52 * @access private
53 */
54
55 /**
56 * @static
57 */
58 function MediaWikiCredits() {
59 global $wgVersion;
60
61 $dbr =& wfGetDB( DB_SLAVE );
62
63 $ret =
64 "__NOTOC__
65 <div dir='ltr'>
66 This wiki is powered by '''[http://www.mediawiki.org/ MediaWiki]''',
67 copyright (C) 2001-2005 Magnus Manske, Brion Vibber, Lee Daniel Crocker,
68 Tim Starling, Erik Möller, and others.
69
70 MediaWiki is free software; you can redistribute it and/or modify
71 it under the terms of the GNU General Public License as published by
72 the Free Software Foundation; either version 2 of the License, or
73 (at your option) any later version.
74
75 MediaWiki is distributed in the hope that it will be useful,
76 but WITHOUT ANY WARRANTY; without even the implied warranty of
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78 GNU General Public License for more details.
79
80 You should have received [{{SERVER}}{{SCRIPTPATH}}/COPYING a copy of the GNU General Public License]
81 along with this program; if not, write to the Free Software
82 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
83 or [http://www.gnu.org/copyleft/gpl.html read it online]
84
85 * [http://www.mediawiki.org/ MediaWiki]: $wgVersion
86 * [http://www.php.net/ PHP]: " . phpversion() . " (" . php_sapi_name() . ")
87 " . $this->getServerSoftware() . "
88 * " . $dbr->getSoftwareLink() . ": " . $dbr->getServerVersion() . "
89 </div>";
90
91 return str_replace( "\t\t", '', $ret );
92 }
93
94 function getServerSoftware() {
95 # Return tweaked version of $_SERVER['SERVER_SOFTWARE']
96 if( isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
97 $osver = explode( ' ', $_SERVER['SERVER_SOFTWARE'] );
98 $ssoft = "* " . ( count( $osver ) > 1 ? $osver[0] . ' ' . $osver[1] : $osver[0] );
99 } else {
100 $ssoft = "";
101 }
102 return( $ssoft );
103 }
104
105 function extensionCredits() {
106 global $wgExtensionCredits, $wgExtensionFunctions, $wgSkinExtensionFunction;
107
108 if ( ! count( $wgExtensionCredits ) && ! count( $wgExtensionFunctions ) && ! count( $wgSkinExtensionFunction ) )
109 return '';
110
111 $extensionTypes = array(
112 'specialpage' => 'Special pages',
113 'parserhook' => 'Parser hooks',
114 'variable' => 'Variables',
115 'other' => 'Other',
116 );
117 wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
118
119 $out = "\n* Extensions:\n";
120 foreach ( $extensionTypes as $type => $text ) {
121 if ( count( @$wgExtensionCredits[$type] ) ) {
122 $out .= "** $text:\n";
123
124 usort( $wgExtensionCredits[$type], array( $this, 'compare' ) );
125
126 foreach ( $wgExtensionCredits[$type] as $extension ) {
127 wfSuppressWarnings();
128 $out .= $this->formatCredits(
129 $extension['name'],
130 $extension['version'],
131 $extension['author'],
132 $extension['url'],
133 $extension['description']
134 );
135 wfRestoreWarnings();
136 }
137 }
138 }
139
140 if ( count( $wgExtensionFunctions ) ) {
141 $out .= "** Extension functions:\n";
142 $out .= '***' . $this->langObj->listToText( $wgExtensionFunctions ) . "\n";
143 }
144
145 if ( count( $wgSkinExtensionFunction ) ) {
146 $out .= "** Skin extension functions:\n";
147 $out .= '***' . $this->langObj->listToText( $wgSkinExtensionFunction ) . "\n";
148 }
149
150 return $out;
151 }
152
153 function compare( $a, $b ) {
154 if ( $a['name'] === $b['name'] )
155 return 0;
156 else
157 return $this->langObj->lc( $a['name'] ) > $this->langObj->lc( $b['name'] ) ? 1 : -1;
158 }
159
160 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
161 $ret = '*** ';
162 if ( isset( $url ) )
163 $ret .= "[$url ";
164 $ret .= "''$name";
165 if ( isset( $version ) )
166 $ret .= " (version $version)";
167 $ret .= "''";
168 if ( isset( $url ) )
169 $ret .= ']';
170 if ( isset( $description ) )
171 $ret .= ', ' . $description;
172 if ( isset( $description ) && isset( $author ) )
173 $ret .= ', ';
174 if ( isset( $author ) )
175 $ret .= ' by ' . $this->langObj->listToText( (array)$author );
176
177 return "$ret\n";
178 }
179
180 function wgHooks() {
181 global $wgHooks;
182
183 $myWgHooks = $wgHooks;
184 ksort( $myWgHooks );
185
186 $ret = "* Hooks:\n";
187 foreach ($myWgHooks as $hook => $hooks)
188 $ret .= "** $hook:" . $this->langObj->listToText( $hooks ) . "\n";
189
190 return $ret;
191 }
192
193 /**
194 * @static
195 */
196 function IPInfo() {
197 $ip = str_replace( '--', ' - ', htmlspecialchars( wfGetIP() ) );
198 return "<!-- visited from $ip -->\n";
199 }
200
201 /**#@-*/
202 }
203
204 /**#@-*/
205 ?>