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

1047 lines
39KB

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