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

929 lines
40KB

  1. <?php
  2. /**
  3. * 文档处理
  4. *
  5. * @version $Id: archives_do.php 1 8:26 2010年7月12日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__) . '/config.php');
  12. require_once(DEDEADMIN . '/inc/inc_batchup.php');
  13. require_once(DEDEADMIN . '/inc/inc_archives_functions.php');
  14. require_once(DEDEINC . '/typelink.class.php');
  15. require_once(DEDEINC . '/arc.archives.class.php');
  16. $ENV_GOBACK_URL = (empty($_COOKIE['ENV_GOBACK_URL']) ? 'content_list.php' : $_COOKIE['ENV_GOBACK_URL']);
  17. if (empty($dopost)) {
  18. ShowMsg('对不起,你没指定运行参数!', '-1');
  19. exit();
  20. }
  21. $aid = isset($aid) ? preg_replace("#[^0-9]#", '', $aid) : '';
  22. /*--------------------------
  23. //编辑文档
  24. function editArchives(){ }
  25. ---------------------------*/
  26. if ($dopost == 'editArchives') {
  27. $query = "SELECT arc.id,arc.typeid,ch.maintable,ch.editcon
  28. FROM `#@__arctiny` arc
  29. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  30. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  31. WHERE arc.id='$aid' ";
  32. $row = $dsql->GetOne($query);
  33. $gurl = $row['editcon'];
  34. if ($gurl == '') $gurl = 'article_edit.php';
  35. header("location:{$gurl}?aid=$aid");
  36. exit();
  37. }
  38. /*--------------------------
  39. //浏览文档
  40. function viewArchives(){ }
  41. ---------------------------*/ else if ($dopost == "viewArchives") {
  42. $aid = preg_replace("#[^0-9]#", '', $aid);
  43. //获取主表信息
  44. $query = "SELECT arc.*,ch.maintable,ch.addtable,ch.issystem,ch.editcon,
  45. tp.typedir,tp.typename,tp.corank,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.sitepath,tp.siteurl
  46. FROM `#@__arctiny` arc
  47. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  48. LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
  49. WHERE arc.id='$aid' ";
  50. $trow = $dsql->GetOne($query);
  51. $trow['maintable'] = (trim($trow['maintable']) == '' ? '#@__archives' : trim($trow['maintable']));
  52. if ($trow['issystem'] != -1) {
  53. $arcQuery = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.sitepath,tp.siteurl
  54. FROM `{$trow['maintable']}` arc LEFT JOIN `#@__arctype` tp on arc.typeid=tp.id
  55. LEFT JOIN `#@__channeltype` ch on ch.id=arc.channel WHERE arc.id='$aid' ";
  56. $arcRow = $dsql->GetOne($arcQuery);
  57. PutCookie('DedeUserID', $arcRow['mid'], 1800);
  58. PutCookie('DedeLoginTime', time(), 1800);
  59. if ($arcRow['ismake'] == -1 || $arcRow['corank'] != 0 || $arcRow['arcrank'] != 0 || ($arcRow['typeid'] == 0 && $arcRow['channel'] != -1) || $arcRow['money'] > 0) {
  60. echo "<script language='javascript'>location.href='{$cfg_phpurl}/view.php?aid={$aid}';</script>";
  61. exit();
  62. }
  63. } else {
  64. $arcRow['id'] = $aid;
  65. $arcRow['typeid'] = $trow['typeid'];
  66. $arcRow['senddate'] = $trow['senddate'];
  67. $arcRow['title'] = '';
  68. $arcRow['ismake'] = 1;
  69. $arcRow['arcrank'] = $trow['corank'];
  70. $arcRow['namerule'] = $trow['namerule'];
  71. $arcRow['typedir'] = $trow['typedir'];
  72. $arcRow['money'] = 0;
  73. $arcRow['filename'] = '';
  74. $arcRow['moresite'] = $trow['moresite'];
  75. $arcRow['siteurl'] = $trow['siteurl'];
  76. $arcRow['sitepath'] = $trow['sitepath'];
  77. }
  78. $arcurl = GetFileUrl(
  79. $arcRow['id'],
  80. $arcRow['typeid'],
  81. $arcRow['senddate'],
  82. $arcRow['title'],
  83. $arcRow['ismake'],
  84. $arcRow['arcrank'],
  85. $arcRow['namerule'],
  86. $arcRow['typedir'],
  87. $arcRow['money'],
  88. $arcRow['filename'],
  89. $arcRow['moresite'],
  90. $arcRow['siteurl'],
  91. $arcRow['sitepath']
  92. );
  93. $arcfile = GetFileUrl(
  94. $arcRow['id'],
  95. $arcRow['typeid'],
  96. $arcRow['senddate'],
  97. $arcRow['title'],
  98. $arcRow['ismake'],
  99. $arcRow['arcrank'],
  100. $arcRow['namerule'],
  101. $arcRow['typedir'],
  102. $arcRow['money'],
  103. $arcRow['filename']
  104. );
  105. if (preg_match("#^http:#", $arcfile)) {
  106. $arcfile = preg_replace("#^http:\/\/([^\/]*)\/#i", '/', $arcfile);
  107. }
  108. $truefile = GetTruePath() . $arcfile;
  109. if (!file_exists($truefile)) {
  110. MakeArt($aid, TRUE);
  111. }
  112. echo "<script language='javascript'>location.href='$arcurl" . "?" . time() . "';</script>";
  113. exit();
  114. }
  115. /*--------------------------
  116. //异步上传缩略图
  117. function uploadLitpic(){ }
  118. ---------------------------*/ else if ($dopost == "uploadLitpic") {
  119. $upfile = AdminUpload('litpic', 'imagelit', 0, false);
  120. if ($upfile == '-1') {
  121. $msg = "<script language='javascript'>
  122. parent.document.getElementById('uploadwait').style.display = 'none';
  123. alert('你没指定要上传的文件或文件大小超过限制!');
  124. </script>";
  125. } else if ($upfile == '-2') {
  126. $msg = "<script language='javascript'>
  127. parent.document.getElementById('uploadwait').style.display = 'none';
  128. alert('上传文件失败,请检查原因!');
  129. </script>";
  130. } else if ($upfile == '0') {
  131. $msg = "<script language='javascript'>
  132. parent.document.getElementById('uploadwait').style.display = 'none';
  133. alert('文件类型不正确!');
  134. </script>";
  135. } else {
  136. if (!empty($cfg_uplitpic_cut) && $cfg_uplitpic_cut == 'N') {
  137. $msg = "<script language='javascript'>
  138. parent.document.getElementById('uploadwait').style.display = 'none';
  139. parent.document.getElementById('picname').value = '{$upfile}';
  140. if(parent.document.getElementById('divpicview'))
  141. {
  142. parent.document.getElementById('divpicview').style.width = '150px';
  143. parent.document.getElementById('divpicview').innerHTML = \"<img src='{$upfile}?n' width='150' />\";
  144. }
  145. </script>";
  146. } else {
  147. $msg = "<script language='javascript'>
  148. parent.document.getElementById('uploadwait').style.display = 'none';
  149. window.open('imagecut.php?f=picname&isupload=yes&file={$upfile}', 'popUpImagesWin', 'scrollbars=yes,resizable=yes,statebar=no,width=800,height=600,left=150, top=50');
  150. </script>";
  151. }
  152. }
  153. echo $msg;
  154. exit();
  155. }
  156. /*--------------------------
  157. //推荐文档
  158. function commendArchives(){ }
  159. ---------------------------*/ else if ($dopost == "commendArchives") {
  160. CheckPurview('a_Commend,sys_ArcBatch');
  161. if (!empty($aid) && empty($qstr)) {
  162. $qstr = $aid;
  163. }
  164. if ($qstr == '') {
  165. ShowMsg("参数无效!", $ENV_GOBACK_URL);
  166. exit();
  167. }
  168. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  169. $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
  170. LEFT JOIN `#@__arctype` tp on tp.id=arc.typeid
  171. LEFT JOIN `#@__channeltype` ch on ch.id=tp.channeltype
  172. WHERE arc.id in($arcids) ";
  173. $dsql->SetQuery($query);
  174. $dsql->Execute();
  175. while ($row = $dsql->GetArray()) {
  176. $aid = $row['id'];
  177. if ($row['issystem'] != -1) {
  178. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  179. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  180. $flag = ($arr['flag'] == '' ? 'c' : $arr['flag'] . ',c');
  181. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE id='{$aid}' ");
  182. } else {
  183. $maintable = trim($row['addtable']);
  184. $arr = $dsql->GetOne("SELECT flag From `{$maintable}` where aid='$aid' ");
  185. $flag = ($arr['flag'] == '' ? 'c' : $arr['flag'] . ',c');
  186. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE aid='{$aid}' ");
  187. }
  188. }
  189. ShowMsg("成功把所选的文档设为推荐!", $ENV_GOBACK_URL);
  190. exit();
  191. }
  192. /*--------------------------
  193. //生成HTML
  194. function makeArchives();
  195. ---------------------------*/ else if ($dopost == "makeArchives") {
  196. CheckPurview('sys_MakeHtml,sys_ArcBatch');
  197. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  198. if ($qstr == '') {
  199. ShowMsg('参数无效!', $ENV_GOBACK_URL);
  200. exit();
  201. }
  202. require_once(DEDEADMIN . '/inc/inc_archives_functions.php');
  203. $qstrs = explode('`', $qstr);
  204. $i = 0;
  205. foreach ($qstrs as $aid) {
  206. $i++;
  207. $pageurl = MakeArt($aid, false);
  208. }
  209. ShowMsg("成功更新指定 $i 个文件...", $ENV_GOBACK_URL);
  210. exit();
  211. }
  212. /*--------------------------
  213. //审核文档
  214. function checkArchives() { }
  215. ---------------------------*/ else if ($dopost == "checkArchives") {
  216. CheckPurview('a_Check,a_AccCheck,sys_ArcBatch');
  217. require_once(DEDEADMIN . "/inc/inc_archives_functions.php");
  218. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  219. if ($qstr == '') {
  220. ShowMsg("参数无效!", $ENV_GOBACK_URL);
  221. exit();
  222. }
  223. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  224. $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
  225. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  226. LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
  227. WHERE arc.id in($arcids) ";
  228. $dsql->SetQuery($query);
  229. $dsql->Execute('ckall');
  230. while ($row = $dsql->GetArray('ckall')) {
  231. $aid = $row['id'];
  232. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  233. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET arcrank='0' WHERE id='$aid' ");
  234. if ($row['issystem'] == -1) {
  235. $dsql->ExecuteNoneQuery("UPDATE `" . trim($row['addtable']) . "` SET arcrank='0' WHERE aid='$aid' ");
  236. } else {
  237. $dsql->ExecuteNoneQuery("UPDATE `$maintable` SET arcrank='0', dutyadmin='" . $cuserLogin->getUserID() . "' WHERE id='$aid' ");
  238. }
  239. $dsql->ExecuteNoneQuery("UPDATE `#@__taglist` SET arcrank='0' WHERE aid='$aid' ");
  240. $pageurl = MakeArt($aid, false);
  241. }
  242. ShowMsg("成功审核指定的文档!", $ENV_GOBACK_URL);
  243. exit();
  244. }
  245. /*--------------------------
  246. //删除文档
  247. function delArchives(){ }
  248. ---------------------------*/ else if ($dopost == "delArchives") {
  249. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  250. require_once(DEDEINC . "/oxwindow.class.php");
  251. if (empty($fmdo)) $fmdo = '';
  252. if ($fmdo == 'yes') {
  253. if (!empty($aid) && empty($qstr)) {
  254. $qstr = $aid;
  255. }
  256. if ($qstr == '') {
  257. ShowMsg("参数无效!", $ENV_GOBACK_URL);
  258. exit();
  259. }
  260. $qstrs = explode("`", $qstr);
  261. $okaids = array();
  262. foreach ($qstrs as $aid) {
  263. if (!isset($okaids[$aid])) {
  264. DelArc($aid);
  265. } else {
  266. $okaids[$aid] = 1;
  267. }
  268. }
  269. ShowMsg("成功删除指定的文档!", $ENV_GOBACK_URL);
  270. exit();
  271. } else {
  272. $wintitle = "文档管理-删除文档";
  273. $wecome_info = "<a href='" . $ENV_GOBACK_URL . "'>文档管理</a>::删除文档";
  274. $win = new OxWindow();
  275. $win->Init("archives_do.php", "js/blank.js", "POST");
  276. $win->AddHidden("fmdo", "yes");
  277. $win->AddHidden("dopost", $dopost);
  278. $win->AddHidden("qstr", $qstr);
  279. $win->AddHidden("aid", $aid);
  280. $win->AddTitle("你确实要删除“ $qstr 和 $aid ”这些文档?");
  281. $winform = $win->GetWindow("ok");
  282. $win->Display();
  283. }
  284. }
  285. /*-----------------------------
  286. function moveArchives(){ }
  287. ------------------------------*/ else if ($dopost == 'moveArchives') {
  288. CheckPurview('sys_ArcBatch');
  289. if (empty($totype)) {
  290. require_once(DEDEINC . '/typelink.class.php');
  291. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  292. AjaxHead();
  293. $channelid = empty($channelid) ? 0 : $channelid;
  294. $tl = new TypeLink($aid);
  295. $typeOptions = $tl->GetOptionArray(0, $admin_catalogs, $channelid);
  296. $typeOptions = "<select name='totype' style='width:90%'>
  297. <option value='0'>请选择移动到的位置...</option>\r\n
  298. $typeOptions
  299. </select>";
  300. //输出AJAX可移动窗体
  301. $divname = 'moveArchives';
  302. echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">\r\n";
  303. echo " <div class='titLeft'>移动文档</div>\r\n";
  304. echo " <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' alt='关闭' title='关闭' /></div>\r\n";
  305. echo "</div>\r\n";
  306. echo "<form name='quickeditform' action='archives_do.php' method='post'>\r\n";
  307. echo "<input type='hidden' name='dopost' value='{$dopost}' />\r\n";
  308. echo "<input type='hidden' name='qstr' value='{$qstr}' />\r\n";
  309. echo "<table width='100%' style='margin-top:6px;z-index:9000;'>\r\n";
  310. ?>
  311. <tr height='28'>
  312. <td width="80" class='bline'>&nbsp;目标栏目:</td>
  313. <td class='bline'>
  314. <?php echo $typeOptions; ?>
  315. </td>
  316. </tr>
  317. <tr height='32'>
  318. <td width="80" class='bline'>&nbsp;文档ID:</td>
  319. <td class='bline'>
  320. <input type='text' name='tmpids' value="<?php echo $qstr; ?>" style='width:310px;overflow:hidden;' />
  321. <br />
  322. 移动到的目标栏目必须和选定的文档频道类型一致,否则程序会自动勿略不符合的文档。
  323. </td>
  324. </tr>
  325. <tr height='32'>
  326. <td colspan='2' align='center' style='padding-top:12px'>
  327. <input name="imageField" type="image" src="images/button_ok.gif" width="60" height="22" class="np" border="0" style="cursor:pointer" />
  328. &nbsp;&nbsp;
  329. <img src="images/button_back.gif" width="60" height="22" border="0" onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' style="cursor:pointer" />
  330. </td>
  331. </td>
  332. </tr>
  333. </table>
  334. </form>
  335. <?php
  336. //AJAX窗体结束
  337. } else {
  338. $totype = preg_replace("#[^0-9]#", '', $totype);
  339. $typeInfos = $dsql->GetOne("SELECT tp.channeltype,tp.ispart,tp.channeltype,ch.maintable,ch.addtable,ch.issystem FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch on ch.id=tp.channeltype WHERE tp.id='$totype' ");
  340. $idtype = "id";
  341. if (!is_array($typeInfos)) {
  342. ShowMsg('参数错误!', '-1');
  343. exit();
  344. }
  345. if ($typeInfos['ispart'] != 0) {
  346. ShowMsg('文档保存的栏目必须为最终列表栏目!', '-1');
  347. exit();
  348. }
  349. if (empty($typeInfos['addtable'])) {
  350. $typeInfos['maintable'] = '#@__archives';
  351. }
  352. //增加单表模型判断
  353. if ($typeInfos['issystem'] == -1) {
  354. $typeInfos['maintable'] = $typeInfos['addtable'];
  355. $idtype = "aid";
  356. }
  357. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  358. $arc = '';
  359. $j = 0;
  360. $okids = array();
  361. $dsql->SetQuery("SELECT {$idtype},typeid FROM `{$typeInfos['maintable']}` WHERE {$idtype} in($arcids) AND channel='{$typeInfos['channeltype']}' ");
  362. $dsql->Execute();
  363. while ($row = $dsql->GetArray()) {
  364. if ($row['typeid'] != $totype) {
  365. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
  366. $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['maintable']}` SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
  367. $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['addtable']}` SET typeid='$totype' WHERE aid='{$row[$idtype]}' ");
  368. $okids[] = $row[$idtype];
  369. $j++;
  370. }
  371. }
  372. //更新HTML
  373. foreach ($okids as $aid) {
  374. $arc = new Archives($aid);
  375. $arc->MakeHtml();
  376. }
  377. ShowMsg("成功移动 $j 个文档!", $ENV_GOBACK_URL);
  378. exit();
  379. }
  380. }
  381. /*-----------------------------
  382. //还原文档
  383. function RbReturnArchives(){ }
  384. ------------------------------*/ else if ($dopost == 'return') {
  385. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  386. require_once(DEDEINC . "/oxwindow.class.php");
  387. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  388. if ($qstr == '') {
  389. ShowMsg("参数无效!", "recycling.php");
  390. exit();
  391. }
  392. $qstrs = explode("`", $qstr);
  393. foreach ($qstrs as $aid) {
  394. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET arcrank='-1',ismake='0' WHERE id='$aid'");
  395. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET `arcrank` = '-1' WHERE id = '$aid'; ");
  396. }
  397. ShowMsg("成功还原指定的文档!", "recycling.php");
  398. exit();
  399. }
  400. /*-----------------------------
  401. //清空文档
  402. function RbClearArchives(){ }
  403. ------------------------------*/ else if ($dopost == 'clear') {
  404. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  405. require_once(DEDEINC . "/oxwindow.class.php");
  406. if (empty($fmdo)) $fmdo = '';
  407. $recycle = empty($recycle) ? "" : $recycle;
  408. if ($fmdo == 'yes') {
  409. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  410. if ($qstr == '') {
  411. ShowMsg("参数无效!", "recycling.php");
  412. exit();
  413. }
  414. $qstrs = explode(",", $qstr);
  415. $okaids = array();
  416. foreach ($qstrs as $qstr) {
  417. if (!isset($okaids[$qstr])) {
  418. DelArc($qstr, "OK", FALSE, $recycle);
  419. $okaids[$qstr] = $qstr;
  420. } else {
  421. $okaids[$qstr] = 1;
  422. }
  423. }
  424. ShowMsg("成功删除指定的文档!", "recycling.php");
  425. exit();
  426. } else {
  427. $dsql->SetQuery("SELECT id FROM `#@__archives` WHERE `arcrank` = '-2'");
  428. $dsql->Execute();
  429. $qstr = '';
  430. while ($row = $dsql->GetArray()) {
  431. $qstr .= $row['id'] . ",";
  432. $aid = $row['id'];
  433. }
  434. $num = $dsql->GetTotalRow();
  435. if (empty($num)) {
  436. ShowMsg("对不起,未发现相关文档!", "recycling.php");
  437. exit();
  438. }
  439. $wintitle = "文档管理-清空所有文档";
  440. $wecome_info = "<a href='recycling.php'>文档回收站</a>::清空所有文档";
  441. $win = new OxWindow();
  442. $win->Init("archives_do.php", "js/blank.js", "POST");
  443. $win->AddHidden("fmdo", "yes");
  444. $win->AddHidden("dopost", $dopost);
  445. $win->AddHidden("qstr", $qstr);
  446. $win->AddHidden("aid", $aid);
  447. $win->AddHidden("recycle", $recycle);
  448. $win->AddTitle("本次操作将清空回收站<font color='#FF0000'>所有共 $num 篇文档</font><br>你确实要永久删除“ $qstr ”这些文档?");
  449. $winform = $win->GetWindow("ok");
  450. $win->Display();
  451. }
  452. }
  453. /*-----------------------------
  454. //清除文档
  455. function RbDelArchives(){ }
  456. ------------------------------*/ else if ($dopost == 'del') {
  457. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  458. require_once(DEDEINC . "/oxwindow.class.php");
  459. if (empty($fmdo)) $fmdo = '';
  460. $recycle = empty($recycle) ? "" : $recycle;
  461. if ($fmdo == 'yes') {
  462. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  463. if ($qstr == '') {
  464. ShowMsg("参数无效!", "recycling.php");
  465. exit();
  466. }
  467. $qstrs = explode("`", $qstr);
  468. $okaids = array();
  469. foreach ($qstrs as $aid) {
  470. if (!isset($okaids[$aid])) {
  471. DelArc($aid, "OK", "", $recycle);
  472. } else {
  473. $okaids[$aid] = 1;
  474. }
  475. }
  476. ShowMsg("成功删除指定的文档!", "recycling.php");
  477. exit();
  478. } else {
  479. $wintitle = "文档管理-删除文档";
  480. $wecome_info = "<a href='recycling.php'>文档管理</a>::删除文档";
  481. $win = new OxWindow();
  482. $win->Init("archives_do.php", "js/blank.js", "POST");
  483. $win->AddHidden("fmdo", "yes");
  484. $win->AddHidden("dopost", $dopost);
  485. $win->AddHidden("qstr", $qstr);
  486. $win->AddHidden("aid", $aid);
  487. $win->AddHidden("recycle", $recycle);
  488. $win->AddTitle("你确实要永久删除“ $qstr 和 $aid ”这些文档?");
  489. $winform = $win->GetWindow("ok");
  490. $win->Display();
  491. }
  492. }
  493. /*-----------------------------
  494. //快速编辑
  495. function quickEdit(){ }
  496. ------------------------------*/ else if ($dopost == 'quickEdit') {
  497. require_once(DEDEADMIN . "/inc/inc_catalog_options.php");
  498. AjaxHead();
  499. $query = "SELECT ch.typename as channelname,ch.addtable,ar.membername as rankname,arc.*
  500. FROM `#@__archives` arc
  501. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  502. LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id='$aid' ";
  503. $arcRow = $dsql->GetOne($query);
  504. $divname = 'quickEdit';
  505. echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">\r\n";
  506. echo " <div class='titLeft'>快速属性编辑</div>\r\n";
  507. echo " <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' alt='关闭' title='关闭' /></div>\r\n";
  508. echo "</div>\r\n";
  509. echo "<form name='quickeditform' action='archives_do.php?dopost=quickEditSave&aid={$aid}' method='post'>\r\n";
  510. echo "<input type='hidden' name='addtable' value='{$arcRow['addtable']}' />\r\n";
  511. echo "<input type='hidden' name='oldtypeid' value='{$arcRow['typeid']}' />\r\n";
  512. echo "<table width='100%' style='margin-top:6px;z-index:9000;'>\r\n";
  513. ?>
  514. <tr height='32'>
  515. <td width="80" class='bline'>&nbsp;所属栏目:</td>
  516. <td class='bline'>
  517. <?php
  518. $typeOptions = GetOptionList($arcRow['typeid'], $cuserLogin->getUserChannel(), $arcRow['channel']);
  519. echo "<select name='typeid' style='width:70%'>\r\n";
  520. if ($arcRow["typeid"] == "0") echo "<option value='0' selected>请选择栏目...</option>\r\n";
  521. echo $typeOptions;
  522. echo "</select>";
  523. ?>
  524. </td>
  525. </tr>
  526. <tr height='28'>
  527. <td width="80" class='bline'>&nbsp;属 性:</td>
  528. <td class='bline'>
  529. <input type='hidden' name='oldflag' value='<?php echo $arcRow['flag']; ?>' />
  530. <?php
  531. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
  532. $dsql->Execute();
  533. while ($trow = $dsql->GetObject()) {
  534. if ($trow->att == 'j' || $trow->att == 'p') continue;
  535. if (preg_match("#" . $trow->att . "#", $arcRow['flag']))
  536. echo "<label><input class='np' type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}' checked='checked' /> {$trow->attname}.{$trow->att}</label> ";
  537. else
  538. echo "<label><input class='np' type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}' /> {$trow->attname}.{$trow->att}</label> ";
  539. }
  540. ?>
  541. </td>
  542. </tr>
  543. <tr height='32'>
  544. <td width="80" class='bline'>&nbsp;标 题:</td>
  545. <td class='bline'>
  546. <input name="title" type="text" id="title" value="<?php echo $arcRow['title']; ?>" style="width:90%" />
  547. </td>
  548. </tr>
  549. <tr height='32'>
  550. <td width="80" class='bline'>&nbsp;简略标题:</td>
  551. <td class='bline'>
  552. <input name="shorttitle" type="text" id="shorttitle" value="<?php echo $arcRow['shorttitle']; ?>" style="width:60%" />
  553. </td>
  554. </tr>
  555. <tr height='32'>
  556. <td width="80" class='bline'>&nbsp;阅读权限:</td>
  557. <td class='bline'>
  558. <select name="arcrank" id="arcrank" style="width:120px">
  559. <option value='<?php echo $arcRow["arcrank"] ?>'>
  560. <?php echo $arcRow["rankname"] ?> </option>
  561. <?php
  562. $urank = $cuserLogin->getUserRank();
  563. $dsql->SetQuery("SELECT * FROM `#@__arcrank` WHERE adminrank<='$urank'");
  564. $dsql->Execute();
  565. while ($row = $dsql->GetObject()) {
  566. echo " <option value='" . $row->rank . "'>" . $row->membername . "</option>\r\n";
  567. }
  568. ?>
  569. </select>
  570. 需要金币:<input name="money" type="text" id="money" value="<?php echo $arcRow["money"]; ?>" style="width:80px" />
  571. </td>
  572. </tr>
  573. <tr height='32'>
  574. <td width="80" class='bline'>&nbsp;关键字:</td>
  575. <td class='bline'>
  576. <input name="keywords" type="text" id="keywords" value="<?php echo $arcRow['keywords']; ?>" style="width:70%" />
  577. </td>
  578. </tr>
  579. <tr height='32'>
  580. <td colspan='2' align='center' style='padding-top:12px' class='py-3'>
  581. <button type="submit" class="btn btn-secondary">保存</button>
  582. &nbsp;&nbsp;
  583. <button type="button" onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' class="btn btn-secondary">关闭</button>
  584. </td>
  585. </td>
  586. </tr>
  587. </table>
  588. </form>
  589. <?php
  590. //AJAX窗体结束
  591. }
  592. /*-----------------------------
  593. //保存快速编辑的内容
  594. function quickEditSave(){ }
  595. ------------------------------*/ else if ($dopost == 'quickEditSave') {
  596. require_once(DEDEADMIN . '/inc/inc_archives_functions.php');
  597. //权限检测
  598. if (!TestPurview('a_Edit')) {
  599. if (TestPurview('a_AccEdit')) {
  600. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的文档权限!");
  601. } else {
  602. CheckArcAdmin($aid, $cuserLogin->getUserID());
  603. }
  604. }
  605. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  606. $shorttitle = cn_substrR($shorttitle, 36);
  607. $keywords = trim(cn_substrR($keywords, 60));
  608. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  609. $adminid = $cuserLogin->getUserID();
  610. //属性处理
  611. $flag = isset($flags) ? join(',', $flags) : '';
  612. if (!empty($flag)) {
  613. if (preg_match("#p#", $oldflag)) $flag .= ',p';
  614. if (preg_match("#j#", $oldflag)) $flag .= ',j';
  615. }
  616. /*
  617. else
  618. {
  619. $flag = $oldflag;
  620. }
  621. */
  622. $query = "UPDATE `#@__archives` SET
  623. typeid = '$typeid',
  624. flag = '$flag',
  625. arcrank = '$arcrank',
  626. money = '$money',
  627. title = '$title',
  628. shorttitle = '$shorttitle',
  629. keywords = '$keywords',
  630. dutyadmin = '$adminid'
  631. WHERE id = '$aid'; ";
  632. //更新主表
  633. $dsql->ExecuteNoneQuery($query);
  634. //更新微表
  635. $dsql->ExecuteNoneQuery(" UPDATE `#@__arctiny` SET typeid='$typeid',arcrank='$arcrank' WHERE id='$aid' ");
  636. //更新附加表
  637. if ($typeid != $oldtypeid) {
  638. $addtable = trim($addtable);
  639. if (empty($addtable)) $addtable = '#@__addonarticle';
  640. else $addtable = preg_replace("#[^a-z0-9__#@-]#i", "", $addtable);
  641. $dsql->ExecuteNoneQuery(" UPDATE `$addtable` SET typeid='$typeid' WHERE aid='$aid' ");
  642. }
  643. //更新HTML
  644. $artUrl = MakeArt($aid, TRUE, TRUE);
  645. $backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : '-1';
  646. ShowMsg('成功更新一篇文档的基本信息!', $backurl);
  647. exit();
  648. }
  649. /*--------------------------
  650. 分析并自动获取文档关键词
  651. function makekw(){ }
  652. --------------------------*/ else if ($dopost == "makekw") {
  653. CheckPurview('a_Commend,sys_ArcBatch');
  654. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  655. if ($qstr == '') {
  656. ShowMsg("参数无效!", $ENV_GOBACK_URL);
  657. exit();
  658. }
  659. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  660. $query = "SELECT arc.*, addt.* From `#@__archives` arc LEFT JOIN `#@__addonarticle` addt ON addt.aid=arc.id WHERE arc.id in($arcids) AND arc.channel=1 ";
  661. $dsql->SetQuery($query);
  662. $dsql->Execute();
  663. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  664. $client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port);
  665. $client->appid = $cfg_bizcore_appid;
  666. $client->key = $cfg_bizcore_key;
  667. while ($row = $dsql->GetArray()) {
  668. //跳过已经有关键字的内容
  669. if (trim($row['keywords']) != '') continue;
  670. $aid = $row['id'];
  671. $keywords = '';
  672. $title = $row['title'];
  673. $description = $row['description'];
  674. $body = cn_substr($row['body'], 5000);
  675. $data = $client->Spliteword($title . Html2Text($body));
  676. $keywords = $data->data;
  677. $description = str_replace(' ', ' ', trim($description));
  678. $description = str_replace('[', ' ', $description);
  679. $description = str_replace(']', ' ', $description);
  680. $description = preg_replace("#[ \r\n\t]{1,}#is", ' ', $description);
  681. $description = str_replace('关键字', '', $description);
  682. $description = str_replace('关键词', '', $description);
  683. $description = addslashes($description);
  684. $dsql->ExecuteNoneQuery(" UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  685. }
  686. $client->Close();
  687. } else {
  688. include_once(DEDEINC . '/splitword.class.php');
  689. $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
  690. while ($row = $dsql->GetArray()) {
  691. //跳过已经有关键字的内容
  692. if (trim($row['keywords']) != '') continue;
  693. $aid = $row['id'];
  694. $keywords = '';
  695. $title = $row['title'];
  696. $description = $row['description'];
  697. $body = cn_substr($row['body'], 5000);
  698. $sp->SetSource($title, $cfg_soft_lang, $cfg_soft_lang);
  699. $sp->StartAnalysis();
  700. $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  701. $sp->SetSource(Html2Text($body), $cfg_soft_lang, $cfg_soft_lang);
  702. $sp->StartAnalysis();
  703. $allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  704. if (is_array($allindexs) && is_array($titleindexs)) {
  705. foreach ($titleindexs as $k => $v) {
  706. if (strlen($keywords . $k) >= 60) {
  707. break;
  708. } else {
  709. if (strlen($k) <= 2) continue;
  710. $keywords .= $k . ',';
  711. }
  712. }
  713. foreach ($allindexs as $k => $v) {
  714. if (strlen($keywords . $k) >= 60) {
  715. break;
  716. } else if (!in_array($k, $titleindexs)) {
  717. if (strlen($k) <= 2) continue;
  718. $keywords .= $k . ',';
  719. }
  720. }
  721. }
  722. $description = str_replace(' ', ' ', trim($description));
  723. $description = str_replace('[', ' ', $description);
  724. $description = str_replace(']', ' ', $description);
  725. $description = preg_replace("#[ \r\n\t]{1,}#is", ' ', $description);
  726. $description = str_replace('关键字', '', $description);
  727. $description = str_replace('关键词', '', $description);
  728. $description = addslashes($description);
  729. $dsql->ExecuteNoneQuery(" UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  730. }
  731. $sp = null;
  732. }
  733. ShowMsg("成功分析指定文档的关键词!", $ENV_GOBACK_URL);
  734. exit();
  735. }
  736. /*--------------------------
  737. //批量增加属性
  738. function attsAdd(){ }
  739. ---------------------------*/ else if ($dopost == 'attsAdd') {
  740. CheckPurview('a_Commend,sys_ArcBatch');
  741. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  742. if ($qstr == '') {
  743. ShowMsg("参数无效!", $ENV_GOBACK_URL);
  744. exit();
  745. }
  746. if (empty($flagname)) {
  747. ShowMsg("必须指定要添加的属性!", $ENV_GOBACK_URL);
  748. exit();
  749. }
  750. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  751. $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
  752. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  753. LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
  754. WHERE arc.id in($arcids) ";
  755. $dsql->SetQuery($query);
  756. $dsql->Execute();
  757. while ($row = $dsql->GetArray()) {
  758. $aid = $row['id'];
  759. if ($row['issystem'] != -1) {
  760. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  761. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  762. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'] . ',' . $flagname);
  763. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE id='{$aid}' ");
  764. } else {
  765. $maintable = trim($row['addtable']);
  766. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  767. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'] . ',' . $flagname);
  768. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE aid='{$aid}' ");
  769. }
  770. }
  771. ShowMsg("成功对选中文档增加指定的属性!", $ENV_GOBACK_URL);
  772. exit();
  773. }
  774. /*--------------------------
  775. //批量删除属性
  776. function attsDel(){ }
  777. ---------------------------*/ else if ($dopost == 'attsDel') {
  778. CheckPurview('a_Commend,sys_ArcBatch');
  779. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  780. if ($qstr == '') {
  781. ShowMsg("参数无效!", $ENV_GOBACK_URL);
  782. exit();
  783. }
  784. if (empty($flagname)) {
  785. ShowMsg("必须指定要删除的属性!", $ENV_GOBACK_URL);
  786. exit();
  787. }
  788. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  789. $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
  790. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  791. LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
  792. WHERE arc.id in($arcids) ";
  793. $dsql->SetQuery($query);
  794. $dsql->Execute();
  795. while ($row = $dsql->GetArray()) {
  796. $aid = $row['id'];
  797. if ($row['issystem'] != -1) {
  798. $idname = 'id';
  799. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  800. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  801. } else {
  802. $idname = 'aid';
  803. $maintable = trim($row['addtable']);
  804. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  805. }
  806. $flag = $arr['flag'];
  807. if (trim($flag) == '' || !preg_match("#" . $flagname . "#", $flag)) {
  808. continue;
  809. } else {
  810. $flags = explode(',', $flag);
  811. $okflags = array();
  812. foreach ($flags as $f) {
  813. if ($f != $flagname) $okflags[] = $f;
  814. }
  815. }
  816. $flag = trim(join(',', $okflags));
  817. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE {$idname}='{$aid}' ");
  818. }
  819. ShowMsg("成功对选中文档删除指定的属性!", $ENV_GOBACK_URL);
  820. exit();
  821. }
  822. /*--------------------------
  823. //获得批量属性处理的AJAX窗体
  824. function attsDlg(){ }
  825. ---------------------------*/ else if ($dopost == 'attsDlg') {
  826. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  827. $dojobname = ($dojob == 'attsDel' ? '批量删除属性' : '批量增加属性');
  828. AjaxHead();
  829. //输出AJAX可移动窗体
  830. $divname = 'attsDlg';
  831. echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">\r\n";
  832. echo " <div class='titLeft'>{$dojobname}</div>\r\n";
  833. echo " <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' alt='关闭' title='关闭' /></div>\r\n";
  834. echo "</div>\r\n";
  835. echo "<form name='quickeditform' action='archives_do.php' method='post'>\r\n";
  836. echo "<input type='hidden' name='dopost' value='{$dojob}' />\r\n";
  837. echo "<input type='hidden' name='qstr' value='{$qstr}' />\r\n";
  838. echo "<table width='100%' style='margin-top:6px;z-index:9000;'>\r\n";
  839. ?>
  840. <tr height='28'>
  841. <td width="80" class='bline'>&nbsp;属 性:</td>
  842. <td class='bline'>
  843. <input type='hidden' name='oldflag' value='<?php echo $arcRow['flag']; ?>' />
  844. <?php
  845. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
  846. $dsql->Execute();
  847. while ($trow = $dsql->GetObject()) {
  848. if ($trow->att == 'j' || $trow->att == 'p') continue;
  849. echo "<label><input class='np' type='radio' name='flagname' id='flags{$trow->att}' value='{$trow->att}' /> {$trow->attname}.{$trow->att}</label>";
  850. }
  851. ?>
  852. </td>
  853. </tr>
  854. <tr height='32'>
  855. <td width="80" class='bline'>&nbsp;文档ID:</td>
  856. <td class='bline'>
  857. <input type='text' name='tmpids' value="<?php echo $qstr; ?>" style='width:310px;overflow:hidden;' />
  858. </td>
  859. </tr>
  860. <tr height='32'>
  861. <td colspan='2' align='center' style='padding-top:12px'>
  862. <input name="imageField" type="image" src="images/button_ok.gif" width="60" height="22" class="np" border="0" style="cursor:pointer" />
  863. &nbsp;&nbsp;
  864. <img src="images/button_back.gif" width="60" height="22" border="0" onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' style="cursor:pointer" />
  865. </td>
  866. </td>
  867. </tr>
  868. </table>
  869. </form>
  870. <?php
  871. //AJAX窗体结束
  872. }
  873. /*------------------------
  874. function getCatMap() { }
  875. -------------------------*/ else if ($dopost == 'getCatMap') {
  876. require_once(DEDEINC . '/typeunit.class.selector.php');
  877. AjaxHead();
  878. //输出AJAX可移动窗体
  879. $divname = 'getCatMap';
  880. echo "<div class='title' style='cursor:default;'>\r\n";
  881. echo " <div class='titLeft'>栏目快速选择器</div>\r\n";
  882. echo " <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' alt='关闭' title='关闭' /></div>\r\n";
  883. echo "</div>\r\n";
  884. $tus = new TypeUnitSelector();
  885. ?>
  886. <form name='quicksel' action='javascript:;' method='get'>
  887. <div class='quicksel'>
  888. <?php $tus->ListAllType($channelid); ?>
  889. </div>
  890. <div align='center' class='quickselfoot'>
  891. <img src="images/button_ok.gif" onclick="getSelCat('<?php echo $targetid; ?>');" width="60" height="22" class="np" border="0" style="cursor:pointer" />
  892. &nbsp;&nbsp;
  893. <img src="images/button_back.gif" onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' width="60" height="22" border="0" style="cursor:pointer" />
  894. </div>
  895. </form>
  896. <?php
  897. //AJAX窗体结束
  898. }
  899. ?>