Modified Special:Userlogout to subclass UnlistedSpecialPage
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogout.php
1 <?php
2 /**
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 */
19
20 /**
21 * Implements Special:Userlogout
22 * @ingroup SpecialPage
23 */
24 class SpecialUserlogout extends UnlistedSpecialPage {
25
26 function __construct() {
27 parent::__construct( 'Userlogout' );
28 }
29
30 function execute( $par ) {
31 global $wgUser, $wgOut;
32
33 /**
34 * Some satellite ISPs use broken precaching schemes that log people out straight after
35 * they're logged in (bug 17790). Luckily, there's a way to detect such requests.
36 */
37 if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], '&amp;' ) !== false ) {
38 wfDebug( "Special:Userlogout request {$_SERVER['REQUEST_URI']} looks suspicious, denying.\n" );
39 wfHttpError( 400, wfMsg( 'loginerror' ), wfMsg( 'suspicious-userlogout' ) );
40 return;
41 }
42
43 $this->setHeaders();
44 $this->outputHeader();
45
46 $oldName = $wgUser->getName();
47 $wgUser->logout();
48
49 $wgOut->addWikiMsg( 'logouttext' );
50
51 // Hook.
52 $injected_html = '';
53 wfRunHooks( 'UserLogoutComplete', array( &$wgUser, &$injected_html, $oldName ) );
54 $wgOut->addHTML( $injected_html );
55
56 $wgOut->returnToMain();
57 }
58 }