templets_one_edit.php
3.46 KB
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
<?php
/**
* 编辑一个模板
*
* @version $Id: templets_one_edit.php 1 23:07 2010年7月20日Z tianya $
* @package DedeCMS.Administrator
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require(dirname(__FILE__)."/config.php");
CheckPurview('temp_One');
if(empty($dopost)) $dopost = "";
$aid = isset($aid) && is_numeric($aid) ? $aid : 0;
if($dopost=="saveedit")
{
include_once(DEDEINC."/arc.sgpage.class.php");
$uptime = time();
$body = str_replace('"', '\\"', $body);
$filename = preg_replace("#^\/#", "", $nfilename);
//如果更改了文件名,删除旧文件
if($oldfilename!=$filename)
{
$oldfilename = $cfg_basedir.$cfg_cmspath."/".$oldfilename;
if(is_file($oldfilename))
{
unlink($oldfilename);
}
}
if($likeidsel!=$oldlikeid )
{
$likeid = $likeidsel;
}
$inQuery = "
UPDATE `#@__sgpage` SET
title='$title',
keywords='$keywords',
description='$description',
likeid='$likeid',
ismake='$ismake',
filename='$filename',
template='$template',
uptime='$uptime',
body='$body'
WHERE aid='$aid'; ";
if(!$dsql->ExecuteNoneQuery($inQuery))
{
ShowMsg("更新页面数据时失败,请检查长相是否有问题!","-1");
exit();
}
$sg = new sgpage($aid);
$sg->SaveToHtml();
ShowMsg("成功修改一个页面!", "templets_one.php");
exit();
}
else if($dopost=="delete")
{
$row = $dsql->GetOne("SELECT filename FROM `#@__sgpage` WHERE aid='$aid'");
$filename = preg_replace("#\/{1,}#", "/", $cfg_basedir.$cfg_cmspath."/".$row['filename']);
$dsql->ExecuteNoneQuery(" DELETE FROM `#@__sgpage` WHERE aid='$aid' ");
if(is_file($filename))
{
unlink($filename);
}
ShowMsg("成功删除一个页面!", "templets_one.php");
exit();
}
else if($dopost=="make")
{
include_once(DEDEINC."/arc.sgpage.class.php");
$row = $dsql->GetOne("SELECT filename FROM `#@__sgpage` WHERE aid='$aid'");
$fileurl = $cfg_cmsurl.'/'.preg_replace("#\/{1,}#", "/", $row['filename']);
$sg = new sgpage($aid);
$sg->SaveToHtml();
ShowMsg("成功更新一个页面!", $fileurl);
exit();
}
else if($dopost=="mkall")
{
include_once(DEDEINC."/arc.sgpage.class.php");
$dsql->Execute("ex","SELECT aid FROM `#@__sgpage` ");
$i = 0;
while($row = $dsql->GetArray("ex"))
{
$sg = new sgpage($row['aid']);
$sg->SaveToHtml();
$i++;
}
ShowMsg("成功更新 $i 个页面!", '-1');
exit();
}
else if($dopost=="mksel")
{
if(empty($ids))
{
$ids = '';
}
include_once(DEDEINC."/arc.sgpage.class.php");
$i = 0;
if($ids == 0)
{
ShowMsg('您没有选择需要更新的文档!','-1');
exit();
}
else if(is_array($ids))
{
foreach($ids as $aid)
{
$sg = new sgpage($aid);
$sg->SaveToHtml();
$i++;
}
ShowMsg("成功更新 $i 个页面!",'-1');
exit();
}
}
else if($dopost=="view")
{
if(empty($aid))
{
ShowMsg('错误的ID!','javascript:;');
exit();
}
include_once(DEDEINC."/arc.sgpage.class.php");
$sg = new sgpage($aid);
$sg->display();
exit();
}
$row = $dsql->GetOne("SELECT * FROM `#@__sgpage` WHERE aid='$aid' ");
include(DEDEADMIN."/templets/templets_one_edit.htm");