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

872 lines
37KB

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