setHeaders(); # Permission check if( !$this->userCanExecute( $this->getUser() ) ) { $this->displayRestrictionError(); return; } $this->outputHeader(); $request = $this->getRequest(); $action = $request->getVal( 'action' ); if ( $action == 'success' ) { $this->showSuccess(); } elseif ( $action == 'submit' && $request->wasPosted() && $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) { $this->doSubmit(); } else { $this->showForm(); } } private function showForm( $err = '' ) { global $wgReadOnlyFile; $out = $this->getOutput(); if( !file_exists( $wgReadOnlyFile ) ) { $out->addWikiMsg( 'databasenotlocked' ); return; } $out->addWikiMsg( 'unlockdbtext' ); if ( $err != '' ) { $out->setSubtitle( wfMsg( 'formerror' ) ); $out->addHTML( '

' . htmlspecialchars( $err ) . "

\n" ); } $out->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', array( 'id' => 'mw-input-wpunlockconfirm' ) ) . " " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . Html::openElement( 'label', array( 'for' => 'mw-input-wpunlockconfirm' ) ) . wfMsgHtml( 'unlockconfirm' ) . " " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . " " . Html::input( 'wpLock', wfMsg( 'unlockbtn' ), 'submit' ) . "
 
\n" . Html::hidden( 'wpEditToken', $this->getUser()->editToken() ) . "\n" . Html::closeElement( 'form' ) ); } private function doSubmit() { global $wgReadOnlyFile; if ( !$this->getRequest()->getCheck( 'wpLockConfirm' ) ) { $this->showForm( wfMsg( 'locknoconfirm' ) ); return; } wfSuppressWarnings(); $res = unlink( $wgReadOnlyFile ); wfRestoreWarnings(); if ( $res ) { $this->getOutput()->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); } else { $this->getOutput()->addWikiMsg( 'filedeleteerror', $wgReadOnlyFile ); } } private function showSuccess() { $out = $this->getOutput(); $out->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) ); $out->addWikiMsg( 'unlockdbsuccesstext' ); } }