isAllowed( 'siteadmin' ) ) { $wgOut->permissionRequired( 'siteadmin' ); return; } # If the lock file isn't writable, we can do sweet bugger all global $wgReadOnlyFile; if( !is_writable( dirname( $wgReadOnlyFile ) ) ) { DBLockForm::notWritable(); return; } $action = $wgRequest->getVal( 'action' ); $f = new DBLockForm(); if ( 'success' == $action ) { $f->showSuccess(); } else if ( 'submit' == $action && $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { $f->doSubmit(); } else { $f->showForm( '' ); } } /** * A form to make the database readonly (eg for maintenance purposes). * @addtogroup SpecialPage */ class DBLockForm { var $reason = ''; function DBLockForm() { global $wgRequest; $this->reason = $wgRequest->getText( 'wpLockReason' ); } function showForm( $err ) { global $wgOut, $wgUser; $wgOut->setPagetitle( wfMsg( 'lockdb' ) ); $wgOut->addWikiMsg( 'lockdbtext' ); if ( "" != $err ) { $wgOut->setSubtitle( wfMsg( 'formerror' ) ); $wgOut->addHTML( '
' . htmlspecialchars( $err ) . "
\n" ); } $lc = htmlspecialchars( wfMsg( 'lockconfirm' ) ); $lb = htmlspecialchars( wfMsg( 'lockbtn' ) ); $elr = htmlspecialchars( wfMsg( 'enterlockreason' ) ); $titleObj = SpecialPage::getTitleFor( 'Lockdb' ); $action = $titleObj->escapeLocalURL( 'action=submit' ); $reason = htmlspecialchars( $this->reason ); $token = htmlspecialchars( $wgUser->editToken() ); $wgOut->addHTML( <<{$lc} | |
(by " . $wgUser->getName() . " at " . $wgLang->timeanddate( wfTimestampNow() ) . ")\n" ); fclose( $fp ); $titleObj = SpecialPage::getTitleFor( 'Lockdb' ); $wgOut->redirect( $titleObj->getFullURL( 'action=success' ) ); } function showSuccess() { global $wgOut; $wgOut->setPagetitle( wfMsg( 'lockdb' ) ); $wgOut->setSubtitle( wfMsg( 'lockdbsuccesssub' ) ); $wgOut->addWikiMsg( 'lockdbsuccesstext' ); } public static function notWritable() { global $wgOut; $wgOut->errorPage( 'lockdb', 'lockfilenotwritable' ); } }