Skip to content

Commit

Permalink
version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmi08 committed Apr 10, 2017
1 parent 4b2a5b7 commit bd53a3d
Show file tree
Hide file tree
Showing 11 changed files with 468 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# recaptcha
NoCaptcha ReCaptcha for e107 v 2.1.5 higher
No CAPTCHA reCAPTCHA Captcha replacement for e107 v2.1.3 or higher. ReCaptcha for e107 v 2.1.5 higher

You should use this plugin on your own risk.

You can support next development by donation on https://www.e107.sk/

Source and thanks:

https://github.com/e107inc/visualcaptcha

https://webdesign.tutsplus.com/tutorials/how-to-integrate-no-captcha-recaptcha-in-your-website--cms-23024

http://stackoverflow.com/questions/1241947/how-do-i-show-multiple-recaptchas-on-a-single-page
151 changes: 151 additions & 0 deletions admin_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php

// Generated e107 Plugin Admin Area

require_once('../../class2.php');
if (!getperms('P'))
{
e107::redirect('admin');
exit;
}

// e107::lan('recaptcha',true);


class recaptcha_adminArea extends e_admin_dispatcher
{

protected $modes = array(

'main' => array(
'controller' => 'recaptcha_ui',
'path' => null,
'ui' => 'recaptcha_form_ui',
'uipath' => null
),


);


protected $adminMenu = array(

'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'P'),

// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P')
);

protected $adminMenuAliases = array(
'main/edit' => 'main/list'
);

protected $menuTitle = 'No CAPTCHA reCAPTCHA';
}





class recaptcha_ui extends e_admin_ui
{

protected $pluginTitle = 'No CAPTCHA reCAPTCHA';
protected $pluginName = 'recaptcha';
// protected $eventName = 'recaptcha-'; // remove comment to enable event triggers in admin.
protected $table = '';
protected $pid = '';
protected $perPage = 10;
protected $batchDelete = true;
// protected $batchCopy = true;
// protected $sortField = 'somefield_order';
// protected $orderStep = 10;
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.

// protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.

protected $listOrder = ' DESC';

protected $fields = NULL;

protected $fieldpref = array();


// protected $preftabs = array('General', 'Other' );
protected $prefs = array(
'active' => array('title'=> 'Active', 'tab'=>0, 'type'=>'bool', 'data' => 'int', 'help'=>''),
'sitekey' => array('title'=> 'Site Key', 'tab'=>0, 'type'=>'text', 'data' => 'str', 'help'=>'', 'writeParms' => array('size'=>'block-level')),
'secretkey' => array('title'=> 'Secret Key', 'tab'=>0, 'type'=>'text', 'data' => 'str', 'help'=>'', 'writeParms' => array('size'=>'block-level')),
);

public function init()
{
// Set drop-down values (if any).

}

// ------- Customize Create --------

public function beforeCreate($new_data,$old_data)
{
return $new_data;
}

public function afterCreate($new_data, $old_data, $id)
{
// do something
}

public function onCreateError($new_data, $old_data)
{
// do something
}


// ------- Customize Update --------

public function beforeUpdate($new_data, $old_data, $id)
{
return $new_data;
}

public function afterUpdate($new_data, $old_data, $id)
{
// do something
}

public function onUpdateError($new_data, $old_data, $id)
{
// do something
}


/*
// optional - a custom page.
public function customPage()
{
$text = 'Hello World!';
$otherField = $this->getController()->getFieldVar('other_field_name');
return $text;
}
*/

}



class recaptcha_form_ui extends e_admin_form_ui
{

}


new recaptcha_adminArea();

require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();

require_once(e_ADMIN."footer.php");
exit;

?>
31 changes: 31 additions & 0 deletions e_header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
$recaptchaActive = e107::pref('recaptcha', 'active');
$recaptchaSiteKey = e107::pref('recaptcha', 'sitekey');

if($recaptchaActive)
{
// e107::js("footer", "https://www.google.com/recaptcha/api.js?onload=myCallBack" , 'jquery');

/* WORKROUND you can't use async defer with e107::js now) */
if(!function_exists("theme_foot")) {
function theme_foot() {
// e107::js("footer", "https://www.google.com/recaptcha/api.js" , 'jquery');
echo '<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
async defer>
</script>';
}
}

$script = " var onloadCallback = function() {
$('.g-recaptcha').each(function(){
grecaptcha.render(this,{'sitekey' : '{$recaptchaSiteKey}'});
})
}; ";

e107::js("footer-inline", $script , 'jquery');

}



?>
112 changes: 112 additions & 0 deletions e_module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* User signup
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/signup.php $
* $Id: signup.php 12780 2012-06-02 14:36:22Z secretr $
*
*/

$recaptchaActive = e107::pref('recaptcha', 'active');
$recaptchaSiteKey = e107::pref('recaptcha', 'sitekey');
$recaptchaSecretKey = e107::pref('recaptcha', 'secretkey');

if($recaptchaActive)
{




class e107recaptcha
{

public function __construct()
{

e107::lan('recaptcha', false, true);
}

static function blank()
{
return ;
}

static function input()
{
//$text = '<div class="g-recaptcha" data-sitekey="'.e107::pref('recaptcha', 'sitekey').'" ></div> ';

$text = '<div class="g-recaptcha" ></div> ';
return $text;
}

static function hiddeninput()
{
$frm = e107::getForm();
return $frm->hidden("rand_num", 'google' );
}

static function verify($code, $other)
{

if ( ! function_exists( 'recaptcha_get_html' ) )
require_once e_PLUGIN.'recaptcha/inc/recaptchalib.php';

// your secret key
$secret = e107::pref('recaptcha', 'secretkey');

// empty response
$response = null;

// check secret key
$reCaptcha = new ReCaptcha($secret);

// if submitted check response
if ($_POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}

if ($response != null && $response->success) {
return true;
} else {
return false;
}
}

// Return an Error message (true) if check fails, otherwise return false.
/**
* @param $rec_num
* @param $checkstr
* @return bool|mixed|string
*/
function invalidinvalid($code, $other)
{

if(self::verify($rec_num,$checkstr))
{
return false;
}
else
{
return 'You did not pass robot test';
}

}

}

/* remove original captcha */
e107::getOverride()->replace('secure_image::r_image', 'e107recaptcha::input');
e107::getOverride()->replace('secure_image::renderInput', 'e107recaptcha::hiddeninput');
e107::getOverride()->replace('secure_image::invalidCode', 'e107recaptcha::invalid');
e107::getOverride()->replace('secure_image::renderLabel', 'e107recaptcha::blank');
e107::getOverride()->replace('secure_image::verify_code', 'e107recaptcha::verify');
}
Binary file added images/_icon_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/_icon_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/_icon_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/_icon_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bd53a3d

Please sign in to comment.