2008-06-27 06:18:51 +00:00
|
|
|
<?php
|
2010-08-19 21:12:09 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
die();
|
2010-08-19 21:12:09 +00:00
|
|
|
}
|
2008-06-27 06:18:51 +00:00
|
|
|
|
|
|
|
class SpecialAbuseLog extends SpecialPage {
|
2009-10-07 13:57:06 +00:00
|
|
|
public function __construct() {
|
2010-05-27 15:56:53 +00:00
|
|
|
wfLoadExtensionMessages( 'AbuseFilter' );
|
2008-06-27 06:18:51 +00:00
|
|
|
parent::__construct( 'AbuseLog', 'abusefilter-log' );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
public function execute( $parameter ) {
|
|
|
|
global $wgUser, $wgOut, $wgRequest, $wgAbuseFilterStyleVersion;
|
|
|
|
|
2009-03-11 05:55:06 +00:00
|
|
|
AbuseFilter::addNavigationLinks( $wgOut, $wgUser->getSkin(), 'log' );
|
2008-06-27 06:18:51 +00:00
|
|
|
|
|
|
|
$this->setHeaders();
|
2009-02-27 09:12:25 +00:00
|
|
|
$this->outputHeader( 'abusefilter-log-summary' );
|
2008-06-27 06:18:51 +00:00
|
|
|
$this->loadParameters();
|
|
|
|
|
|
|
|
$wgOut->setPageTitle( wfMsg( 'abusefilter-log' ) );
|
2008-07-23 19:33:28 +00:00
|
|
|
$wgOut->setRobotPolicy( "noindex,nofollow" );
|
2008-06-27 06:18:51 +00:00
|
|
|
$wgOut->setArticleRelated( false );
|
|
|
|
$wgOut->enableClientCache( false );
|
2009-01-26 19:23:27 +00:00
|
|
|
|
|
|
|
global $wgScriptPath;
|
2010-02-13 14:10:36 +00:00
|
|
|
$wgOut->addExtensionStyle( $wgScriptPath .
|
2009-02-07 09:34:11 +00:00
|
|
|
"/extensions/AbuseFilter/abusefilter.css?$wgAbuseFilterStyleVersion" );
|
2009-01-27 17:32:30 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
// Are we allowed?
|
2010-02-13 14:10:36 +00:00
|
|
|
$errors = $this->getTitle()->getUserPermissionsErrors(
|
2009-02-07 09:34:11 +00:00
|
|
|
'abusefilter-log', $wgUser, true, array( 'ns-specialprotected' ) );
|
|
|
|
if ( count( $errors ) ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
// Go away.
|
|
|
|
$wgOut->showPermissionsErrorPage( $errors, 'abusefilter-log' );
|
|
|
|
return;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-03-22 23:33:27 +00:00
|
|
|
$detailsid = $wgRequest->getIntOrNull( 'details' );
|
2010-06-25 20:04:55 +00:00
|
|
|
$hideid = $wgRequest->getIntOrNull( 'hide' );
|
2010-08-20 06:25:19 +00:00
|
|
|
|
|
|
|
if ( $parameter ) {
|
|
|
|
$detailsid = $parameter;
|
|
|
|
}
|
|
|
|
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( $detailsid ) {
|
2009-03-22 23:33:27 +00:00
|
|
|
$this->showDetails( $detailsid );
|
2010-06-25 20:04:55 +00:00
|
|
|
} elseif ( $hideid ) {
|
|
|
|
$this->showHideForm( $hideid );
|
2009-10-07 13:57:06 +00:00
|
|
|
} else {
|
2009-03-22 23:33:27 +00:00
|
|
|
// Show the search form.
|
|
|
|
$this->searchForm();
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-03-22 23:33:27 +00:00
|
|
|
// Show the log itself.
|
|
|
|
$this->showList();
|
|
|
|
}
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
function loadParameters() {
|
|
|
|
global $wgRequest;
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$this->mSearchUser = $wgRequest->getText( 'wpSearchUser' );
|
2009-04-01 03:38:57 +00:00
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
$t = Title::newFromText( trim( $this->mSearchUser ) );
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( $t ) {
|
2009-04-01 03:38:57 +00:00
|
|
|
$this->mSearchUser = $t->getText(); // Username normalisation
|
2009-05-22 06:42:10 +00:00
|
|
|
} else {
|
|
|
|
$this->mSearchUser = null;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$this->mSearchTitle = $wgRequest->getText( 'wpSearchTitle' );
|
2009-08-04 17:56:18 +00:00
|
|
|
$this->mSearchFilter = null;
|
2010-06-25 20:04:55 +00:00
|
|
|
if ( self::canSeeDetails() ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
$this->mSearchFilter = $wgRequest->getIntOrNull( 'wpSearchFilter' );
|
2009-05-22 06:42:10 +00:00
|
|
|
}
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
function searchForm() {
|
2010-07-24 21:12:27 +00:00
|
|
|
global $wgOut;
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$output = Xml::element( 'legend', null, wfMsg( 'abusefilter-log-search' ) );
|
|
|
|
$fields = array();
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
// Search conditions
|
2010-02-13 14:10:36 +00:00
|
|
|
$fields['abusefilter-log-search-user'] =
|
2009-02-07 09:34:11 +00:00
|
|
|
Xml::input( 'wpSearchUser', 45, $this->mSearchUser );
|
2010-06-25 20:04:55 +00:00
|
|
|
if ( self::canSeeDetails() ) {
|
2010-02-13 14:10:36 +00:00
|
|
|
$fields['abusefilter-log-search-filter'] =
|
2009-02-07 09:34:11 +00:00
|
|
|
Xml::input( 'wpSearchFilter', 45, $this->mSearchFilter );
|
|
|
|
}
|
2010-02-13 14:10:36 +00:00
|
|
|
$fields['abusefilter-log-search-title'] =
|
2009-02-07 09:34:11 +00:00
|
|
|
Xml::input( 'wpSearchTitle', 45, $this->mSearchTitle );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$form = Xml::hidden( 'title', $this->getTitle()->getPrefixedText() );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$form .= Xml::buildForm( $fields, 'abusefilter-log-search-submit' );
|
2009-10-07 13:57:06 +00:00
|
|
|
$output .= Xml::tags( 'form',
|
2010-08-19 21:12:09 +00:00
|
|
|
array( 'method' => 'get', 'action' => $this->getTitle()->getLocalURL() ),
|
2009-02-07 09:34:11 +00:00
|
|
|
$form );
|
2008-06-27 06:18:51 +00:00
|
|
|
$output = Xml::tags( 'fieldset', null, $output );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $output );
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
function showHideForm( $id ) {
|
|
|
|
global $wgOut, $wgUser;
|
2010-08-19 21:12:09 +00:00
|
|
|
|
|
|
|
if ( !$wgUser->isAllowed( 'abusefilter-hide-log' ) ) {
|
2010-06-25 20:04:55 +00:00
|
|
|
$wgOut->addWikiMsg( 'abusefilter-log-hide-forbidden' );
|
|
|
|
return;
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
2010-08-19 21:12:09 +00:00
|
|
|
$row = $dbr->selectRow(
|
|
|
|
array( 'abuse_filter_log', 'abuse_filter' ),
|
|
|
|
'*',
|
|
|
|
array( 'afl_id' => $id ),
|
|
|
|
__METHOD__,
|
|
|
|
array(),
|
|
|
|
array( 'abuse_filter' => array( 'LEFT JOIN', 'af_id=afl_filter' ) )
|
|
|
|
);
|
2010-06-25 20:04:55 +00:00
|
|
|
|
|
|
|
if ( !$row ) {
|
|
|
|
return;
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
$formInfo = array(
|
|
|
|
'logid' => array(
|
|
|
|
'type' => 'info',
|
|
|
|
'default' => $id,
|
|
|
|
'label-message' => 'abusefilter-log-hide-id',
|
|
|
|
),
|
|
|
|
'reason' => array(
|
|
|
|
'type' => 'text',
|
|
|
|
'label-message' => 'abusefilter-log-hide-reason',
|
|
|
|
),
|
|
|
|
'hidden' => array(
|
|
|
|
'type' => 'toggle',
|
|
|
|
'default' => $row->afl_deleted,
|
|
|
|
'label-message' => 'abusefilter-log-hide-hidden',
|
|
|
|
),
|
|
|
|
);
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
$form = new HTMLForm( $formInfo );
|
|
|
|
$form->setTitle( $this->getTitle() );
|
|
|
|
$form->addHiddenField( 'hide', $id );
|
|
|
|
$form->setSubmitCallback( array( $this, 'saveHideForm' ) );
|
|
|
|
$form->show();
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
function saveHideForm( $fields ) {
|
|
|
|
global $wgRequest, $wgOut;
|
|
|
|
$logid = $wgRequest->getVal( 'hide' );
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2010-08-19 21:12:09 +00:00
|
|
|
|
|
|
|
$dbw->update(
|
|
|
|
'abuse_filter_log',
|
|
|
|
array( 'afl_deleted' => $fields['hidden'] ),
|
|
|
|
array( 'afl_id' => $logid ),
|
|
|
|
__METHOD__
|
|
|
|
);
|
2010-08-20 06:25:19 +00:00
|
|
|
|
|
|
|
$logPage = new LogPage( 'suppress' );
|
|
|
|
$action = $fields['hidden'] ? 'hide-afl' : 'unhide-afl';
|
|
|
|
|
|
|
|
$logPage->addEntry( $action, $this->getTitle( $logid ), $fields['reason'] );
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
$wgOut->redirect( SpecialPage::getTitleFor( 'AbuseLog' )->getFullURL() );
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
function showList() {
|
|
|
|
global $wgOut;
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
// Generate conditions list.
|
|
|
|
$conds = array();
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-26 13:08:15 +00:00
|
|
|
if ( $this->mSearchUser ) {
|
2010-06-25 00:06:07 +00:00
|
|
|
$user = User::newFromName( $this->mSearchUser );
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 00:06:07 +00:00
|
|
|
if ( !$user ) {
|
|
|
|
$conds[] = 'afl_ip=afl_user_text';
|
|
|
|
$conds['afl_user'] = 0;
|
|
|
|
$conds['afl_user_text'] = $this->mSearchUser;
|
2010-08-19 21:12:09 +00:00
|
|
|
} else {
|
2010-06-25 00:06:07 +00:00
|
|
|
$conds['afl_user'] = $user->getId();
|
|
|
|
$conds['afl_user_text'] = $user->getName();
|
|
|
|
}
|
2009-05-22 06:42:10 +00:00
|
|
|
}
|
2009-05-26 13:08:15 +00:00
|
|
|
|
|
|
|
if ( $this->mSearchFilter ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
$conds['afl_filter'] = $this->mSearchFilter;
|
2009-05-22 06:42:10 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$searchTitle = Title::newFromText( $this->mSearchTitle );
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( $this->mSearchTitle && $searchTitle ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
$conds['afl_namespace'] = $searchTitle->getNamespace();
|
2009-05-24 08:33:57 +00:00
|
|
|
$conds['afl_title'] = $searchTitle->getDBkey();
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$pager = new AbuseLogPager( $this, $conds );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $pager->getNavigationBar() .
|
2009-06-04 06:17:03 +00:00
|
|
|
Xml::tags( 'ul', null, $pager->getBody() ) .
|
2008-06-27 06:18:51 +00:00
|
|
|
$pager->getNavigationBar() );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
function showDetails( $id ) {
|
2010-06-25 20:04:55 +00:00
|
|
|
if ( !self::canSeeDetails() ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2010-08-19 21:12:09 +00:00
|
|
|
$row = $dbr->selectRow(
|
|
|
|
array( 'abuse_filter_log', 'abuse_filter' ),
|
|
|
|
'*',
|
|
|
|
array( 'afl_id' => $id ),
|
|
|
|
__METHOD__,
|
|
|
|
array(),
|
|
|
|
array( 'abuse_filter' => array( 'LEFT JOIN', 'af_id=afl_filter' ) )
|
|
|
|
);
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( !$row ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
return;
|
2009-05-22 06:42:10 +00:00
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
if ( $row->afl_deleted && !self::canSeeHidden() ) {
|
|
|
|
global $wgOut;
|
|
|
|
$wgOut->addWikiMsg( 'abusefilter-log-details-hidden' );
|
|
|
|
return;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$output = '';
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$output .= Xml::element( 'legend', null, wfMsg( 'abusefilter-log-details-legend', $id ) );
|
2008-10-21 15:14:30 +00:00
|
|
|
$output .= Xml::tags( 'p', null, $this->formatRow( $row, false ) );
|
2009-03-22 23:33:27 +00:00
|
|
|
|
2010-02-13 14:10:36 +00:00
|
|
|
// Load data
|
2009-02-27 03:06:19 +00:00
|
|
|
$vars = AbuseFilter::loadVarDump( $row->afl_var_dump );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-03-18 05:45:36 +00:00
|
|
|
// Diff, if available
|
|
|
|
if ( $vars->getVar( 'action' )->toString() == 'edit' ) {
|
2009-10-07 13:57:06 +00:00
|
|
|
$old_wikitext = $vars->getVar( 'old_wikitext' )->toString();
|
|
|
|
$new_wikitext = $vars->getVar( 'new_wikitext' )->toString();
|
2009-05-26 13:08:15 +00:00
|
|
|
|
2010-07-09 14:11:07 +00:00
|
|
|
$diffEngine = new DifferenceEngine( $this->mSearchTitle );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-26 13:08:15 +00:00
|
|
|
$diffEngine->showDiffStyle();
|
|
|
|
$formattedDiff = $diffEngine->generateDiffBody( $old_wikitext, $new_wikitext );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
static $colDescriptions = "<col class='diff-marker' />
|
2009-05-26 13:08:15 +00:00
|
|
|
<col class='diff-content' />
|
|
|
|
<col class='diff-marker' />
|
|
|
|
<col class='diff-content' />";
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
$formattedDiff =
|
|
|
|
"<table class='diff'>$colDescriptions<tbody>$formattedDiff</tbody></table>";
|
|
|
|
|
|
|
|
$output .=
|
|
|
|
Xml::tags(
|
|
|
|
'h3',
|
|
|
|
null,
|
|
|
|
wfMsgExt( 'abusefilter-log-details-diff', 'parseinline' )
|
|
|
|
);
|
|
|
|
|
2009-03-18 05:45:36 +00:00
|
|
|
$output .= $formattedDiff;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-03-22 23:33:27 +00:00
|
|
|
$output .= Xml::element( 'h3', null, wfMsg( 'abusefilter-log-details-vars' ) );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-03-22 23:33:27 +00:00
|
|
|
// Build a table.
|
|
|
|
$output .= AbuseFilter::buildVarDumpTable( $vars );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
if ( self::canSeePrivate() ) {
|
2008-06-27 08:11:09 +00:00
|
|
|
// Private stuff, like IPs.
|
2009-10-07 13:57:06 +00:00
|
|
|
$header =
|
|
|
|
Xml::element( 'th', null, wfMsg( 'abusefilter-log-details-var' ) ) .
|
2009-02-07 09:34:11 +00:00
|
|
|
Xml::element( 'th', null, wfMsg( 'abusefilter-log-details-val' ) );
|
2008-06-27 08:11:09 +00:00
|
|
|
$output .= Xml::element( 'h3', null, wfMsg( 'abusefilter-log-details-private' ) );
|
2009-10-07 13:57:06 +00:00
|
|
|
$output .=
|
|
|
|
Xml::openElement( 'table',
|
|
|
|
array(
|
|
|
|
'class' => 'wikitable mw-abuselog-private',
|
|
|
|
'style' => 'width: 80%;'
|
|
|
|
)
|
|
|
|
) .
|
2009-02-07 09:34:11 +00:00
|
|
|
Xml::openElement( 'tbody' );
|
2008-06-27 08:11:09 +00:00
|
|
|
$output .= $header;
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 08:11:09 +00:00
|
|
|
// IP address
|
2009-10-07 13:57:06 +00:00
|
|
|
$output .=
|
|
|
|
Xml::tags( 'tr', null,
|
|
|
|
Xml::element( 'td',
|
|
|
|
array( 'style' => 'width: 30%;' ),
|
|
|
|
wfMsg( 'abusefilter-log-details-ip' )
|
|
|
|
) .
|
|
|
|
Xml::element( 'td', null, $row->afl_ip )
|
2009-02-07 09:34:11 +00:00
|
|
|
);
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 08:11:09 +00:00
|
|
|
$output .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$output = Xml::tags( 'fieldset', null, $output );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
global $wgOut;
|
|
|
|
$wgOut->addHTML( $output );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
static function canSeeDetails() {
|
2008-06-27 06:18:51 +00:00
|
|
|
global $wgUser;
|
2010-06-25 20:04:55 +00:00
|
|
|
return $wgUser->isAllowed( 'abusefilter-log-detail' );
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
static function canSeePrivate() {
|
|
|
|
global $wgUser;
|
|
|
|
return $wgUser->isAllowed( 'abusefilter-private' );
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
static function canSeeHidden() {
|
2008-06-27 08:11:09 +00:00
|
|
|
global $wgUser;
|
2010-06-25 20:04:55 +00:00
|
|
|
return $wgUser->isAllowed( 'abusefilter-hidden-log' );
|
2008-06-27 08:11:09 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-10-21 15:14:30 +00:00
|
|
|
function formatRow( $row, $li = true ) {
|
2009-10-07 13:57:06 +00:00
|
|
|
global $wgLang, $wgUser;
|
|
|
|
|
2010-08-19 21:12:09 +00:00
|
|
|
# One-time setup
|
2009-10-07 13:57:06 +00:00
|
|
|
static $sk = null;
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
$actionLinks = array();
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( is_null( $sk ) ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$title = Title::makeTitle( $row->afl_namespace, $row->afl_title );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( !$row->afl_wiki ) {
|
2009-03-30 06:12:12 +00:00
|
|
|
$pageLink = $sk->link( $title );
|
|
|
|
} else {
|
|
|
|
$pageLink = WikiMap::makeForeignLink( $row->afl_wiki, $row->afl_title );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( !$row->afl_wiki ) {
|
2009-03-30 06:12:12 +00:00
|
|
|
// Local user
|
|
|
|
$user = $sk->userLink( $row->afl_user, $row->afl_user_text ) .
|
|
|
|
$sk->userToolLinks( $row->afl_user, $row->afl_user_text );
|
|
|
|
} else {
|
|
|
|
$user = WikiMap::foreignUserLink( $row->afl_wiki, $row->afl_user_text );
|
2009-10-07 13:57:06 +00:00
|
|
|
$user .= ' (' . WikiMap::getWikiName( $row->afl_wiki ) . ')';
|
2009-03-30 06:12:12 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$description = '';
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-02-26 21:45:07 +00:00
|
|
|
$timestamp = $wgLang->timeanddate( $row->afl_timestamp, true );
|
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
$actions_taken = $row->afl_actions;
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( !strlen( trim( $actions_taken ) ) ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
$actions_taken = wfMsg( 'abusefilter-log-noactions' );
|
2009-01-28 01:26:38 +00:00
|
|
|
} else {
|
2009-05-22 06:42:10 +00:00
|
|
|
$actions = explode( ',', $actions_taken );
|
2009-01-28 01:26:38 +00:00
|
|
|
$displayActions = array();
|
|
|
|
|
2010-02-13 14:10:36 +00:00
|
|
|
foreach ( $actions as $action ) {
|
2009-03-30 06:12:12 +00:00
|
|
|
$displayActions[] = AbuseFilter::getActionDisplay( $action );
|
2009-01-28 01:26:38 +00:00
|
|
|
}
|
2010-03-13 17:23:08 +00:00
|
|
|
$actions_taken = $wgLang->commaList( $displayActions );
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-03-30 06:12:12 +00:00
|
|
|
$globalIndex = AbuseFilter::decodeGlobalName( $row->afl_filter );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-01-31 01:59:13 +00:00
|
|
|
global $wgOut;
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( $globalIndex ) {
|
2009-03-30 06:12:12 +00:00
|
|
|
// Pull global filter description
|
|
|
|
$parsed_comments =
|
|
|
|
$wgOut->parseInline( AbuseFilter::getGlobalFilterDescription( $globalIndex ) );
|
|
|
|
} else {
|
|
|
|
$parsed_comments = $wgOut->parseInline( $row->af_public_comments );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
if ( self::canSeeDetails() ) {
|
2009-10-07 13:57:06 +00:00
|
|
|
$examineTitle = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/log/' . $row->afl_id );
|
|
|
|
$detailsLink = $sk->makeKnownLinkObj(
|
2010-08-20 06:25:19 +00:00
|
|
|
$this->getTitle($row->afl_id),
|
|
|
|
wfMsg( 'abusefilter-log-detailslink' )
|
2009-10-07 13:57:06 +00:00
|
|
|
);
|
|
|
|
$examineLink = $sk->link(
|
|
|
|
$examineTitle,
|
|
|
|
wfMsgExt( 'abusefilter-changeslist-examine', 'parseinline' ),
|
|
|
|
array()
|
|
|
|
);
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
$actionLinks[] = $detailsLink;
|
|
|
|
$actionLinks[] = $examineLink;
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
if ( $wgUser->isAllowed( 'abusefilter-hide-log' ) ) {
|
|
|
|
$hideLink = $sk->link(
|
|
|
|
$this->getTitle(),
|
|
|
|
wfMsg( 'abusefilter-log-hidelink' ),
|
|
|
|
array(),
|
|
|
|
array( 'hide' => $row->afl_id )
|
|
|
|
);
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
$actionLinks[] = $hideLink;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( $globalIndex ) {
|
2009-03-30 06:12:12 +00:00
|
|
|
global $wgAbuseFilterCentralDB;
|
|
|
|
$globalURL =
|
|
|
|
WikiMap::getForeignURL( $wgAbuseFilterCentralDB,
|
2009-10-07 13:57:06 +00:00
|
|
|
'Special:AbuseFilter/' . $globalIndex );
|
|
|
|
|
2009-03-30 06:12:12 +00:00
|
|
|
$linkText = wfMsgExt( 'abusefilter-log-detailedentry-global',
|
2009-10-07 13:57:06 +00:00
|
|
|
'parseinline', array( $globalIndex ) );
|
|
|
|
|
2009-03-30 06:12:12 +00:00
|
|
|
$filterLink = $sk->makeExternalLink( $globalURL, $linkText );
|
|
|
|
} else {
|
|
|
|
$title = SpecialPage::getTitleFor( 'AbuseFilter', $row->afl_filter );
|
|
|
|
$linkText = wfMsgExt( 'abusefilter-log-detailedentry-local',
|
2009-10-07 13:57:06 +00:00
|
|
|
'parseinline', array( $row->afl_filter ) );
|
2009-03-30 06:12:12 +00:00
|
|
|
$filterLink = $sk->link( $title, $linkText );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
$description = wfMsgExt( 'abusefilter-log-detailedentry-meta',
|
2009-02-07 09:34:11 +00:00
|
|
|
array( 'parseinline', 'replaceafter' ),
|
2009-10-07 13:57:06 +00:00
|
|
|
array(
|
|
|
|
$timestamp,
|
|
|
|
$user,
|
|
|
|
$filterLink,
|
|
|
|
$row->afl_action,
|
|
|
|
$pageLink,
|
|
|
|
$actions_taken,
|
|
|
|
$parsed_comments,
|
2010-06-25 20:04:55 +00:00
|
|
|
$wgLang->pipeList( $actionLinks ),
|
2009-10-07 13:57:06 +00:00
|
|
|
)
|
2009-02-07 09:34:11 +00:00
|
|
|
);
|
2008-06-27 06:18:51 +00:00
|
|
|
} else {
|
2009-10-07 13:57:06 +00:00
|
|
|
$description = wfMsgExt(
|
|
|
|
'abusefilter-log-entry',
|
|
|
|
array( 'parseinline', 'replaceafter' ),
|
|
|
|
array(
|
|
|
|
$timestamp,
|
|
|
|
$user,
|
|
|
|
$row->afl_action,
|
|
|
|
$sk->link( $title ),
|
|
|
|
$actions_taken,
|
|
|
|
$parsed_comments
|
2010-02-13 14:10:36 +00:00
|
|
|
)
|
2009-02-07 09:34:11 +00:00
|
|
|
);
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
if ( $row->afl_deleted ) {
|
|
|
|
$description .= ' '.
|
|
|
|
wfMsgExt( 'abusefilter-log-hidden', 'parseinline' );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2008-10-21 15:14:30 +00:00
|
|
|
return $li ? Xml::tags( 'li', null, $description ) : $description;
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AbuseLogPager extends ReverseChronologicalPager {
|
|
|
|
public $mForm, $mConds;
|
|
|
|
|
|
|
|
function __construct( $form, $conds = array(), $details = false ) {
|
|
|
|
$this->mForm = $form;
|
|
|
|
$this->mConds = $conds;
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatRow( $row ) {
|
|
|
|
return $this->mForm->formatRow( $row );
|
|
|
|
}
|
|
|
|
|
|
|
|
function getQueryInfo() {
|
|
|
|
$conds = $this->mConds;
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
$info = array(
|
2009-10-07 13:57:06 +00:00
|
|
|
'tables' => array( 'abuse_filter_log', 'abuse_filter' ),
|
2008-06-27 06:18:51 +00:00
|
|
|
'fields' => '*',
|
|
|
|
'conds' => $conds,
|
2009-03-30 06:12:12 +00:00
|
|
|
'join_conds' =>
|
|
|
|
array( 'abuse_filter' =>
|
|
|
|
array(
|
|
|
|
'LEFT JOIN',
|
|
|
|
'af_id=afl_filter',
|
|
|
|
),
|
|
|
|
),
|
2008-06-27 06:18:51 +00:00
|
|
|
);
|
2010-08-19 21:12:09 +00:00
|
|
|
|
|
|
|
if ( !$this->mForm->canSeeHidden() ) {
|
2010-06-25 20:04:55 +00:00
|
|
|
$info['conds']['afl_deleted'] = 0;
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-06-25 20:04:55 +00:00
|
|
|
return $info;
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getIndexField() {
|
|
|
|
return 'afl_timestamp';
|
|
|
|
}
|
2008-12-20 09:32:47 +00:00
|
|
|
}
|