[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * SpamBlacklist extension API 4 * 5 * Copyright © 2013 Wikimedia Foundation 6 * Based on code by Ian Baker, Victor Vasiliev, Bryan Tong Minh, Roan Kattouw, 7 * Alex Z., and Jackmcbarn 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License along 20 * with this program; if not, write to the Free Software Foundation, Inc., 21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 * http://www.gnu.org/copyleft/gpl.html 23 */ 24 25 /** 26 * Query module check a URL against the blacklist 27 * 28 * @ingroup API 29 * @ingroup Extensions 30 */ 31 class ApiSpamBlacklist extends ApiBase { 32 33 public function execute() { 34 $params = $this->extractRequestParams(); 35 $matches = BaseBlacklist::getInstance( 'spam' )->filter( $params['url'], NULL, true ); 36 $res = $this->getResult(); 37 38 if ( $matches !== false ) { 39 // this url is blacklisted. 40 $res->addValue( 'spamblacklist', 'result', 'blacklisted' ); 41 $res->setIndexedTagName( $matches, 'match' ); 42 $res->addValue( 'spamblacklist', 'matches', $matches ); 43 } else { 44 // not blacklisted 45 $res->addValue( 'spamblacklist', 'result', 'ok' ); 46 } 47 } 48 49 public function getAllowedParams() { 50 return array( 51 'url' => array( 52 ApiBase::PARAM_REQUIRED => true, 53 ApiBase::PARAM_ISMULTI => true, 54 ) 55 ); 56 } 57 58 public function getParamDescription() { 59 return array( 60 'url' => 'A pipe-separated list of URLs to validate against the blacklist', 61 ); 62 } 63 64 public function getDescription() { 65 return 'Validate one or more URLs against the SpamBlacklist.'; 66 } 67 68 public function getExamples() { 69 return array( 70 'api.php?action=spamblacklist&url=http%3A%2F%2Fwww.example.com%2F%7Chttp%3A%2F%2Fwww.example.org%2F', 71 'api.php?action=spamblacklist&url=https%3A%2F%2Fwww.example.net%2Findex.php', 72 ); 73 } 74 75 public function getHelpUrls() { 76 return array( 'https://www.mediawiki.org/wiki/Extension:SpamBlacklist/API' ); 77 } 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |