Restore Special:Userrights and bureaucrat log messages mysteriously deleted under...
[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 * @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 */
25 var $langObj;
26
27 /**
28 * Constructor
29 */
30 function SpecialVersion() {
31 // English motherfucker, do you speak it?
32 $this->langObj = setupLangObj( 'LanguageEn' );
33 $this->langObj->initEncoding();
34 }
35
36 function execute() {
37 global $wgOut;
38
39 $wgOut->addWikiText( $this->MediaWikiCredits() . $this->extensionCredits() . $this->wgHooks() );
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 wfRunHooks( 'SpecialVersionExtensionTypes', array( &$extensionTypes ) );
90
91 $out = "\n* Extensions:\n";
92 foreach ( $extensionTypes as $type => $text ) {
93 if ( count( @$wgExtensionCredits[$type] ) ) {
94 $out .= "** $text:\n";
95 foreach ( $wgExtensionCredits[$type] as $extension ) {
96 wfSuppressWarnings();
97 $out .= $this->formatCredits(
98 $extension['name'],
99 $extension['version'],
100 $extension['author'],
101 $extension['url'],
102 $extension['description']
103 );
104 wfRestoreWarnings();
105 }
106 }
107 }
108
109 if ( count( $wgExtensionFunctions ) ) {
110 $out .= "** Extension functions:\n";
111 $out .= '***' . $this->langObj->listToText( $wgExtensionFunctions ) . "\n";
112 }
113
114 if ( count( $wgSkinExtensionFunction ) ) {
115 $out .= "** Skin extension functions:\n";
116 $out .= '***' . $this->langObj->listToText( $wgSkinExtensionFunction ) . "\n";
117 }
118
119 return $out;
120 }
121
122 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
123 $ret = '*** ';
124 if ( isset( $url ) )
125 $ret .= "[$url ";
126 $ret .= "''$name";
127 if ( isset( $version ) )
128 $ret .= " (version $version)";
129 $ret .= "''";
130 if ( isset( $url ) )
131 $ret .= ']';
132 if ( isset( $description ) )
133 $ret .= ', ' . $description;
134 if ( isset( $description ) && isset( $author ) )
135 $ret .= ', ';
136 if ( isset( $author ) )
137 $ret .= ' by ' . $this->langObj->listToText( (array)$author );
138
139 return htmlspecialchars( $ret ) . "\n";
140 }
141
142 function wgHooks() {
143 global $wgHooks;
144
145 $ret = "* Hooks:\n";
146 foreach ($wgHooks as $hook => $hooks)
147 $ret .= "** $hook: " . $this->langObj->listToText( $hooks ) . "\n";
148
149 return $ret;
150 }
151
152 function IPInfo() {
153 $ip = str_replace( '--', ' - - ', htmlspecialchars( wfGetIP() ) );
154 return "<!-- visited from $ip -->\n";
155 }
156 }
157 ?>