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

1017 lines
38KB

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