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

868 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("成功更新指定<span class='text-primary'>$i</span>个文件", $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='admin-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="admin-td">目标栏目:</td>
  286. <td class="admin-td"><?php echo $typeOptions;?></td>
  287. </tr>
  288. <tr>
  289. <td width="90" class="admin-td">文档id:</td>
  290. <td class="admin-td">
  291. <input type="text" name="tmpids" class="admin-input-md" value="<?php echo $qstr;?>"><br>
  292. 移动到目标栏目必须和选定文档栏目类型一致,否则程序会自动勿略不符合文档
  293. </td>
  294. </tr>
  295. <tr>
  296. <td colspan="2" align="center">
  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("成功移动<span class='text-primary'>$j</span>个文档", $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("您确定删除,序号<span class='text-primary'>$qstr</span>文档");
  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("回收站将清空<span class='text-primary'>$num</span>篇文档<br>您确定删除,序号<span class='text-primary'>$qstr</span>文档");
  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("您确要删除,序号<span class='text-primary'>$qstr</span>文档");
  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="admin-td">所属栏目:</td>
  523. <td class="admin-td">
  524. <?php
  525. $typeOptions = GetOptionList($arcRow['typeid'], $cuserLogin->getUserChannel(), $arcRow['channel']);
  526. echo "<select name='typeid' class='admin-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="admin-td">属性:</td>
  535. <td class="admin-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-2'><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-2'><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="admin-td">标题:</td>
  552. <td class="admin-td"><input type="text" name="title" id="title" value="<?php echo $arcRow['title'];?>" class="admin-input-md"></td>
  553. </tr>
  554. <tr>
  555. <td width="90" class="admin-td">简略标题:</td>
  556. <td class="admin-td"><input type="text" name="shorttitle" id="shorttitle" value="<?php echo $arcRow['shorttitle'];?>" class="admin-input-md"></td>
  557. </tr>
  558. <tr>
  559. <td width="90" class="admin-td">阅读权限:</td>
  560. <td class="admin-td">
  561. <select name="arcrank" id="arcrank" class="admin-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="admin-input-xs">
  574. </td>
  575. </tr>
  576. <tr>
  577. <td width="90" class="admin-td">关键词:</td>
  578. <td class="admin-td"><input type="text" name="keywords" id="keywords" value="<?php echo $arcRow['keywords'];?>" class="admin-input-md"></td>
  579. </tr>
  580. <tr>
  581. <td colspan="2" align="center">
  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. CheckCatalog($typeid, "对不起,您没有操作栏目<span class='text-primary'>{$typeid}</span>文档权限");
  600. }
  601. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  602. $shorttitle = cn_substrR($shorttitle, 36);
  603. $keywords = trim(cn_substrR($keywords, 60));
  604. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  605. $adminid = $cuserLogin->getUserID();
  606. //属性处理
  607. $flag = isset($flags) ? join(',', $flags) : '';
  608. if (!empty($flag)) {
  609. if (preg_match("#p#", $oldflag)) $flag .= ',p';
  610. if (preg_match("#j#", $oldflag)) $flag .= ',j';
  611. }
  612. $query = "UPDATE `#@__archives` SET typeid='$typeid',flag='$flag',arcrank='$arcrank',money='$money',title='$title',shorttitle='$shorttitle',keywords='$keywords',dutyadmin='$adminid' WHERE id='$aid'; ";
  613. //更新主表
  614. $dsql->ExecuteNoneQuery($query);
  615. //更新微表
  616. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET typeid='$typeid',arcrank='$arcrank' WHERE id='$aid' ");
  617. //更新附加表
  618. if ($typeid != $oldtypeid) {
  619. $addtable = trim($addtable);
  620. if (empty($addtable)) $addtable = '#@__addonarticle';
  621. else $addtable = preg_replace("#[^a-z0-9__#@-]#i", "", $addtable);
  622. $dsql->ExecuteNoneQuery("UPDATE `$addtable` SET typeid='$typeid' WHERE aid='$aid' ");
  623. }
  624. //更新网页
  625. $artUrl = MakeArt($aid, TRUE, TRUE);
  626. $backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : '-1';
  627. ShowMsg('成功更新一篇文档基本信息', $backurl);
  628. exit();
  629. }
  630. /*--------------------------
  631. 分析并自动获取文档关键词
  632. function makekw(){ }
  633. --------------------------*/
  634. else if ($dopost == "makekw") {
  635. CheckPurview('a_Commend,sys_ArcBatch');
  636. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  637. if ($qstr == '') {
  638. ShowMsg("参数无效", $ENV_GOBACK_URL);
  639. exit();
  640. }
  641. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  642. $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 ";
  643. $dsql->SetQuery($query);
  644. $dsql->Execute();
  645. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  646. $client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port);
  647. $client->appid = $cfg_bizcore_appid;
  648. $client->key = $cfg_bizcore_key;
  649. while ($row = $dsql->GetArray()) {
  650. //跳过已经有关键词文档
  651. if (trim($row['keywords']) != '') continue;
  652. $aid = $row['id'];
  653. $keywords = '';
  654. $title = $row['title'];
  655. $description = $row['description'];
  656. $body = cn_substr($row['body'], 5000);
  657. $data = $client->Spliteword($title.Html2Text($body));
  658. $keywords = $data->data;
  659. $description = str_replace(' ', ' ', trim($description));
  660. $description = str_replace('[', ' ', $description);
  661. $description = str_replace(']', ' ', $description);
  662. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  663. $description = str_replace('关键词', '', $description);
  664. $description = str_replace('关键词', '', $description);
  665. $description = addslashes($description);
  666. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  667. }
  668. $client->Close();
  669. } else {
  670. include_once(DEDEINC.'/libraries/splitword.class.php');
  671. $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
  672. while ($row = $dsql->GetArray()) {
  673. //跳过已经有关键词文档
  674. if (trim($row['keywords']) != '') continue;
  675. $aid = $row['id'];
  676. $keywords = '';
  677. $title = $row['title'];
  678. $description = $row['description'];
  679. $body = cn_substr($row['body'], 5000);
  680. $sp->SetSource($title, $cfg_soft_lang, $cfg_soft_lang);
  681. $sp->StartAnalysis();
  682. $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  683. $sp->SetSource(Html2Text($body), $cfg_soft_lang, $cfg_soft_lang);
  684. $sp->StartAnalysis();
  685. $allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  686. if (is_array($allindexs) && is_array($titleindexs)) {
  687. foreach ($titleindexs as $k => $v) {
  688. if (strlen($keywords.$k) >= 60) {
  689. break;
  690. } else {
  691. if (strlen($k) <= 2) continue;
  692. $keywords .= $k.',';
  693. }
  694. }
  695. foreach ($allindexs as $k => $v) {
  696. if (strlen($keywords.$k) >= 60) {
  697. break;
  698. } else if (!in_array($k, $titleindexs)) {
  699. if (strlen($k) <= 2) continue;
  700. $keywords .= $k.',';
  701. }
  702. }
  703. }
  704. $description = str_replace(' ', ' ', trim($description));
  705. $description = str_replace('[', ' ', $description);
  706. $description = str_replace(']', ' ', $description);
  707. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  708. $description = str_replace('关键词', '', $description);
  709. $description = str_replace('关键词', '', $description);
  710. $description = addslashes($description);
  711. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  712. }
  713. $sp = null;
  714. }
  715. ShowMsg("成功分析指定文档关键词", $ENV_GOBACK_URL);
  716. exit();
  717. }
  718. /*--------------------------
  719. //批量增加属性
  720. function attsAdd(){ }
  721. ---------------------------*/
  722. else if ($dopost == 'attsAdd') {
  723. CheckPurview('a_Commend,sys_ArcBatch');
  724. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  725. if ($qstr == '') {
  726. ShowMsg("参数无效", $ENV_GOBACK_URL);
  727. exit();
  728. }
  729. if (empty($flagname)) {
  730. ShowMsg("必须指定要添加属性", $ENV_GOBACK_URL);
  731. exit();
  732. }
  733. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  734. $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) ";
  735. $dsql->SetQuery($query);
  736. $dsql->Execute();
  737. while ($row = $dsql->GetArray()) {
  738. $aid = $row['id'];
  739. if ($row['issystem'] != -1) {
  740. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  741. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  742. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  743. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET `flag`='$flag' WHERE id='{$aid}' ");
  744. } else {
  745. $maintable = trim($row['addtable']);
  746. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  747. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  748. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET `flag`='$flag' WHERE aid='{$aid}' ");
  749. }
  750. }
  751. ShowMsg("成功对选中文档增加指定属性", $ENV_GOBACK_URL);
  752. exit();
  753. }
  754. /*--------------------------
  755. //批量删除属性
  756. function attsDel(){ }
  757. ---------------------------*/
  758. else if ($dopost == 'attsDel') {
  759. CheckPurview('a_Commend,sys_ArcBatch');
  760. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  761. if ($qstr == '') {
  762. ShowMsg("参数无效", $ENV_GOBACK_URL);
  763. exit();
  764. }
  765. if (empty($flagname)) {
  766. ShowMsg("必须指定要删除属性", $ENV_GOBACK_URL);
  767. exit();
  768. }
  769. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  770. $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) ";
  771. $dsql->SetQuery($query);
  772. $dsql->Execute();
  773. while ($row = $dsql->GetArray()) {
  774. $aid = $row['id'];
  775. if ($row['issystem'] != -1) {
  776. $idname = 'id';
  777. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  778. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  779. } else {
  780. $idname = 'aid';
  781. $maintable = trim($row['addtable']);
  782. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  783. }
  784. $flag = $arr['flag'];
  785. if (trim($flag) == '' || !preg_match("#".$flagname."#", $flag)) {
  786. continue;
  787. } else {
  788. $flags = explode(',', $flag);
  789. $okflags = array();
  790. foreach ($flags as $f) {
  791. if ($f != $flagname) $okflags[] = $f;
  792. }
  793. }
  794. $flag = trim(join(',', $okflags));
  795. $dsql->ExecuteNoneQuery("UPDATE `{$maintable}` SET `flag`='$flag' WHERE {$idname}='{$aid}' ");
  796. }
  797. ShowMsg("成功对选中文档删除指定属性", $ENV_GOBACK_URL);
  798. exit();
  799. }
  800. /*--------------------------
  801. //获得批量属性处理AJAX窗体
  802. function attsDlg(){ }
  803. ---------------------------*/
  804. else if ($dopost == 'attsDlg') {
  805. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  806. $dojobname = ($dojob == 'attsDel' ? '批量删除属性' : '批量增加属性');
  807. AjaxHead();
  808. //输出AJAX可移动窗体
  809. $divname = 'attsDlg';
  810. echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 260);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">{$dojobname}</div>";
  811. echo "<form name='quickeditform' action='archives_do.php' method='post'>";
  812. echo "<input type='hidden' name='dopost' value='{$dojob}'>";
  813. echo "<input type='hidden' name='qstr' value='{$qstr}'>";
  814. echo "<table width='100%' style='display:inline-block;padding:2px;z-index:9000'>";
  815. ?>
  816. <tr>
  817. <td width="90" class="admin-td">属性:</td>
  818. <td class="admin-td">
  819. <input type="hidden" name="oldflag" value="<?php echo $arcRow['flag'];?>">
  820. <?php
  821. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
  822. $dsql->Execute();
  823. while ($trow = $dsql->GetObject()) {
  824. if ($trow->att == 'j' || $trow->att == 'p') continue;
  825. echo "<label class='mr-2'><input type='radio' name='flagname' id='flags{$trow->att}' value='{$trow->att}'> {$trow->attname}[{$trow->att}]</label>";
  826. }
  827. ?>
  828. </td>
  829. </tr>
  830. <tr>
  831. <td width="90" class="admin-td">文档id:</td>
  832. <td class="admin-td"><input type="text" name="tmpids" value="<?php echo $qstr;?>"></td>
  833. </tr>
  834. <tr>
  835. <td colspan="2" align="center">
  836. <button type="submit" class="btn btn-success btn-sm">保存</button>
  837. <button type="button" onclick="HideObj('<?php echo $divname;?>');ChangeFullDiv('hide');" class="btn btn-success btn-sm">关闭</button>
  838. </td>
  839. </tr>
  840. </table>
  841. </form>
  842. <?php
  843. //AJAX窗体结束
  844. }
  845. /*------------------------
  846. function getCatMap() { }
  847. -------------------------*/
  848. else if ($dopost == 'getCatMap') {
  849. require_once(DEDEINC.'/typelink/typeunit.class.selector.php');
  850. AjaxHead();
  851. //输出AJAX可移动窗体
  852. $divname = 'getCatMap';
  853. echo "<div class='title' style='cursor:default'>栏目快速选择器</div>";
  854. $tus = new TypeUnitSelector();
  855. ?>
  856. <form name="quicksel" action="javascript:;" method="get">
  857. <div class="quicksel"><?php $tus->ListAllType($channelid);?></div>
  858. <div align="center" class="quickselfoot">
  859. <button onclick="getSelCat('<?php echo $targetid;?>');" class="btn btn-success btn-sm">保存</button>
  860. <button type="button" onclick="HideObj('<?php echo $divname;?>');ChangeFullDiv('hide');" class="btn btn-success btn-sm">关闭</button>
  861. </div>
  862. </form>
  863. <?php
  864. //AJAX窗体结束
  865. }
  866. ?>