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

807 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. echo "<option value='".$row->rank."'>".$row->membername."</option>";
  530. }
  531. ?>
  532. </select>
  533. <label>需要金币:<input type="text" name="money" id="money" value="<?php echo $arcRow["money"];?>" class="admin-input-xs"></label>
  534. </td>
  535. </tr>
  536. <tr>
  537. <td width="120" class="admin-td">关键词:</td>
  538. <td class="admin-td"><input type="text" name="keywords" id="keywords" value="<?php echo $arcRow['keywords'];?>" class="admin-input-lg"></td>
  539. </tr>
  540. <tr>
  541. <td bgcolor="f5f5f5" colspan="2" align="center" class="py-2">
  542. <button type="submit" class="btn btn-success btn-sm">保存</button>
  543. <button type="button" onclick="HideObj('<?php echo $divname;?>');ChangeFullDiv('hide');" class="btn btn-outline-success btn-sm">关闭</button>
  544. </td>
  545. </tr>
  546. </table>
  547. </form>
  548. <?php
  549. //Ajax窗体结束
  550. }
  551. //保存快速修改文档
  552. else if ($dopost == 'quickEditSave') {
  553. require_once(DEDEADMIN.'/inc/inc_archives_functions.php');
  554. //权限检测
  555. if (!TestPurview('a_Edit')) {
  556. CheckCatalog($typeid, "您没有操作栏目<span class='text-primary'>{$typeid}</span>文档权限");
  557. }
  558. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  559. $shorttitle = cn_substrR($shorttitle, 36);
  560. $keywords = trim(cn_substrR($keywords, 60));
  561. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  562. $adminid = $cuserLogin->getUserID();
  563. //属性处理
  564. $flag = isset($flags) ? join(',', $flags) : '';
  565. if (!empty($flag)) {
  566. if (preg_match("#p#", $oldflag)) $flag .= ',p';
  567. if (preg_match("#j#", $oldflag)) $flag .= ',j';
  568. }
  569. $query = "UPDATE `#@__archives` SET typeid='$typeid',flag='$flag',arcrank='$arcrank',money='$money',title='$title',shorttitle='$shorttitle',keywords='$keywords',dutyadmin='$adminid' WHERE id='$aid'; ";
  570. //更新主表
  571. $dsql->ExecuteNoneQuery($query);
  572. //更新微表
  573. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET typeid='$typeid',arcrank='$arcrank' WHERE id='$aid' ");
  574. //更新附加表
  575. if ($typeid != $oldtypeid) {
  576. $addtable = trim($addtable);
  577. if (empty($addtable)) $addtable = '#@__addonarticle';
  578. else $addtable = preg_replace("#[^a-z0-9__#@-]#i", "", $addtable);
  579. $dsql->ExecuteNoneQuery("UPDATE `$addtable` SET typeid='$typeid' WHERE aid='$aid' ");
  580. }
  581. //更新网页
  582. $artUrl = MakeArt($aid, TRUE, TRUE);
  583. $backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : '-1';
  584. ShowMsg('成功更新一篇文档指定属性', $backurl);
  585. exit();
  586. }
  587. //分析并自动获取文档关键词
  588. else if ($dopost == "makekw") {
  589. CheckPurview('a_Commend,sys_ArcBatch');
  590. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  591. if ($qstr == '') {
  592. ShowMsg("操作失败", $ENV_GOBACK_URL);
  593. exit();
  594. }
  595. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  596. $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 ";
  597. $dsql->SetQuery($query);
  598. $dsql->Execute();
  599. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  600. $client = new DedeBizClient();
  601. while ($row = $dsql->GetArray()) {
  602. //跳过已经有关键词文档
  603. if (trim($row['keywords']) != '') continue;
  604. $aid = $row['id'];
  605. $keywords = '';
  606. $title = $row['title'];
  607. $description = $row['description'];
  608. $body = cn_substr($row['body'], 5000);
  609. $data = $client->Spliteword($title.Html2Text($body));
  610. $keywords = $data->data;
  611. $description = str_replace(' ', ' ', trim($description));
  612. $description = str_replace('[', ' ', $description);
  613. $description = str_replace(']', ' ', $description);
  614. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  615. $description = str_replace('关键词', '', $description);
  616. $description = str_replace('关键词', '', $description);
  617. $description = addslashes($description);
  618. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  619. }
  620. $client->Close();
  621. } else {
  622. include_once(DEDEINC.'/libraries/splitword.class.php');
  623. $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
  624. while ($row = $dsql->GetArray()) {
  625. //跳过已经有关键词文档
  626. if (trim($row['keywords']) != '') continue;
  627. $aid = $row['id'];
  628. $keywords = '';
  629. $title = $row['title'];
  630. $description = $row['description'];
  631. $body = cn_substr($row['body'], 5000);
  632. $sp->SetSource($title, $cfg_soft_lang, $cfg_soft_lang);
  633. $sp->StartAnalysis();
  634. $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  635. $sp->SetSource(Html2Text($body), $cfg_soft_lang, $cfg_soft_lang);
  636. $sp->StartAnalysis();
  637. $allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  638. if (is_array($allindexs) && is_array($titleindexs)) {
  639. foreach ($titleindexs as $k => $v) {
  640. if (strlen($keywords.$k) >= 60) {
  641. break;
  642. } else {
  643. if (strlen($k) <= 2) continue;
  644. $keywords .= $k.',';
  645. }
  646. }
  647. foreach ($allindexs as $k => $v) {
  648. if (strlen($keywords.$k) >= 60) {
  649. break;
  650. } else if (!in_array($k, $titleindexs)) {
  651. if (strlen($k) <= 2) continue;
  652. $keywords .= $k.',';
  653. }
  654. }
  655. }
  656. $description = str_replace(' ', ' ', trim($description));
  657. $description = str_replace('[', ' ', $description);
  658. $description = str_replace(']', ' ', $description);
  659. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  660. $description = str_replace('关键词', '', $description);
  661. $description = str_replace('关键词', '', $description);
  662. $description = addslashes($description);
  663. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  664. }
  665. $sp = null;
  666. }
  667. ShowMsg("成功分析指定文档关键词", $ENV_GOBACK_URL);
  668. exit();
  669. }
  670. //批量添加属性
  671. else if ($dopost == 'attsAdd') {
  672. CheckPurview('a_Commend,sys_ArcBatch');
  673. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  674. if ($qstr == '') {
  675. ShowMsg("操作失败", $ENV_GOBACK_URL);
  676. exit();
  677. }
  678. if (empty($flagname)) {
  679. ShowMsg("必须指定要添加属性", $ENV_GOBACK_URL);
  680. exit();
  681. }
  682. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  683. $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) ";
  684. $dsql->SetQuery($query);
  685. $dsql->Execute();
  686. while ($row = $dsql->GetArray()) {
  687. $aid = $row['id'];
  688. if ($row['issystem'] != -1) {
  689. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  690. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  691. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  692. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET `flag`='$flag' WHERE id='{$aid}' ");
  693. } else {
  694. $maintable = trim($row['addtable']);
  695. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  696. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  697. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET `flag`='$flag' WHERE aid='{$aid}' ");
  698. }
  699. }
  700. ShowMsg("成功对选中文档添加指定属性", $ENV_GOBACK_URL);
  701. exit();
  702. }
  703. //批量删除属性
  704. else if ($dopost == 'attsDel') {
  705. CheckPurview('a_Commend,sys_ArcBatch');
  706. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  707. if ($qstr == '') {
  708. ShowMsg("操作失败", $ENV_GOBACK_URL);
  709. exit();
  710. }
  711. if (empty($flagname)) {
  712. ShowMsg("必须指定要删除属性", $ENV_GOBACK_URL);
  713. exit();
  714. }
  715. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  716. $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) ";
  717. $dsql->SetQuery($query);
  718. $dsql->Execute();
  719. while ($row = $dsql->GetArray()) {
  720. $aid = $row['id'];
  721. if ($row['issystem'] != -1) {
  722. $idname = 'id';
  723. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  724. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  725. } else {
  726. $idname = 'aid';
  727. $maintable = trim($row['addtable']);
  728. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  729. }
  730. $flag = $arr['flag'];
  731. if (trim($flag) == '' || !preg_match("#".$flagname."#", $flag)) {
  732. continue;
  733. } else {
  734. $flags = explode(',', $flag);
  735. $okflags = array();
  736. foreach ($flags as $f) {
  737. if ($f != $flagname) $okflags[] = $f;
  738. }
  739. }
  740. $flag = trim(join(',', $okflags));
  741. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET `flag`='$flag' WHERE {$idname}='{$aid}' ");
  742. }
  743. ShowMsg("成功对选中文档删除指定属性", $ENV_GOBACK_URL);
  744. exit();
  745. }
  746. //获得批量属性处理Ajax窗体
  747. else if ($dopost == 'attsDlg') {
  748. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  749. $dojobname = ($dojob == 'attsDel' ? '批量删除属性' : '批量添加属性');
  750. AjaxHead();
  751. //输出Ajax可移动窗体
  752. $divname = 'attsDlg';
  753. echo "<div class='title'>{$dojobname}</div>";
  754. echo "<form name='quickeditform' action='archives_do.php' method='post'>";
  755. echo "<input type='hidden' name='dopost' value='{$dojob}'>";
  756. echo "<input type='hidden' name='qstr' value='{$qstr}'>";
  757. echo "<table>";
  758. ?>
  759. <tr>
  760. <td width="120" class="admin-td">属性:</td>
  761. <td class="admin-td">
  762. <input type="hidden" name="oldflag" value="<?php echo $arcRow['flag'];?>">
  763. <?php
  764. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
  765. $dsql->Execute();
  766. while ($trow = $dsql->GetObject()) {
  767. if ($trow->att == 'j' || $trow->att == 'p') continue;
  768. echo "<label class='mr-2'><input type='radio' name='flagname' id='flags{$trow->att}' value='{$trow->att}'> {$trow->attname}[{$trow->att}]</label>";
  769. }
  770. ?>
  771. </td>
  772. </tr>
  773. <tr>
  774. <td width="120" class="admin-td">文档id:</td>
  775. <td class="admin-td"><input type="text" name="tmpids" value="<?php echo $qstr;?>"></td>
  776. </tr>
  777. <tr>
  778. <td bgcolor="f5f5f5" colspan="2" align="center" class="py-2">
  779. <button type="submit" class="btn btn-success btn-sm">保存</button>
  780. <button type="button" onclick="HideObj('<?php echo $divname;?>');ChangeFullDiv('hide');" class="btn btn-outline-success btn-sm">关闭</button>
  781. </td>
  782. </tr>
  783. </table>
  784. </form>
  785. <?php
  786. //Ajax窗体结束
  787. } else if ($dopost == 'getCatMap') {
  788. require_once(DEDEINC.'/typelink/typeunit.class.selector.php');
  789. AjaxHead();
  790. //输出Ajax可移动窗体
  791. $divname = 'getCatMap';
  792. echo "<div class='title'>选择副栏目</div>";
  793. $tus = new TypeUnitSelector();
  794. ?>
  795. <form name="quicksel" action="javascript:;" method="get">
  796. <div class="quicksel"><?php $tus->ListAllType($channelid);?></div>
  797. <div align="center" class="quickselfoot">
  798. <button onclick="getSelCat('<?php echo $targetid;?>');" class="btn btn-success btn-sm">保存</button>
  799. <button type="button" onclick="HideObj('<?php echo $divname;?>');ChangeFullDiv('hide');" class="btn btn-outline-success btn-sm">关闭</button>
  800. </div>
  801. </form>
  802. <?php
  803. //Ajax窗体结束
  804. }
  805. ?>