国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
5.3KB

  1. <?php
  2. /**
  3. * @version $Id: story_do.php 1 9:02 2010年9月25日Z 蓝色随想 $
  4. * @package DedeCMS.Module.Book
  5. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  6. * @license http://help.dedecms.com/usersguide/license.html
  7. * @link http://www.dedecms.com
  8. */
  9. require_once(dirname(__FILE__). "/config.php");
  10. CheckPurview('story_Del');
  11. require_once(DEDEINC. "/oxwindow.class.php");
  12. if(empty($action))
  13. {
  14. ShowMsg("你没指定任何参数!","-1");
  15. exit();
  16. }
  17. /*--------------------
  18. function DelBook()
  19. 删除整本图书
  20. -------------------*/
  21. if($action=='delbook')
  22. {
  23. $bids = explode(',', $bid);
  24. foreach($bids as $i => $bid)
  25. {
  26. if(intval($bid)<=0)
  27. {
  28. continue;
  29. }
  30. $row = $dsql->GetOne("SELECT booktype FROM #@__story_books WHERE bid='$bid' ");
  31. $dsql->ExecuteNoneQuery("DELETE FROM #@__story_books WHERE bid='$bid' ");
  32. $dsql->ExecuteNoneQuery("DELETE FROM #@__story_chapter WHERE bookid='$bid' ");
  33. //删除图片
  34. if(empty($row['booktype']))
  35. {
  36. $row['booktype'] = '';
  37. }
  38. if($row['booktype']==1)
  39. {
  40. $dsql->SetQuery("SELECT bigpic FROM #@__story_content WHERE bookid='$bid' ");
  41. $dsql->Execute();
  42. while($row = $dsql->GetArray())
  43. {
  44. $bigpic = $row['bigpic'];
  45. if( $bigpic!="" && !eregi('^http://',$bigpic) )
  46. {
  47. @unlink($cfg_basedir.$bigpic);
  48. }
  49. }
  50. }
  51. $dsql->ExecuteNoneQuery("DELETE FROM #@__story_content WHERE bookid='$bid' ");
  52. }
  53. $i = $i+1;
  54. if(empty($ENV_GOBACK_URL))
  55. {
  56. $ENV_GOBACK_URL = 'story_books.php';
  57. }
  58. ShowMsg("成功删除 {$i} 本图书!",$ENV_GOBACK_URL);
  59. exit();
  60. }
  61. /*--------------------
  62. function DelStoryContent()
  63. 删除图书内容
  64. -------------------*/
  65. else if($action=='delcontent')
  66. {
  67. $row = $dsql->GetOne("SELECT bigpic,chapterid,bookid FROM #@__story_content WHERE id='$cid' ");
  68. $chapterid = $row['chapterid'];
  69. $bookid = $row['bookid'];
  70. //如果图片不为空,先删除图片
  71. if( $row['bigpic']!="" && !eregi('^http://',$row['bigpic']) )
  72. {
  73. @unlink($cfg_basedir.$row['bigpic']);
  74. }
  75. $dsql->ExecuteNoneQuery(" DELETE FROM #@__story_content WHERE id='$cid' ");
  76. //更新图书记录
  77. $row = $dsql->GetOne("SELECT count(id) AS dd FROM #@__story_content WHERE bookid='$bookid' ");
  78. $dsql->ExecuteNoneQuery("Update #@__story_books SET postnum='{$row['dd']}' WHERE bid='$bookid' ");
  79. //更新章节记录
  80. $row = $dsql->GetOne("SELECT count(id) AS dd FROM #@__story_content WHERE chapterid='$chapterid' ");
  81. $dsql->ExecuteNoneQuery("Update #@__story_chapter SET postnum='{$row['dd']}' WHERE id='$chapterid' ");
  82. ShowMsg("成功删除指定内容!",$ENV_GOBACK_URL);
  83. exit();
  84. }
  85. /*--------------------
  86. function EditChapter()
  87. 保存章节信息
  88. -------------------*/
  89. else if($action=='editChapter')
  90. {
  91. require_once(DEDEINC."/charSET.func.php");
  92. //$chaptername = gb2utf8($chaptername);
  93. $dsql->ExecuteNoneQuery("Update #@__story_chapter SET chaptername='$chaptername',chapnum='$chapnum' WHERE id='$cid' ");
  94. AjaxHead();
  95. echo "<font color='red'>成功更新章节:{$chaptername} ! [<a href=\"javascript:CloseLayer('editchapter')\">关闭提示</a>]</font> <br /><br /> 提示:修改章节名称或章节序号直接在左边修改,然后点击右边的 [更新] 会保存。 ";
  96. exit();
  97. }
  98. /*--------------------
  99. function DelChapter()
  100. 删除章节信息
  101. -------------------*/
  102. else if($action=='delChapter')
  103. {
  104. $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' ");
  105. $bookid = $row['bookid'];
  106. $booktype = $row['booktype'];
  107. $dsql->ExecuteNoneQuery("DELETE FROM #@__story_chapter WHERE id='$cid' ");
  108. //删除图片
  109. if($booktype==1)
  110. {
  111. $dsql->SetQuery("SELECT bigpic FROM #@__story_content WHERE bookid='$bookid' ");
  112. $dsql->Execute();
  113. while($row = $dsql->GetArray())
  114. {
  115. $bigpic = $row['bigpic'];
  116. if( $bigpic!="" && !eregi('^http://',$bigpic) )
  117. {
  118. @unlink($cfg_basedir.$bigpic);
  119. }
  120. }
  121. }
  122. $dsql->ExecuteNoneQuery("DELETE FROM #@__story_content WHERE chapterid='$cid' ");
  123. //更新图书记录
  124. $row = $dsql->GetOne("SELECT count(id) AS dd FROM #@__story_content WHERE bookid='$bookid' ");
  125. $dsql->ExecuteNoneQuery("UPDATE #@__story_books SET postnum='{$row['dd']}' WHERE bid='$bookid' ");
  126. ShowMsg("成功删除指定章节!",$ENV_GOBACK_URL);
  127. exit();
  128. }
  129. /*---------------
  130. function EditChapterAll()
  131. 批量修改章节
  132. -------------------*/
  133. else if($action=='upChapterSort')
  134. {
  135. if(isSET($ids) && is_array($ids))
  136. {
  137. foreach($ids as $cid)
  138. {
  139. $chaptername = ${'chaptername_'.$cid};
  140. $chapnum= ${'chapnum_'.$cid};
  141. $dsql->ExecuteNoneQuery("UPDATE #@__story_chapter SET chaptername='$chaptername',chapnum='$chapnum' WHERE id='$cid' ");
  142. }
  143. }
  144. ShowMsg("成功更新指定章节信息!", $ENV_GOBACK_URL);
  145. exit();
  146. }