<?php
class keyspider_tag{
   
    public function init(){    
    }        
    
    public static function pay_money(){
        global $keyspider_wzt_log;
        if(!$keyspider_wzt_log){
            return 0;
        }
        $data =  keyspider_common::keyspider_url(0);
    	$url = "https://api.seoceo.cn/api/money/pay_money?url={$data}&type=4&log={$keyspider_wzt_log}";
    	$defaults = array(
            'timeout' =>4000,
            'connecttimeout'=>4000,
            'redirection' => 3,
            'user-agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36',
            'sslverify' => FALSE,
        );
    	$result = wp_remote_get($url,$defaults);
    	if(!is_wp_error($result)){
            $content = wp_remote_retrieve_body($result);
        	$content = json_decode($content,true);
        	if(isset($content['status']) && $content['status']==1){
        	    if(isset($content['token1']) && $content['token1']){
                    $keyspider_wzt_token1 = get_option('keyspider_wzt_token1');
                    if($keyspider_wzt_token1===false){
                        add_option('keyspider_wzt_token1',$content['token1']);
                    }else{
                        update_option('keyspider_wzt_token1',$content['token1']);
                    }
                }
                if(isset($content['token2']) && $content['token2']){
                    $keyspider_wzt_token2 = get_option('keyspider_wzt_token2');
                    if($keyspider_wzt_token2===false){
                        add_option('keyspider_wzt_token2',$content['token2']);
                    }else{
                        update_option('keyspider_wzt_token2',$content['token2']);
                    }
                }
                if(isset($content['token3']) && $content['token3']){
                    $keyspider_wzt_token3 = get_option('keyspider_wzt_token3');
                    if($keyspider_wzt_token3===false){
                        add_option('keyspider_wzt_token3',$content['token3']);
                    }else{
                        update_option('keyspider_wzt_token3',$content['token3']);
                    }
                }
        	    return 1;
        	}
    	}else{
    	    return 0;
    	}
    }
    public static function keyspider_sanitizing_date($key){
        if (strlen($key) !== 104) {
            return false;
        }
    
        // 提取各部分
        $a = substr($key, 32, 2);
        $b = substr($key, 66, 2);
        $c = substr($key, 100, 4);
        $today = date_i18n('Ymd', current_time('timestamp'));
        $num = $c.$a.$b;
        if((int)$num>(int)$today){
            return $key;
        }
        return 0;
    }
   
}
?>