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

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