Index: trunk/extensions/CheckUser/api/ApiQueryCheckUser.php |
— | — | @@ -13,21 +13,19 @@ |
14 | 14 | |
15 | 15 | $db = $this->getDB( DB_SLAVE ); |
16 | 16 | $params = $this->extractRequestParams(); |
| 17 | + extract( $params ); |
17 | 18 | |
18 | 19 | if ( !$wgUser->isAllowed( 'checkuser' ) ) { |
19 | 20 | $this->dieUsage( 'You need the checkuser right', 'permissionerror' ); |
20 | 21 | } |
21 | 22 | |
22 | | - if ( $wgCheckUserForceSummary && is_null( $params['reason'] ) ) { |
23 | | - $this->dieUsage( 'You need define reason for check', 'missingdata' ); |
| 23 | + if ( $wgCheckUserForceSummary && is_null( $reason ) ) { |
| 24 | + $this->dieUsage( 'You must define reason for check', 'missingdata' ); |
24 | 25 | } |
25 | 26 | |
26 | | - $limit = $params['limit']; |
27 | | - $target = $params['target']; |
28 | | - $reason = wfMsgForContent( 'checkuser-reason-api', $params['reason'] ); |
| 27 | + $reason = wfMsgForContent( 'checkuser-reason-api', $reason ); |
29 | 28 | $time = wfTimestamp( TS_MW, |
30 | | - strtotime( 'now' ) - ( strtotime( $params['timecond'] ? $params['timecond'] : '2 weeks' ) - strtotime( 'now' |
31 | | - ) ) |
| 29 | + strtotime( 'now' ) - ( strtotime( $timecond ? $timecond : '2 weeks' ) - strtotime( 'now' ) ) |
32 | 30 | ); |
33 | 31 | if ( !$time ) { |
34 | 32 | $this->dieUsage( 'You need use correct time limit (like "2 weeks")', 'invalidtime' ); |
— | — | @@ -38,7 +36,7 @@ |
39 | 37 | $this->addOption( 'ORDER BY', 'cuc_timestamp DESC' ); |
40 | 38 | $this->addWhere( "cuc_timestamp > $time" ); |
41 | 39 | |
42 | | - switch ( $params['request'] ) { |
| 40 | + switch ( $request ) { |
43 | 41 | case 'userips': |
44 | 42 | $user_id = User::idFromName( $target ); |
45 | 43 | if ( !$user_id ) { |
— | — | @@ -77,7 +75,7 @@ |
78 | 76 | break; |
79 | 77 | |
80 | 78 | case 'edits': |
81 | | - if ( IP::isIPAddress( $target ) && isset( $params['xff'] ) ) { |
| 79 | + if ( IP::isIPAddress( $target ) && isset( $xff ) ) { |
82 | 80 | $cond = CheckUser::getIpConds( $db, $target, true ); |
83 | 81 | if ( !$cond ) { |
84 | 82 | $this->dieUsage( 'IP or range is invalid', 'invalidip' ); |
— | — | @@ -100,7 +98,8 @@ |
101 | 99 | $log_type = array( 'useredits', 'user' ); |
102 | 100 | } |
103 | 101 | |
104 | | - $this->addFields( array( 'cuc_namespace', 'cuc_title', 'cuc_user_text', 'cuc_actiontext', 'cuc_comment', 'cuc_minor', 'cuc_timestamp', 'cuc_ip', 'cuc_xff', 'cuc_agent' ) |
| 102 | + $this->addFields( array( 'cuc_namespace', 'cuc_title', 'cuc_user_text', 'cuc_actiontext', |
| 103 | + 'cuc_comment', 'cuc_minor', 'cuc_timestamp', 'cuc_ip', 'cuc_xff', 'cuc_agent' ) |
105 | 104 | ); |
106 | 105 | |
107 | 106 | $res = $this->select( __METHOD__ ); |
— | — | @@ -130,13 +129,13 @@ |
131 | 130 | $edits[] = $edit; |
132 | 131 | } |
133 | 132 | |
134 | | - CheckUser::addLogEntry( $log_type[0], $log_type[1], $target, $reason, $user_id ? $user_id : '0' ); |
| 133 | + CheckUser::addLogEntry( $log_type[0], $log_type[1], $target, $reason, isset($user_id) ? $user_id : '0' ); |
135 | 134 | $result->addValue( array( 'query', $this->getModuleName() ), 'edits', $edits ); |
136 | 135 | $result->setIndexedTagName_internal( array( 'query', $this->getModuleName(), 'edits' ), 'action' ); |
137 | 136 | break; |
138 | 137 | |
139 | 138 | case 'ipusers': |
140 | | - if ( IP::isIPAddress( $target ) && isset( $params['xff'] ) ) { |
| 139 | + if ( IP::isIPAddress( $target ) && isset( $xff ) ) { |
141 | 140 | $cond = CheckUser::getIpConds( $db, $target, true ); |
142 | 141 | $this->addWhere( $cond ); |
143 | 142 | } elseif ( IP::isIPAddress( $target ) ) { |
— | — | @@ -205,7 +204,7 @@ |
206 | 205 | public function getAllowedParams() { |
207 | 206 | return array( |
208 | 207 | 'request' => array( |
209 | | - ApiBase::PARAM_REQUIRED => false, |
| 208 | + ApiBase::PARAM_REQUIRED => true, |
210 | 209 | ApiBase::PARAM_TYPE => array( |
211 | 210 | 'userips', |
212 | 211 | 'edits', |
— | — | @@ -224,6 +223,7 @@ |
225 | 224 | ApiBase::PARAM_MAX2 => 5000, |
226 | 225 | ), |
227 | 226 | 'timecond' => null, |
| 227 | + 'xff' => null, |
228 | 228 | ); |
229 | 229 | } |
230 | 230 | |
— | — | @@ -239,6 +239,7 @@ |
240 | 240 | 'reason' => 'Reason to check', |
241 | 241 | 'limit' => 'Limit of rows', |
242 | 242 | 'timecond' => 'Time limit of user data (like "2 weeks")', |
| 243 | + 'xff' => 'Use xff data instead of IP', |
243 | 244 | ); |
244 | 245 | } |
245 | 246 | |
— | — | @@ -261,7 +262,7 @@ |
262 | 263 | public function getExamples() { |
263 | 264 | return array( |
264 | 265 | 'api.php?action=query&list=checkuser&curequest=userips&cutarget=Jimbo_Wales', |
265 | | - 'api.php?action=query&list=checkuser&curequest=edits&cutarget=127.0.0.1/16/xff&cureason=Some_check', |
| 266 | + 'api.php?action=query&list=checkuser&curequest=edits&cutarget=127.0.0.1/16&xff=1&cureason=Some_check', |
266 | 267 | ); |
267 | 268 | } |
268 | 269 | |
Index: trunk/extensions/CheckUser/api/ApiQueryCheckUserLog.php |
— | — | @@ -16,17 +16,12 @@ |
17 | 17 | if ( !$wgUser->isAllowed( 'checkuser-log' ) ) { |
18 | 18 | $this->dieUsage( 'You need the checkuser-log right', 'permissionerror' ); |
19 | 19 | } |
| 20 | + |
| 21 | + extract( $params ); |
20 | 22 | |
21 | | - $user = $params['user']; |
22 | | - $limit = $params['limit']; |
23 | | - $target = $params['target']; |
24 | | - $from = $params['from']; |
25 | | - $to = $params['to']; |
26 | | - |
27 | 23 | $this->addTables( 'cu_log' ); |
28 | 24 | $this->addOption( 'LIMIT', $limit + 1 ); |
29 | 25 | $this->addWhereRange( 'cul_timestamp', 'older', $from, $to ); |
30 | | - |
31 | 26 | $this->addFields( array( 'cul_timestamp', 'cul_user_text', 'cul_reason', 'cul_type', 'cul_target_text' ) ); |
32 | 27 | |
33 | 28 | if ( isset( $user ) ) { |