00001 <?php 00002 00003 function wfSpecialUnlockdb() 00004 { 00005 global $wgUser, $wgOut, $wgRequest; 00006 00007 if ( ! $wgUser->isDeveloper() ) { 00008 $wgOut->developerRequired(); 00009 return; 00010 } 00011 $action = $wgRequest->getText( 'action' ); 00012 $f = new DBUnlockForm(); 00013 00014 if ( "success" == $action ) { $f->showSuccess(); } 00015 else if ( "submit" == $action ) { $f->doSubmit(); } 00016 else { $f->showForm( "" ); } 00017 } 00018 00019 class DBUnlockForm { 00020 function showForm( $err ) 00021 { 00022 global $wgOut, $wgUser, $wgLang; 00023 00024 $wgOut->setPagetitle( wfMsg( "unlockdb" ) ); 00025 $wgOut->addWikiText( wfMsg( "unlockdbtext" ) ); 00026 00027 if ( "" != $err ) { 00028 $wgOut->setSubtitle( wfMsg( "formerror" ) ); 00029 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" ); 00030 } 00031 $lc = wfMsg( "unlockconfirm" ); 00032 $lb = wfMsg( "unlockbtn" ); 00033 $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" ); 00034 $action = $titleObj->escapeLocalURL( "action=submit" ); 00035 00036 $wgOut->addHTML( "<p> 00037 <form id=\"unlockdb\" method=\"post\" action=\"{$action}\"> 00038 <table border=0><tr> 00039 <td align=right> 00040 <input type=checkbox name=\"wpLockConfirm\"> 00041 </td> 00042 <td align=\"left\">{$lc}<td> 00043 </tr><tr> 00044 <td> </td><td align=left> 00045 <input type=submit name=\"wpLock\" value=\"{$lb}\"> 00046 </td></tr></table> 00047 </form>\n" ); 00048 00049 } 00050 00051 function doSubmit() 00052 { 00053 global $wgOut, $wgUser, $wgLang; 00054 global $wgRequest, $wgReadOnlyFile; 00055 00056 $wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' ); 00057 if ( ! $wpLockConfirm ) { 00058 $this->showForm( wfMsg( "locknoconfirm" ) ); 00059 return; 00060 } 00061 if ( ! unlink( $wgReadOnlyFile ) ) { 00062 $wgOut->fileDeleteError( $wgReadOnlyFile ); 00063 return; 00064 } 00065 $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" ); 00066 $success = $titleObj->getFullURL( "action=success" ); 00067 $wgOut->redirect( $success ); 00068 } 00069 00070 function showSuccess() 00071 { 00072 global $wgOut, $wgUser; 00073 global $ip; 00074 00075 $wgOut->setPagetitle( wfMsg( "unlockdb" ) ); 00076 $wgOut->setSubtitle( wfMsg( "unlockdbsuccesssub" ) ); 00077 $wgOut->addWikiText( wfMsg( "unlockdbsuccesstext", $ip ) ); 00078 } 00079 } 00080 00081 ?>