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

894 lines
38KB

  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) 2022, 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'><?php echo $typeOptions; ?></td>
  321. </tr>
  322. <tr height='26'>
  323. <td width="80" class='bline'>&nbsp;文档ID:</td>
  324. <td class='bline'>
  325. <input type='text' name='tmpids' value="<?php echo $qstr; ?>" style='width:320px;overflow:hidden'>
  326. <br>移动到的目标栏目必须和选定的文档频道类型一致,否则程序会自动勿略不符合的文档。
  327. </td>
  328. </tr>
  329. <tr height='36'>
  330. <td colspan='2' align='center' style='padding-top:10px'>
  331. <button type='submit' class='btn btn-success'>保存</button>
  332. <button type='button' onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' class='btn btn-success'>关闭</button>
  333. </td>
  334. </tr>
  335. </table>
  336. </form>
  337. <?php
  338. //AJAX窗体结束
  339. } else {
  340. $totype = preg_replace("#[^0-9]#", '', $totype);
  341. $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' ");
  342. $idtype = "id";
  343. if (!is_array($typeInfos)) {
  344. ShowMsg('参数错误', '-1');
  345. exit();
  346. }
  347. if ($typeInfos['ispart'] != 0) {
  348. ShowMsg('文档保存的栏目必须为最终列表栏目', '-1');
  349. exit();
  350. }
  351. if (empty($typeInfos['addtable'])) {
  352. $typeInfos['maintable'] = '#@__archives';
  353. }
  354. //增加单表模型判断
  355. if ($typeInfos['issystem'] == -1) {
  356. $typeInfos['maintable'] = $typeInfos['addtable'];
  357. $idtype = "aid";
  358. }
  359. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  360. $arc = '';
  361. $j = 0;
  362. $okids = array();
  363. $dsql->SetQuery("SELECT {$idtype},typeid FROM `{$typeInfos['maintable']}` WHERE {$idtype} in($arcids) AND channel='{$typeInfos['channeltype']}' ");
  364. $dsql->Execute();
  365. while ($row = $dsql->GetArray()) {
  366. if ($row['typeid'] != $totype) {
  367. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
  368. $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['maintable']}` SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
  369. $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['addtable']}` SET typeid='$totype' WHERE aid='{$row[$idtype]}' ");
  370. $okids[] = $row[$idtype];
  371. $j++;
  372. }
  373. }
  374. //更新HTML
  375. foreach ($okids as $aid) {
  376. $arc = new Archives($aid);
  377. $arc->MakeHtml();
  378. }
  379. ShowMsg("成功移动 $j 个文档", $ENV_GOBACK_URL);
  380. exit();
  381. }
  382. }
  383. /*-----------------------------
  384. //还原文档
  385. function RbReturnArchives(){ }
  386. ------------------------------*/
  387. else if ($dopost == 'return') {
  388. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  389. require_once(DEDEINC."/oxwindow.class.php");
  390. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  391. if ($qstr == '') {
  392. ShowMsg("参数无效", "recycling.php");
  393. exit();
  394. }
  395. $qstrs = explode("`", $qstr);
  396. foreach ($qstrs as $aid) {
  397. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET arcrank='-1',ismake='0' WHERE id='$aid'");
  398. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET `arcrank` = '-1' WHERE id = '$aid'; ");
  399. }
  400. ShowMsg("成功还原指定的文档", "recycling.php");
  401. exit();
  402. }
  403. /*-----------------------------
  404. //清空文档
  405. function RbClearArchives(){ }
  406. ------------------------------*/
  407. else if ($dopost == 'clear') {
  408. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  409. require_once(DEDEINC."/oxwindow.class.php");
  410. if (empty($fmdo)) $fmdo = '';
  411. $recycle = empty($recycle) ? "" : $recycle;
  412. if ($fmdo == 'yes') {
  413. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  414. if ($qstr == '') {
  415. ShowMsg("参数无效", "recycling.php");
  416. exit();
  417. }
  418. $qstrs = explode(",", $qstr);
  419. $okaids = array();
  420. foreach ($qstrs as $qstr) {
  421. if (!isset($okaids[$qstr])) {
  422. DelArc($qstr, "OK", FALSE, $recycle);
  423. $okaids[$qstr] = $qstr;
  424. } else {
  425. $okaids[$qstr] = 1;
  426. }
  427. }
  428. ShowMsg("成功删除指定的文档", "recycling.php");
  429. exit();
  430. } else {
  431. $dsql->SetQuery("SELECT id FROM `#@__archives` WHERE `arcrank` = '-2'");
  432. $dsql->Execute();
  433. $qstr = '';
  434. while ($row = $dsql->GetArray()) {
  435. $qstr .= $row['id'].",";
  436. $aid = $row['id'];
  437. }
  438. $num = $dsql->GetTotalRow();
  439. if (empty($num)) {
  440. ShowMsg("对不起,未发现相关文档", "recycling.php");
  441. exit();
  442. }
  443. $wintitle = "文档管理-清空所有文档";
  444. $wecome_info = "<a href='recycling.php'>文档回收站</a>::清空所有文档";
  445. $win = new OxWindow();
  446. $win->Init("archives_do.php", "js/blank.js", "POST");
  447. $win->AddHidden("fmdo", "yes");
  448. $win->AddHidden("dopost", $dopost);
  449. $win->AddHidden("qstr", $qstr);
  450. $win->AddHidden("aid", $aid);
  451. $win->AddHidden("recycle", $recycle);
  452. $win->AddTitle("本次操作将清空回收站所有共 $num 篇文档<br>您确实要永久删除 $qstr 这些文档?");
  453. $winform = $win->GetWindow("ok");
  454. $win->Display();
  455. }
  456. }
  457. /*-----------------------------
  458. //清除文档
  459. function RbDelArchives(){ }
  460. ------------------------------*/
  461. else if ($dopost == 'del') {
  462. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  463. require_once(DEDEINC."/oxwindow.class.php");
  464. if (empty($fmdo)) $fmdo = '';
  465. $recycle = empty($recycle) ? "" : $recycle;
  466. if ($fmdo == 'yes') {
  467. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  468. if ($qstr == '') {
  469. ShowMsg("参数无效", "recycling.php");
  470. exit();
  471. }
  472. $qstrs = explode("`", $qstr);
  473. $okaids = array();
  474. foreach ($qstrs as $aid) {
  475. if (!isset($okaids[$aid])) {
  476. DelArc($aid, "OK", "", $recycle);
  477. } else {
  478. $okaids[$aid] = 1;
  479. }
  480. }
  481. ShowMsg("成功删除指定的文档", "recycling.php");
  482. exit();
  483. } else {
  484. $wintitle = "文档管理-删除文档";
  485. $wecome_info = "<a href='recycling.php'>文档管理</a>::删除文档";
  486. $win = new OxWindow();
  487. $win->Init("archives_do.php", "js/blank.js", "POST");
  488. $win->AddHidden("fmdo", "yes");
  489. $win->AddHidden("dopost", $dopost);
  490. $win->AddHidden("qstr", $qstr);
  491. $win->AddHidden("aid", $aid);
  492. $win->AddHidden("recycle", $recycle);
  493. $win->AddTitle("您确实要永久删除 $qstr 和 $aid 这些文档?");
  494. $winform = $win->GetWindow("ok");
  495. $win->Display();
  496. }
  497. }
  498. /*-----------------------------
  499. //快速编辑
  500. function quickEdit(){ }
  501. ------------------------------*/
  502. else if ($dopost == 'quickEdit') {
  503. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  504. AjaxHead();
  505. $query = "SELECT ch.typename as channelname,ch.addtable,ar.membername as rankname,arc.*
  506. FROM `#@__archives` arc
  507. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  508. LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id='$aid' ";
  509. $arcRow = $dsql->GetOne($query);
  510. $divname = 'quickEdit';
  511. echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">";
  512. echo "<div class='titLeft'>快速属性编辑</div>";
  513. echo "<div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' title='关闭'></div>";
  514. echo "</div>";
  515. echo "<form name='quickeditform' action='archives_do.php?dopost=quickEditSave&aid={$aid}' method='post'>";
  516. echo "<input type='hidden' name='addtable' value='{$arcRow['addtable']}'>";
  517. echo "<input type='hidden' name='oldtypeid' value='{$arcRow['typeid']}'>";
  518. echo "<table width='100%' style='display:inline-block;z-index:9000'>";
  519. ?>
  520. <tr height='26'>
  521. <td width="80" class='bline'>&nbsp;所属栏目:</td>
  522. <td class='bline'>
  523. <?php
  524. $typeOptions = GetOptionList($arcRow['typeid'], $cuserLogin->getUserChannel(), $arcRow['channel']);
  525. echo "<select name='typeid' style='width:320px'>";
  526. if ($arcRow["typeid"] == "0") echo "<option value='0' selected>请选择栏目</option>";
  527. echo $typeOptions;
  528. echo "</select>";
  529. ?>
  530. </td>
  531. </tr>
  532. <tr height='26'>
  533. <td width="80" class='bline'>&nbsp;属性:</td>
  534. <td class='bline'>
  535. <input type='hidden' name='oldflag' value='<?php echo $arcRow['flag']; ?>'>
  536. <?php
  537. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY `sortid` ASC");
  538. $dsql->Execute();
  539. while ($trow = $dsql->GetObject()) {
  540. if ($trow->att == 'j' || $trow->att == 'p') continue;
  541. if (preg_match("#".$trow->att."#", $arcRow['flag']))
  542. 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;";
  543. else
  544. echo "<label><input class='np' type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}'>&nbsp;{$trow->attname}[{$trow->att}]</label>&nbsp;";
  545. }
  546. ?>
  547. </td>
  548. </tr>
  549. <tr height='26'>
  550. <td width="80" class='bline'>&nbsp;标题:</td>
  551. <td class='bline'><input name="title" type="text" id="title" value="<?php echo $arcRow['title']; ?>" style="width:320px"></td>
  552. </tr>
  553. <tr height='26'>
  554. <td width="80" class='bline'>&nbsp;简略标题:</td>
  555. <td class='bline'><input name="shorttitle" type="text" id="shorttitle" value="<?php echo $arcRow['shorttitle']; ?>" style="width:320px"></td>
  556. </tr>
  557. <tr height='26'>
  558. <td width="80" class='bline'>&nbsp;阅读权限:</td>
  559. <td class='bline'>
  560. <select name="arcrank" id="arcrank" style="width:100px">
  561. <option value='<?php echo $arcRow["arcrank"] ?>'>
  562. <?php echo $arcRow["rankname"] ?> </option>
  563. <?php
  564. $urank = $cuserLogin->getUserRank();
  565. $dsql->SetQuery("SELECT * FROM `#@__arcrank` WHERE `adminrank`<='$urank'");
  566. $dsql->Execute();
  567. while ($row = $dsql->GetObject()) {
  568. echo "<option value='".$row->rank."'>".$row->membername."</option>";
  569. }
  570. ?>
  571. </select>
  572. 需要金币:<input name="money" type="text" id="money" value="<?php echo $arcRow["money"]; ?>" style="width:100px">
  573. </td>
  574. </tr>
  575. <tr height='26'>
  576. <td width="80" class='bline'>&nbsp;关键字:</td>
  577. <td class='bline'><input name="keywords" type="text" id="keywords" value="<?php echo $arcRow['keywords']; ?>" style="width:320px"></td>
  578. </tr>
  579. <tr height='36'>
  580. <td colspan='2' align='center' class='py-3' style='padding-top:10px'>
  581. <button type='submit' class='btn btn-success'>保存</button>
  582. <button type='button' onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' class='btn btn-success'>关闭</button>
  583. </td>
  584. </tr>
  585. </table>
  586. </form>
  587. <?php
  588. //AJAX窗体结束
  589. }
  590. /*-----------------------------
  591. //保存快速编辑的内容
  592. function quickEditSave(){ }
  593. ------------------------------*/
  594. else if ($dopost == 'quickEditSave') {
  595. require_once(DEDEADMIN.'/inc/inc_archives_functions.php');
  596. //权限检测
  597. if (!TestPurview('a_Edit')) {
  598. if (TestPurview('a_AccEdit')) {
  599. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的文档权限");
  600. } else {
  601. CheckArcAdmin($aid, $cuserLogin->getUserID());
  602. }
  603. }
  604. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  605. $shorttitle = cn_substrR($shorttitle, 36);
  606. $keywords = trim(cn_substrR($keywords, 60));
  607. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  608. $adminid = $cuserLogin->getUserID();
  609. //属性处理
  610. $flag = isset($flags) ? join(',', $flags) : '';
  611. if (!empty($flag)) {
  612. if (preg_match("#p#", $oldflag)) $flag .= ',p';
  613. if (preg_match("#j#", $oldflag)) $flag .= ',j';
  614. }
  615. $query = "UPDATE `#@__archives` SET
  616. typeid = '$typeid',
  617. flag = '$flag',
  618. arcrank = '$arcrank',
  619. money = '$money',
  620. title = '$title',
  621. shorttitle = '$shorttitle',
  622. keywords = '$keywords',
  623. dutyadmin = '$adminid'
  624. WHERE id = '$aid'; ";
  625. //更新主表
  626. $dsql->ExecuteNoneQuery($query);
  627. //更新微表
  628. $dsql->ExecuteNoneQuery(" UPDATE `#@__arctiny` SET typeid='$typeid',arcrank='$arcrank' WHERE id='$aid' ");
  629. //更新附加表
  630. if ($typeid != $oldtypeid) {
  631. $addtable = trim($addtable);
  632. if (empty($addtable)) $addtable = '#@__addonarticle';
  633. else $addtable = preg_replace("#[^a-z0-9__#@-]#i", "", $addtable);
  634. $dsql->ExecuteNoneQuery(" UPDATE `$addtable` SET typeid='$typeid' WHERE aid='$aid' ");
  635. }
  636. //更新HTML
  637. $artUrl = MakeArt($aid, TRUE, TRUE);
  638. $backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : '-1';
  639. ShowMsg('成功更新一篇文档的基本信息', $backurl);
  640. exit();
  641. }
  642. /*--------------------------
  643. 分析并自动获取文档关键词
  644. function makekw(){ }
  645. --------------------------*/
  646. else if ($dopost == "makekw") {
  647. CheckPurview('a_Commend,sys_ArcBatch');
  648. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  649. if ($qstr == '') {
  650. ShowMsg("参数无效", $ENV_GOBACK_URL);
  651. exit();
  652. }
  653. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  654. $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 ";
  655. $dsql->SetQuery($query);
  656. $dsql->Execute();
  657. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  658. $client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port);
  659. $client->appid = $cfg_bizcore_appid;
  660. $client->key = $cfg_bizcore_key;
  661. while ($row = $dsql->GetArray()) {
  662. //跳过已经有关键字的内容
  663. if (trim($row['keywords']) != '') continue;
  664. $aid = $row['id'];
  665. $keywords = '';
  666. $title = $row['title'];
  667. $description = $row['description'];
  668. $body = cn_substr($row['body'], 5000);
  669. $data = $client->Spliteword($title.Html2Text($body));
  670. $keywords = $data->data;
  671. $description = str_replace(' ', ' ', trim($description));
  672. $description = str_replace('[', ' ', $description);
  673. $description = str_replace(']', ' ', $description);
  674. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  675. $description = str_replace('关键字', '', $description);
  676. $description = str_replace('关键词', '', $description);
  677. $description = addslashes($description);
  678. $dsql->ExecuteNoneQuery(" UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  679. }
  680. $client->Close();
  681. } else {
  682. include_once(DEDEINC.'/splitword.class.php');
  683. $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
  684. while ($row = $dsql->GetArray()) {
  685. //跳过已经有关键字的内容
  686. if (trim($row['keywords']) != '') continue;
  687. $aid = $row['id'];
  688. $keywords = '';
  689. $title = $row['title'];
  690. $description = $row['description'];
  691. $body = cn_substr($row['body'], 5000);
  692. $sp->SetSource($title, $cfg_soft_lang, $cfg_soft_lang);
  693. $sp->StartAnalysis();
  694. $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  695. $sp->SetSource(Html2Text($body), $cfg_soft_lang, $cfg_soft_lang);
  696. $sp->StartAnalysis();
  697. $allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  698. if (is_array($allindexs) && is_array($titleindexs)) {
  699. foreach ($titleindexs as $k => $v) {
  700. if (strlen($keywords.$k) >= 60) {
  701. break;
  702. } else {
  703. if (strlen($k) <= 2) continue;
  704. $keywords .= $k.',';
  705. }
  706. }
  707. foreach ($allindexs as $k => $v) {
  708. if (strlen($keywords.$k) >= 60) {
  709. break;
  710. } else if (!in_array($k, $titleindexs)) {
  711. if (strlen($k) <= 2) continue;
  712. $keywords .= $k.',';
  713. }
  714. }
  715. }
  716. $description = str_replace(' ', ' ', trim($description));
  717. $description = str_replace('[', ' ', $description);
  718. $description = str_replace(']', ' ', $description);
  719. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  720. $description = str_replace('关键字', '', $description);
  721. $description = str_replace('关键词', '', $description);
  722. $description = addslashes($description);
  723. $dsql->ExecuteNoneQuery(" UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  724. }
  725. $sp = null;
  726. }
  727. ShowMsg("成功分析指定文档的关键词", $ENV_GOBACK_URL);
  728. exit();
  729. }
  730. /*--------------------------
  731. //批量增加属性
  732. function attsAdd(){ }
  733. ---------------------------*/
  734. else if ($dopost == 'attsAdd') {
  735. CheckPurview('a_Commend,sys_ArcBatch');
  736. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  737. if ($qstr == '') {
  738. ShowMsg("参数无效", $ENV_GOBACK_URL);
  739. exit();
  740. }
  741. if (empty($flagname)) {
  742. ShowMsg("必须指定要添加的属性", $ENV_GOBACK_URL);
  743. exit();
  744. }
  745. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  746. $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
  747. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  748. LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
  749. WHERE arc.id in($arcids) ";
  750. $dsql->SetQuery($query);
  751. $dsql->Execute();
  752. while ($row = $dsql->GetArray()) {
  753. $aid = $row['id'];
  754. if ($row['issystem'] != -1) {
  755. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  756. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  757. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  758. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE id='{$aid}' ");
  759. } else {
  760. $maintable = trim($row['addtable']);
  761. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  762. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  763. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE aid='{$aid}' ");
  764. }
  765. }
  766. ShowMsg("成功对选中文档增加指定的属性", $ENV_GOBACK_URL);
  767. exit();
  768. }
  769. /*--------------------------
  770. //批量删除属性
  771. function attsDel(){ }
  772. ---------------------------*/
  773. else if ($dopost == 'attsDel') {
  774. CheckPurview('a_Commend,sys_ArcBatch');
  775. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  776. if ($qstr == '') {
  777. ShowMsg("参数无效", $ENV_GOBACK_URL);
  778. exit();
  779. }
  780. if (empty($flagname)) {
  781. ShowMsg("必须指定要删除的属性", $ENV_GOBACK_URL);
  782. exit();
  783. }
  784. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  785. $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
  786. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  787. LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
  788. WHERE arc.id in($arcids) ";
  789. $dsql->SetQuery($query);
  790. $dsql->Execute();
  791. while ($row = $dsql->GetArray()) {
  792. $aid = $row['id'];
  793. if ($row['issystem'] != -1) {
  794. $idname = 'id';
  795. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  796. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  797. } else {
  798. $idname = 'aid';
  799. $maintable = trim($row['addtable']);
  800. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  801. }
  802. $flag = $arr['flag'];
  803. if (trim($flag) == '' || !preg_match("#".$flagname."#", $flag)) {
  804. continue;
  805. } else {
  806. $flags = explode(',', $flag);
  807. $okflags = array();
  808. foreach ($flags as $f) {
  809. if ($f != $flagname) $okflags[] = $f;
  810. }
  811. }
  812. $flag = trim(join(',', $okflags));
  813. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE {$idname}='{$aid}' ");
  814. }
  815. ShowMsg("成功对选中文档删除指定的属性", $ENV_GOBACK_URL);
  816. exit();
  817. }
  818. /*--------------------------
  819. //获得批量属性处理的AJAX窗体
  820. function attsDlg(){ }
  821. ---------------------------*/
  822. else if ($dopost == 'attsDlg') {
  823. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  824. $dojobname = ($dojob == 'attsDel' ? '批量删除属性' : '批量增加属性');
  825. AjaxHead();
  826. //输出AJAX可移动窗体
  827. $divname = 'attsDlg';
  828. echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">";
  829. echo "<div class='titLeft'>{$dojobname}</div>";
  830. echo "<div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' title='关闭'></div>";
  831. echo "</div>";
  832. echo "<form name='quickeditform' action='archives_do.php' method='post'>";
  833. echo "<input type='hidden' name='dopost' value='{$dojob}'>";
  834. echo "<input type='hidden' name='qstr' value='{$qstr}'>";
  835. echo "<table width='100%' style='display:inline-block;z-index:9000'>";
  836. ?>
  837. <tr height='26'>
  838. <td width="80" class='bline'>&nbsp;属性:</td>
  839. <td class='bline'>
  840. <input type='hidden' name='oldflag' value='<?php echo $arcRow['flag']; ?>'>
  841. <?php
  842. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY `sortid` ASC");
  843. $dsql->Execute();
  844. while ($trow = $dsql->GetObject()) {
  845. if ($trow->att == 'j' || $trow->att == 'p') continue;
  846. echo "<label><input class='np' type='radio' name='flagname' id='flags{$trow->att}' value='{$trow->att}'>&nbsp;{$trow->attname}[{$trow->att}]</label>&nbsp;";
  847. }
  848. ?>
  849. </td>
  850. </tr>
  851. <tr height='26'>
  852. <td width="80" class='bline'>&nbsp;文档ID:</td>
  853. <td class='bline'><input type='text' name='tmpids' value="<?php echo $qstr; ?>" style='width:320px;overflow:hidden'></td>
  854. </tr>
  855. <tr height='36'>
  856. <td colspan='2' align='center' style='padding-top:10px'>
  857. <button type='submit' class='btn btn-success'>保存</button>
  858. <button type='button' onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' class='btn btn-success'>关闭</button>
  859. </td>
  860. </tr>
  861. </table>
  862. </form>
  863. <?php
  864. //AJAX窗体结束
  865. }
  866. /*------------------------
  867. function getCatMap() { }
  868. -------------------------*/
  869. else if ($dopost == 'getCatMap') {
  870. require_once(DEDEINC.'/typeunit.class.selector.php');
  871. AjaxHead();
  872. //输出AJAX可移动窗体
  873. $divname = 'getCatMap';
  874. echo "<div class='title' style='cursor:default'>";
  875. echo "<div class='titLeft'>栏目快速选择器</div>";
  876. echo "<div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' title='关闭'></div>";
  877. echo "</div>";
  878. $tus = new TypeUnitSelector();
  879. ?>
  880. <form name='quicksel' action='javascript:;' method='get'>
  881. <div class='quicksel'><?php $tus->ListAllType($channelid); ?></div>
  882. <div align='center' class='quickselfoot'>
  883. <button onclick='getSelCat("<?php echo $targetid; ?>");' class='btn btn-success'>保存</button>
  884. <button type='button' onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' class='btn btn-success'>关闭</button>
  885. </div>
  886. </form>
  887. <?php
  888. //AJAX窗体结束
  889. }
  890. ?>