story_do.php
5.16 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
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
<?php
/**
* @version $Id: story_do.php 1 9:02 2010年9月25日Z 蓝色随想 $
* @package DedeCMS.Module.Book
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require_once(dirname(__FILE__). "/config.php");
CheckPurview('story_Del');
require_once(DEDEINC. "/oxwindow.class.php");
if(empty($action))
{
ShowMsg("你没指定任何参数!","-1");
exit();
}
/*--------------------
function DelBook()
删除整本图书
-------------------*/
if($action=='delbook')
{
$bids = explode(',', $bid);
foreach($bids as $i => $bid)
{
if(intval($bid)<=0)
{
continue;
}
$row = $dsql->GetOne("SELECT booktype FROM #@__story_books WHERE bid='$bid' ");
$dsql->ExecuteNoneQuery("DELETE FROM #@__story_books WHERE bid='$bid' ");
$dsql->ExecuteNoneQuery("DELETE FROM #@__story_chapter WHERE bookid='$bid' ");
//删除图片
if(empty($row['booktype']))
{
$row['booktype'] = '';
}
if($row['booktype']==1)
{
$dsql->SetQuery("SELECT bigpic FROM #@__story_content WHERE bookid='$bid' ");
$dsql->Execute();
while($row = $dsql->GetArray())
{
$bigpic = $row['bigpic'];
if( $bigpic!="" && !eregi('^http://',$bigpic) )
{
@unlink($cfg_basedir.$bigpic);
}
}
}
$dsql->ExecuteNoneQuery("DELETE FROM #@__story_content WHERE bookid='$bid' ");
}
$i = $i+1;
if(empty($ENV_GOBACK_URL))
{
$ENV_GOBACK_URL = 'story_books.php';
}
ShowMsg("成功删除 {$i} 本图书!",$ENV_GOBACK_URL);
exit();
}
/*--------------------
function DelStoryContent()
删除图书内容
-------------------*/
else if($action=='delcontent')
{
$row = $dsql->GetOne("SELECT bigpic,chapterid,bookid FROM #@__story_content WHERE id='$cid' ");
$chapterid = $row['chapterid'];
$bookid = $row['bookid'];
//如果图片不为空,先删除图片
if( $row['bigpic']!="" && !eregi('^http://',$row['bigpic']) )
{
@unlink($cfg_basedir.$row['bigpic']);
}
$dsql->ExecuteNoneQuery(" DELETE FROM #@__story_content WHERE id='$cid' ");
//更新图书记录
$row = $dsql->GetOne("SELECT count(id) AS dd FROM #@__story_content WHERE bookid='$bookid' ");
$dsql->ExecuteNoneQuery("Update #@__story_books SET postnum='{$row['dd']}' WHERE bid='$bookid' ");
//更新章节记录
$row = $dsql->GetOne("SELECT count(id) AS dd FROM #@__story_content WHERE chapterid='$chapterid' ");
$dsql->ExecuteNoneQuery("Update #@__story_chapter SET postnum='{$row['dd']}' WHERE id='$chapterid' ");
ShowMsg("成功删除指定内容!",$ENV_GOBACK_URL);
exit();
}
/*--------------------
function EditChapter()
保存章节信息
-------------------*/
else if($action=='editChapter')
{
require_once(DEDEINC."/charSET.func.php");
//$chaptername = gb2utf8($chaptername);
$dsql->ExecuteNoneQuery("Update #@__story_chapter SET chaptername='$chaptername',chapnum='$chapnum' WHERE id='$cid' ");
AjaxHead();
echo "<font color='red'>成功更新章节:{$chaptername} ! [<a href=\"javascript:CloseLayer('editchapter')\">关闭提示</a>]</font> <br /><br /> 提示:修改章节名称或章节序号直接在左边修改,然后点击右边的 [更新] 会保存。 ";
exit();
}
/*--------------------
function DelChapter()
删除章节信息
-------------------*/
else if($action=='delChapter')
{
$row = $dsql->GetOne("SELECT c.bookid,b.booktype FROM #@__story_chapter c LEFT JOIN #@__story_books b ON b.bid=c.bookid WHERE c.id='$cid' ");
$bookid = $row['bookid'];
$booktype = $row['booktype'];
$dsql->ExecuteNoneQuery("DELETE FROM #@__story_chapter WHERE id='$cid' ");
//删除图片
if($booktype==1)
{
$dsql->SetQuery("SELECT bigpic FROM #@__story_content WHERE bookid='$bookid' ");
$dsql->Execute();
while($row = $dsql->GetArray())
{
$bigpic = $row['bigpic'];
if( $bigpic!="" && !eregi('^http://',$bigpic) )
{
@unlink($cfg_basedir.$bigpic);
}
}
}
$dsql->ExecuteNoneQuery("DELETE FROM #@__story_content WHERE chapterid='$cid' ");
//更新图书记录
$row = $dsql->GetOne("SELECT count(id) AS dd FROM #@__story_content WHERE bookid='$bookid' ");
$dsql->ExecuteNoneQuery("UPDATE #@__story_books SET postnum='{$row['dd']}' WHERE bid='$bookid' ");
ShowMsg("成功删除指定章节!",$ENV_GOBACK_URL);
exit();
}
/*---------------
function EditChapterAll()
批量修改章节
-------------------*/
else if($action=='upChapterSort')
{
if(isSET($ids) && is_array($ids))
{
foreach($ids as $cid)
{
$chaptername = ${'chaptername_'.$cid};
$chapnum= ${'chapnum_'.$cid};
$dsql->ExecuteNoneQuery("UPDATE #@__story_chapter SET chaptername='$chaptername',chapnum='$chapnum' WHERE id='$cid' ");
}
}
ShowMsg("成功更新指定章节信息!", $ENV_GOBACK_URL);
exit();
}