wiki.techinc.nl/includes/SpecialUnlockdb.php

102 lines
2.3 KiB
PHP
Raw Normal View History

<?php
/**
*
* @package MediaWiki
* @subpackage SpecialPage
*/
2003-04-14 23:10:40 +00:00
/**
*
*/
function wfSpecialUnlockdb() {
2004-04-01 12:53:01 +00:00
global $wgUser, $wgOut, $wgRequest;
if( $wgUser->isAllowed( 'siteadmin' ) ) {
$form = new DBUnlockForm();
if( $action == 'success' ) {
$form->showSuccess();
} else if( $action == 'submit' && wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
$form->doSubmit();
} else {
$form->showForm();
} else {
$wgOut->permissionRequired( 'siteadmin' );
return;
}
2003-04-14 23:10:40 +00:00
}
/**
*
* @package MediaWiki
* @subpackage SpecialPage
*/
2003-04-14 23:10:40 +00:00
class DBUnlockForm {
function showForm( $error = false ) {
global $wgOut, $wgUser;
$wgOut->setPagetitle( wfMsg( 'unlockdb' ) );
$wgOut->addWikiText( wfMsg( 'unlockdbtext' ) );
if( $error ) {
$wgOut->setSubtitle( wfMsg( 'formerror' ) );
$wgOut->addHTML( '<p class="error">' . htmlspecialchars( $error ) . "</p>\n" );
2003-04-14 23:10:40 +00:00
}
$lc = htmlspecialchars( wfMsg( "unlockconfirm" ) );
$lb = htmlspecialchars( wfMsg( "unlockbtn" ) );
$titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" );
$action = $titleObj->escapeLocalURL( "action=submit" );
$token = htmlspecialchars( $wgUser->editToken() );
2003-04-14 23:10:40 +00:00
2004-10-14 05:53:30 +00:00
$wgOut->addHTML( <<<END
<form id="unlockdb" method="post" action="{$action}">
<table border="0">
<tr>
<td align="right">
<input type="checkbox" name="wpLockConfirm" />
</td>
<td align="left">{$lc}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left">
<input type="submit" name="wpLock" value="{$lb}" />
</td>
</tr>
</table>
<input type="hidden" name="wpEditToken" value="{$token}" />
2004-10-14 05:53:30 +00:00
</form>
END
);
2003-04-14 23:10:40 +00:00
}
function doSubmit() {
2005-12-04 18:27:59 +00:00
global $wgOut, $wgUser, $wgRequest, $wgReadOnlyFile;
2003-04-14 23:10:40 +00:00
2004-04-01 12:53:01 +00:00
$wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' );
2003-04-14 23:10:40 +00:00
if ( ! $wpLockConfirm ) {
$this->showForm( wfMsg( "locknoconfirm" ) );
return;
}
2004-10-14 05:53:30 +00:00
if ( @! unlink( $wgReadOnlyFile ) ) {
2003-04-14 23:10:40 +00:00
$wgOut->fileDeleteError( $wgReadOnlyFile );
return;
}
$titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" );
$success = $titleObj->getFullURL( "action=success" );
2003-04-14 23:10:40 +00:00
$wgOut->redirect( $success );
}
function showSuccess() {
2003-04-14 23:10:40 +00:00
global $wgOut, $wgUser;
global $ip;
$wgOut->setPagetitle( wfMsg( "unlockdb" ) );
$wgOut->setSubtitle( wfMsg( "unlockdbsuccesssub" ) );
2003-11-15 13:41:26 +00:00
$wgOut->addWikiText( wfMsg( "unlockdbsuccesstext", $ip ) );
2003-04-14 23:10:40 +00:00
}
}
?>