chengkun
2025-04-24 5d55579fd424e024c52e62265b72e24c38a45004
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/*
* $Author :PHPYUN开发团队
*
* 官网: http://www.phpyun.com
*
* 版权所有 2009-2021 宿迁鑫潮信息技术有限公司,并保留所有权利。
*
* 软件声明:未经授权前提下,不得用于商业运营、二次开发以及任何形式的再次发布。
 */
class datacall_controller extends adminCommon{
    function index_action(){
        $dataM            =    $this -> MODEL('data');
        $where          =   array();
        $limit            =    $this->config["sy_listnum"];//定义显示条数
        $urlarr            =   $_GET;
        $urlarr["page"]    =    "{{page}}";
        
        $pageurl        =    Url($_GET['m'],$urlarr,'admin');
        //提取分页
        $pageM            =    $this  -> MODEL('page');
        $pages            =    $pageM -> pageList('outside',$where,$pageurl,$_GET['page'],$limit);
        
        //分页数大于0的情况下 执行列表查询
        if($pages['total'] > 0){
            
            //limit order 只有在列表查询时才需要
            if($_GET['order'])
            {
                $where['orderby']        =    $_GET['t'].','.$_GET['order'];
                $urlarr['order']        =    $_GET['order'];
                $urlarr['t']            =    $_GET['t'];
            }else{
                $where['orderby']        =    'id';
            }
            $where['limit']    =    $pages['limit'];
            
            $List    =    $dataM -> getList($where);
            
            $this->yunset("rows" , $List['list']);
        }
        
        include CONFIG_PATH."/db.data.php";
        
        $this->yunset("datacall",$arr_data['datacall']);
        
        $this->yuntpl(array('admin/admin_datacall'));
    }
    function add_action(){
        $dataM    =    $this -> MODEL('data');
        extract($_POST);
        include CONFIG_PATH."/db.data.php";
        if($_GET[id]){
            
            $info = $dataM->getInfo(array('id'=>$_GET[id]));
            
            $w=@explode(",",$info[where]);
            if(is_array($w)){
                foreach($w as $key=>$va){
                    $arr=@explode("_",$va);
                    $t[$arr[0]]=$arr[1];
                }
            }
            $this->yunset("info",$info);
            $this->yunset("where",$t);
        }
        if($submit){
            if($name==''){
                $this->ACT_layer_msg("请填写调用名称!",8);
            }
            if(empty($row)){
                
                $postdata    =    $_POST;
                
                if(is_array($arr_data["datacall"][$type]["where"])){
                    foreach($arr_data["datacall"][$type]["where"] as $key=>$va){
                        $cont[]=$key."_".$$key;
                    }
                    $postdata['where']    =    implode(',',$cont);
                }
                include LIB_PATH."/datacall.class.php";
                $call= new datacall("../data/plus/data/",$this->obj);
                if($id){
                    
                    unset($postdata['id']);
                    
                    $return = $dataM -> upInfo($postdata,array('id'=>$id));
                    
                    $call->editcache($id);//生成缓存
                    
                    $this->ACT_layer_msg($return['msg'],$return['errcode'],"index.php?m=datacall",2,1);
                }else{
                    
                    $return = $dataM->addInfo($postdata);
                    
                    $call->editcache($id);//生成缓存
                    
                    $this->ACT_layer_msg($return['msg'],$return['errcode'],"index.php?m=datacall",2,1);
                }
            }else{
                $this->ACT_layer_msg("调用名称重复,请重新输入!",8,$_SERVER['HTTP_REFERER']);
            }
        }
        $this->yunset("datacall",$arr_data['datacall'][$_GET['type']]);
        $this->yuntpl(array('admin/admin_datacall_add'));
    }
    function preview_action(){
        $src = $this->config["sy_weburl"]."/data/plus/outside.php?id=".$_GET["name"];
        $src = str_replace(" ","",$src);
        $this->yunset("src",$src);
        $this->yuntpl(array('admin/admin_datacall_preview'));
    }
    function del_action(){
        $this->check_token();
        if($_GET[id]){
            $_GET[id] = intval($_GET[id]);
            @unlink(PLUS_PATH."/data/".$_GET["id"].".php");
            $return=$this -> MODEL('data')->delData($_GET["id"]);
            $return['id']?$this->layer_msg($return['msg'],$return['errcode'],$return['layertype'],"index.php?m=datacall"):$this->layer_msg($return['msg'],$return['errcode'],$return['layertype'],"index.php?m=datacall");
        }
    }
    function cache_action(){
        $dataM=$this -> MODEL('data');
        if($_GET["aid"]==1){
            
            $where['orderby']    =    'id,asc';
            
            $one = $dataM -> getInfo($where);
            
            $wheretwo['id']        =    array('>',$one["id"]);
            $wheretwo['orderby']=    'id,asc';
            
            $two = $dataM -> getInfo("outside",$wheretwo);
            
            $this->update_cache($one["id"],$two);
        }
        if($_GET["id"]){
            $where['id']        =    array('>',$_GET["id"]);
            
            $where['orderby']    =    'id,asc';
            
            $next = $dataM -> getInfo($where);
            
            $this->update_cache($_GET["id"],$next);
        }else{
            $this->ACT_layer_msg("缓存更新成功!",9,"index.php?m=datacall",2,1);
        }
    }
    function make_action(){
        extract($_GET);
        $this->update_cache($id,'');
    }
    function update_cache($one,$two){ 
        include LIB_PATH."datacall.class.php"; 
        $call= new datacall("../data/plus/data/",$this->obj); 
        
        $row=$call->editcache($one);//生成缓存 
        
        if($two[id]!=""){
            echo "正在更新".$row[name]."...请稍后!";
 
        }
        if($two['id']){
            echo "<script>location.href='index.php?m=datacall&c=cache&id=".$two[id]."'</script>";die;
        }else{
            $this->layer_msg('缓存更新成功!',9,0,"index.php?m=datacall");
        }
    }
}
?>