* Replace dirname( __FILE__ ) by __DIR__.
* Replace deprecated method calls. Now requires MediaWiki 1.19 or later.
* Fix some documentation.
* Remove commented out code.
* Remove superfluous newlines.
Change-Id: Ib73e1619aa331c83e375224b6adae4c1e5db3bb9
exit;
}
-$dir = dirname( __FILE__ ) . '/';
+$dir = __DIR__ . '/';
require_once( "$dir/ConfirmEdit.php" );
-$dir = dirname( __FILE__ ) . '/';
$wgCaptchaClass = 'Asirra';
$wgExtensionMessagesFiles['Asirra'] = "$dir/Asirra.i18n.php";
<?php
class SimpleCaptcha {
-
function getCaptcha() {
$a = mt_rand( 0, 100 );
$b = mt_rand( 0, 10 );
* Show a message asking the user to enter a captcha on edit
* The result will be treated as wiki text
*
- * @param $action Action being performed
+ * @param $action string Action being performed
* @return string
*/
function getMessage( $action ) {
if ( $wgCaptchaWhitelistIP ) {
global $wgRequest;
- // Compat: WebRequest::getIP is only available since MW 1.19.
- $ip = method_exists( $wgRequest, 'getIP' ) ? $wgRequest->getIP() : wfGetIP();
+ $ip = $wgRequest->getIP();
foreach ( $wgCaptchaWhitelistIP as $range ) {
if ( IP::isInRange( $ip, $range ) ) {
*/
function badLoginKey() {
global $wgRequest;
- // Compat: WebRequest::getIP is only available since MW 1.19.
- $ip = method_exists( $wgRequest, 'getIP' ) ? $wgRequest->getIP() : wfGetIP();
+ $ip = $wgRequest->getIP();
return wfMemcKey( 'captcha', 'badlogin', 'ip', $ip );
}
/**
* Filter callback function for URL whitelisting
- * @param string url to check
+ * @param $url string to check
* @return bool true if unknown, false if whitelisted
* @access private
*/
/**
* Build regex from whitelist
- * @param string lines from [[MediaWiki:Captcha-addurl-whitelist]]
+ * @param $lines string from [[MediaWiki:Captcha-addurl-whitelist]]
* @return string Regex or bool false if whitelist is empty
* @access private
*/
}
/**
- * @param $module ApiBae
+ * @param $module ApiBase
* @param $desc array
* @return bool
*/
/** Register special page */
$wgSpecialPages['Captcha'] = 'CaptchaSpecialPage';
-$wgConfirmEditIP = dirname( __FILE__ );
+$wgConfirmEditIP = __DIR__;
$wgExtensionMessagesFiles['ConfirmEdit'] = "$wgConfirmEditIP/ConfirmEdit.i18n.php";
$wgExtensionMessagesFiles['ConfirmEditAlias'] = "$wgConfirmEditIP/ConfirmEdit.alias.php";
$info = $this->retrieveCaptcha();
if ( $info ) {
- /*
- // Be a little less restrictive for now; in at least some circumstances,
- // Konqueror tries to reload the image even if you haven't navigated
- // away from the page.
- if( $info['viewed'] ) {
- wfHttpError( 403, 'Access Forbidden', "Can't view captcha image a second time." );
- return false;
- }
- */
-
- $info['viewed'] = wfTimestamp();
+ $timestamp = new MWTimestamp();
+ $info['viewed'] = $timestamp->getTimestamp();
$this->storeCaptcha( $info );
$salt = $info['salt'];
global $IP;
require_once "$IP/includes/StreamFile.php";
header( "Cache-Control: private, s-maxage=0, max-age=3600" );
- wfStreamFile( $file );
+ StreamFile::stream( $file );
return true;
}
}
* Show a message asking the user to enter a captcha on edit
* The result will be treated as wiki text
*
- * @param $action Action being performed
+ * @param $action string Action being performed
* @return string
*/
function getMessage( $action ) {
exit;
}
-require_once dirname( __FILE__ ) . '/ConfirmEdit.php';
+$dir = __DIR__;
+require_once $dir . '/ConfirmEdit.php';
$wgCaptchaClass = 'FancyCaptcha';
global $wgCaptchaDirectory;
*/
$wgCaptchaDeleteOnSolve = false;
-$wgExtensionMessagesFiles['FancyCaptcha'] = dirname( __FILE__ ) . '/FancyCaptcha.i18n.php';
-$wgAutoloadClasses['FancyCaptcha'] = dirname( __FILE__ ) . '/FancyCaptcha.class.php';
+$wgExtensionMessagesFiles['FancyCaptcha'] = $dir . '/FancyCaptcha.i18n.php';
+$wgAutoloadClasses['FancyCaptcha'] = $dir . '/FancyCaptcha.class.php';
* @class
*/
class HTMLCaptchaField extends HTMLFormField {
-
/**
* @var Captcha
*/
exit;
}
-require_once dirname( __FILE__ ) . '/ConfirmEdit.php';
+$dir = __DIR__;
+require_once $dir . '/ConfirmEdit.php';
$wgCaptchaClass = 'MathCaptcha';
-$wgAutoloadClasses['MathCaptcha'] = dirname( __FILE__ ) . '/MathCaptcha.class.php';
+$wgAutoloadClasses['MathCaptcha'] = $dir . '/MathCaptcha.class.php';
exit;
}
-require_once dirname( __FILE__ ) . '/ConfirmEdit.php';
+$dir = __DIR__;
+require_once $dir . '/ConfirmEdit.php';
$wgCaptchaClass = 'QuestyCaptcha';
global $wgCaptchaQuestions;
// You can also provide several acceptable answers to a given question (the answers shall be in lowercase):
// $wgCaptchaQuestions[] = array( 'question' => "2 + 2 ?", 'answer' => array( '4', 'four' ) );
-$wgExtensionMessagesFiles['QuestyCaptcha'] = dirname( __FILE__ ) . '/QuestyCaptcha.i18n.php';
-$wgAutoloadClasses['QuestyCaptcha'] = dirname( __FILE__ ) . '/QuestyCaptcha.class.php';
+$wgExtensionMessagesFiles['QuestyCaptcha'] = $dir . '/QuestyCaptcha.i18n.php';
+$wgAutoloadClasses['QuestyCaptcha'] = $dir . '/QuestyCaptcha.class.php';
return false;
}
- // Compat: WebRequest::getIP is only available since MW 1.19.
- $ip = method_exists( $wgRequest, 'getIP' ) ? $wgRequest->getIP() : wfGetIP();
+ $ip = $wgRequest->getIP();
$recaptcha_response = recaptcha_check_answer(
$wgReCaptchaPrivateKey,
* Show a message asking the user to enter a captcha on edit
* The result will be treated as wiki text
*
- * @param $action Action being performed
+ * @param $action string Action being performed
* @return string
*/
function getMessage( $action ) {
exit;
}
-require_once dirname( __FILE__ ) . '/ConfirmEdit.php';
+$dir = __DIR__;
+require_once $dir . '/ConfirmEdit.php';
$wgCaptchaClass = 'ReCaptcha';
-$dir = dirname( __FILE__ );
-
$wgExtensionMessagesFiles['ReCaptcha'] = $dir . '/ReCaptcha.i18n.php';
$wgAutoloadClasses['ReCaptcha'] = $dir . '/ReCaptcha.class.php';