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

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