2008-06-27 06:18:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class SpecialAbuseLog extends SpecialPage {
|
2011-07-25 22:09:05 +00:00
|
|
|
/**
|
|
|
|
* @var User
|
|
|
|
*/
|
|
|
|
protected $mSearchUser;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Title
|
|
|
|
*/
|
|
|
|
protected $mSearchTitle;
|
|
|
|
|
2012-08-03 21:55:35 +00:00
|
|
|
protected $mSearchWiki;
|
|
|
|
|
2011-07-25 22:09:05 +00:00
|
|
|
protected $mSearchFilter;
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
public function __construct() {
|
2008-06-27 06:18:51 +00:00
|
|
|
parent::__construct( 'AbuseLog', 'abusefilter-log' );
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2013-12-27 08:44:46 +00:00
|
|
|
/**
|
|
|
|
* Back-compat function for pre-1.23 MediaWiki versions
|
|
|
|
* @param bool|string $subpage
|
|
|
|
* @return Title
|
|
|
|
*/
|
|
|
|
public function getPageTitle( $subpage = false ) {
|
|
|
|
return self::getTitleFor( $this->getName(), $subpage );
|
|
|
|
}
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
public function execute( $parameter ) {
|
2011-11-16 05:34:24 +00:00
|
|
|
$out = $this->getOutput();
|
|
|
|
$request = $this->getRequest();
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2011-11-17 00:55:53 +00:00
|
|
|
AbuseFilter::addNavigationLinks( $this->getContext(), '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();
|
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->setPageTitle( $this->msg( 'abusefilter-log' ) );
|
|
|
|
$out->setRobotPolicy( "noindex,nofollow" );
|
|
|
|
$out->setArticleRelated( false );
|
|
|
|
$out->enableClientCache( false );
|
2009-01-26 19:23:27 +00:00
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->addModuleStyles( 'ext.abuseFilter' );
|
2009-01-27 17:32:30 +00:00
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
// Are we allowed?
|
2013-12-27 06:36:34 +00:00
|
|
|
$errors = $this->getPageTitle()->getUserPermissionsErrors(
|
2011-11-16 05:34:24 +00:00
|
|
|
'abusefilter-log', $this->getUser(), true, array( 'ns-specialprotected' ) );
|
2009-02-07 09:34:11 +00:00
|
|
|
if ( count( $errors ) ) {
|
2008-06-27 06:18:51 +00:00
|
|
|
// Go away.
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->showPermissionsErrorPage( $errors, 'abusefilter-log' );
|
2008-06-27 06:18:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$detailsid = $request->getIntOrNull( 'details' );
|
|
|
|
$hideid = $request->getIntOrNull( 'hide' );
|
2011-07-04 22:00:06 +00:00
|
|
|
|
2010-08-20 06:25:19 +00:00
|
|
|
if ( $parameter ) {
|
|
|
|
$detailsid = $parameter;
|
|
|
|
}
|
2011-07-04 22:00:06 +00:00
|
|
|
|
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() {
|
2012-08-03 21:55:35 +00:00
|
|
|
global $wgAbuseFilterIsCentral;
|
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$request = $this->getRequest();
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2013-03-25 00:02:40 +00:00
|
|
|
$this->mSearchUser = trim( $request->getText( 'wpSearchUser' ) );
|
2012-08-03 21:55:35 +00:00
|
|
|
if ( $wgAbuseFilterIsCentral ) {
|
|
|
|
$this->mSearchWiki = $request->getText( 'wpSearchWiki' );
|
|
|
|
}
|
2009-04-01 03:38:57 +00:00
|
|
|
|
2013-03-25 00:02:40 +00:00
|
|
|
$u = User::newFromName( $this->mSearchUser );
|
|
|
|
if ( $u ) {
|
|
|
|
$this->mSearchUser = $u->getName(); // Username normalisation
|
|
|
|
} elseif( IP::isIPAddress( $this->mSearchUser ) ) {
|
|
|
|
// It's an IP
|
|
|
|
$this->mSearchUser = IP::sanitizeIP( $this->mSearchUser );
|
2009-05-22 06:42:10 +00:00
|
|
|
} else {
|
|
|
|
$this->mSearchUser = null;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$this->mSearchTitle = $request->getText( 'wpSearchTitle' );
|
2009-08-04 17:56:18 +00:00
|
|
|
$this->mSearchFilter = null;
|
2011-12-23 20:23:29 +00:00
|
|
|
if ( self::canSeeDetails() ) {
|
2013-07-09 22:49:19 +00:00
|
|
|
$this->mSearchFilter = $request->getText( '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() {
|
2012-08-03 21:55:35 +00:00
|
|
|
global $wgAbuseFilterIsCentral;
|
|
|
|
|
2012-09-02 11:07:02 +00:00
|
|
|
$output = Xml::element( 'legend', null, $this->msg( 'abusefilter-log-search' )->text() );
|
2008-06-27 06:18:51 +00:00
|
|
|
$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 );
|
2011-12-23 20:23:29 +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
|
|
|
|
2012-08-03 21:55:35 +00:00
|
|
|
if ( $wgAbuseFilterIsCentral ) {
|
|
|
|
// Add free form input for wiki name. Would be nice to generate
|
|
|
|
// a select with unique names in the db at some point.
|
|
|
|
$fields['abusefilter-log-search-wiki'] =
|
|
|
|
Xml::input( 'wpSearchWiki', 45, $this->mSearchWiki );
|
|
|
|
}
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
$output .= Xml::tags( 'form',
|
2013-12-27 06:36:34 +00:00
|
|
|
array( 'method' => 'get', 'action' => $this->getPageTitle()->getLocalURL() ),
|
2012-09-23 16:35:14 +00:00
|
|
|
Xml::buildForm( $fields, 'abusefilter-log-search-submit' )
|
|
|
|
);
|
2008-06-27 06:18:51 +00:00
|
|
|
$output = Xml::tags( 'fieldset', null, $output );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$this->getOutput()->addHTML( $output );
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2012-03-11 20:51:54 +00:00
|
|
|
/**
|
|
|
|
* @param $id
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2010-06-25 20:04:55 +00:00
|
|
|
function showHideForm( $id ) {
|
2011-11-16 05:34:24 +00:00
|
|
|
if ( !$this->getUser()->isAllowed( 'abusefilter-hide-log' ) ) {
|
|
|
|
$this->getOutput()->addWikiMsg( 'abusefilter-log-hide-forbidden' );
|
2010-06-25 20:04:55 +00:00
|
|
|
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
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$form = new HTMLForm( $formInfo, $this->getContext() );
|
2013-12-27 06:36:34 +00:00
|
|
|
$form->setTitle( $this->getPageTitle() );
|
2012-09-02 11:07:02 +00:00
|
|
|
$form->setWrapperLegend( $this->msg( 'abusefilter-log-hide-legend' )->text() );
|
2010-06-25 20:04:55 +00:00
|
|
|
$form->addHiddenField( 'hide', $id );
|
|
|
|
$form->setSubmitCallback( array( $this, 'saveHideForm' ) );
|
|
|
|
$form->show();
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2012-03-11 20:51:54 +00:00
|
|
|
/**
|
|
|
|
* @param $fields
|
|
|
|
* @return bool
|
|
|
|
*/
|
2010-06-25 20:04:55 +00:00
|
|
|
function saveHideForm( $fields ) {
|
2011-11-16 05:34:24 +00:00
|
|
|
$logid = $this->getRequest()->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__
|
|
|
|
);
|
2011-07-04 22:00:06 +00:00
|
|
|
|
2010-08-20 06:25:19 +00:00
|
|
|
$logPage = new LogPage( 'suppress' );
|
|
|
|
$action = $fields['hidden'] ? 'hide-afl' : 'unhide-afl';
|
2011-07-04 22:00:06 +00:00
|
|
|
|
2013-12-27 06:36:34 +00:00
|
|
|
$logPage->addEntry( $action, $this->getPageTitle( $logid ), $fields['reason'] );
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$this->getOutput()->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() {
|
2011-11-16 05:34:24 +00:00
|
|
|
$out = $this->getOutput();
|
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_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
|
|
|
|
2012-08-03 21:55:35 +00:00
|
|
|
if ( $this->mSearchWiki ) {
|
|
|
|
$conds['afl_wiki'] = $this->mSearchWiki;
|
|
|
|
}
|
|
|
|
|
2009-05-26 13:08:15 +00:00
|
|
|
if ( $this->mSearchFilter ) {
|
2012-01-03 17:29:10 +00:00
|
|
|
// if the filter is hidden, users who can't view private filters should not be able to find log entries generated by it
|
2012-07-03 03:11:13 +00:00
|
|
|
if ( !AbuseFilter::filterHidden( $this->mSearchFilter )
|
|
|
|
|| AbuseFilterView::canViewPrivate()
|
|
|
|
|| $this->getUser()->isAllowed( 'abusefilter-log-private' )
|
|
|
|
) {
|
2012-01-03 17:29:10 +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 );
|
2011-07-05 00:09:09 +00:00
|
|
|
$pager->doQuery();
|
2011-07-04 22:00:06 +00:00
|
|
|
$result = $pager->getResult();
|
|
|
|
if( $result && $result->numRows() !== 0 ) {
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->addHTML( $pager->getNavigationBar() .
|
2013-07-09 20:36:37 +00:00
|
|
|
Xml::tags( 'ul', array( 'class' => 'plainlinks' ), $pager->getBody() ) .
|
2011-06-06 23:46:13 +00:00
|
|
|
$pager->getNavigationBar() );
|
|
|
|
} else {
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->addWikiMsg( 'abusefilter-log-noresults' );
|
2011-06-06 23:46:13 +00:00
|
|
|
}
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2012-03-11 20:51:54 +00:00
|
|
|
/**
|
|
|
|
* @param $id
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2008-06-27 06:18:51 +00:00
|
|
|
function showDetails( $id ) {
|
2011-11-16 05:34:24 +00:00
|
|
|
$out = $this->getOutput();
|
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
|
|
|
|
2012-01-03 17:29:10 +00:00
|
|
|
if ( AbuseFilter::decodeGlobalName( $row->afl_filter ) ) {
|
|
|
|
$filter_hidden = null;
|
|
|
|
} else {
|
|
|
|
$filter_hidden = $row->af_hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !self::canSeeDetails( $row->afl_filter, $filter_hidden ) ) {
|
|
|
|
$out->addWikiMsg( 'abusefilter-log-cannot-see-details' );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-10 23:41:05 +00:00
|
|
|
if ( self::isHidden( $row ) && !self::canSeeHidden() ) {
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->addWikiMsg( 'abusefilter-log-details-hidden' );
|
2010-06-25 20:04:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2013-07-09 22:49:19 +00:00
|
|
|
$output = Xml::element(
|
2012-09-02 11:07:02 +00:00
|
|
|
'legend',
|
|
|
|
null,
|
|
|
|
$this->msg( 'abusefilter-log-details-legend', $id )->text()
|
|
|
|
);
|
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
|
2012-07-24 13:50:01 +00:00
|
|
|
if ( $vars && $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
|
|
|
|
2013-06-10 19:53:33 +00:00
|
|
|
$diffEngine = new DifferenceEngine( $this->getContext() );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-05-26 13:08:15 +00:00
|
|
|
$diffEngine->showDiffStyle();
|
2013-06-10 16:57:27 +00:00
|
|
|
|
2013-04-01 17:48:39 +00:00
|
|
|
// Note: generateDiffBody has been deprecated in favour of generateTextDiffBody in 1.21 but we can't use it for b/c
|
|
|
|
$formattedDiff = $diffEngine->generateDiffBody( $old_wikitext, $new_wikitext );
|
2013-06-10 16:57:27 +00:00
|
|
|
$formattedDiff = $diffEngine->addHeader( $formattedDiff, '', '' );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
|
|
|
$output .=
|
|
|
|
Xml::tags(
|
|
|
|
'h3',
|
|
|
|
null,
|
2012-09-02 11:07:02 +00:00
|
|
|
$this->msg( 'abusefilter-log-details-diff' )->parse()
|
2009-10-07 13:57:06 +00:00
|
|
|
);
|
|
|
|
|
2009-03-18 05:45:36 +00:00
|
|
|
$output .= $formattedDiff;
|
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2012-09-02 11:07:02 +00:00
|
|
|
$output .= Xml::element( 'h3', null, $this->msg( 'abusefilter-log-details-vars' )->text() );
|
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
|
|
|
|
2011-12-23 20:23:29 +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 =
|
2012-09-02 11:07:02 +00:00
|
|
|
Xml::element( 'th', null, $this->msg( 'abusefilter-log-details-var' )->text() ) .
|
|
|
|
Xml::element( 'th', null, $this->msg( 'abusefilter-log-details-val' )->text() );
|
|
|
|
$output .= Xml::element( 'h3', null, $this->msg( 'abusefilter-log-details-private' )->text() );
|
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%;' ),
|
2012-09-02 11:07:02 +00:00
|
|
|
$this->msg( 'abusefilter-log-details-ip' )->text()
|
2009-10-07 13:57:06 +00:00
|
|
|
) .
|
|
|
|
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
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$out->addHTML( $output );
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2011-07-25 22:09:05 +00:00
|
|
|
/**
|
2012-03-11 20:51:54 +00:00
|
|
|
* @param $filter_id null
|
|
|
|
* @param $filter_hidden null
|
2011-07-25 22:09:05 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2012-01-03 17:29:10 +00:00
|
|
|
static function canSeeDetails( $filter_id = null, $filter_hidden = null ) {
|
2011-12-23 20:23:29 +00:00
|
|
|
global $wgUser;
|
2012-01-03 17:29:10 +00:00
|
|
|
|
|
|
|
if ( $filter_id !== null ) {
|
|
|
|
if ( $filter_hidden === null ) {
|
|
|
|
$filter_hidden = AbuseFilter::filterHidden( $filter_id );
|
|
|
|
}
|
|
|
|
if ( $filter_hidden ) {
|
2012-06-17 08:20:10 +00:00
|
|
|
return $wgUser->isAllowed( 'abusefilter-log-detail' ) && (
|
|
|
|
AbuseFilterView::canViewPrivate() || $wgUser->isAllowed( 'abusefilter-log-private' )
|
|
|
|
);
|
2012-01-03 17:29:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-23 20:23:29 +00:00
|
|
|
return $wgUser->isAllowed( 'abusefilter-log-detail' );
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2011-07-25 22:09:05 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2011-12-23 20:23:29 +00:00
|
|
|
static function canSeePrivate() {
|
2010-06-25 20:04:55 +00:00
|
|
|
global $wgUser;
|
|
|
|
return $wgUser->isAllowed( 'abusefilter-private' );
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2011-07-25 22:09:05 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2011-12-23 20:23:29 +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
|
|
|
|
2012-03-11 20:51:54 +00:00
|
|
|
/**
|
|
|
|
* @param $row
|
2014-01-06 20:16:27 +00:00
|
|
|
* @param $isListItem bool
|
2012-03-11 20:51:54 +00:00
|
|
|
* @return String
|
|
|
|
*/
|
2014-01-06 20:16:27 +00:00
|
|
|
function formatRow( $row, $isListItem = true ) {
|
2011-11-16 05:34:24 +00:00
|
|
|
$user = $this->getUser();
|
2011-11-22 16:08:18 +00:00
|
|
|
$lang = $this->getLanguage();
|
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
|
|
|
|
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
|
|
|
|
2012-02-10 23:41:05 +00:00
|
|
|
$diffLink = false;
|
|
|
|
|
|
|
|
if ( self::isHidden($row) && ! $this->canSeeHidden() ) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2009-05-22 06:42:10 +00:00
|
|
|
if ( !$row->afl_wiki ) {
|
2012-04-11 13:45:57 +00:00
|
|
|
$pageLink = Linker::link( $title );
|
2012-02-10 23:41:05 +00:00
|
|
|
if ( $row->afl_rev_id ) {
|
2012-07-13 22:22:23 +00:00
|
|
|
$diffLink = Linker::link( $title,
|
2012-02-10 23:41:05 +00:00
|
|
|
wfMessage('abusefilter-log-diff')->parse(), array(),
|
|
|
|
array( 'diff' => 'prev', 'oldid' => $row->afl_rev_id ) );
|
|
|
|
}
|
2009-03-30 06:12:12 +00:00
|
|
|
} else {
|
|
|
|
$pageLink = WikiMap::makeForeignLink( $row->afl_wiki, $row->afl_title );
|
2012-02-10 23:41:05 +00:00
|
|
|
|
|
|
|
if ( $row->afl_rev_id ) {
|
|
|
|
$diffUrl = WikiMap::getForeignURL( $row->afl_wiki, $row->afl_title );
|
|
|
|
$diffUrl = wfAppendQuery( $diffUrl,
|
|
|
|
array( 'diff' => 'prev', 'oldid' => $row->afl_rev_id ) );
|
|
|
|
|
|
|
|
$diffLink = Linker::makeExternalLink( $diffUrl,
|
|
|
|
wfMessage('abusefilter-log-diff')->parse() );
|
|
|
|
}
|
2009-03-30 06:12:12 +00:00
|
|
|
}
|
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
|
2013-06-26 22:58:36 +00:00
|
|
|
$userLink = Linker::userLink( $row->afl_user, $row->afl_user_text ) .
|
|
|
|
Linker::userToolLinks( $row->afl_user, $row->afl_user_text, true );
|
2009-03-30 06:12:12 +00:00
|
|
|
} else {
|
2013-06-26 22:58:36 +00:00
|
|
|
$userLink = WikiMap::foreignUserLink( $row->afl_wiki, $row->afl_user_text );
|
2011-11-16 05:34:24 +00:00
|
|
|
$userLink .= ' (' . WikiMap::getWikiName( $row->afl_wiki ) . ')';
|
2009-03-30 06:12:12 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
$timestamp = $lang->timeanddate( $row->afl_timestamp, true );
|
2009-02-26 21:45:07 +00:00
|
|
|
|
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 ) ) ) {
|
2012-09-02 11:07:02 +00:00
|
|
|
$actions_taken = $this->msg( 'abusefilter-log-noactions' )->text();
|
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
|
|
|
}
|
2011-11-16 05:34:24 +00:00
|
|
|
$actions_taken = $lang->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-05-22 06:42:10 +00:00
|
|
|
if ( $globalIndex ) {
|
2009-03-30 06:12:12 +00:00
|
|
|
// Pull global filter description
|
|
|
|
$parsed_comments =
|
2012-09-02 11:07:02 +00:00
|
|
|
$this->getOutput()->parseInline( AbuseFilter::getGlobalFilterDescription( $globalIndex ) );
|
2012-01-03 17:29:10 +00:00
|
|
|
$filter_hidden = null;
|
2009-03-30 06:12:12 +00:00
|
|
|
} else {
|
2012-09-02 11:07:02 +00:00
|
|
|
$parsed_comments = $this->getOutput()->parseInline( $row->af_public_comments );
|
2012-01-03 17:29:10 +00:00
|
|
|
$filter_hidden = $row->af_hidden;
|
2009-03-30 06:12:12 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2012-01-03 17:29:10 +00:00
|
|
|
if ( self::canSeeDetails( $row->afl_filter, $filter_hidden ) ) {
|
2014-01-06 20:16:27 +00:00
|
|
|
if( $isListItem ) {
|
|
|
|
$detailsLink = Linker::linkKnown(
|
|
|
|
$this->getPageTitle($row->afl_id),
|
|
|
|
$this->msg( 'abusefilter-log-detailslink' )->escaped()
|
|
|
|
);
|
|
|
|
$actionLinks[] = $detailsLink;
|
|
|
|
}
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
$examineTitle = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/log/' . $row->afl_id );
|
2012-03-11 20:51:54 +00:00
|
|
|
$examineLink = Linker::link(
|
2009-10-07 13:57:06 +00:00
|
|
|
$examineTitle,
|
2012-09-02 11:07:02 +00:00
|
|
|
$this->msg( 'abusefilter-changeslist-examine' )->parse(),
|
2009-10-07 13:57:06 +00:00
|
|
|
array()
|
|
|
|
);
|
2010-06-25 20:04:55 +00:00
|
|
|
$actionLinks[] = $examineLink;
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2012-02-10 23:41:05 +00:00
|
|
|
if ($diffLink)
|
|
|
|
$actionLinks[] = $diffLink;
|
|
|
|
|
2011-11-16 05:34:24 +00:00
|
|
|
if ( $user->isAllowed( 'abusefilter-hide-log' ) ) {
|
2012-03-11 20:51:54 +00:00
|
|
|
$hideLink = Linker::link(
|
2013-12-27 06:36:34 +00:00
|
|
|
$this->getPageTitle(),
|
2012-09-02 11:07:02 +00:00
|
|
|
$this->msg( 'abusefilter-log-hidelink' )->text(),
|
|
|
|
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 );
|
|
|
|
|
2011-10-17 07:56:05 +00:00
|
|
|
$linkText = wfMessage( 'abusefilter-log-detailedentry-global' )->numParams( $globalIndex )->escaped();
|
2012-03-11 20:51:54 +00:00
|
|
|
$filterLink = Linker::makeExternalLink( $globalURL, $linkText );
|
2009-03-30 06:12:12 +00:00
|
|
|
} else {
|
|
|
|
$title = SpecialPage::getTitleFor( 'AbuseFilter', $row->afl_filter );
|
2011-10-17 07:56:05 +00:00
|
|
|
$linkText = wfMessage( 'abusefilter-log-detailedentry-local' )->numParams( $row->afl_filter )->escaped();
|
2012-03-11 20:51:54 +00:00
|
|
|
$filterLink = Linker::link( $title, $linkText );
|
2009-03-30 06:12:12 +00:00
|
|
|
}
|
2012-09-02 11:07:02 +00:00
|
|
|
$description = $this->msg( 'abusefilter-log-detailedentry-meta' )->rawParams(
|
|
|
|
$timestamp,
|
|
|
|
$userLink,
|
|
|
|
$filterLink,
|
|
|
|
$row->afl_action,
|
|
|
|
$pageLink,
|
|
|
|
$actions_taken,
|
|
|
|
$parsed_comments,
|
2012-12-16 10:06:19 +00:00
|
|
|
$lang->pipeList( $actionLinks ),
|
|
|
|
$row->afl_user_text
|
2012-09-02 11:07:02 +00:00
|
|
|
)->parse();
|
2008-06-27 06:18:51 +00:00
|
|
|
} else {
|
2014-01-06 03:53:05 +00:00
|
|
|
if ( $diffLink ) {
|
|
|
|
$msg = 'abusefilter-log-entry-withdiff';
|
|
|
|
} else {
|
|
|
|
$msg = 'abusefilter-log-entry';
|
|
|
|
}
|
|
|
|
$description = $this->msg( $msg )->rawParams(
|
2012-09-02 11:07:02 +00:00
|
|
|
$timestamp,
|
|
|
|
$userLink,
|
|
|
|
$row->afl_action,
|
2013-07-09 16:04:53 +00:00
|
|
|
$pageLink,
|
2012-09-02 11:07:02 +00:00
|
|
|
$actions_taken,
|
2014-01-06 03:53:05 +00:00
|
|
|
$parsed_comments,
|
|
|
|
$diffLink // Passing $7 to 'abusefilter-log-entry' will do nothing, as it's not used.
|
2012-09-02 11:07:02 +00:00
|
|
|
)->parse();
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2012-02-10 23:41:05 +00:00
|
|
|
if ( self::isHidden( $row ) === true ) {
|
2010-06-25 20:04:55 +00:00
|
|
|
$description .= ' '.
|
2012-09-02 11:07:02 +00:00
|
|
|
$this->msg( 'abusefilter-log-hidden' )->parse();
|
2013-03-28 14:09:52 +00:00
|
|
|
$class = 'afl-hidden';
|
2012-02-10 23:41:05 +00:00
|
|
|
} elseif ( self::isHidden($row) === 'implicit' ) {
|
|
|
|
$description .= ' '.
|
2012-09-02 11:07:02 +00:00
|
|
|
$this->msg( 'abusefilter-log-hidden-implicit' )->parse();
|
2010-06-25 20:04:55 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2014-01-06 20:16:27 +00:00
|
|
|
if ( $isListItem ) {
|
2013-03-28 14:09:52 +00:00
|
|
|
return Xml::tags( 'li', isset( $class ) ? array( 'class' => $class ) : null, $description );
|
|
|
|
} else {
|
|
|
|
return Xml::tags( 'span', isset( $class ) ? array( 'class' => $class ) : null, $description );
|
|
|
|
}
|
|
|
|
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
2011-07-04 22:00:06 +00:00
|
|
|
|
2011-07-25 22:09:05 +00:00
|
|
|
/**
|
|
|
|
* @param $db DatabaseBase
|
|
|
|
* @return string
|
|
|
|
*/
|
2010-08-28 11:54:49 +00:00
|
|
|
public static function getNotDeletedCond( $db ) {
|
|
|
|
$deletedZeroCond = $db->makeList(
|
|
|
|
array( 'afl_deleted' => 0 ), LIST_AND );
|
|
|
|
$deletedNullCond = $db->makeList(
|
|
|
|
array( 'afl_deleted' => null ), LIST_AND );
|
|
|
|
$notDeletedCond = $db->makeList(
|
|
|
|
array( $deletedZeroCond, $deletedNullCond ), LIST_OR );
|
2011-07-04 22:00:06 +00:00
|
|
|
|
2010-08-28 11:54:49 +00:00
|
|
|
return $notDeletedCond;
|
|
|
|
}
|
2012-02-10 23:41:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a log entry row, decides whether or not it can be viewed by the public.
|
|
|
|
*
|
2012-09-02 11:07:02 +00:00
|
|
|
* @param $row stdClass The abuse_filter_log row object.
|
2012-02-10 23:41:05 +00:00
|
|
|
*
|
|
|
|
* @return Mixed true if the item is explicitly hidden, false if it is not.
|
|
|
|
* The string 'implicit' if it is hidden because the corresponding revision is hidden.
|
|
|
|
*/
|
|
|
|
public static function isHidden( $row ) {
|
|
|
|
if ( $row->afl_rev_id ) {
|
|
|
|
$revision = Revision::newFromId( $row->afl_rev_id );
|
|
|
|
if ( $revision && $revision->getVisibility() != 0 ) {
|
|
|
|
return 'implicit';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (bool)$row->afl_deleted;
|
|
|
|
}
|
2008-06-27 06:18:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class AbuseLogPager extends ReverseChronologicalPager {
|
2011-07-04 22:00:06 +00:00
|
|
|
/**
|
|
|
|
* @var HtmlForm
|
|
|
|
*/
|
|
|
|
public $mForm;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $mConds;
|
2008-06-27 06:18:51 +00:00
|
|
|
|
2012-03-11 20:51:54 +00:00
|
|
|
/**
|
2013-10-15 13:22:05 +00:00
|
|
|
* @param SpecialAbuseLog $form
|
2012-03-11 20:51:54 +00:00
|
|
|
* @param array $conds
|
|
|
|
* @param bool $details
|
|
|
|
*/
|
2008-06-27 06:18:51 +00:00
|
|
|
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-08-28 11:54:49 +00:00
|
|
|
$db = $this->mDb;
|
|
|
|
$info['conds'][] = SpecialAbuseLog::getNotDeletedCond($db);
|
2010-06-25 20:04:55 +00:00
|
|
|
}
|
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
|
|
|
}
|