码迷,mamicode.com
首页 > 其他好文 > 详细

登陆页老是提示验证码错误,validate验证控件IE下用remote方法明明返回true 但是还是报错,提示验证码错误

时间:2015-11-16 15:57:04      阅读:675      评论:0      收藏:0      [点我收藏+]

标签:验证码

登陆页后台:login.php


<?php

/**

 * 前台登录 退出操作

 *

 */

defined(‘IN_B2B2C‘) or exit(‘Access Invalid!‘);


header("Content-type: text/html; charset=utf-8"); 


class loginControl extends BaseHomeControl {


public function __construct(){

parent::__construct();

Tpl::output(‘hidden_nctoolbar‘, 1);

}


/**

* 登录操作

*

*/

public function indexOp(){

Language::read("home_login_index");

$lang = Language::getLangContent();

$model_member = Model(‘member‘);

//检查登录状态

$model_member->checkloginMember();

if ($_GET[‘inajax‘] == 1 && C(‘captcha_status_login‘) == ‘1‘){

   $script = "document.getElementById(‘codeimage‘).src=‘".APP_SITE_URL."/index.php?act=seccode&op=makecode&nchash=".getNchash()."&t=‘ + Math.random();";

}

$result = chksubmit(true,C(‘captcha_status_login‘),‘num‘);

if ($result !== false){

if ($result === -11){

showDialog($lang[‘login_index_login_illegal‘]);

}elseif ($result === -12){

showDialog($lang[‘login_index_wrong_checkcode‘]);

}

if (processClass::islock(‘login‘)) {

showDialog($lang[‘nc_common_op_repeat‘],SHOP_SITE_URL);

}

$obj_validate = new Validate();

$obj_validate->validateparam = array(

array("input"=>$_POST["user_name"], "require"=>"true", "message"=>$lang[‘login_index_username_isnull‘]),

array("input"=>$_POST["password"], "require"=>"true", "message"=>$lang[‘login_index_password_isnull‘]),

);

$error = $obj_validate->validate();

if ($error != ‘‘){

showValidateError($error);exit;

}

$array = array();

$array[‘member_name‘] = $_POST[‘user_name‘];

$array[‘member_passwd‘] = md5($_POST[‘password‘]);

$member_info = $model_member->infoMember($array);

if(is_array($member_info) and !empty($member_info)) {

if(!$member_info[‘member_state‘]){

       showDialog($lang[‘login_index_account_stop‘]);

}

}else{//再此处验证为了防止原来 手机号就是账号的用户自动加GFM登陆不上

$array[‘member_name‘] = ‘GFM‘.$_POST[‘user_name‘];

$member_info = $model_member->infoMember($array);

if(is_array($member_info) and !empty($member_info)) {

if(!$member_info[‘member_state‘]){

       showDialog($lang[‘login_index_account_stop‘]);

}

}else{

processClass::addprocess(‘login‘);

    showDialog($lang[‘login_index_login_fail‘]);

}

}

    $model_member->createSession($member_info);    

processClass::clear(‘login‘);

// cookie中的cart存入数据库

$this->mergecart($member_info);

//添加会员积分

if (C(‘points_isuse‘)){

//一天内只有第一次登录赠送积分

if(trim(@date(‘Y-m-d‘,$member_info[‘member_login_time‘]))!=trim(date(‘Y-m-d‘))){

$points_model = Model(‘points‘);

$points_model->savePointsLog(‘login‘,array(‘pl_memberid‘=>$member_info[‘member_id‘],‘pl_membername‘=>$member_info[‘member_name‘]),true);

}

}

showDialog($lang[‘login_index_login_success‘],$_POST[‘ref_url‘] == ‘‘ ? ‘reload‘ : $_POST[‘ref_url‘],‘succ‘,$extrajs);


}else{


//登录表单页面

$_pic = @unserialize(C(‘login_pic‘));

if ($_pic[0] != ‘‘){

Tpl::output(‘lpic‘,UPLOAD_SITE_URL.‘/‘.ATTACH_LOGIN.‘/‘.$_pic[array_rand($_pic)]);

}else{

Tpl::output(‘lpic‘,UPLOAD_SITE_URL.‘/‘.ATTACH_LOGIN.‘/‘.rand(1,4).‘.jpg‘);

}


if(empty($_GET[‘ref_url‘])) {

   $ref_url = getReferer();

   if (!preg_match(‘/act=login&op=logout/‘, $ref_url)) {

    $_GET[‘ref_url‘] = $ref_url;

   }

}

//新添

if(!empty($_GET[‘ref_url‘])&&preg_match(‘/pusername=/‘,$_GET[‘ref_url‘])) {

$arr=explode("&",$_GET[‘ref_url‘]);

$pusername=$arr[2];

$pusername=substr($pusername,10);

if(!empty($pusername)) {

Tpl::output(‘ref_url_ret‘,$_GET[‘ref_url‘]);

}

}

Tpl::output(‘html_title‘,C(‘site_name‘).‘ - ‘.$lang[‘login_index_login‘]);

if ($_GET[‘inajax‘] == 1){

Tpl::showpage(‘login_inajax‘,‘null_layout‘);

}else{

Tpl::showpage(‘login‘);

}

}

}


/**

* 退出操作

*

* @param int $id 记录ID

* @return array $rs_row 返回数组形式的查询结果

*/

public function logoutOp(){

Language::read("home_login_index");

$lang = Language::getLangContent();

session_unset();

session_destroy();

/* 清除member_id, cookie   Author  Yusure */

setcookie( ‘member_id‘, "", time()-3600, ‘/‘, C(‘cookie_domain‘), false );

setNcCookie(‘goodsnum‘,‘‘,-3600);

if(empty($_GET[‘ref_url‘])){

$ref_url = getReferer();

}else {

$ref_url = $_GET[‘ref_url‘];

}

showMessage($lang[‘login_logout_success‘],‘index.php?act=login&ref_url=‘.urlencode($ref_url),‘html‘,‘succ‘,1,2000);

}


/**

* 会员注册页面

*

* @param

* @return

*/

public function registerOp() {

Language::read("home_login_register");

$lang = Language::getLangContent();

$model_member = Model(‘member‘);

$model_member->checkloginMember();

Tpl::output(‘html_title‘,C(‘site_name‘).‘ - ‘.$lang[‘login_register_join_us‘]);

Tpl::showpage(‘register‘);

}


/**

* 会员添加操作

*

* @param

* @return

*/

public function usersaveOp() {

//重复注册验证

$dlM = Model("distribute_level");

$min_level_info = $dlM->getMinLevelInfo("grade" ,"is_valid = ‘1‘");

if (processClass::islock(‘reg‘)){

showDialog(Language::get(‘nc_common_op_repeat‘),‘index.php‘);

}

Language::read("home_login_register");

$lang = Language::getLangContent();

$model_member = Model(‘member‘);

$model_member->checkloginMember();


$result = chksubmit(true,C(‘captcha_status_login‘),‘num‘);

if ($result !== false){

if ($result === -11){

showDialog($lang[‘invalid_request‘]);

}elseif ($result === -12){

showDialog($lang[‘login_usersave_wrong_code‘]);

}

}


        $register_info = array();

        $register_info[‘username‘] = $_POST[‘user_name‘];

        $register_info[‘password‘] = $_POST[‘password‘];

        $register_info[‘password_confirm‘] = $_POST[‘password_confirm‘];

        $register_info[‘email‘] = $_POST[‘email‘];

        $member_info = $model_member->register($register_info);

      

        if(!isset($member_info[‘error‘])) {

        /*用户注册后就要成为分销商,等级是最低的,且父与祖父是空

        *Modify by Chen

        */

        $dlM = Model("distribute_level");

$min_level_info = $dlM->getMinLevelInfo("grade" ,"is_valid = ‘1‘");

$level_id = $min_level_info[‘level_id‘];

$dis_mem[‘member_id‘]  = $member_info[‘member_id‘];

$dis_mem[‘member_name‘] = $member_info[‘member_name‘];

$dis_mem[‘distribute_level‘] = $level_id;

$dis_mem[‘distribute_addtime‘] = time();

$dis_mem[‘is_valid‘] = "1";

//$dis_mem[‘is_reg_member‘] = 1;

$dmM = Model("distribute_member");

$dmM->addMemberInfo($dis_mem);

            $model_member->createSession($member_info);

processClass::addprocess(‘reg‘);


$this->mergecart();


$_POST[‘ref_url‘] = (strstr($_POST[‘ref_url‘],‘logout‘)=== false && !empty($_POST[‘ref_url‘]) ? $_POST[‘ref_url‘] : ‘index.php?act=member&op=home‘);

showDialog(str_replace(‘site_name‘,C(‘site_name‘),$lang[‘login_usersave_regist_success_ajax‘]),$_POST[‘ref_url‘],‘succ‘,$synstr,3);

        } else {

showDialog($member_info[‘error‘]);

        }

}

/**

* 会员名称检测

*

* @param

* @return

*/

public function check_memberOp() {

/**

* 实例化模型

*/

$model_member = Model(‘member‘);


$check_member_name = $model_member->infoMember(array(‘member_name‘=>trim($_GET[‘user_name‘])));

if(is_array($check_member_name) and count($check_member_name)>0) {

echo ‘false‘;

} else {

echo ‘true‘;

}

}


/**

* 登录之后,把登录前购物车内的商品加到购物车表

*

*/

private function mergecart($member_info = array()){

   if (!$member_info[‘member_id‘]) return;

   $model_cart = Model(‘cart‘);

$save_type = C(‘cache.type‘) != ‘file‘ ? ‘cache‘ : ‘cookie‘;

        $cart_new_list = $model_cart->listCart($save_type);

        if (empty($cart_new_list)) return;

        //取出当前DB购物车已有信息

        $cart_cur_list = $model_cart->listCart(‘db‘,array(‘buyer_id‘=>$_SESSION[‘member_id‘]));

//数据库购物车已经有的商品,不再添加

if (!empty($cart_cur_list) && is_array($cart_cur_list) && is_array($cart_new_list)) {

    foreach ($cart_new_list as $k=>$v){

    if (!is_numeric($k) || in_array($k,array_keys($cart_cur_list))){

    unset($cart_new_list[$k]);

    }

    }

}

//查询在购物车中,不是店铺自己的商品,未禁售,上架,有库存的商品,并加入DB购物车

        $mode_goods= Model(‘goods‘);

        $condition = array();

        if (!empty($_SESSION[‘store_id‘])) {

            $condition[‘store_id‘] = array(‘neq‘,$_SESSION[‘store_id‘]);

        }

        $condition[‘goods_id‘] = array(‘in‘,array_keys($cart_new_list));

$goods_list = Model(‘goods‘)->getGoodsOnlineList($condition);

if (!empty($goods_list)){

foreach ($goods_list as $goods_info){

   $goods_info[‘buyer_id‘] = $member_info[‘member_id‘];

   $model_cart->addCart($goods_info,‘db‘,$cart_new_list[$goods_info[‘goods_id‘]][‘goods_num‘]);

}

}

//最后清空登录前购物车内容

$model_cart->clearCart($save_type);

}

/**

* 电子邮箱检测

*

* @param

* @return

*/

public function check_emailOp() {

$model_member = Model(‘member‘);

$check_member_email = $model_member->infoMember(array(‘member_email‘=>trim($_GET[‘email‘])));

if(is_array($check_member_email) and count($check_member_email)>0) {

echo ‘false‘;

} else {

echo ‘true‘;

}

}

/**

* 手机号码检测

*

* @param

* @return

*/

public function check_telOp() {

/**

* 实例化模型

*/

$model_member = Model(‘member‘);


$check_member_name = $model_member->infoMember(array(‘member_tel‘=>trim($_GET[‘member_tel‘])));

if(is_array($check_member_name) and count($check_member_name)>0) {

echo ‘false‘;

} else {

echo ‘true‘;

}

}

/**

* 忘记密码页面

*/

public function forget_passwordOp(){

/**

* 读取语言包

*/

Language::read(‘home_login_register‘);

$_pic = @unserialize(C(‘login_pic‘));

if ($_pic[0] != ‘‘){

Tpl::output(‘lpic‘,UPLOAD_SITE_URL.‘/‘.ATTACH_LOGIN.‘/‘.$_pic[array_rand($_pic)]);

}else{

Tpl::output(‘lpic‘,UPLOAD_SITE_URL.‘/‘.ATTACH_LOGIN.‘/‘.rand(1,4).‘.jpg‘);

}

Tpl::output(‘html_title‘,C(‘site_name‘).‘ - ‘.Language::get(‘login_index_find_password‘));

Tpl::showpage(‘find_password‘);

}


/**

* 找回密码的发邮件处理

*/

public function find_passwordOp(){

Language::read(‘home_login_register‘);

$lang = Language::getLangContent();


$result = chksubmit(true,true,‘num‘);

if (!$result){

   showDialog(‘非法提交‘);

}elseif ($result === -11){

   showDialog(‘非法提交‘);

}elseif ($result === -12){

   showDialog(‘验证码错误‘);

}


if(empty($_POST[‘username‘])){

showDialog($lang[‘login_password_input_username‘]);

}


if (processClass::islock(‘forget‘)) {

   showDialog($lang[‘nc_common_op_repeat‘],‘reload‘);

}


$member_model = Model(‘member‘);

$member = $member_model->infoMember(array(‘member_name‘=>$_POST[‘username‘]));

if(empty($member) or !is_array($member)){

   processClass::addprocess(‘forget‘);

showDialog($lang[‘login_password_username_not_exists‘],‘reload‘);

}


if(empty($_POST[‘email‘])){

showDialog($lang[‘login_password_input_email‘],‘reload‘);

}


if(strtoupper($_POST[‘email‘])!=strtoupper($member[‘member_email‘])){

   processClass::addprocess(‘forget‘);

showDialog($lang[‘login_password_email_not_exists‘],‘reload‘);

}

processClass::clear(‘forget‘);

//产生密码

$new_password = random(15);

if(!($member_model->updateMember(array(‘member_passwd‘=>md5($new_password)),$member[‘member_id‘]))){

showDialog($lang[‘login_password_email_fail‘],‘reload‘);

}

$cron_data = array(‘exetime‘=>TIMESTAMP,‘exeid‘=>$member[‘member_id‘],‘type‘=>2,‘code‘=>‘email_touser_find_password‘,

‘content‘=>array(array(

‘site_name‘ => $GLOBALS[‘setting_config‘][‘site_name‘],

‘site_url‘ => SHOP_SITE_URL,

‘user_name‘ => $_POST[‘username‘],

‘new_password‘ => $new_password

),false));

$this->addcron($cron_data,true);

$extend_js = "<script src=‘".SHOP_SITE_URL."/index.php?act=login&op=send_email‘></script>";

showMessage($lang[‘login_password_email_success‘].$extend_js,SHOP_SITE_URL);

}


/**

* 异步发送邮件

*/

public function send_emailOp() {

   Model(‘member‘)->checkloginMember();


   $model_cron = Model(‘cron‘);

   $condition = array();

        $condition[‘type‘] = 2;

        $condition[‘exeid‘] = $_SESSION[‘member_id‘];

        $condition[‘code‘] = ‘email_touser_find_password‘;

   $cron_info = $model_cron->getCronInfo();

   if (empty($cron_info)) return ;


   $content = unserialize($cron_info[‘content‘]);

   if (!$content[1]) $content[1] = false;


   $this->send_notice($cron_info[‘exeid‘],$cron_info[‘code‘],$content[0],$content[1]);

   $model_cron->delCron($condition);

}

  /**

     * 登陆生成token

     */

    private function _get_token($member_id, $member_name, $client) {

        $model_mb_user_token = Model(‘mb_user_token‘);


        //重新登陆后以前的令牌失效

        //暂时停用

        //$condition = array();

        //$condition[‘member_id‘] = $member_id;

        //$condition[‘client_type‘] = $_POST[‘client‘];

        //$model_mb_user_token->delMbUserToken($condition);


        //生成新的token

        $mb_user_token_info = array();

        $token = md5($member_name . strval(TIMESTAMP) . strval(rand(0,999999)));

        $mb_user_token_info[‘member_id‘] = $member_id;

        $mb_user_token_info[‘member_name‘] = $member_name;

        $mb_user_token_info[‘token‘] = $token;

        $mb_user_token_info[‘login_time‘] = TIMESTAMP;

        $mb_user_token_info[‘client_type‘] = $client;

        $result = $model_mb_user_token->addMbUserToken($mb_user_token_info);


        if($result) {

            return $token;

        } else {

            return null;

        }


    }

  /* 根据用户输入的地址解密参数

     * */

    public function  decodeUrlOp(){

    $auth = urldecode($_GET[‘auth‘]);

    $authSplitKey=‘GYPAUTH‘;//避免短信端在url添加的内容无法用explode分割【分割字符串】

      $auths = explode($authSplitKey,$auth);//中文下的空格,且只能用explode不能用substr

      $auth=$auths[0];

    $jump_url = WAPS_URL."/index.html";

    $key = "SDGOYIPN53487216";//密钥

    $username = decrypt($auth,$key);//还是他妈原生态的好用

    $username = json_decode($username);//在加密之前必须json_encode一下防止解密出错

    if($username != "" && $username !=null){//url解码后

    $query_arr[‘member_name‘] = $username;

    $m = Model("member");

    $mem_info = $m->where($query_arr)->find();

    if($mem_info!=null){//判断用户是否存在,存在就模拟登录

    $token = $this->_get_token($mem_info[‘member_id‘], $mem_info[‘member_name‘], "wap");

    if($token) {//用js给username和key赋值

            $str = "<script>

function addcookie(name, value, expireHours) {

var cookieString = name + ‘=‘ + escape(value) + ‘; path=/‘;

// 判断是否设置过期时间

if (expireHours > 0) {

var date = new Date();

date.setTime(date.getTime + expireHours * 3600 * 1000);

cookieString = cookieString + ‘; expire=‘ + date.toGMTString();

}

document.cookie = cookieString;

if (!document.cookie || document.cookie.length == 0) {

// Cookie 不好使

localStorage.setItem(name, value);

// TODO 对时间或者说有效期做一些处理

}

}

            </script>";

            $str .= "<script>

            addcookie(‘username‘,‘{$mem_info[‘member_name‘]}‘);

            addcookie(‘key‘,‘{$token}‘);

            addcookie(‘isannoy‘,‘true‘);

            alert(‘登录成功‘);

            </script>";

            echo $str;

               echo  "<script>location.href=‘{$jump_url}‘;</script>";

           } else {

               echo  "<script>alert(‘对不起,尝试登录失败请重新操作!‘);location.href=‘{$jump_url}‘;</script>";

           }

   

    }else{

    echo  "<script>alert(‘对不起,用户不存在请联系管理员确认!‘);location.href=‘{$jump_url}‘;</script>";

    }

   

   

    }else{//参数有问题,跳主页

    echo  "<script>alert(‘对不起,参数不正确请确认!‘);location.href=‘{$jump_url}‘;</script>";

   

    }

    }

}




登陆页前台:


<?php defined(‘IN_B2B2C‘) or exit(‘Access Invalid!‘);?>

<style type="text/css">

.public-top-layout, .head-search-bar, .head-user-menu, .public-nav-layout, .nch-breadcrumb-layout, #faq {

display: none !important;

}


.wrapper {

width: 1000px;

}

#footer {

border-top: none!important;

padding-top: 30px;

}

</style>

<div class="nc-login-layout">

  <div class="left-pic"><img src=\‘#\‘" echo $output[‘lpic‘];?>"  border="0"></div>

  <div class="nc-login">

    <div class="nc-login-title">

      <h3><?php echo $lang[‘login_index_user_login‘];?></h3>

    </div>

    <div class="nc-login-content" id="demo-form-site">

      <form id="login_form" method="post" class="bg">

        <?php Security::getToken();?>

        <input type="hidden" name="form_submit" value="ok" />

        <input name="nchash" type="hidden" value="<?php echo getNchash();?>" />

        <dl>

          <dt><?php echo $lang[‘login_index_username‘];?></dt>

          <dd>

            <input type="text" class="text" autocomplete="off"  name="user_name" id="user_name">

            <label></label>

          </dd>

        </dl>

        <dl>

          <dt><?php echo $lang[‘login_index_password‘];?> </dt>

          <dd>

            <input type="password" class="text" name="password" autocomplete="off"  id="password">

            <label></label>

          </dd>

        </dl>

        <?php if(C(‘captcha_status_login‘) == ‘1‘) { ?>

        <dl>

          <dt><?php echo $lang[‘login_index_checkcode‘];?></dt>

          <dd>

            <input type="text" name="captcha" class="text w50 fl" id="captcha" maxlength="4" size="10" />

            <img src=\‘#\‘" echo SHOP_SITE_URL?>/index.php?act=seccode&op=makecode&nchash=<?php echo getNchash();?>" name="codeimage" border="0" id="codeimage" class="fl ml5"> <a href="javascript:void(0)" class="ml5" onclick="javascript:document.getElementById(‘codeimage‘).src=\‘#\‘" echo SHOP_SITE_URL?>/index.php?act=seccode&op=makecode&nchash=<?php echo getNchash();?>&t=‘ + Math.random();"><?php echo $lang[‘login_index_change_checkcode‘];?></a>

            <label></label>

          </dd>

        </dl>

        <?php } ?>

        <dl>

          <dt>&nbsp;</dt>

          <dd>

            <input type="button" class="submit" value="<?php echo $lang[‘login_index_login‘];?>" name="Submit">

            <a class="forget" href="index.php?act=login&op=forget_password"><?php echo $lang[‘login_index_forget_password‘];?></a>

            <input type="hidden" value="<?php echo $_GET[‘ref_url‘]?>" name="ref_url">

          </dd>

        </dl>

      </form>

      <?php if($output[‘ref_url_ret‘]) {?>

       <dl class="mt10 mb10">

        <dt>&nbsp;</dt>

        <dd><?php echo $lang[‘login_index_regist_now_1‘];?><a title="" href="index.php?act=login&op=register&ref_url=<?php echo urlencode($_GET[‘ref_url‘]);?>" class="register"><?php echo $lang[‘login_index_regist_now_2‘];?></a></dd>

      </dl>

      <?php } else {?>

      <dl class="mt10 mb10">

        <dt>&nbsp;</dt>

        <dd><?php echo $lang[‘login_index_regist_now_1‘];?><a title="" href="index.php?act=login&op=register&ref_url=<?php echo urlencode($output[‘ref_url‘]);?>" class="register"><?php echo $lang[‘login_index_regist_now_2‘];?></a></dd>

      </dl>

      <?php }?>

      <?php if ($GLOBALS[‘setting_config‘][‘qq_isuse‘] == 1 || $GLOBALS[‘setting_config‘][‘sina_isuse‘] == 1){?>

      <dl>

        <dd class="nc-login-other">

          <p><?php echo $lang[‘nc_otherlogintip‘];?></p>

          <?php if ($GLOBALS[‘setting_config‘][‘qq_isuse‘] == 1){?>

          <a href="<?php echo SHOP_SITE_URL;?>/api.php?act=toqq" title="QQ" class="qq">&nbsp;</a>

          <?php } ?>

          <?php if ($GLOBALS[‘setting_config‘][‘sina_isuse‘] == 1){?>

          <a href="<?php echo SHOP_SITE_URL;?>/api.php?act=tosina" title="<?php echo $lang[‘nc_otherlogintip_sina‘]; ?>" class="sina">&nbsp;</a>

          <?php } ?>

        </dd>

      </dl>

      <?php } ?>

    </div>

    <div class="nc-login-bottom"></div>

  </div>

</div>

<script>

$(document).ready(function(){

    $(‘input[name="Submit"]‘).click(function(){

        if($("#login_form").valid()){

        $("#login_form").submit();

        } else{

        document.getElementById(‘codeimage‘).src=\‘#\‘" echo SHOP_SITE_URL?>/index.php?act=seccode&op=makecode&nchash=<?php echo getNchash();?>&t=‘ + Math.random();

        }

    });

$("#login_form").validate({

        errorPlacement: function(error, element){

            var error_td = element.parent(‘dd‘);

            error_td.find(‘label‘).hide();

            error_td.append(error);

        },

rules: {

user_name: "required",

password: "required"

<?php if(C(‘captcha_status_login‘) == ‘1‘) { ?>

            ,captcha : {

                required : true,

                minlength: 4,

                remote   : {

                    url : ‘<?php echo SHOP_SITE_URL?>/index.php?act=seccode&op=check&nchash=<?php echo getNchash();?>‘,

                    type: ‘get‘,

                    data:{

                        captcha : function(){

                            return $(‘#captcha‘).val();

                        }

                    }

                }

            }

<?php } ?>

},

messages: {

user_name: "<?php echo $lang[‘login_index_input_username‘];?>",

password: "<?php echo $lang[‘login_index_input_password‘];?>"

<?php if(C(‘captcha_status_login‘) == ‘1‘) { ?>

            ,captcha : {

                required : ‘<?php echo $lang[‘login_index_input_checkcode‘];?>‘,

                minlength: ‘<?php echo $lang[‘login_index_input_checkcode‘];?>‘,

remote : ‘<?php echo $lang[‘login_index_wrong_checkcode‘];?>‘

            }

<?php } ?>

}

});

});

</script>




前台调用了seccode.php 中check方法 



header("Content-type:text/html;charset=utf-8");


只需要在seccode.php文件中加入这句话就可以了


seccode.php


<?php

/**

 * 验证码

 *

 */

defined(‘IN_B2B2C‘) or exit(‘Access Invalid!‘);

header("Content-type:text/html;charset=utf-8");

class seccodeControl{

public function __construct(){

}


/**

* 产生验证码

*

*/

public function makecodeOp(){

$refererhost = parse_url($_SERVER[‘HTTP_REFERER‘]);

$refererhost[‘host‘] .= !empty($refererhost[‘port‘]) ? (‘:‘.$refererhost[‘port‘]) : ‘‘;


$seccode = makeSeccode($_GET[‘nchash‘]);


@header("Expires: -1");

@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);

@header("Pragma: no-cache");


$code = new seccode();

$code->code = $seccode;

$code->width = 90;

$code->height = 26;

$code->background = 1;

$code->adulterate = 1;

$code->scatter = ‘‘;

$code->color = 1;

$code->size = 0;

$code->shadow = 1;

$code->animator = 0;

$code->datapath =  BASE_DATA_PATH.‘/resource/seccode/‘;

$code->display();

}


/**

* AJAX验证

*

*/

public function checkOp(){

if (checkSeccode($_GET[‘nchash‘],$_GET[‘captcha‘])){

exit(‘true‘);

}else{

exit(‘false‘);

}

}

}


?>


登陆页老是提示验证码错误,validate验证控件IE下用remote方法明明返回true 但是还是报错,提示验证码错误

标签:验证码

原文地址:http://5361806.blog.51cto.com/5351806/1713091

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!