Fix for compatibility with short_open_tag = Off
[lhc/web/wiklou.git] / includes / SpecialLockdb.php
1 <?php
2
3 function wfSpecialLockdb()
4 {
5 global $wgUser, $wgOut, $action;
6
7 if ( ! $wgUser->isDeveloper() ) {
8 $wgOut->developerRequired();
9 return;
10 }
11 $fields = array( "wpLockReason" );
12 wfCleanFormFields( $fields );
13
14 $f = new DBLockForm();
15
16 if ( "success" == $action ) { $f->showSuccess(); }
17 else if ( "submit" == $action ) { $f->doSubmit(); }
18 else { $f->showForm( "" ); }
19 }
20
21 class DBLockForm {
22
23 function showForm( $err )
24 {
25 global $wgOut, $wgUser, $wgLang;
26 global $wpLockConfirm;
27
28 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
29 $wgOut->addWikiText( wfMsg( "lockdbtext" ) );
30
31 if ( "" != $err ) {
32 $wgOut->setSubtitle( wfMsg( "formerror" ) );
33 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
34 }
35 $lc = wfMsg( "lockconfirm" );
36 $lb = wfMsg( "lockbtn" );
37 $elr = wfMsg( "enterlockreason" );
38 $action = wfLocalUrlE( $wgLang->specialPage( "Lockdb" ),
39 "action=submit" );
40
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" );
56
57 }
58
59 function doSubmit()
60 {
61 global $wgOut, $wgUser, $wgLang;
62 global $wpLockConfirm, $wpLockReason, $wgReadOnlyFile;
63
64 if ( ! $wpLockConfirm ) {
65 $this->showForm( wfMsg( "locknoconfirm" ) );
66 return;
67 }
68 $fp = fopen( $wgReadOnlyFile, "w" );
69
70 if ( false === $fp ) {
71 $wgOut->fileNotFoundError( $wgReadOnlyFile );
72 return;
73 }
74 fwrite( $fp, $wpLockReason );
75 fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " .
76 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
77 fclose( $fp );
78
79 $success = wfLocalUrl( $wgLang->specialPage( "Lockdb" ),
80 "action=success" );
81 $wgOut->redirect( $success );
82 }
83
84 function showSuccess()
85 {
86 global $wgOut, $wgUser;
87 global $ip;
88
89 $wgOut->setPagetitle( wfMsg( "lockdb" ) );
90 $wgOut->setSubtitle( wfMsg( "lockdbsuccesssub" ) );
91 $wgOut->addWikiText( wfMsg( "lockdbsuccesstext", $ip ) );
92 }
93 }
94
95 ?>