chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
 
//模板操作类
class admin_uc_controller extends adminCommon{
    function index_action()
    {
        $this->yunset("sy_weburl",$this->config['sy_weburl']);
        $path = APP_PATH."data/api/uc/config.inc.php";
        require_once $path;
        $this->yunset("ucinfo",$ucinfo);
        $this->yuntpl(array('admin/admin_uc'));
    }
    function save_action(){
        $config = "<?php \r\n";
        if($_POST){
            $parr                    =    "";
            $sy_uc_type                =    $_POST['sy_uc_type'];//设置状态
            unset($_POST['submit']);
            unset($_POST['sy_uc_type']);
            $_POST['UC_CONNECT']    =    "mysql";
            $_POST['UC_DBCONNECT']    =    "0";
            $_POST['UC_DBCHARSET']    =    'utf8';
            $_POST['UC_IP']            =    "";
            $_POST['UC_DBTABLEPRE']    =    "`".$_POST['UC_DBNAME']."`.".$_POST['UC_DBTABLEPRE_NEW'];
            
            foreach($_POST as $key=>$value)
            {
                $config.= "define(\"".$key."\",\"".$value."\"); \r\n";
                $parr  .= "\"".$key."\"=>\"".$value."\",";
            }
            $parr        = rtrim($parr,",");
            $config       .= "\$ucinfo=array(".$parr."); \r\n";
        }
        $path    =    APP_PATH."data/api/uc/config.inc.php";
        $fp        =    @fopen($path,"w");
        fwrite($fp,$config);
        fclose($fp);
        
        $this -> MODEL('config') -> setConfig(array('sy_uc_type'=>$sy_uc_type));
        
        $this->web_config();        
        $this->ACT_layer_msg("保存成功!",9,"index.php?m=admin_uc",2,1); 
    }
    function pw_action(){
        $this->yunset("sy_weburl",$this->config['sy_weburl']);
        $path = APP_PATH."data/api/pw_api/pw_config.php";
        require_once $path;
        $this->yunset("ucinfo",$ucinfo);
        $this->yuntpl(array('admin/admin_pw'));
    }
    function pwsave_action() { 
        
        $configM    =    $this -> MODEL('config');
        
        $userinfoM    =    $this -> MODEL('userinfo');
        $config = "<?php \r\n";
        if($_POST){
            $parr                    =    "";
            $sy_pw_type                =    $_POST['sy_pw_type'];//设置状态
            unset($_POST['submit']);
            unset($_POST['sy_pw_type']);
            $_POST['UC_DBCONNECT']    =    "0";
            $_POST['UC_IP']            =    "";
            $_POST['UC_DBCHARSET']    =    $_POST['UC_CHARSET'];
            foreach($_POST as $key=>$value){
                $config.= "define(\"".$key."\",\"".$value."\"); \r\n";
                $parr  .= "\"".$key."\"=>\"".$value."\",";
            }
            $parr       = rtrim($parr,",");
            $config    .= "\$ucinfo=array(".$parr."); \r\n";
        }
        $path    =    APP_PATH."data/api/pw_api/pw_config.php";
        $fp     =    @fopen($path,"w");
        fwrite($fp,$config);
        fclose($fp);
        
        $configM -> setConfig(array('sy_pw_type'=>$sy_pw_type));
        
        $configM -> upInfo(array('name'=>'sy_uc_type'),array('config'=>''));
        $this->web_config();
        if($sy_pw_type=='pw_center'){
            $user_arr = $userinfoM -> getList("1",array('field'=>'`uid`,`username`,`password`,`salt`'));
 
            require_once APP_PATH.'/api/pw_api/pw_client/class_db.php';
 
            $db_uc = new UcDB;
 
            include(APP_PATH."data/api/pw_api/pw_config.php");
            $db_uc->connect(UC_DBHOST, UC_DBUSER, UC_DBPW, UC_DBNAME, UC_DBCONNECT, UC_DBCHARSET);
            $pw_query=$db_uc->query("SELECT `uid`,`username`,`password` FROM ".UC_DBTABLEPRE."members");
            
            while($pw_rs = $db_uc->fetch_array($pw_query)){
                if(is_array($user_arr)){
                    foreach($user_arr as $key=>$value){
                        //判断是否有重名用户
                        if($value['username']==$pw_rs['username']&&$value['pw_repeat']!="1"){
                            if($value['pwuid']<1){
                                //判断密码是否一致
                                if($value['password']==md5($pw_rs['password'].$value['salt'])){
                                    //用户名密码一致,绑定用户PWid
                                    $userinfoM -> upInfo(array('pwuid'=>$pw_rs['uid']),array('uid'=>$value['uid']));
                                }else{
                                    //用户名密码不一致设定为重名用户,不予同步
                                    $userinfoM -> upInfo(array('pw_repeat'=>'1'),array('uid'=>$value['uid']));
                                }
                            }
                        }
                    }
                }
            } 
        }
        
        $this->ACT_layer_msg("保存成功!",9,"index.php?m=admin_uc&c=pw");
    }
}
?>