Modified:Recaptcha V2 Added
This commit is contained in:
parent
6ff2f28f57
commit
c276f3bef5
9 changed files with 303 additions and 3 deletions
26
upload/plugins/recaptcha_v2/admin/recaptcha_v2_configs.html
Executable file
26
upload/plugins/recaptcha_v2/admin/recaptcha_v2_configs.html
Executable file
|
@ -0,0 +1,26 @@
|
|||
<div class="heading">
|
||||
<h2>reCaptcha V2 configurations</h2>
|
||||
</div>
|
||||
<div class="row" style="margin-left:20px;">
|
||||
<p class="grey-text font-size" style="margin-top:0px;">Google's recaptcha v2 won't work unless you provide these configurations to get your website's configurations<a href='https://www.google.com/recaptcha/admin' target="blank"> Click here</a>.</p>
|
||||
<form id="special-thumb" class="clearfix" method="post" enctype="multipart/form-data">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<label for="recaptcha_v2_site_key">Site key *</label>
|
||||
<input name="recaptcha_v2_site_key" type="text" id="recaptcha_v2_site_key" value="{$rec_config.recaptcha_v2_site_key}" class="form-control"/>
|
||||
<p class="grey-text font-size" style="margin-top:0px;">Enter your google's recaptcha v2 site key</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="recaptcha_v2_secret_key">Secret key *</label>
|
||||
<input name="recaptcha_v2_secret_key" type="text" id="recaptcha_v2_secret_key" value="{$rec_config.recaptcha_v2_secret_key}" class="form-control"/>
|
||||
<p class="grey-text font-size" style="margin-top:0px;">Enter your google's recaptcha v2 secret key</p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-lg-4 form-group">
|
||||
<input type="submit" name="recaptcha_v2_update" class="form-control btn btn-primary btn-block" value="Update configurations" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
47
upload/plugins/recaptcha_v2/admin/recaptcha_v2_configs.php
Executable file
47
upload/plugins/recaptcha_v2/admin/recaptcha_v2_configs.php
Executable file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
if(!defined('IN_CLIPBUCKET'))
|
||||
exit('Invalid access');
|
||||
|
||||
|
||||
$userquery->admin_login_check();
|
||||
$pages->page_redir();
|
||||
|
||||
if(!defined('MAIN_PAGE')){
|
||||
define('MAIN_PAGE', 'reCaptcha v2');
|
||||
}
|
||||
if(!defined('SUB_PAGE')){
|
||||
define('SUB_PAGE', "Configurations");
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if(isset($_POST['recaptcha_v2_update'])){
|
||||
|
||||
|
||||
$param = $_POST;
|
||||
|
||||
$response = $recv2->update_recaptcha_confs($param);
|
||||
|
||||
e($response,"m");
|
||||
}
|
||||
|
||||
|
||||
$rec_config=$recv2->get_recaptcha_confs();
|
||||
assign('rec_config',$rec_config);
|
||||
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
|
||||
e($e->getMessage(),"e");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
subtitle("reCaptcha V2 configurations");
|
||||
template_files(RECAPTCHA_V2_DIR.'/admin/recaptcha_v2_configs.html');
|
49
upload/plugins/recaptcha_v2/admin/recaptchav2_doc.html
Executable file
49
upload/plugins/recaptcha_v2/admin/recaptchav2_doc.html
Executable file
|
@ -0,0 +1,49 @@
|
|||
|
||||
<section class="clearfix form-elements cb-uikit">
|
||||
|
||||
<header class="clearfix">
|
||||
<h2 class="">Documentation</h2>
|
||||
</header>
|
||||
<div class="clearfix">
|
||||
<div class="alert alert-danger">
|
||||
<strong>Note:</strong> Plugin will only work with site key and the secret key set in configurations.
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix">
|
||||
<h3 class="greycolor text_cent">Information About Plugin</h3>
|
||||
<ul>
|
||||
<li><strong>Created:</strong> November, 2017</li>
|
||||
<li><strong>Author:</strong> Awais Fiaz</li>
|
||||
<li><strong>Author Website:</strong> http://clip-bucket.com</li>
|
||||
<li><strong>Version:</strong> 1.0</li>
|
||||
<li><strong>ClipBucket Version:</strong> 2.8.x</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="clearfix">
|
||||
<h3 class="greycolor text_cent">Why You Need reCaptcha v2</h3>
|
||||
<p>reCaptcha v2 is the latest reCaptcha from google which is being used all over the web now a days to save websites from bots and scamers.All new reCaptcha is hard on bots and easy on humans just requires one click authentication.</p>
|
||||
</div>
|
||||
|
||||
<div class="clearfix">
|
||||
|
||||
<h3 class="greycolor text_cent">Plugin Configurations</h3>
|
||||
<h4 class="greycolor text_cent">Prerequisites</h4>
|
||||
<p>Before getting started with reCaptcha v2 plugin you would have to get the site key and secret key from google reCaptcha to get them <strong><a href="https://www.google.com/recaptcha/admin" target="blank">CLICK HERE</a></strong> sign in here with your google account and get you site key and site secret by follow these steps given below.</p>
|
||||
|
||||
<ul class="align_ol">
|
||||
<li>After signing in you will have to choose reCaptcha type select <strong>reCAPTCHA V2</strong> don't forget to add a label you can add you website's name here.</li>
|
||||
<li>Add your domains into domains section you can add more than one if you want.</li>
|
||||
<li>Accept the terms and conditions and click on register.</li>
|
||||
<li>On the next page you will have you website's secret key and website key.</li>
|
||||
<li>copy them both and add them to clipbucket's reCaptcha v2 configurations.DONE! you are good to go.</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="alert alert-warning">
|
||||
<strong>Warning :</strong> Plugin will only work on live domains it does not work for ip(s) or on localhost(s).
|
||||
</div>
|
||||
<div class="clearfix">
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
19
upload/plugins/recaptcha_v2/admin/recaptchav2_doc.php
Executable file
19
upload/plugins/recaptcha_v2/admin/recaptchav2_doc.php
Executable file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
if(!defined('IN_CLIPBUCKET'))
|
||||
exit('Invalid access');
|
||||
|
||||
$userquery->admin_login_check();
|
||||
$pages->page_redir();
|
||||
|
||||
if(!defined('MAIN_PAGE')){
|
||||
define('MAIN_PAGE', 'reCaptcha v2');
|
||||
}
|
||||
if(!defined('SUB_PAGE')){
|
||||
define('SUB_PAGE', "ReCaptcha v2 docs");
|
||||
}
|
||||
|
||||
|
||||
|
||||
subtitle("Documentation");
|
||||
template_files(RECAPTCHA_V2_DIR.'/admin/recaptchav2_doc.html');
|
||||
?>
|
69
upload/plugins/recaptcha_v2/classes/reCaptchav2.class.php
Executable file
69
upload/plugins/recaptcha_v2/classes/reCaptchav2.class.php
Executable file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class reCaptchav2
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
# code...
|
||||
}
|
||||
|
||||
function update_recaptcha_confs($param)
|
||||
{
|
||||
# code...
|
||||
global $db;
|
||||
|
||||
$sitekey = $param['recaptcha_v2_site_key'];
|
||||
$secretkey = $param['recaptcha_v2_secret_key'];
|
||||
|
||||
if($sitekey==NULL || empty($sitekey)){
|
||||
|
||||
throw new Exception("Please add recapcha's site key!");
|
||||
|
||||
}elseif($sitekey==NULL || empty($sitekey)){
|
||||
|
||||
throw new Exception("Please add recapcha's secret key!");
|
||||
|
||||
}else{
|
||||
|
||||
$sitekey = mysql_clean($sitekey);
|
||||
$secretkey = mysql_clean($secretkey);
|
||||
|
||||
|
||||
$db->update(tbl('config'),array('value'),array($sitekey)," name='recaptcha_v2_site_key'");
|
||||
$db->update(tbl('config'),array('value'),array($secretkey)," name='recaptcha_v2_secret_key'");
|
||||
|
||||
$response="reCaptchav2 configurations Updated!";
|
||||
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
function get_recaptcha_confs()
|
||||
{
|
||||
# code...
|
||||
global $Cbucket;
|
||||
|
||||
$rec_config = $Cbucket->configs;
|
||||
// pr($rec_config,true);
|
||||
if(!empty($rec_config)){
|
||||
|
||||
return $rec_config;
|
||||
|
||||
}else{
|
||||
|
||||
throw new Exception("There was an error getting reCaptchav2 configs!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
8
upload/plugins/recaptcha_v2/install_recaptcha_v2.php
Executable file
8
upload/plugins/recaptcha_v2/install_recaptcha_v2.php
Executable file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
//Insert Recaptcha field in configurations
|
||||
|
||||
$db->insert(tbl("config"),array("name","value"),array("recaptcha_v2_site_key",""));
|
||||
$db->insert(tbl("config"),array("name","value"),array("recaptcha_v2_secret_key",""));
|
||||
|
||||
?>
|
76
upload/plugins/recaptcha_v2/recaptcha_v2.php
Executable file
76
upload/plugins/recaptcha_v2/recaptcha_v2.php
Executable file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Plugin Name: ReCaptcha V2
|
||||
Description: Advanced recaptcha varification plugin integrated with google's Recaptcha V2 API
|
||||
Author: Awais Fiaz
|
||||
Author Website: http://clip-bucket.com/
|
||||
ClipBucket Version: 2.8.x
|
||||
Version: 1.0
|
||||
Website: http://clip-bucket.com/
|
||||
Plugin Type: global
|
||||
*/
|
||||
|
||||
// Get a key from https://www.google.com/recaptcha/admin
|
||||
|
||||
|
||||
define("_RECAPTCHA_V2_",basename(dirname(__FILE__)));
|
||||
define("RECAPTCHA_V2_DIR",PLUG_DIR.'/'._RECAPTCHA_V2_);
|
||||
define("RECAPTCHA_V2_URL",PLUG_URL.'/'._RECAPTCHA_V2_);
|
||||
assign("recaptcha_v2_dir",RECAPTCHA_V2_DIR);
|
||||
assign("recaptcha_v2_url",RECAPTCHA_V2_URL);
|
||||
|
||||
require_once("classes/reCaptchav2.class.php");
|
||||
|
||||
$recv2 = new reCaptchav2();
|
||||
assign('recv2',$recv2);
|
||||
|
||||
$sitekey = $Cbucket->configs['recaptcha_v2_site_key'];
|
||||
$privatekey = $Cbucket->configs['recaptcha_v2_secret_key'];
|
||||
|
||||
# the response from reCAPTCHA v2
|
||||
$resp = null;
|
||||
# the error code from reCAPTCHA v2, if any
|
||||
$error = null;
|
||||
|
||||
|
||||
|
||||
function cbrecaptcha_v2(){
|
||||
|
||||
global $sitekey, $privatekey, $error;
|
||||
return "<div class='g-recaptcha' data-sitekey='".$sitekey."'></div>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
function validrecaptcha_v2()
|
||||
{
|
||||
global $privatekey;
|
||||
$ch = curl_init(sprintf(
|
||||
'https://www.google.com/recaptcha/api/siteverify?secret=%s&response=%s&remoteip=%s',
|
||||
$privatekey,
|
||||
$_POST['g-recaptcha-response'],
|
||||
$_SERVER['REMOTE_ADDR']
|
||||
));
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
$resp = curl_exec($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
if (($answer = json_decode($resp)) !== null) {
|
||||
return $answer->success;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
register_cb_captcha('cbrecaptcha_v2','validrecaptcha_v2',false);
|
||||
register_anchor('; Recaptcha.reload ();','onClickAddComment');
|
||||
add_admin_menu("reCaptcha v2","Configurations",'recaptcha_v2_configs.php',_RECAPTCHA_V2_.'/admin');
|
||||
add_admin_menu("reCaptcha v2","ReCaptcha v2 docs",'recaptchav2_doc.php',_RECAPTCHA_V2_.'/admin');
|
||||
|
||||
?>
|
8
upload/plugins/recaptcha_v2/uninstall_recaptcha_v2.php
Executable file
8
upload/plugins/recaptcha_v2/uninstall_recaptcha_v2.php
Executable file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
//Insert Recaptcha field in configurations
|
||||
|
||||
$db->delete(tbl("config"),array("name"),array("recaptcha_v2_site_key"));
|
||||
$db->delete(tbl("config"),array("name"),array("recaptcha_v2_secret_key"));
|
||||
|
||||
?>
|
|
@ -69,9 +69,7 @@
|
|||
<script src="{$baseurl}/js/clipbucket.min.js"></script>
|
||||
{/if}
|
||||
<script src="{$theme}/js/uslider_js/jquery.mousewheel.js"></script>
|
||||
{if $smarty.const.THIS_PAGE == 'signup'}
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
{/if}
|
||||
<script async src='https://www.google.com/recaptcha/api.js'></script>
|
||||
|
||||
|
||||
<!-- Script For Home Page Videos Slider //-->
|
||||
|
|
Loading…
Add table
Reference in a new issue