aboutsummaryrefslogtreecommitdiffstats
path: root/includes/SpecialLockdb.php
diff options
context:
space:
mode:
authorLee Daniel Crocker <lcrocker@users.mediawiki.org>2003-04-14 23:10:40 +0000
committerLee Daniel Crocker <lcrocker@users.mediawiki.org>2003-04-14 23:10:40 +0000
commitd82c14fb4fbac288b42ca5918b0a72f33ecb1e69 (patch)
tree382c2ed7e9a167c7520d1e70aad1aef0874bbe8c /includes/SpecialLockdb.php
downloadmediawikicore-d82c14fb4fbac288b42ca5918b0a72f33ecb1e69.tar.gz
mediawikicore-d82c14fb4fbac288b42ca5918b0a72f33ecb1e69.zip
Initial revision
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/1284 http://mediawiki.org/wiki/Special:Code/MediaWiki/1286
Diffstat (limited to 'includes/SpecialLockdb.php')
-rw-r--r--includes/SpecialLockdb.php96
1 files changed, 96 insertions, 0 deletions
diff --git a/includes/SpecialLockdb.php b/includes/SpecialLockdb.php
new file mode 100644
index 000000000000..efc75a0d0b78
--- /dev/null
+++ b/includes/SpecialLockdb.php
@@ -0,0 +1,96 @@
+<?
+
+function wfSpecialLockdb()
+{
+ global $wgUser, $wgOut, $action;
+
+ if ( ! $wgUser->isDeveloper() ) {
+ $wgOut->developerRequired();
+ return;
+ }
+ $fields = array( "wpLockReason" );
+ wfCleanFormFields( $fields );
+
+ $f = new DBLockForm();
+
+ if ( "success" == $action ) { $f->showSuccess(); }
+ else if ( "submit" == $action ) { $f->doSubmit(); }
+ else { $f->showForm( "" ); }
+}
+
+class DBLockForm {
+
+ function showForm( $err )
+ {
+ global $wgOut, $wgUser, $wgLang;
+ global $wpLockConfirm;
+
+ $wgOut->setPagetitle( wfMsg( "lockdb" ) );
+ $wgOut->addWikiText( wfMsg( "lockdbtext" ) );
+
+ if ( "" != $err ) {
+ $wgOut->setSubtitle( wfMsg( "formerror" ) );
+ $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
+ }
+ $lc = wfMsg( "lockconfirm" );
+ $lb = wfMsg( "lockbtn" );
+ $elr = wfMsg( "enterlockreason" );
+ $action = wfLocalUrlE( $wgLang->specialPage( "Lockdb" ),
+ "action=submit" );
+
+ $wgOut->addHTML( "<p>
+<form id=\"lockdb\" method=\"post\" action=\"{$action}\">
+{$elr}:
+<textarea name=\"wpLockReason\" rows=10 cols=60 wrap=virtual>
+</textarea>
+<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>
+</form>\n" );
+
+ }
+
+ function doSubmit()
+ {
+ global $wgOut, $wgUser, $wgLang;
+ global $wpLockConfirm, $wpLockReason, $wgReadOnlyFile;
+
+ if ( ! $wpLockConfirm ) {
+ $this->showForm( wfMsg( "locknoconfirm" ) );
+ return;
+ }
+ $fp = fopen( $wgReadOnlyFile, "w" );
+
+ if ( false === $fp ) {
+ $wgOut->fileNotFoundError( $wgReadOnlyFile );
+ return;
+ }
+ fwrite( $fp, $wpLockReason );
+ fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " .
+ $wgLang->timeanddate( date( "YmdHis" ) ) . ")\n" );
+ fclose( $fp );
+
+ $success = wfLocalUrl( $wgLang->specialPage( "Lockdb" ),
+ "action=success" );
+ $wgOut->redirect( $success );
+ }
+
+ function showSuccess()
+ {
+ global $wgOut, $wgUser;
+ global $ip;
+
+ $wgOut->setPagetitle( wfMsg( "lockdb" ) );
+ $wgOut->setSubtitle( wfMsg( "lockdbsuccesssub" ) );
+ $text = str_replace( "$1", $ip, wfMsg( "lockdbsuccesstext" ) );
+ $wgOut->addWikiText( $text );
+ }
+}
+
+?>