Don't complain about empty log file... I thought this had already been fixed
[lhc/web/wiklou.git] / includes / SpecialUnlockdb.php
1 <?
2
3 function wfSpecialUnlockdb()
4 {
5 global $wgUser, $wgOut, $action;
6
7 if ( ! $wgUser->isDeveloper() ) {
8 $wgOut->developerRequired();
9 return;
10 }
11 $f = new DBUnlockForm();
12
13 if ( "success" == $action ) { $f->showSuccess(); }
14 else if ( "submit" == $action ) { $f->doSubmit(); }
15 else { $f->showForm( "" ); }
16 }
17
18 class DBUnlockForm {
19
20 function showForm( $err )
21 {
22 global $wgOut, $wgUser, $wgLang;
23 global $wpLockConfirm;
24
25 $wgOut->setPagetitle( wfMsg( "unlockdb" ) );
26 $wgOut->addWikiText( wfMsg( "unlockdbtext" ) );
27
28 if ( "" != $err ) {
29 $wgOut->setSubtitle( wfMsg( "formerror" ) );
30 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
31 }
32 $lc = wfMsg( "unlockconfirm" );
33 $lb = wfMsg( "unlockbtn" );
34 $action = wfLocalUrlE( $wgLang->specialPage( "Unlockdb" ),
35 "action=submit" );
36
37 $wgOut->addHTML( "<p>
38 <form id=\"unlockdb\" method=\"post\" action=\"{$action}\">
39 <table border=0><tr>
40 <td align=right>
41 <input type=checkbox name=\"wpLockConfirm\">
42 </td>
43 <td align=\"left\">{$lc}<td>
44 </tr><tr>
45 <td>&nbsp;</td><td align=left>
46 <input type=submit name=\"wpLock\" value=\"{$lb}\">
47 </td></tr></table>
48 </form>\n" );
49
50 }
51
52 function doSubmit()
53 {
54 global $wgOut, $wgUser, $wgLang;
55 global $wpLockConfirm, $wgReadOnlyFile;
56
57 if ( ! $wpLockConfirm ) {
58 $this->showForm( wfMsg( "locknoconfirm" ) );
59 return;
60 }
61 if ( ! unlink( $wgReadOnlyFile ) ) {
62 $wgOut->fileDeleteError( $wgReadOnlyFile );
63 return;
64 }
65 $success = wfLocalUrl( $wgLang->specialPage( "Unlockdb" ),
66 "action=success" );
67 $wgOut->redirect( $success );
68 }
69
70 function showSuccess()
71 {
72 global $wgOut, $wgUser;
73 global $ip;
74
75 $wgOut->setPagetitle( wfMsg( "unlockdb" ) );
76 $wgOut->setSubtitle( wfMsg( "unlockdbsuccesssub" ) );
77 $wgOut->addWikiText( wfMsg( "unlockdbsuccesstext", $ip ) );
78 }
79 }
80
81 ?>