|
@@ -13,167 +13,6 @@ class Template extends Common{ |
|
@@ -13,167 +13,6 @@ class Template extends Common{ |
|
13
|
$this->publicpath = 'static/home/';
|
13
|
$this->publicpath = 'static/home/';
|
|
14
|
$this->assign ( 'viewSuffix',$this->viewSuffix );
|
14
|
$this->assign ( 'viewSuffix',$this->viewSuffix );
|
|
15
|
}
|
15
|
}
|
|
16
|
- /*public function index(){
|
|
|
|
17
|
- $type= input('param.type') ? input('param.type') : $this->viewSuffix;
|
|
|
|
18
|
- if($type==$this->viewSuffix){
|
|
|
|
19
|
- $path=$this->filepath;
|
|
|
|
20
|
- }else{
|
|
|
|
21
|
- $path=$this->publicpath.$type.'/';
|
|
|
|
22
|
- }
|
|
|
|
23
|
- $files = dir_list($path,$type);
|
|
|
|
24
|
- $templates = array();
|
|
|
|
25
|
- foreach ($files as $key=>$file){
|
|
|
|
26
|
- $filename = basename($file);
|
|
|
|
27
|
- $templates[$key]['value'] = substr($filename,0,strrpos($filename, '.'));
|
|
|
|
28
|
- $templates[$key]['filename'] = $filename;
|
|
|
|
29
|
- $templates[$key]['filepath'] = $file;
|
|
|
|
30
|
- $templates[$key]['filesize']=byte_format(filesize($file));
|
|
|
|
31
|
- $templates[$key]['filemtime']=filemtime($file);
|
|
|
|
32
|
- $templates[$key]['ext'] = strtolower(substr($filename,strrpos($filename, '.')-strlen($filename)));
|
|
|
|
33
|
- }
|
|
|
|
34
|
- $this->assign ( 'templates',$templates );
|
|
|
|
35
|
-
|
|
|
|
36
|
- return $this->fetch();
|
|
|
|
37
|
- }*/
|
|
|
|
38
|
-
|
|
|
|
39
|
- /*public function add(){
|
|
|
|
40
|
- $this->assign ( 'title','添加模版' );
|
|
|
|
41
|
- return $this->fetch();
|
|
|
|
42
|
- }
|
|
|
|
43
|
- public function insert(){
|
|
|
|
44
|
- $filename = input('post.file');
|
|
|
|
45
|
- $type = input('post.type');
|
|
|
|
46
|
- $path = $type==$this->viewSuffix ? $this->filepath : $this->publicpath.$type.'/';
|
|
|
|
47
|
- $file = $path.$filename.'.'.$type;
|
|
|
|
48
|
- if(file_exists($file)){
|
|
|
|
49
|
- $result['msg'] = '文件已经存在!';
|
|
|
|
50
|
- $result['status'] = 0;
|
|
|
|
51
|
- return $result;
|
|
|
|
52
|
- }
|
|
|
|
53
|
- file_put_contents($file,stripslashes(input('post.content')));
|
|
|
|
54
|
- $result['msg'] = '添加成功!';
|
|
|
|
55
|
- if($type==$this->viewSuffix){
|
|
|
|
56
|
- $result['url'] = url('index');
|
|
|
|
57
|
- }else{
|
|
|
|
58
|
- $result['url'] = url('index',array('type'=>$type));
|
|
|
|
59
|
- }
|
|
|
|
60
|
- $result['code'] = 1;
|
|
|
|
61
|
- return $result;
|
|
|
|
62
|
- }
|
|
|
|
63
|
-
|
|
|
|
64
|
- public function edit(){
|
|
|
|
65
|
- $filename = input('param.file');
|
|
|
|
66
|
- if(input('param.type')){
|
|
|
|
67
|
- $type = input('param.type');
|
|
|
|
68
|
- }else{
|
|
|
|
69
|
- $type = strtolower(substr($filename,strrpos($filename, '.')-strlen($filename)+1));
|
|
|
|
70
|
- }
|
|
|
|
71
|
- $path = $type==$this->viewSuffix ? $this->filepath : $this->publicpath.$type.'/';
|
|
|
|
72
|
- $file = $path.$filename;
|
|
|
|
73
|
- if(file_exists($file)){
|
|
|
|
74
|
- $file=iconv('gb2312','utf-8',$file);
|
|
|
|
75
|
- $content = file_get_contents($file);
|
|
|
|
76
|
- $this->assign ( 'filename',$filename );
|
|
|
|
77
|
- $this->assign ( 'title','修改模版内容' );
|
|
|
|
78
|
- $this->assign ( 'file',$file );
|
|
|
|
79
|
- $this->assign ( 'content',$content );
|
|
|
|
80
|
- }else{
|
|
|
|
81
|
- $this->error('文件不存在!');
|
|
|
|
82
|
- }
|
|
|
|
83
|
- return $this->fetch();
|
|
|
|
84
|
- }
|
|
|
|
85
|
- public function update(){
|
|
|
|
86
|
- $filename = input('post.file');
|
|
|
|
87
|
- $type= input('param.type') ? input('param.type') : $this->viewSuffix;
|
|
|
|
88
|
- $path = $type==$this->viewSuffix ? $this->filepath : $this->publicpath.$type.'/';
|
|
|
|
89
|
- $file = $path.$filename;
|
|
|
|
90
|
- if(file_exists($file)){
|
|
|
|
91
|
- file_put_contents($file,stripslashes(input('content')));
|
|
|
|
92
|
- $result['msg'] = '修改成功!';
|
|
|
|
93
|
- if($type==$this->viewSuffix){
|
|
|
|
94
|
- $result['url'] = url('index');
|
|
|
|
95
|
- }else{
|
|
|
|
96
|
- $result['url'] = url('index',array('type'=>$type));
|
|
|
|
97
|
- }
|
|
|
|
98
|
- $result['code'] = 1;
|
|
|
|
99
|
- return $result;
|
|
|
|
100
|
- }else{
|
|
|
|
101
|
- $result['msg'] = '文件不存在!';
|
|
|
|
102
|
- $result['code'] = 0;
|
|
|
|
103
|
- return $result;
|
|
|
|
104
|
- }
|
|
|
|
105
|
- }
|
|
|
|
106
|
-
|
|
|
|
107
|
- public function delete(){
|
|
|
|
108
|
- $filename = input('param.file');
|
|
|
|
109
|
- $type = strtolower(substr($filename,strrpos($filename, '.')-strlen($filename)+1));
|
|
|
|
110
|
- $path = $type==$this->viewSuffix ? $path=$this->filepath : $this->publicpath.$type.'/';
|
|
|
|
111
|
- $file = $path.$filename;
|
|
|
|
112
|
- if(file_exists($file)){
|
|
|
|
113
|
- unlink($file);
|
|
|
|
114
|
- if($type==$this->viewSuffix){
|
|
|
|
115
|
- $this->redirect('index');
|
|
|
|
116
|
- }else{
|
|
|
|
117
|
- $this->redirect('index',array('type'=>$type));
|
|
|
|
118
|
- }
|
|
|
|
119
|
- }else{
|
|
|
|
120
|
- if($type==$this->viewSuffix){
|
|
|
|
121
|
- $this->redirect('index');
|
|
|
|
122
|
- }else{
|
|
|
|
123
|
- $this->redirect('index',array('type'=>$type));
|
|
|
|
124
|
- }
|
|
|
|
125
|
- }
|
|
|
|
126
|
- }
|
|
|
|
127
|
-
|
|
|
|
128
|
- public function images(){
|
|
|
|
129
|
- $path = $this->publicpath.'images/'.input('folder').'/';
|
|
|
|
130
|
- $uppath = explode('/',input('folder'));
|
|
|
|
131
|
- $leve = count($uppath)-1;
|
|
|
|
132
|
- unset($uppath[$leve]);
|
|
|
|
133
|
- if($leve>1){
|
|
|
|
134
|
- unset($uppath[$leve-1]);
|
|
|
|
135
|
- $uppath = implode('/',$uppath).'/';
|
|
|
|
136
|
- }else{
|
|
|
|
137
|
- $uppath = '';
|
|
|
|
138
|
- }
|
|
|
|
139
|
- $this->assign ( 'leve',$leve);
|
|
|
|
140
|
- $this->assign ( 'uppath',$uppath);
|
|
|
|
141
|
- $files = glob($path.'*');
|
|
|
|
142
|
- $folders=array();
|
|
|
|
143
|
- foreach($files as $key => $file) {
|
|
|
|
144
|
- $filename = basename($file);
|
|
|
|
145
|
- if(is_dir($file)){
|
|
|
|
146
|
- $folders[$key]['filename'] = $filename;
|
|
|
|
147
|
- $folders[$key]['filepath'] = $file;
|
|
|
|
148
|
- $folders[$key]['ext'] = 'folder';
|
|
|
|
149
|
- }else{
|
|
|
|
150
|
- $templates[$key]['filename'] = $filename;
|
|
|
|
151
|
- $templates[$key]['filepath'] = $file;
|
|
|
|
152
|
- $templates[$key]['ext'] = strtolower(substr($filename,strrpos($filename, '.')-strlen($filename)+1));
|
|
|
|
153
|
- if(!in_array($templates[$key]['ext'],array('gif','jpg','png','bmp'))) $templates[$key]['ico'] =1;
|
|
|
|
154
|
- }
|
|
|
|
155
|
- }
|
|
|
|
156
|
- $this->assign ( 'title','媒体文件' );
|
|
|
|
157
|
- $this->assign ( 'path',$path);
|
|
|
|
158
|
- $this->assign ( 'folders',$folders );
|
|
|
|
159
|
- $this->assign ( 'files',$templates );
|
|
|
|
160
|
- return $this->fetch();
|
|
|
|
161
|
- }
|
|
|
|
162
|
- public function imgDel(){
|
|
|
|
163
|
- $path = $this->publicpath.'images/'.input('post.folder');
|
|
|
|
164
|
- $file=$path.input('post.filename');
|
|
|
|
165
|
- if(file_exists($file)){
|
|
|
|
166
|
- is_dir($file) ? dir_delete($file) : unlink($file);
|
|
|
|
167
|
-
|
|
|
|
168
|
- $result['msg'] = '删除成功!';
|
|
|
|
169
|
- $result['code'] = 1;
|
|
|
|
170
|
- return $result;
|
|
|
|
171
|
- }else{
|
|
|
|
172
|
- $result['msg'] = '文件不存在!';
|
|
|
|
173
|
- $result['code'] = 0;
|
|
|
|
174
|
- return $result;
|
|
|
|
175
|
- }
|
|
|
|
176
|
- }*/
|
|
|
|
177
|
|
16
|
|
|
178
|
public function index(){
|
17
|
public function index(){
|
|
179
|
//$path = $this->publicpath.'images/'.input('folder').'/'; ///Applications/XAMPP/xamppfiles/htdocs/dashboard/images/
|
18
|
//$path = $this->publicpath.'images/'.input('folder').'/'; ///Applications/XAMPP/xamppfiles/htdocs/dashboard/images/
|