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

912 lines
39KB

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