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

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