isAllowed( 'interwiki' ); $this->setHeaders(); if( $admin ){ $wgOut->setPagetitle( wfMsg( 'interwiki' ) ); } else { $wgOut->setPagetitle( wfMsg( 'interwiki-title-norights' ) ); } $action = $wgRequest->getVal( 'action', $par ); // checking $selfTitle = $this->getTitle(); // Protect administrative actions against malicious requests $safePost = $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); switch( $action ){ case "delete": if( !$admin ){ $wgOut->permissionRequired('interwiki'); return; } $prefix = $wgRequest->getVal( 'prefix' ); $encPrefix = htmlspecialchars( $prefix ); $actionUrl = $selfTitle->escapeLocalURL( "action=submit" ); $button = wfMsgHtml( 'delete' ); $topmessage = wfMsgHtml( 'interwiki_delquestion', $prefix ); $deletingmessage = wfMsgHtml( 'interwiki_deleting', $prefix ); $reasonmessage = wfMsgHtml( 'deletecomment' ); $defaultreason = wfMsgForContent( 'interwiki_defaultreason' ); $token = htmlspecialchars( $wgUser->editToken() ); $wgOut->addHTML( "
$topmessage
$deletingmessage
$reasonmessage  
\n" ); break; case "edit" : case "add" : if( !$admin ){ $wgOut->permissionRequired( 'interwiki' ); return; } if( $action == "edit" ){ $prefix = $wgRequest->getVal( 'prefix' ); $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'interwiki', '*', array( 'iw_prefix' => $prefix ) ); if( !$row ){ $wgOut->wrapWikiMsg( '
$1
', array( 'interwiki_editerror', $prefix ) ); return; } $prefix = htmlspecialchars( $row->iw_prefix ); $defaulturl = htmlspecialchars( $row->iw_url ); $site = ' value="' . htmlspecialchars( $row->iw_site ).'"'; $trans = $row->iw_trans ? " checked='checked'" : '' ; $local = $row->iw_local ? " checked='checked'" : ''; $old = ""; $topmessage = wfMsgHtml( 'interwiki_edittext' ); $intromessage = wfMsgHtml( 'interwiki_editintro' ); $button = wfMsgHtml( 'edit' ); } else { $prefix = ""; $local = ''; $trans = ''; $old = ''; $defaulturl = wfMsgHtml( 'interwiki_defaulturl' ); $topmessage = wfMsgHtml( 'interwiki_addtext' ); $intromessage = wfMsgHtml( 'interwiki_addintro' ); $button = wfMsgHtml( 'interwiki_addbutton' ); } $actionUrl = $selfTitle->escapeLocalURL( 'action=submit' ); $prefixmessage = wfMsgHtml( 'interwiki_prefix' ); $localmessage = wfMsgHtml( 'interwiki_local' ); $transmessage = wfMsgHtml( 'interwiki_trans' ); $reasonmessage = wfMsgHtml( 'interwiki_reasonfield' ); $urlmessage = wfMsgHtml( 'interwiki_url' ); $token = htmlspecialchars( $wgUser->editToken() ); $defaultreason = htmlspecialchars( wfMsgForContent( 'interwiki_defaultreason' ) ); $wgOut->addHTML( "
$topmessage $intromessage
$prefixmessage $prefix
$localmessage
$transmessage
$urlmessage
$reasonmessage
$old
\n" ); break; case "submit": if( !$admin ){ $wgOut->permissionRequired('interwiki'); return; } if( !$safePost ){ $wgOut->addWikiText( wfMsg('sessionfailure') ); return; } $prefix = $wgRequest->getVal('prefix'); $reason = $wgRequest->getText('reason'); $do = $wgRequest->getVal('do'); $dbw = wfGetDB( DB_MASTER ); switch( $do ){ case "delete": $dbw->delete( 'interwiki', array( 'iw_prefix' => $prefix ), __METHOD__ ); if ($dbw->affectedRows() == 0) { $wgOut->addWikiText( '' . wfMsg( 'interwiki_delfailed', $prefix ) . '' ); } else { $wgOut->addWikiText( wfMsg( 'interwiki_deleted', $prefix )); $wgOut->returnToMain( false, $selfTitle ); $log = new LogPage( 'interwiki' ); $log->addEntry( 'iw_delete', $selfTitle, $reason, array( $prefix ) ); } break; case "edit": case "add": $theurl = $wgRequest->getVal('theurl'); $local = $wgRequest->getCheck('local') ? 1 : 0; $trans = $wgRequest->getCheck('trans') ? 1 : 0; $data = array( 'iw_prefix' => $prefix, 'iw_url' => $theurl, 'iw_local' => $local, 'iw_trans' => $trans ); if( $do == 'add' ){ $dbw->insert( 'interwiki', $data, __METHOD__, 'IGNORE' ); } else { $dbw->update( 'interwiki', $data, array( 'iw_prefix' => $prefix ), __METHOD__, 'IGNORE' ); } if( $dbw->affectedRows() == 0 ) { $wgOut->addWikiText( '' . wfMsg( "interwiki_{$do}failed", $prefix ) . '' ); } else { $wgOut->addWikiText( wfMsg( "interwiki_{$do}ed", $prefix )); $wgOut->returnToMain( false, $selfTitle ); $log = new LogPage( 'interwiki' ); $log->addEntry( 'iw_'.$do, $selfTitle, $reason, array( $prefix, $theurl, $trans, $local ) ); } break; } break; default: $prefixmessage = wfMsgHtml( 'interwiki_prefix' ); $urlmessage = wfMsgHtml( 'interwiki_url' ); $localmessage = wfMsgHtml( 'interwiki_local' ); $transmessage = wfMsgHtml( 'interwiki_trans' ); $wgOut->addWikiText( wfMsg( 'interwiki_intro', '[http://www.mediawiki.org/wiki/Interwiki_table MediaWiki.org]' ) ); if ($admin) { $skin = $wgUser->getSkin(); $addtext = wfMsgHtml( 'interwiki_addtext' ); $addlink = $skin->makeLinkObj( $selfTitle, $addtext, 'action=add' ); $wgOut->addHTML( '' ); } $out = "
"; if( $admin ) { $deletemessage = wfMsgHtml( 'delete' ); $editmessage = wfMsgHtml( 'edit' ); $out .= ""; } $out .= "\n"; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'interwiki', '*' ); $numrows = $dbr->numRows( $res ); if ($numrows == 0) { $errormessage = wfMsgHtml('interwiki_error'); $out .= "
$errormessage

"; } while( $s = $dbr->fetchObject( $res ) ) { $prefix = htmlspecialchars( $s->iw_prefix ); $url = htmlspecialchars( $s->iw_url ); $trans = htmlspecialchars( $s->iw_trans ); $local = htmlspecialchars( $s->iw_local ); $out .= ""; if( $admin ) { $out .= ''; } $out .= "\n\n"; } $dbr->freeResult( $res ); $out .= "
$prefixmessage $urlmessage $localmessage $transmessage$editmessage
$prefix $url $local $trans'; $out .= $skin->makeLinkObj( $selfTitle, $editmessage, 'action=edit&prefix=' . urlencode( $s->iw_prefix ) ); $out .= ', '; $out .= $skin->makeLinkObj( $selfTitle, $deletemessage, 'action=delete&prefix=' . urlencode( $s->iw_prefix ) ); $out .= '

"; $wgOut->addHTML($out); } } }