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

810 lines
35KB

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