setHeaders(); if( !$wgUser->isAllowed( 'siteadmin' ) ) { $wgOut->permissionRequired( 'siteadmin' ); return; } $this->outputHeader(); $action = $wgRequest->getVal( 'action' ); if ( $action == 'success' ) { $this->showSuccess(); } else if ( $action == 'submit' && $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { $this->doSubmit(); } else { $this->showForm(); } } private function showForm( $err = '' ) { global $wgOut, $wgUser; global $wgReadOnlyFile; if( !file_exists( $wgReadOnlyFile ) ) { $wgOut->addWikiMsg( 'databasenotlocked' ); return; } $wgOut->addWikiMsg( 'unlockdbtext' ); if ( $err != '' ) { $wgOut->setSubtitle( wfMsg( 'formerror' ) ); $wgOut->addHTML( '

' . htmlspecialchars( $err ) . "

\n" ); } $wgOut->addHTML( Html::openElement( 'form', array( 'id' => 'unlockdb', 'method' => 'POST', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ) . " " . Html::openElement( 'td', array( 'style' => 'text-align:right' ) ) . " " . Html::input( 'wpLockConfirm', null, 'checkbox' ) . " " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . wfMsgHtml( 'unlockconfirm' ) . " " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . " " . Html::input( 'wpLock', wfMsg( 'unlockbtn' ), 'submit' ) . "
 
\n" . Html::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" . Html::closeElement( 'form' ) ); } private function doSubmit() { global $wgOut, $wgRequest, $wgReadOnlyFile; $wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' ); if ( !$wpLockConfirm ) { $this->showForm( wfMsg( 'locknoconfirm' ) ); return; } if ( @!unlink( $wgReadOnlyFile ) ) { $wgOut->showFileDeleteError( $wgReadOnlyFile ); return; } $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); } private function showSuccess() { global $wgOut; $wgOut->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) ); $wgOut->addWikiMsg( 'unlockdbsuccesstext' ); } }