2015-08-21 65 views
2

我想禁用嘗試登錄時出現的驗證碼。我嘗試刪除它,但登錄失敗。如何禁用驗證碼?

這裏是驗證驗證碼的響應,並通過用戶而來的verify.php登錄:

<?php 
include("db.php"); 
session_start(); 
if($_SERVER["REQUEST_METHOD"] == "POST") 
{ 
$recaptcha=$_POST['g-recaptcha-response']; 
if(!empty($recaptcha)) 
{ 
include("getCurlData.php"); 
$google_url="https://www.google.com/recaptcha/api/siteverify"; 
$secret='6Ld-ogsTAAAAAK0DpO4o4Ama4OPg3xS-Quamaqkq'; //secret key google captcha 
$ip=$_SERVER['REMOTE_ADDR']; 
$url=$google_url."?secret=".$secret."&response=".$recaptcha."&remoteip=".$ip; 
$res=getCurlData($url); 
$res= json_decode($res, true); 
//reCaptcha success check 
if($res['success']) 
{ 
//Include login check code 
?> 
<META http-equiv="refresh" content="2;URL=http://domain.com/login.php?user=<?php echo("".$_GET['user']."");?>"> 

我該如何解決這個問題?

回答

0

這不是優雅,但以下應繞過驗證碼。

<?php 
    include("db.php"); 
    session_start(); 
    $enable_captcha=false; 
    $res['success']=false; 

    if($_SERVER["REQUEST_METHOD"] == "POST") { 

     $recaptcha=$_POST['g-recaptcha-response']; 

     if(!empty($recaptcha)) { 

      if($enable_captcha){ 

       include("getCurlData.php"); 
       $google_url="https://www.google.com/recaptcha/api/siteverify"; 
       $secret='6Ld-ogsTAAAAAK0DpO4o4Ama4OPg3xS-Quamaqkq'; 
       $ip=$_SERVER['REMOTE_ADDR']; 
       $url=$google_url."?secret=".$secret."&response=".$recaptcha."&remoteip=".$ip; 
       $res=getCurlData($url); 
       $res= json_decode($res, true); 
      } 


      if($res['success'] or !$enable_captcha){ 

       /* Include login check code */ 

      } else { /* do something else */ } 
     } 
    } 
?>