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

906 lines
37KB

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