chengkun
2025-04-27 cc0f23e36407bd75f9fa45a63b7b68e69cf9c769
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/*
* $Author :PHPYUN开发团队
*
* 官网: http://www.phpyun.com
*
* 版权所有 2009-2021 宿迁鑫潮信息技术有限公司,并保留所有权利。
*
* 软件声明:未经授权前提下,不得用于商业运营、二次开发以及任何形式的再次发布。
 */
 
/**
 * cookie操作类
 */
class cookie_model extends model{
  private function _getCookieDomain(){
    global $pageType;
    if($this->config['sy_web_site'] == '1' || ((isset($pageType) && $pageType=='wap' && strpos($this->config['sy_wapdomain'],'/wap')===false && $this->config['sy_wapdomain']))){
        
        if($this->config['sy_web_site'] == '1' && $this->config['sy_onedomain']!=""){
            $weburl  =  get_domain($this->config['sy_onedomain']);
        }elseif($this->config['sy_web_site'] == '1' && $this->config['sy_indexdomain']!=""){
            $weburl  =  get_domain($this->config['sy_indexdomain']);
        }elseif($this->config['sy_wapdomain']){
            $weburl  =  get_domain($this->config['sy_wapdomain']);
        }else{
            
            $weburl  =  get_domain($this->config['sy_weburl']);
        }
    }else{
        $weburl = '';
    }
    return $weburl;
  }
 
  //设置cookie
  //原common addcookie
    public function setcookie($name,$value,$time=0){
    $weburl = $this->_getCookieDomain();
    if(is_array($value)){
      foreach ($value as $k => $v) {
        SetCookie($name . '[' . $k . ']', $v, $time,'/', $weburl);
      }
    }else{
      SetCookie($name,$value,$time,"/",$weburl);
    }
  }
  
  public function add_cookie($uid,$username,$salt,$email,$pass,$type,$expire="1",$userdid='',$isadmin='0'){
    if($expire){
        $expire_date=$expire*86400;
    }else{
        $expire_date=86400;
    }
        
    if($this->config['did']&&$userdid==''){
        $userdid=$this->config['did'];
    }
 
    $this->setcookie("uid",$uid,time() + $expire_date);
    $this->setcookie("shell",md5($username.$pass.$salt), time() + $expire_date);
    $this->setcookie("usertype",$type,time()+$expire_date);
    $this->setcookie("userdid",$userdid,time()+$expire_date);
     $this->setcookie("amtype",$isadmin,time()+$expire_date);
  }
    
  public function unset_cookie(){
 
     
    $this->setcookie("uid","",0,"/");
    $this->setcookie("shell", "", 0,"/");
    $this->setcookie("usertype","",0,"/");
    $this->setcookie("userdid","",0,"/");
 
    $this->setcookie("lookjob","",0, "/");
    $this->setcookie("lookresume","",0, "/");
    $this->setcookie("favjob","",0, "/");
    $this->setcookie("talentpool","",0, "/");
    $this->setcookie("useridjob","",0, "/");
    $this->setcookie("exprefresh","",0, "/");
    $this->setcookie("jobrefresh","",0, "/");
    $this->setcookie("support","",0, "/");
    $this->setcookie("couponOT","",0, "/");
    $this->setcookie("couponRest","",0, "/");
    $this->setcookie("wxloginid","",0, "/");
    $this->setcookie("amtype","",0, "/");
        if(is_weixin()){
            $this->setcookie("wxout",'1',time()+604800,"/");
        }
  }
}