5 * @subpackage SpecialPage
11 function wfSpecialLockdb() {
12 global $wgUser, $wgOut, $wgRequest;
14 if ( ! $wgUser->isAllowed('siteadmin') ) {
15 $wgOut->developerRequired();
18 $action = $wgRequest->getVal( 'action' );
19 $f = new DBLockForm();
21 if ( 'success' == $action ) {
23 } else if ( 'submit' == $action && $wgRequest->wasPosted() &&
24 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
34 * @subpackage SpecialPage
39 function DBLockForm() {
41 $this->reason
= $wgRequest->getText( 'wpLockReason' );
44 function showForm( $err ) {
45 global $wgOut, $wgUser;
47 $wgOut->setPagetitle( wfMsg( 'lockdb' ) );
48 $wgOut->addWikiText( wfMsg( 'lockdbtext' ) );
51 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
52 $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" );
54 $lc = htmlspecialchars( wfMsg( 'lockconfirm' ) );
55 $lb = htmlspecialchars( wfMsg( 'lockbtn' ) );
56 $elr = htmlspecialchars( wfMsg( 'enterlockreason' ) );
57 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Lockdb' );
58 $action = $titleObj->escapeLocalURL( 'action=submit' );
59 $token = htmlspecialchars( $wgUser->editToken() );
61 $wgOut->addHTML( <<<END
62 <form id="lockdb" method="post" action="{$action}">
64 <textarea name="wpLockReason" rows="10" cols="60" wrap="virtual"></textarea>
68 <input type="checkbox" name="wpLockConfirm" />
70 <td align="left">{$lc}</td>
75 <input type="submit" name="wpLock" value="{$lb}" />
79 <input type="hidden" name="wpEditToken" value="{$token}" />
87 global $wgOut, $wgUser, $wgLang, $wgRequest;
88 global $wgReadOnlyFile;
90 if ( ! $wgRequest->getCheck( 'wpLockConfirm' ) ) {
91 $this->showForm( wfMsg( 'locknoconfirm' ) );
94 $fp = fopen( $wgReadOnlyFile, 'w' );
96 if ( false === $fp ) {
97 $wgOut->showFileNotFoundError( $wgReadOnlyFile );
100 fwrite( $fp, $this->reason
);
101 fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " .
102 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
105 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Lockdb' );
106 $wgOut->redirect( $titleObj->getFullURL( 'action=success' ) );
109 function showSuccess() {
112 $wgOut->setPagetitle( wfMsg( 'lockdb' ) );
113 $wgOut->setSubtitle( wfMsg( 'lockdbsuccesssub' ) );
114 $wgOut->addWikiText( wfMsg( 'lockdbsuccesstext' ) );