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

818 line
34KB

  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 GNU GPL v2 (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}'>\";
  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("成功更新指定".$i."个文档", $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. $indexedsql = "";
  231. if (TableHasField("#@__arctiny", "indexed")) {
  232. $indexedsql = ", `indexed`=2 ";
  233. }
  234. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET arcrank='0'{$indexedsql} WHERE id='$aid' ");
  235. if ($row['issystem'] == -1) {
  236. $dsql->ExecuteNoneQuery("UPDATE `".trim($row['addtable'])."` SET arcrank='0' WHERE aid='$aid' ");
  237. } else {
  238. $dsql->ExecuteNoneQuery("UPDATE `$maintable` SET arcrank='0', dutyadmin='".$cuserLogin->getUserID()."' WHERE id='$aid' ");
  239. }
  240. $dsql->ExecuteNoneQuery("UPDATE `#@__taglist` SET arcrank='0' WHERE aid='$aid' ");
  241. $pageurl = MakeArt($aid, false);
  242. DedeSearchDo("add", array("id" => $aid));
  243. }
  244. ShowMsg("成功审核指定文档", $ENV_GOBACK_URL);
  245. exit();
  246. } else if ($dopost == 'moveArchives') {
  247. CheckPurview('sys_ArcBatch');
  248. if (empty($totype)) {
  249. require_once(DEDEINC.'/typelink/typelink.class.php');
  250. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  251. AjaxHead();
  252. $channelid = empty($channelid) ? 0 : $channelid;
  253. $tl = new TypeLink($aid);
  254. $typeOptions = $tl->GetOptionArray(0, $admin_catalogs, $channelid);
  255. $typeOptions = "<select name='totype' class='admin-input-sm'>
  256. <option value='0'>请选择移动位置</option>
  257. $typeOptions
  258. </select>";
  259. //输出Ajax可移动窗体
  260. $divname = 'moveArchives';
  261. echo "<div class='card shadow-sm'><div class='card-header'>移动文档</div><div class='card-body'>";
  262. echo "<form name='quickeditform' action='archives_do.php' method='post'>";
  263. echo "<input type='hidden' name='dopost' value='{$dopost}'>";
  264. echo "<input type='hidden' name='qstr' value='{$qstr}'>";
  265. echo "<table class='table table-borderless'>";
  266. ?>
  267. <tbody>
  268. <tr>
  269. <td width="160">指定栏目</td>
  270. <td><?php echo $typeOptions;?></td>
  271. </tr>
  272. <tr>
  273. <td>文档id</td>
  274. <td><input type="text" name="tmpids" class="admin-input-lg" value="<?php echo $qstr;?>"></td>
  275. </tr>
  276. <tr>
  277. <td colspan="2" align="center">
  278. <button type="submit" class="btn btn-success btn-sm">保存</button>
  279. <button type="button" onclick="HideObj('<?php echo $divname;?>');ChangeFullDiv('hide');" class="btn btn-outline-success btn-sm">关闭</button>
  280. </td>
  281. </tr>
  282. </tbody>
  283. </table>
  284. </form>
  285. </div>
  286. </div>
  287. <?php
  288. //Ajax窗体结束
  289. } else {
  290. $totype = preg_replace("#[^0-9]#", '', $totype);
  291. $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' ");
  292. $idtype = "id";
  293. if (!is_array($typeInfos)) {
  294. ShowMsg('参数错误', '-1');
  295. exit();
  296. }
  297. if ($typeInfos['ispart'] != 0) {
  298. ShowMsg('文档保存栏目必须为列表栏目', '-1');
  299. exit();
  300. }
  301. if (empty($typeInfos['addtable'])) {
  302. $typeInfos['maintable'] = '#@__archives';
  303. }
  304. //添加自定义模型判断
  305. if ($typeInfos['issystem'] == -1) {
  306. $typeInfos['maintable'] = $typeInfos['addtable'];
  307. $idtype = "aid";
  308. }
  309. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  310. $arc = '';
  311. $j = 0;
  312. $okids = array();
  313. $dsql->SetQuery("SELECT {$idtype},typeid FROM `{$typeInfos['maintable']}` WHERE {$idtype} in($arcids) AND channel='{$typeInfos['channeltype']}' ");
  314. $dsql->Execute();
  315. while ($row = $dsql->GetArray()) {
  316. if ($row['typeid'] != $totype) {
  317. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
  318. $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['maintable']}` SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
  319. $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['addtable']}` SET typeid='$totype' WHERE aid='{$row[$idtype]}' ");
  320. $okids[] = $row[$idtype];
  321. $j++;
  322. }
  323. }
  324. //更新网页
  325. foreach ($okids as $aid) {
  326. $arc = new Archives($aid);
  327. DedeSearchDo("update", array("id" => $aid));
  328. $arc->MakeHtml();
  329. }
  330. ShowMsg("成功移动".$j."个文档", $ENV_GOBACK_URL);
  331. exit();
  332. }
  333. }
  334. //还原文档
  335. else if ($dopost == 'return') {
  336. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  337. require_once(DEDEINC."/libraries/oxwindow.class.php");
  338. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  339. if ($qstr == '') {
  340. ShowMsg("操作失败", "recycling.php");
  341. exit();
  342. }
  343. $qstrs = explode('`', $qstr);
  344. foreach ($qstrs as $aid) {
  345. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET arcrank='-1',ismake='0' WHERE id='$aid'");
  346. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET `arcrank` = '-1' WHERE id = '$aid';");
  347. DedeSearchDo("add", array("id" => $aid));
  348. }
  349. ShowMsg("成功还原指定文档", "recycling.php");
  350. exit();
  351. }
  352. //删除文档
  353. else if ($dopost == "delArchives") {
  354. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  355. require_once(DEDEINC."/libraries/oxwindow.class.php");
  356. if (empty($fmdo)) $fmdo = '';
  357. if ($fmdo == 'yes') {
  358. if (!empty($aid) && empty($qstr)) {
  359. $qstr = $aid;
  360. }
  361. if ($qstr == '') {
  362. ShowMsg("操作失败", $ENV_GOBACK_URL);
  363. exit();
  364. }
  365. $qstrs = explode('`', $qstr);
  366. $okaids = array();
  367. foreach ($qstrs as $aid) {
  368. if (!isset($okaids[$aid])) {
  369. DelArc($aid);
  370. } else {
  371. $okaids[$aid] = 1;
  372. }
  373. }
  374. ShowMsg("成功删除指定文档", $ENV_GOBACK_URL);
  375. exit();
  376. } else {
  377. $wintitle = "删除指定文档";
  378. $win = new OxWindow();
  379. $win->Init("archives_do.php", "/static/web/js/admin.blank.js", "POST");
  380. $win->AddHidden("fmdo", "yes");
  381. $win->AddHidden("dopost", $dopost);
  382. $win->AddHidden("qstr", $qstr);
  383. $win->AddHidden("aid", $aid);
  384. $win->AddTitle("您确定删除,序号".$qstr."文档吗");
  385. $winform = $win->GetWindow("ok");
  386. $win->Display();
  387. }
  388. }
  389. //清空文档
  390. else if ($dopost == 'clear') {
  391. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  392. require_once(DEDEINC."/libraries/oxwindow.class.php");
  393. if (empty($fmdo)) $fmdo = '';
  394. $recycle = empty($recycle) ? "" : $recycle;
  395. if ($fmdo == 'yes') {
  396. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  397. if ($qstr == '') {
  398. ShowMsg("操作失败", "recycling.php");
  399. exit();
  400. }
  401. $qstrs = explode('`', $qstr);
  402. $okaids = array();
  403. foreach ($qstrs as $qstr) {
  404. if (!isset($okaids[$qstr])) {
  405. DelArc($qstr, "OK", FALSE, $recycle);
  406. $okaids[$qstr] = $qstr;
  407. } else {
  408. $okaids[$qstr] = 1;
  409. }
  410. }
  411. ShowMsg("成功删除指定文档", "recycling.php");
  412. exit();
  413. } else {
  414. $dsql->SetQuery("SELECT id FROM `#@__archives` WHERE `arcrank` = '-2'");
  415. $dsql->Execute();
  416. $qstr = '';
  417. while ($row = $dsql->GetArray()) {
  418. $qstr .= $row['id'].'`';
  419. $aid = $row['id'];
  420. }
  421. $num = $dsql->GetTotalRow();
  422. if (empty($num)) {
  423. ShowMsg("未发现相关文档", "recycling.php");
  424. exit();
  425. }
  426. $wintitle = "清空回收站所有文档";
  427. $win = new OxWindow();
  428. $win->Init("archives_do.php", "/static/web/js/admin.blank.js", "POST");
  429. $win->AddHidden("fmdo", "yes");
  430. $win->AddHidden("dopost", $dopost);
  431. $win->AddHidden("qstr", $qstr);
  432. $win->AddHidden("aid", $aid);
  433. $win->AddHidden("recycle", $recycle);
  434. $win->AddTitle("您确定删除".$num."篇文档,序号".$qstr."文档吗");
  435. $winform = $win->GetWindow("ok");
  436. $win->Display();
  437. }
  438. }
  439. //清除文档
  440. else if ($dopost == 'del') {
  441. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  442. require_once(DEDEINC."/libraries/oxwindow.class.php");
  443. if (empty($fmdo)) $fmdo = '';
  444. $recycle = empty($recycle) ? "" : $recycle;
  445. if ($fmdo == 'yes') {
  446. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  447. if ($qstr == '') {
  448. ShowMsg("操作失败", "recycling.php");
  449. exit();
  450. }
  451. $qstrs = explode('`', $qstr);
  452. $okaids = array();
  453. foreach ($qstrs as $aid) {
  454. if (!isset($okaids[$aid])) {
  455. DelArc($aid, "OK", "", $recycle);
  456. } else {
  457. $okaids[$aid] = 1;
  458. }
  459. }
  460. ShowMsg("成功删除指定文档", "recycling.php");
  461. exit();
  462. } else {
  463. $wintitle = "删除指定文档";
  464. $win = new OxWindow();
  465. $win->Init("archives_do.php", "/static/web/js/admin.blank.js", "POST");
  466. $win->AddHidden("fmdo", "yes");
  467. $win->AddHidden("dopost", $dopost);
  468. $win->AddHidden("qstr", $qstr);
  469. $win->AddHidden("aid", $aid);
  470. $win->AddHidden("recycle", $recycle);
  471. $win->AddTitle("您确要删除,序号".$qstr."文档吗");
  472. $winform = $win->GetWindow("ok");
  473. $win->Display();
  474. }
  475. }
  476. //快速修改
  477. else if ($dopost == 'quickEdit') {
  478. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  479. AjaxHead();
  480. $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' ";
  481. $arcRow = $dsql->GetOne($query);
  482. $divname = 'quickEdit';
  483. echo "<div class='card shadow-sm'><div class='card-header'>文档属性修改</div><div class='card-body'>";
  484. echo "<form name='quickeditform' action='archives_do.php?dopost=quickEditSave&aid={$aid}' method='post'>";
  485. echo "<input type='hidden' name='addtable' value='{$arcRow['addtable']}'>";
  486. echo "<input type='hidden' name='oldtypeid' value='{$arcRow['typeid']}'>";
  487. echo "<table class='table table-borderless'>";
  488. ?>
  489. <tbody>
  490. <tr>
  491. <td width="160">所属栏目</td>
  492. <td>
  493. <?php
  494. $typeOptions = GetOptionList($arcRow['typeid'], $cuserLogin->getUserChannel(), $arcRow['channel']);
  495. echo "<select name='typeid' class='admin-input-sm'>";
  496. if ($arcRow["typeid"] == "0") echo "<option value='0' selected>请选择文档栏目</option>";
  497. echo $typeOptions;
  498. echo "</select>";
  499. ?>
  500. </td>
  501. </tr>
  502. <tr>
  503. <td>文档属性</td>
  504. <td>
  505. <input type="hidden" name="oldflag" value="<?php echo $arcRow['flag'];?>">
  506. <?php
  507. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
  508. $dsql->Execute();
  509. while ($trow = $dsql->GetObject()) {
  510. if ($trow->att == 'j') continue;
  511. if (preg_match("#".$trow->att."#", $arcRow['flag']))
  512. echo "<label><input type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}' checked> {$trow->attname}{$trow->att}[{$trow->att}]</label> ";
  513. else
  514. echo "<label><input type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}'> {$trow->attname}[{$trow->att}]</label> ";
  515. }
  516. ?>
  517. </td>
  518. </tr>
  519. <tr>
  520. <td>标题</td>
  521. <td><input type="text" name="title" id="title" value="<?php echo $arcRow['title'];?>" class="admin-input-lg"></td>
  522. </tr>
  523. <tr>
  524. <td>简略标题</td>
  525. <td><input type="text" name="shorttitle" id="shorttitle" value="<?php echo $arcRow['shorttitle'];?>" class="admin-input-lg"></td>
  526. </tr>
  527. <tr>
  528. <td>浏览权限</td>
  529. <td>
  530. <select name="arcrank" id="arcrank" class="admin-input-sm">
  531. <option value='<?php echo $arcRow["arcrank"] ?>'>
  532. <?php echo $arcRow["rankname"] ?> </option>
  533. <?php
  534. $urank = $cuserLogin->getUserRank();
  535. $dsql->SetQuery("SELECT * FROM `#@__arcrank` WHERE adminrank<='$urank' ORDER BY `rank` ASC");
  536. $dsql->Execute();
  537. while ($row = $dsql->GetObject()) {
  538. $selected = $row->rank == 0 ? ' selected' : '';
  539. echo "<option value='".$row->rank."'{$selected}>".$row->membername."</option>";
  540. }
  541. ?>
  542. </select>
  543. </td>
  544. </tr>
  545. </tr>
  546. <td>金币</td>
  547. <td><input type="text" name="money" id="money" value="<?php echo $arcRow["money"];?>" class="admin-input-sm"></td>
  548. <tr>
  549. <tr>
  550. <td>关键词</td>
  551. <td><input type="text" name="keywords" id="keywords" value="<?php echo $arcRow['keywords'];?>" class="admin-input-lg"></td>
  552. </tr>
  553. <tr>
  554. <td colspan="2" align="center">
  555. <button type="submit" class="btn btn-success btn-sm">保存</button>
  556. <button type="button" onclick="HideObj('<?php echo $divname;?>');ChangeFullDiv('hide');" class="btn btn-outline-success btn-sm">关闭</button>
  557. </td>
  558. </tr>
  559. </tbody>
  560. </table>
  561. </form>
  562. </div>
  563. </div>
  564. <?php
  565. //Ajax窗体结束
  566. }
  567. //保存快速修改文档
  568. else if ($dopost == 'quickEditSave') {
  569. require_once(DEDEADMIN.'/inc/inc_archives_functions.php');
  570. //权限检测
  571. if (!TestPurview('a_Edit')) {
  572. CheckCatalog($typeid, "您没有操作栏目{$typeid}文档权限");
  573. }
  574. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  575. $shorttitle = cn_substrR($shorttitle, 36);
  576. $keywords = trim(cn_substrR($keywords, 60));
  577. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  578. $adminid = $cuserLogin->getUserID();
  579. //属性处理
  580. $flag = isset($flags) ? join(',', $flags) : '';
  581. if (!empty($flag)) {
  582. if (preg_match("#p#", $oldflag)) $flag .= ',p';
  583. if (preg_match("#j#", $oldflag)) $flag .= ',j';
  584. }
  585. $query = "UPDATE `#@__archives` SET typeid='$typeid',flag='$flag',arcrank='$arcrank',money='$money',title='$title',shorttitle='$shorttitle',keywords='$keywords',dutyadmin='$adminid' WHERE id='$aid'; ";
  586. //更新主表
  587. $dsql->ExecuteNoneQuery($query);
  588. //更新微表
  589. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET typeid='$typeid',arcrank='$arcrank' WHERE id='$aid' ");
  590. //更新附加表
  591. if ($typeid != $oldtypeid) {
  592. $addtable = trim($addtable);
  593. if (empty($addtable)) $addtable = '#@__addonarticle';
  594. else $addtable = preg_replace("#[^a-z0-9__#@-]#i", "", $addtable);
  595. $dsql->ExecuteNoneQuery("UPDATE `$addtable` SET typeid='$typeid' WHERE aid='$aid' ");
  596. }
  597. //更新网页
  598. $artUrl = MakeArt($aid, TRUE, TRUE);
  599. $backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : '-1';
  600. ShowMsg('成功更新一篇文档属性', $backurl);
  601. exit();
  602. }
  603. //分析并自动获取文档关键词
  604. else if ($dopost == "makekw") {
  605. CheckPurview('a_Commend,sys_ArcBatch');
  606. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  607. if ($qstr == '') {
  608. ShowMsg("操作失败", $ENV_GOBACK_URL);
  609. exit();
  610. }
  611. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  612. $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 ";
  613. $dsql->SetQuery($query);
  614. $dsql->Execute();
  615. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  616. $client = new DedeBizClient();
  617. while ($row = $dsql->GetArray()) {
  618. //跳过已经有关键词文档
  619. if (trim($row['keywords']) != '') continue;
  620. $aid = $row['id'];
  621. $keywords = '';
  622. $title = $row['title'];
  623. $description = $row['description'];
  624. $body = cn_substr($row['body'], 3000);
  625. $data = $client->Spliteword($title." ".Html2Text($body));
  626. $keywords = $data->data;
  627. $description = str_replace(' ', ' ', trim($description));
  628. $description = str_replace('[', ' ', $description);
  629. $description = str_replace(']', ' ', $description);
  630. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  631. $description = str_replace('关键词', '', $description);
  632. $description = str_replace('关键词', '', $description);
  633. $description = addslashes($description);
  634. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  635. }
  636. $client->Close();
  637. } else {
  638. include_once(DEDEINC.'/libraries/splitword.class.php');
  639. $sp = new SplitWord();
  640. while ($row = $dsql->GetArray()) {
  641. //跳过已经有关键词文档
  642. if (trim($row['keywords']) != '') continue;
  643. $aid = $row['id'];
  644. $keywords = '';
  645. $title = $row['title'];
  646. $description = $row['description'];
  647. $body = cn_substr($row['body'], 3000);
  648. $sp->SetSource($title." ".Html2Text($body));
  649. $sp->StartAnalysis();
  650. $indexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  651. if (is_array($indexs)) {
  652. foreach ($indexs as $k => $v) {
  653. if (strlen($keywords.$k) >= 60) {
  654. break;
  655. } else {
  656. if (strlen($k) < 6) continue;
  657. $keywords .= ($keywords == '' ? "{$k}" : ",{$k}");
  658. }
  659. }
  660. }
  661. $description = str_replace(' ', ' ', trim($description));
  662. $description = str_replace('[', ' ', $description);
  663. $description = str_replace(']', ' ', $description);
  664. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  665. $description = str_replace('关键词', '', $description);
  666. $description = str_replace('关键词', '', $description);
  667. $description = addslashes($description);
  668. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  669. }
  670. $sp = null;
  671. }
  672. ShowMsg("成功分析指定文档关键词", $ENV_GOBACK_URL);
  673. exit();
  674. }
  675. //批量添加属性
  676. else if ($dopost == 'attsAdd') {
  677. CheckPurview('a_Commend,sys_ArcBatch');
  678. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  679. if ($qstr == '') {
  680. ShowMsg("操作失败", $ENV_GOBACK_URL);
  681. exit();
  682. }
  683. if (empty($flagname)) {
  684. ShowMsg("必须指定要添加属性", $ENV_GOBACK_URL);
  685. exit();
  686. }
  687. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  688. $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) ";
  689. $dsql->SetQuery($query);
  690. $dsql->Execute();
  691. while ($row = $dsql->GetArray()) {
  692. $aid = $row['id'];
  693. if ($row['issystem'] != -1) {
  694. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  695. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  696. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  697. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET `flag`='$flag' WHERE id='{$aid}' ");
  698. } else {
  699. $maintable = trim($row['addtable']);
  700. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  701. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  702. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET `flag`='$flag' WHERE aid='{$aid}' ");
  703. }
  704. }
  705. ShowMsg("成功添加文档指定属性", $ENV_GOBACK_URL);
  706. exit();
  707. }
  708. //批量删除属性
  709. else if ($dopost == 'attsDel') {
  710. CheckPurview('a_Commend,sys_ArcBatch');
  711. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  712. if ($qstr == '') {
  713. ShowMsg("操作失败", $ENV_GOBACK_URL);
  714. exit();
  715. }
  716. if (empty($flagname)) {
  717. ShowMsg("必须指定要删除属性", $ENV_GOBACK_URL);
  718. exit();
  719. }
  720. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  721. $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) ";
  722. $dsql->SetQuery($query);
  723. $dsql->Execute();
  724. while ($row = $dsql->GetArray()) {
  725. $aid = $row['id'];
  726. if ($row['issystem'] != -1) {
  727. $idname = 'id';
  728. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  729. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  730. } else {
  731. $idname = 'aid';
  732. $maintable = trim($row['addtable']);
  733. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  734. }
  735. $flag = $arr['flag'];
  736. if (trim($flag) == '' || !preg_match("#".$flagname."#", $flag)) {
  737. continue;
  738. } else {
  739. $flags = explode(',', $flag);
  740. $okflags = array();
  741. foreach ($flags as $f) {
  742. if ($f != $flagname) $okflags[] = $f;
  743. }
  744. }
  745. $flag = trim(join(',', $okflags));
  746. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET `flag`='$flag' WHERE {$idname}='{$aid}' ");
  747. }
  748. ShowMsg("成功删除文档指定属性", $ENV_GOBACK_URL);
  749. exit();
  750. }
  751. //获得批量属性处理Ajax窗体
  752. else if ($dopost == 'attsDlg') {
  753. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  754. $dojobname = ($dojob == 'attsDel' ? '批量删除属性' : '批量添加属性');
  755. AjaxHead();
  756. //输出Ajax可移动窗体
  757. $divname = 'attsDlg';
  758. echo "<div class='card shadow-sm'><div class='card-header'>{$dojobname}</div><div class='card-body'>";
  759. echo "<form name='quickeditform' action='archives_do.php' method='post'>";
  760. echo "<input type='hidden' name='dopost' value='{$dojob}'>";
  761. echo "<input type='hidden' name='qstr' value='{$qstr}'>";
  762. echo "<table class='table table-borderless'>";
  763. ?>
  764. <tbody>
  765. <tr>
  766. <td width="160">文档属性</td>
  767. <td>
  768. <input type="hidden" name="oldflag" value="<?php echo $arcRow['flag'];?>">
  769. <?php
  770. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
  771. $dsql->Execute();
  772. while ($trow = $dsql->GetObject()) {
  773. if ($trow->att == 'j') continue;
  774. echo "<label><input type='radio' name='flagname' id='flags{$trow->att}' value='{$trow->att}'> {$trow->attname}[{$trow->att}]</label> ";
  775. }
  776. ?>
  777. </td>
  778. </tr>
  779. <tr>
  780. <td>文档id</td>
  781. <td><input type="text" name="tmpids" value="<?php echo $qstr;?>"></td>
  782. </tr>
  783. <tr>
  784. <td colspan="2" align="center">
  785. <button type="submit" class="btn btn-success btn-sm">保存</button>
  786. <button type="button" onclick="HideObj('<?php echo $divname;?>');ChangeFullDiv('hide');" class="btn btn-outline-success btn-sm">关闭</button>
  787. </td>
  788. </tr>
  789. </tbody>
  790. </table>
  791. </form>
  792. </div>
  793. </div>
  794. <?php
  795. //Ajax窗体结束
  796. } else if ($dopost == 'getCatMap') {
  797. require_once(DEDEINC.'/typelink/typeunit.class.selector.php');
  798. AjaxHead();
  799. //输出Ajax可移动窗体
  800. $divname = 'getCatMap';
  801. echo "<div class='card shadow-sm'><div class='card-header'>选择副栏目</div><div class='card-body'>";
  802. $tus = new TypeUnitSelector();
  803. ?>
  804. <form name="quicksel" action="javascript:;" method="get">
  805. <div class="quicksel"><?php $tus->ListAllType($channelid);?></div>
  806. <div class="text-center">
  807. <button onclick="getSelCat('<?php echo $targetid;?>');" class="btn btn-success btn-sm">保存</button>
  808. <button type="button" onclick="HideObj('<?php echo $divname;?>');ChangeFullDiv('hide');" class="btn btn-outline-success btn-sm">关闭</button>
  809. </div>
  810. </form>
  811. </div>
  812. </div>
  813. <?php
  814. //Ajax窗体结束
  815. }
  816. ?>