国内流行的内容管理系统(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.

inc_batchup.php 5.9KB

2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /**
  3. * 文档操作相关函数
  4. *
  5. * @version $Id: inc_batchup.php 1 10:32 2010年7月21日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. /**
  12. * 删除文档信息
  13. *
  14. * @access public
  15. * @param string $aid 文档ID
  16. * @param string $type 类型
  17. * @param string $onlyfile 删除数据库记录
  18. * @return string
  19. */
  20. function DelArc($aid, $type = 'ON', $onlyfile = FALSE, $recycle = 0)
  21. {
  22. global $dsql, $cfg_cookie_encode, $cfg_multi_site, $cfg_medias_dir;
  23. global $cuserLogin, $cfg_upload_switch, $cfg_delete, $cfg_basedir;
  24. global $admin_catalogs, $cfg_admin_channel;
  25. if ($cfg_delete == 'N') $type = 'OK';
  26. if (empty($aid)) return;
  27. $aid = preg_replace("#[^0-9]#i", '', $aid);
  28. $arctitle = $arcurl = '';
  29. if ($recycle == 1) $whererecycle = "AND arcrank = '-2'";
  30. else $whererecycle = "";
  31. //查询表信息
  32. $query = "SELECT ch.maintable,ch.addtable,ch.nid,ch.issystem FROM `#@__arctiny` arc
  33. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  34. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel WHERE arc.id='$aid' ";
  35. $row = $dsql->GetOne($query);
  36. $nid = $row['nid'];
  37. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  38. $addtable = trim($row['addtable']);
  39. $issystem = $row['issystem'];
  40. //查询档案信息
  41. if ($issystem == -1) {
  42. $arcQuery = "SELECT arc.*,tp.* from `$addtable` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id WHERE arc.aid='$aid' ";
  43. } else {
  44. $arcQuery = "SELECT arc.*,tp.*,arc.id AS aid FROM `$maintable` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id WHERE arc.id='$aid' ";
  45. }
  46. $arcRow = $dsql->GetOne($arcQuery);
  47. //检测权限
  48. if (!TestPurview('a_Del,sys_ArcBatch')) {
  49. if (TestPurview('a_AccDel')) {
  50. if (!in_array($arcRow['typeid'], $admin_catalogs) && (count($admin_catalogs) != 0 || $cfg_admin_channel != 'all')) {
  51. return FALSE;
  52. }
  53. } else if (TestPurview('a_MyDel')) {
  54. if ($arcRow['mid'] != $cuserLogin->getUserID()) {
  55. return FALSE;
  56. }
  57. } else {
  58. return FALSE;
  59. }
  60. }
  61. //$issystem==-1 是单表模型,不使用回收站
  62. if ($issystem == -1) $type = 'OK';
  63. if (!is_array($arcRow)) return FALSE;
  64. /** 删除到回收站 **/
  65. if ($cfg_delete == 'Y' && $type == 'ON') {
  66. $dsql->ExecuteNoneQuery("UPDATE `$maintable` SET arcrank='-2' WHERE id='$aid' ");
  67. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET `arcrank` = '-2' WHERE id = '$aid'; ");
  68. } else {
  69. //删除数据库记录
  70. if (!$onlyfile) {
  71. $query = "Delete From `#@__arctiny` where id='$aid' $whererecycle";
  72. if ($dsql->ExecuteNoneQuery($query)) {
  73. $dsql->ExecuteNoneQuery("Delete From `#@__feedback` where aid='$aid' ");
  74. $dsql->ExecuteNoneQuery("Delete From `#@__member_stow` where aid='$aid' ");
  75. $dsql->ExecuteNoneQuery("Delete From `#@__taglist` where aid='$aid' ");
  76. $dsql->ExecuteNoneQuery("Delete From `#@__erradd` where aid='$aid' ");
  77. if ($addtable != '') {
  78. $dsql->ExecuteNoneQuery("Delete From `$addtable` where aid='$aid'");
  79. }
  80. if ($issystem != -1) {
  81. $dsql->ExecuteNoneQuery("Delete From `#@__archives` where id='$aid' $whererecycle");
  82. }
  83. //删除相关附件
  84. if ($cfg_upload_switch == 'Y') {
  85. $dsql->Execute("me", "SELECT * FROM `#@__uploads` WHERE arcid = '$aid'");
  86. while ($row = $dsql->GetArray('me')) {
  87. $addfile = $row['url'];
  88. $aid = $row['aid'];
  89. $dsql->ExecuteNoneQuery("Delete From `#@__uploads` where aid = '$aid' ");
  90. $upfile = $cfg_basedir.$addfile;
  91. if (@file_exists($upfile)) @unlink($upfile);
  92. }
  93. }
  94. }
  95. }
  96. //删除文本数据
  97. $filenameh = DEDEDATA."/textdata/".(ceil($aid / 5000))."/{$aid}-".substr(md5($cfg_cookie_encode), 0, 16).".txt";
  98. if (@is_file($filenameh)) @unlink($filenameh);
  99. }
  100. if (empty($arcRow['money'])) $arcRow['money'] = 0;
  101. if (empty($arcRow['ismake'])) $arcRow['ismake'] = 1;
  102. if (empty($arcRow['arcrank'])) $arcRow['arcrank'] = 0;
  103. if (empty($arcRow['filename'])) $arcRow['filename'] = '';
  104. //删除HTML
  105. if ($arcRow['ismake'] == -1 || $arcRow['arcrank'] != 0 || $arcRow['typeid'] == 0 || $arcRow['money'] > 0) {
  106. return TRUE;
  107. }
  108. //强制转换非多站点模式,以便统一方式获得实际HTML文件
  109. $GLOBALS['cfg_multi_site'] = 'N';
  110. $arcurl = GetFileUrl(
  111. $arcRow['aid'],
  112. $arcRow['typeid'],
  113. $arcRow['senddate'],
  114. $arcRow['title'],
  115. $arcRow['ismake'],
  116. $arcRow['arcrank'],
  117. $arcRow['namerule'],
  118. $arcRow['typedir'],
  119. $arcRow['money'],
  120. $arcRow['filename']
  121. );
  122. if (!preg_match("#\?#", $arcurl)) {
  123. $htmlfile = GetTruePath().str_replace($GLOBALS['cfg_basehost'], '', $arcurl);
  124. if (file_exists($htmlfile) && !is_dir($htmlfile)) {
  125. @unlink($htmlfile);
  126. $arcurls = explode(".", $htmlfile);
  127. $sname = $arcurls[count($arcurls) - 1];
  128. $fname = preg_replace("#(\.$sname)$#", "", $htmlfile);
  129. for ($i = 2; $i <= 100; $i++) {
  130. $htmlfile = $fname."_{$i}.".$sname;
  131. if (@file_exists($htmlfile)) @unlink($htmlfile);
  132. else break;
  133. }
  134. }
  135. }
  136. return true;
  137. }
  138. //获取真实路径
  139. function GetTruePath($siterefer = '', $sitepath = '')
  140. {
  141. $truepath = $GLOBALS['cfg_basedir'];
  142. return $truepath;
  143. }