验证域名是否为该用户的域名
更新:HHH   时间:2023-1-7



主要是验证域名的注册人邮箱是否在用户验证过邮箱中。

用到第三方接口。

会有点慢,加一个 进行中。。。加载图。


前台代码:

 function verifyDomain(val){
       var ajaxurl = APP_ROOT+"/index.php?ctl=uc_domainapply&act=verify";

       var query = new Object();
       query.flag =  1;
       query.fhash = __HASH_KEY__;
       query.domain = val;

       $.ajax({
           url: ajaxurl,
           dataType: "json",
           data:query,
           type: "POST",
           beforeSend:function(){
               $.showSuccess(
                       '<img src="{$TMPL}/p_w_picpaths/loading.gif"  /><span>进行中......</span>'
               );
           },

           success: function(ajaxobj){
               if(ajaxobj.status==0)
               {
                   $.showSuccess(ajaxobj.info,function (){
                       if (ajaxobj.jump != '')
                           location.href = ajaxobj.jump;
                       else
                           location.reload();
                   });

               }
               else
               {
                   $.showErr(ajaxobj.info, function(){
                       if (ajaxobj.jump != '')
                           location.href = ajaxobj.jump;
                       else
                           location.reload();
                   });
               }
           },
           error:function(ajaxobj)
           {
               alert("error");
           }
       });

   }

    </script>


--------

后台代码:

    function verify(){
        $this->check_hash_key();
        $domain = strim($_REQUEST['domain']);
        if($domain=="") {
            $data = array('status' => -2, 'info' => "请传入域名!", 'jump' => "");
            ajax_return($data);
        }
        require_once APP_ROOT_PATH."system/phpwhois/whois.main.php";

        $whois = new Whois();
        $result = $whois->Lookup($domain);
        foreach($result['rawdata'] as $tmp){
            if(strpos($tmp,"egistrant Email")){
                $arr = explode("Registrant Email: ",$tmp);
            }
        }

        $sql3 = "select * from ".DB_PREFIX."c_whois_email where user_id = ".$GLOBALS['user_info']['id']." and flag = 1 and email = '".trim($arr[1])."'";

        $db_whois = $GLOBALS['db']->getRow($sql3);
        if($db_whois){
            //
            $domain_id = $this->get_domain_id($domain);
            $sql4 = "update ".DB_PREFIX."c_user_domain set flag = 1 where user_id = ".$GLOBALS['user_info']['id']." and domain_id = ".$domain_id;
            if($GLOBALS['db']->query($sql4)) {
                $data = array('status' => 2, 'info' => "验证成功!" , 'jump' => "");
                ajax_return($data);
            }else{
                $data = array('status' => -3, 'info' => "验证成功但数据库写入失败,请联系客服!" . $db_whois['id'] . "--" . $sql4, 'jump' => "");
                ajax_return($data);

            }
        }else {
            $data = array('status' => 2, 'info' => "验证失败!", 'jump' => "");
            ajax_return($data);
        }
    }

返回web开发教程...