驗證域名是否爲該用戶的域名


主要是驗證域名的註冊人郵箱是否在用戶驗證過郵箱中。

用到第三方接口。

會有點慢,加一個 進行中。。。加載圖。


前臺代碼:

 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}/images/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);
        }
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章