5 * @subpackage SpecialPage
11 function wfSpecialLockdb() {
12 global $wgUser, $wgOut, $wgRequest;
14 if( !$wgUser->isAllowed( 'siteadmin' ) ) {
15 $wgOut->permissionRequired( 'siteadmin' );
19 # If the lock file isn't writable, we can do sweet bugger all
20 global $wgReadOnlyFile;
21 if( !is_writable( dirname( $wgReadOnlyFile ) ) ) {
22 DBLockForm
::notWritable();
26 $action = $wgRequest->getVal( 'action' );
27 $f = new DBLockForm();
29 if ( 'success' == $action ) {
31 } else if ( 'submit' == $action && $wgRequest->wasPosted() &&
32 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
42 * @subpackage SpecialPage
47 function DBLockForm() {
49 $this->reason
= $wgRequest->getText( 'wpLockReason' );
52 function showForm( $err ) {
53 global $wgOut, $wgUser;
55 $wgOut->setPagetitle( wfMsg( 'lockdb' ) );
56 $wgOut->addWikiText( wfMsg( 'lockdbtext' ) );
59 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
60 $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" );
62 $lc = htmlspecialchars( wfMsg( 'lockconfirm' ) );
63 $lb = htmlspecialchars( wfMsg( 'lockbtn' ) );
64 $elr = htmlspecialchars( wfMsg( 'enterlockreason' ) );
65 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Lockdb' );
66 $action = $titleObj->escapeLocalURL( 'action=submit' );
67 $reason = htmlspecialchars( $this->reason
);
68 $token = htmlspecialchars( $wgUser->editToken() );
70 $wgOut->addHTML( <<<END
71 <form id="lockdb" method="post" action="{$action}">
73 <textarea name="wpLockReason" rows="10" cols="60" wrap="virtual">{$reason}</textarea>
77 <input type="checkbox" name="wpLockConfirm" />
79 <td align="left">{$lc}</td>
84 <input type="submit" name="wpLock" value="{$lb}" />
88 <input type="hidden" name="wpEditToken" value="{$token}" />
96 global $wgOut, $wgUser, $wgLang, $wgRequest;
97 global $wgReadOnlyFile;
99 if ( ! $wgRequest->getCheck( 'wpLockConfirm' ) ) {
100 $this->showForm( wfMsg( 'locknoconfirm' ) );
103 $fp = @fopen
( $wgReadOnlyFile, 'w' );
105 if ( false === $fp ) {
106 # This used to show a file not found error, but the likeliest reason for fopen()
107 # to fail at this point is insufficient permission to write to the file...good old
108 # is_writable() is plain wrong in some cases, it seems...
109 $this->notWritable();
112 fwrite( $fp, $this->reason
);
113 fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " .
114 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
117 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Lockdb' );
118 $wgOut->redirect( $titleObj->getFullURL( 'action=success' ) );
121 function showSuccess() {
124 $wgOut->setPagetitle( wfMsg( 'lockdb' ) );
125 $wgOut->setSubtitle( wfMsg( 'lockdbsuccesssub' ) );
126 $wgOut->addWikiText( wfMsg( 'lockdbsuccesstext' ) );
129 function notWritable() {
131 $wgOut->errorPage( 'lockdb', 'lockfilenotwritable' );