Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief keyCAPTCHA
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 18 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form\Captcha;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* keyCAPTCHA
|
||||
*/
|
||||
class _Keycaptcha
|
||||
{
|
||||
/**
|
||||
* @brief Error
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
/**
|
||||
* Display
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHtml()
|
||||
{
|
||||
$explodedKey = explode( '0', \IPS\Settings::i()->keycaptcha_privatekey, 2 );
|
||||
$uniq = md5( uniqid() );
|
||||
$sign = md5( $uniq . \IPS\Request::i()->ipAddress . $explodedKey[0] );
|
||||
$sign2 = md5( $uniq . $explodedKey[0] );
|
||||
|
||||
return <<<HTML
|
||||
<input type='hidden' id='capcode' name='keycaptcha'>
|
||||
<script type="text/javascript">
|
||||
// required
|
||||
var s_s_c_user_id = '{$explodedKey[1]}';
|
||||
var s_s_c_session_id = '{$uniq}';
|
||||
var s_s_c_captcha_field_id = 'capcode';
|
||||
var s_s_c_submit_button_id ='sbutton-#-r';
|
||||
var s_s_c_web_server_sign = '{$sign}';
|
||||
var s_s_c_web_server_sign2 = '{$sign2}';
|
||||
</script>
|
||||
<div data-ipsCaptcha data-ipsCaptcha-service='keycaptcha' id='div_for_keycaptcha'></div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify
|
||||
*
|
||||
* @return bool|null TRUE/FALSE indicate if the test passed or not. NULL indicates the test failed, but the captcha system will display an error so we don't have to.
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
$explodedResponse = explode( '|', \IPS\Request::i()->keycaptcha );
|
||||
$explodedKey = explode( '0', \IPS\Settings::i()->keycaptcha_privatekey );
|
||||
|
||||
if( $explodedResponse[0] === md5( 'accept' . $explodedResponse[1] . $explodedKey[0] . $explodedResponse[2] ) )
|
||||
{
|
||||
if( (string) \IPS\Http\Url::external( $explodedResponse[2] )->request()->get() === '1' )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief reCAPTCHA
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 18 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form\Captcha;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* reCAPTCHA
|
||||
*/
|
||||
class _Recaptcha
|
||||
{
|
||||
/**
|
||||
* @brief Error
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
/**
|
||||
* Display
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHtml()
|
||||
{
|
||||
$publicKey = \IPS\Settings::i()->recaptcha_public_key;
|
||||
$theme = \IPS\Settings::i()->recaptcha_theme;
|
||||
$lang = preg_replace( '/^(.+?)\..*$/', '$1', \IPS\Member::loggedIn()->language()->short );
|
||||
|
||||
return <<<HTML
|
||||
<div data-ipsCaptcha data-ipsCaptcha-service='recaptcha' data-ipsCaptcha-key="{$publicKey}" data-ipsCaptcha-lang="{$lang}" data-ipsCaptcha-theme="{$theme}">
|
||||
<noscript>
|
||||
<iframe src="//www.google.com/recaptcha/api/noscript?k={$publicKey}&hl={$lang}&error={$this->error}"
|
||||
height="300" width="500" frameborder="0"></iframe><br>
|
||||
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
|
||||
<input type="hidden" name="recaptcha_response_field" value="manual_challenge">
|
||||
</noscript>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify
|
||||
*
|
||||
* @return bool|null TRUE/FALSE indicate if the test passed or not. NULL indicates the test failed, but the captcha system will display an error so we don't have to.
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
try
|
||||
{
|
||||
$response = \IPS\Http\Url::external( 'http://www.google.com/recaptcha/api/verify' )->request()->post( array(
|
||||
'privatekey' => \IPS\Settings::i()->recaptcha_private_key,
|
||||
'remoteip' => \IPS\Request::i()->ipAddress(),
|
||||
'challenge' => \IPS\Request::i()->recaptcha_challenge_field,
|
||||
'response' => \IPS\Request::i()->recaptcha_response_field
|
||||
) );
|
||||
}
|
||||
catch ( \IPS\Http\Request\Exception $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$response = explode( "\n", $response );
|
||||
|
||||
if ( $response[0] === 'true' )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $response[1];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief reCAPTCHA
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 5 Dec 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\Helpers\Form\Captcha;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* reCAPTCHA
|
||||
*/
|
||||
class _Recaptcha2
|
||||
{
|
||||
/**
|
||||
* @brief Error
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
/**
|
||||
* Display
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHtml()
|
||||
{
|
||||
$publicKey = \IPS\Settings::i()->recaptcha2_public_key;
|
||||
$theme = \IPS\Settings::i()->recaptcha2_theme;
|
||||
$lang = preg_replace( '/^(.+?)\..*$/', '$1', \IPS\Member::loggedIn()->language()->short );
|
||||
|
||||
return <<<HTML
|
||||
<div data-ipsCaptcha data-ipsCaptcha-service='recaptcha2' data-ipsCaptcha-key="{$publicKey}" data-ipsCaptcha-lang="{$lang}" data-ipsCaptcha-theme="{$theme}">
|
||||
<noscript>
|
||||
<div style="width: 302px; height: 352px;">
|
||||
<div style="width: 302px; height: 352px; position: relative;">
|
||||
<div style="width: 302px; height: 352px; position: absolute;">
|
||||
<iframe src="https://www.google.com/recaptcha/api/fallback?k={$publicKey}" frameborder="0" scrolling="no" style="width: 302px; height:352px; border-style: none;">
|
||||
</iframe>
|
||||
</div>
|
||||
<div style="width: 250px; height: 80px; position: absolute; border-style: none; bottom: 21px; left: 25px; margin: 0px; padding: 0px; right: 25px;">
|
||||
<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 80px; border: 1px solid #c1c1c1; margin: 0px; padding: 0px; resize: none;" value="">
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</noscript>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify
|
||||
*
|
||||
* @return bool|null TRUE/FALSE indicate if the test passed or not. NULL indicates the test failed, but the captcha system will display an error so we don't have to.
|
||||
*/
|
||||
public function verify()
|
||||
{
|
||||
try
|
||||
{
|
||||
$response = \IPS\Http\Url::external( 'https://www.google.com/recaptcha/api/siteverify' )->request()->post( array(
|
||||
'secret' => \IPS\Settings::i()->recaptcha2_private_key,
|
||||
'response' => trim( \IPS\Request::i()->__get('g-recaptcha-response') ),
|
||||
'remoteip' => \IPS\Request::i()->ipAddress(),
|
||||
) )->decodeJson( TRUE );
|
||||
|
||||
return (bool) $response['success'];
|
||||
}
|
||||
catch( \RuntimeException $e )
|
||||
{
|
||||
if( $e->getMessage() == 'BAD_JSON' )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Whitespace-only changes.
Reference in new issue
Block a user