* (bug 3794) Include OS / platform info in Special:Version
[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 * @authors Ævar Arnfjörð Bjarmason <avarab@gmail.com>, Rob Church <robchur@gmail.com>
9 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason, Rob Church
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 $osver = explode( ' ', $_SERVER['SERVER_SOFTWARE'] );
97 return( count( $osver ) > 1 ? $osver[0] . ' ' . $osver[1] : $osver[0] );
98 }
99
100 function extensionCredits() {
101 global $wgExtensionCredits, $wgExtensionFunctions, $wgSkinExtensionFunction;
102
103 if ( ! count( $wgExtensionCredits ) && ! count( $wgExtensionFunctions ) && ! count( $wgSkinExtensionFunction ) )
104 return '';
105
106 $extensionTypes = array(
107 'specialpage' => 'Special pages',
108 'parserhook' => 'Parser hooks',
109 'variable' => 'Variables',
110 'other' => 'Other',
111 );
112 wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
113
114 $out = "\n* Extensions:\n";
115 foreach ( $extensionTypes as $type => $text ) {
116 if ( count( @$wgExtensionCredits[$type] ) ) {
117 $out .= "** $text:\n";
118
119 usort( $wgExtensionCredits[$type], array( $this, 'compare' ) );
120
121 foreach ( $wgExtensionCredits[$type] as $extension ) {
122 wfSuppressWarnings();
123 $out .= $this->formatCredits(
124 $extension['name'],
125 $extension['version'],
126 $extension['author'],
127 $extension['url'],
128 $extension['description']
129 );
130 wfRestoreWarnings();
131 }
132 }
133 }
134
135 if ( count( $wgExtensionFunctions ) ) {
136 $out .= "** Extension functions:\n";
137 $out .= '***' . $this->langObj->listToText( $wgExtensionFunctions ) . "\n";
138 }
139
140 if ( count( $wgSkinExtensionFunction ) ) {
141 $out .= "** Skin extension functions:\n";
142 $out .= '***' . $this->langObj->listToText( $wgSkinExtensionFunction ) . "\n";
143 }
144
145 return $out;
146 }
147
148 function compare( $a, $b ) {
149 if ( $a['name'] === $b['name'] )
150 return 0;
151 else
152 return $this->langObj->lc( $a['name'] ) > $this->langObj->lc( $b['name'] ) ? 1 : -1;
153 }
154
155 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
156 $ret = '*** ';
157 if ( isset( $url ) )
158 $ret .= "[$url ";
159 $ret .= "''$name";
160 if ( isset( $version ) )
161 $ret .= " (version $version)";
162 $ret .= "''";
163 if ( isset( $url ) )
164 $ret .= ']';
165 if ( isset( $description ) )
166 $ret .= ', ' . $description;
167 if ( isset( $description ) && isset( $author ) )
168 $ret .= ', ';
169 if ( isset( $author ) )
170 $ret .= ' by ' . $this->langObj->listToText( (array)$author );
171
172 return "$ret\n";
173 }
174
175 function wgHooks() {
176 global $wgHooks;
177
178 $myWgHooks = $wgHooks;
179 ksort( $myWgHooks );
180
181 $ret = "* Hooks:\n";
182 foreach ($myWgHooks as $hook => $hooks)
183 $ret .= "** $hook:" . $this->langObj->listToText( $hooks ) . "\n";
184
185 return $ret;
186 }
187
188 /**
189 * @static
190 */
191 function IPInfo() {
192 $ip = str_replace( '--', ' - ', htmlspecialchars( wfGetIP() ) );
193 return "<!-- visited from $ip -->\n";
194 }
195
196 /**#@-*/
197 }
198
199 /**#@-*/
200 ?>