chengkun
2025-05-22 1a8aea45ebb1582c9f65d9e8dcd520002f83ae12
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
<?php
 
 
class admin_tpl_index_controller extends adminCommon{
    function index_action(){
        $where['orderby']    =    'id,desc';
        
        $list    =    $this -> MODEL('tpl') -> getTplindexList($where);
        
        $this->yunset("list",$list);
        
        $this->yuntpl(array('admin/admin_tpl_index'));
    }
    function add_action(){
        if($_GET['id']){
            
            $list    =    $this -> MODEL('tpl') -> getTplindex(array('id'=>$_GET['id']));
            
            $timearr[]        =    date("Y-m-d",$list['stime']);
            
            $timearr[]        =    date("Y-m-d",$list['etime']);
            
            $time            =    implode(" ~ ",$timearr);
            
            $list['time']    =    $time;
            
            $this->yunset("row",$list);
        }
        $this->yuntpl(array('admin/admin_tpl_indexadd'));
    }
    function save_action(){
        $tplM    =    $this -> MODEL('tpl');
        
        if($_FILES['file']['tmp_name']!=''){
            // pc端上传
            $upArr    =  array(
                'file'  =>  $_FILES['file'],
                'dir'   =>  'tplindex'
            );
 
            $uploadM  =  $this->MODEL('upload');
            $pic      =  $uploadM->newUpload($upArr);
 
            if (!empty($pic['msg'])){
 
            $return['msg']      =  $pic['msg'];
            $return['errcode']  =  8;
            return $return;
 
            }elseif (!empty($pic['picurl'])){
 
                $picurl         =   $pic['picurl'];
            }
        }
        if(isset($picurl)){
            $_POST['pic']        =    $picurl;
        }
        $time            =    explode("~",$_POST['time']);
        
        $_POST['stime']    =    strtotime(trim($time[0]));
        
        $_POST['etime']    =    strtotime(trim($time[1]).' 23:59:59');
        
        unset($_POST['msgconfig']);
        
        unset($_POST['time']);
        
        if($_POST['id']){
            
            $return        =    $tplM -> upTplindex($_POST,array("id"=>$_POST['id']));
        }else{
            
            $return        =    $tplM -> addTplindex($_POST);
        }
        $this->cache();
        $return['id']?$this->ACT_layer_msg($return['msg'],$return['errcode'],"index.php?m=admin_tpl_index",2,1):$this->ACT_layer_msg($return['msg'],$return['errcode']);
    }
    function del_action(){
        $this->check_token();
        
        $tplM    =    $this -> MODEL('tpl');
        
        $del=$_GET['id'];
        
        if($del){
            
            $return    =    $tplM -> delTplindex($del);
            
            $this->cache();
            
            $this->layer_msg($return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER']);
        }else{
            $this->cache();
            
            $this->layer_msg('请先选择!',8,0,$_SERVER['HTTP_REFERER']);
        }
        
    }
    /*生成主题的缓存文件*/
    function cache(){
        include_once(LIB_PATH."cache.class.php");
        $cacheclass= new cache(PLUS_PATH,$this->obj);
        $makecache=$cacheclass->indextpl_cache("indextpl.cache.php");
    }
}