URL-escape the main page link on the logo
[mediawiki.git] / includes / SpecialLockdb.php
blobf72b2226f0ed51b70c2a83222227fba320c714d0
1 <?
3 function wfSpecialLockdb()
5 global $wgUser, $wgOut, $action;
7 if ( ! $wgUser->isDeveloper() ) {
8 $wgOut->developerRequired();
9 return;
11 $fields = array( "wpLockReason" );
12 wfCleanFormFields( $fields );
14 $f = new DBLockForm();
16 if ( "success" == $action ) { $f->showSuccess(); }
17 else if ( "submit" == $action ) { $f->doSubmit(); }
18 else { $f->showForm( "" ); }
21 class DBLockForm {
23 function showForm( $err )
25 global $wgOut, $wgUser, $wgLang;
26 global $wpLockConfirm;
28 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
29 $wgOut->addWikiText( wfMsg( "lockdbtext" ) );
31 if ( "" != $err ) {
32 $wgOut->setSubtitle( wfMsg( "formerror" ) );
33 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
35 $lc = wfMsg( "lockconfirm" );
36 $lb = wfMsg( "lockbtn" );
37 $elr = wfMsg( "enterlockreason" );
38 $action = wfLocalUrlE( $wgLang->specialPage( "Lockdb" ),
39 "action=submit" );
41 $wgOut->addHTML( "<p>
42 <form id=\"lockdb\" method=\"post\" action=\"{$action}\">
43 {$elr}:
44 <textarea name=\"wpLockReason\" rows=10 cols=60 wrap=virtual>
45 </textarea>
46 <table border=0><tr>
47 <td align=right>
48 <input type=checkbox name=\"wpLockConfirm\">
49 </td>
50 <td align=left>{$lc}<td>
51 </tr><tr>
52 <td>&nbsp;</td><td align=left>
53 <input type=submit name=\"wpLock\" value=\"{$lb}\">
54 </td></tr></table>
55 </form>\n" );
59 function doSubmit()
61 global $wgOut, $wgUser, $wgLang;
62 global $wpLockConfirm, $wpLockReason, $wgReadOnlyFile;
64 if ( ! $wpLockConfirm ) {
65 $this->showForm( wfMsg( "locknoconfirm" ) );
66 return;
68 $fp = fopen( $wgReadOnlyFile, "w" );
70 if ( false === $fp ) {
71 $wgOut->fileNotFoundError( $wgReadOnlyFile );
72 return;
74 fwrite( $fp, $wpLockReason );
75 fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " .
76 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
77 fclose( $fp );
79 $success = wfLocalUrl( $wgLang->specialPage( "Lockdb" ),
80 "action=success" );
81 $wgOut->redirect( $success );
84 function showSuccess()
86 global $wgOut, $wgUser;
87 global $ip;
89 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
90 $wgOut->setSubtitle( wfMsg( "lockdbsuccesssub" ) );
91 $text = str_replace( "$1", $ip, wfMsg( "lockdbsuccesstext" ) );
92 $wgOut->addWikiText( $text );