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

918 lines
38KB

  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}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">";
  295. echo "<div class='titLeft'>移动文档</div>";
  296. echo "<div class='titRight'><img src='../static/web/img/ico-close.gif' style='cursor:pointer' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' title='关闭'></div>";
  297. echo "</div>";
  298. echo "<form name='quickeditform' action='archives_do.php' method='post'>";
  299. echo "<input type='hidden' name='dopost' value='{$dopost}'>";
  300. echo "<input type='hidden' name='qstr' value='{$qstr}'>";
  301. echo "<table width='100%' style='display:inline-block;z-index:9000'>";
  302. ?>
  303. <tr>
  304. <td width="86" height="26" class="bline">&nbsp;目标栏目:</td>
  305. <td class="bline"><?php echo $typeOptions; ?></td>
  306. </tr>
  307. <tr>
  308. <td width="86" height="26" class="bline">&nbsp;文档ID:</td>
  309. <td class="bline">
  310. <input type="text" name="tmpids" value="<?php echo $qstr; ?>" style="width:320px;overflow:hidden">
  311. <br>移动到的目标栏目必须和选定的文档频道类型一致,否则程序会自动勿略不符合的文档
  312. </td>
  313. </tr>
  314. <tr>
  315. <td colspan="2" align="center" class="py-3">
  316. <button type="submit" class="btn btn-success btn-sm">保存</button>
  317. <button type="button" onclick="HideObj('<?php echo $divname; ?>');ChangeFullDiv('hide');" class="btn btn-success btn-sm">关闭</button>
  318. </td>
  319. </tr>
  320. </table>
  321. </form>
  322. <?php
  323. //AJAX窗体结束
  324. } else {
  325. $totype = preg_replace("#[^0-9]#", '', $totype);
  326. $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' ");
  327. $idtype = "id";
  328. if (!is_array($typeInfos)) {
  329. ShowMsg('参数错误', '-1');
  330. exit();
  331. }
  332. if ($typeInfos['ispart'] != 0) {
  333. ShowMsg('文档保存的栏目必须为最终列表栏目', '-1');
  334. exit();
  335. }
  336. if (empty($typeInfos['addtable'])) {
  337. $typeInfos['maintable'] = '#@__archives';
  338. }
  339. //增加单表模型判断
  340. if ($typeInfos['issystem'] == -1) {
  341. $typeInfos['maintable'] = $typeInfos['addtable'];
  342. $idtype = "aid";
  343. }
  344. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  345. $arc = '';
  346. $j = 0;
  347. $okids = array();
  348. $dsql->SetQuery("SELECT {$idtype},typeid FROM `{$typeInfos['maintable']}` WHERE {$idtype} in($arcids) AND channel='{$typeInfos['channeltype']}' ");
  349. $dsql->Execute();
  350. while ($row = $dsql->GetArray()) {
  351. if ($row['typeid'] != $totype) {
  352. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
  353. $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['maintable']}` SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
  354. $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['addtable']}` SET typeid='$totype' WHERE aid='{$row[$idtype]}' ");
  355. $okids[] = $row[$idtype];
  356. $j++;
  357. }
  358. }
  359. //更新HTML
  360. foreach ($okids as $aid) {
  361. $arc = new Archives($aid);
  362. $arc->MakeHtml();
  363. }
  364. ShowMsg("成功移动 $j 个文档", $ENV_GOBACK_URL);
  365. exit();
  366. }
  367. }
  368. /*-----------------------------
  369. //还原文档
  370. function RbReturnArchives(){ }
  371. ------------------------------*/
  372. else if ($dopost == 'return') {
  373. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  374. require_once(DEDEINC."/libraries/oxwindow.class.php");
  375. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  376. if ($qstr == '') {
  377. ShowMsg("参数无效", "recycling.php");
  378. exit();
  379. }
  380. $qstrs = explode("`", $qstr);
  381. foreach ($qstrs as $aid) {
  382. $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET arcrank='-1',ismake='0' WHERE id='$aid'");
  383. $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET `arcrank` = '-1' WHERE id = '$aid'; ");
  384. }
  385. ShowMsg("成功还原指定的文档", "recycling.php");
  386. exit();
  387. }
  388. /*--------------------------
  389. //删除文档
  390. function delArchives(){ }
  391. ---------------------------*/
  392. else if ($dopost == "delArchives") {
  393. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  394. require_once(DEDEINC."/libraries/oxwindow.class.php");
  395. if (empty($fmdo)) $fmdo = '';
  396. if ($fmdo == 'yes') {
  397. if (!empty($aid) && empty($qstr)) {
  398. $qstr = $aid;
  399. }
  400. if ($qstr == '') {
  401. ShowMsg("参数无效", $ENV_GOBACK_URL);
  402. exit();
  403. }
  404. $qstrs = explode("`", $qstr);
  405. $okaids = array();
  406. foreach ($qstrs as $aid) {
  407. if (!isset($okaids[$aid])) {
  408. DelArc($aid);
  409. } else {
  410. $okaids[$aid] = 1;
  411. }
  412. }
  413. ShowMsg("成功删除指定的文档", $ENV_GOBACK_URL);
  414. exit();
  415. } else {
  416. $wintitle = "文档管理-删除文档";
  417. $wecome_info = "<a href='".$ENV_GOBACK_URL."'>文档管理</a>::删除文档";
  418. $win = new OxWindow();
  419. $win->Init("archives_do.php", "js/blank.js", "POST");
  420. $win->AddHidden("fmdo", "yes");
  421. $win->AddHidden("dopost", $dopost);
  422. $win->AddHidden("qstr", $qstr);
  423. $win->AddHidden("recycle", $recycle);
  424. $win->AddTitle("您确定要删除,序号 $qstr 文档");
  425. $winform = $win->GetWindow("ok");
  426. $win->Display();
  427. }
  428. }
  429. /*-----------------------------
  430. //清空文档
  431. function RbClearArchives(){ }
  432. ------------------------------*/
  433. else if ($dopost == 'clear') {
  434. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  435. require_once(DEDEINC."/libraries/oxwindow.class.php");
  436. if (empty($fmdo)) $fmdo = '';
  437. $recycle = empty($recycle) ? "" : $recycle;
  438. if ($fmdo == 'yes') {
  439. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  440. if ($qstr == '') {
  441. ShowMsg("参数无效", "recycling.php");
  442. exit();
  443. }
  444. $qstrs = explode(",", $qstr);
  445. $okaids = array();
  446. foreach ($qstrs as $qstr) {
  447. if (!isset($okaids[$qstr])) {
  448. DelArc($qstr, "OK", FALSE, $recycle);
  449. $okaids[$qstr] = $qstr;
  450. } else {
  451. $okaids[$qstr] = 1;
  452. }
  453. }
  454. ShowMsg("成功删除指定的文档", "recycling.php");
  455. exit();
  456. } else {
  457. $dsql->SetQuery("SELECT id FROM `#@__archives` WHERE `arcrank` = '-2'");
  458. $dsql->Execute();
  459. $qstr = '';
  460. while ($row = $dsql->GetArray()) {
  461. $qstr .= $row['id'].",";
  462. $aid = $row['id'];
  463. }
  464. $num = $dsql->GetTotalRow();
  465. if (empty($num)) {
  466. ShowMsg("对不起,未发现相关文档", "recycling.php");
  467. exit();
  468. }
  469. $wintitle = "文档管理-清空所有文档";
  470. $wecome_info = "<a href='recycling.php'>文档回收站</a>::清空所有文档";
  471. $win = new OxWindow();
  472. $win->Init("archives_do.php", "js/blank.js", "POST");
  473. $win->AddHidden("fmdo", "yes");
  474. $win->AddHidden("dopost", $dopost);
  475. $win->AddHidden("qstr", $qstr);
  476. $win->AddHidden("recycle", $recycle);
  477. $win->AddTitle("本次操作将清空回收站 $num 篇文档<br>您确定要删除,序号 $qstr 文档");
  478. $winform = $win->GetWindow("ok");
  479. $win->Display();
  480. }
  481. }
  482. /*-----------------------------
  483. //清除文档
  484. function RbDelArchives(){ }
  485. ------------------------------*/
  486. else if ($dopost == 'del') {
  487. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  488. require_once(DEDEINC."/libraries/oxwindow.class.php");
  489. if (empty($fmdo)) $fmdo = '';
  490. $recycle = empty($recycle) ? "" : $recycle;
  491. if ($fmdo == 'yes') {
  492. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  493. if ($qstr == '') {
  494. ShowMsg("参数无效", "recycling.php");
  495. exit();
  496. }
  497. $qstrs = explode("`", $qstr);
  498. $okaids = array();
  499. foreach ($qstrs as $aid) {
  500. if (!isset($okaids[$aid])) {
  501. DelArc($aid, "OK", "", $recycle);
  502. } else {
  503. $okaids[$aid] = 1;
  504. }
  505. }
  506. ShowMsg("成功删除指定的文档", "recycling.php");
  507. exit();
  508. } else {
  509. $wintitle = "文档管理-删除文档";
  510. $wecome_info = "<a href='recycling.php'>文档管理</a>::删除文档";
  511. $win = new OxWindow();
  512. $win->Init("archives_do.php", "js/blank.js", "POST");
  513. $win->AddHidden("fmdo", "yes");
  514. $win->AddHidden("dopost", $dopost);
  515. $win->AddHidden("qstr", $qstr);
  516. $win->AddHidden("recycle", $recycle);
  517. $win->AddTitle("您确定要删除,序号 $qstr 文档");
  518. $winform = $win->GetWindow("ok");
  519. $win->Display();
  520. }
  521. }
  522. /*-----------------------------
  523. //快速编辑
  524. function quickEdit(){ }
  525. ------------------------------*/
  526. else if ($dopost == 'quickEdit') {
  527. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  528. AjaxHead();
  529. $query = "SELECT ch.typename as channelname,ch.addtable,ar.membername as rankname,arc.*
  530. FROM `#@__archives` arc
  531. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  532. LEFT JOIN `#@__arcrank` ar ON ar.`rank`=arc.arcrank WHERE arc.id='$aid' ";
  533. $arcRow = $dsql->GetOne($query);
  534. $divname = 'quickEdit';
  535. echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">";
  536. echo "<div class='titLeft'>快速属性编辑</div>";
  537. echo "<div class='titRight'><img src='../static/web/img/ico-close.gif' style='cursor:pointer' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' title='关闭'></div>";
  538. echo "</div>";
  539. echo "<form name='quickeditform' action='archives_do.php?dopost=quickEditSave&aid={$aid}' method='post'>";
  540. echo "<input type='hidden' name='addtable' value='{$arcRow['addtable']}'>";
  541. echo "<input type='hidden' name='oldtypeid' value='{$arcRow['typeid']}'>";
  542. echo "<table width='100%' style='display:inline-block;z-index:9000'>";
  543. ?>
  544. <tr>
  545. <td width="86" height="26" class="bline">&nbsp;所属栏目:</td>
  546. <td class="bline">
  547. <?php
  548. $typeOptions = GetOptionList($arcRow['typeid'], $cuserLogin->getUserChannel(), $arcRow['channel']);
  549. echo "<select name='typeid' style='width:320px'>";
  550. if ($arcRow["typeid"] == "0") echo "<option value='0' selected>请选择栏目</option>";
  551. echo $typeOptions;
  552. echo "</select>";
  553. ?>
  554. </td>
  555. </tr>
  556. <tr>
  557. <td width="86" height="26" class="bline">&nbsp;属性:</td>
  558. <td class="bline">
  559. <input type="hidden" name="oldflag" value="<?php echo $arcRow['flag']; ?>">
  560. <?php
  561. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
  562. $dsql->Execute();
  563. while ($trow = $dsql->GetObject()) {
  564. if ($trow->att == 'j' || $trow->att == 'p') continue;
  565. if (preg_match("#".$trow->att."#", $arcRow['flag']))
  566. echo "<label><input class='np' type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}' checked='checked'>&nbsp;{$trow->attname}{$trow->att}[{$trow->att}]</label>&nbsp;";
  567. else
  568. echo "<label><input class='np' type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}'>&nbsp;{$trow->attname}[{$trow->att}]</label>&nbsp;";
  569. }
  570. ?>
  571. </td>
  572. </tr>
  573. <tr>
  574. <td width="86" height="26" class="bline">&nbsp;标题:</td>
  575. <td class="bline"><input name="title" type="text" id="title" value="<?php echo $arcRow['title']; ?>" style="width:320px"></td>
  576. </tr>
  577. <tr>
  578. <td width="86" height="26" class="bline">&nbsp;简略标题:</td>
  579. <td class="bline"><input name="shorttitle" type="text" id="shorttitle" value="<?php echo $arcRow['shorttitle']; ?>" style="width:320px"></td>
  580. </tr>
  581. <tr>
  582. <td width="86" height="26" class="bline">&nbsp;阅读权限:</td>
  583. <td class="bline">
  584. <select name="arcrank" id="arcrank" style="width:100px">
  585. <option value='<?php echo $arcRow["arcrank"] ?>'>
  586. <?php echo $arcRow["rankname"] ?> </option>
  587. <?php
  588. $urank = $cuserLogin->getUserRank();
  589. $dsql->SetQuery("SELECT * FROM `#@__arcrank` WHERE adminrank<='$urank'");
  590. $dsql->Execute();
  591. while ($row = $dsql->GetObject()) {
  592. echo "<option value='".$row->rank."'>".$row->membername."</option>";
  593. }
  594. ?>
  595. </select>
  596. 需要金币:<input name="money" type="text" id="money" value="<?php echo $arcRow["money"]; ?>" style="width:100px">
  597. </td>
  598. </tr>
  599. <tr>
  600. <td width="86" height="26" class="bline">&nbsp;关键词:</td>
  601. <td class="bline"><input name="keywords" type="text" id="keywords" value="<?php echo $arcRow['keywords']; ?>" style="width:320px"></td>
  602. </tr>
  603. <tr>
  604. <td colspan="2" align="center" class="py-3">
  605. <button type="submit" class="btn btn-success btn-sm">保存</button>
  606. <button type="button" onclick="HideObj('<?php echo $divname; ?>');ChangeFullDiv('hide');" class="btn btn-success btn-sm">关闭</button>
  607. </td>
  608. </tr>
  609. </table>
  610. </form>
  611. <?php
  612. //AJAX窗体结束
  613. }
  614. /*-----------------------------
  615. //保存快速编辑的内容
  616. function quickEditSave(){ }
  617. ------------------------------*/
  618. else if ($dopost == 'quickEditSave') {
  619. require_once(DEDEADMIN.'/inc/inc_archives_functions.php');
  620. //权限检测
  621. if (!TestPurview('a_Edit')) {
  622. if (TestPurview('a_AccEdit')) {
  623. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的文档权限");
  624. } else {
  625. CheckArcAdmin($aid, $cuserLogin->getUserID());
  626. }
  627. }
  628. $title = dede_htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
  629. $shorttitle = cn_substrR($shorttitle, 36);
  630. $keywords = trim(cn_substrR($keywords, 60));
  631. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  632. $adminid = $cuserLogin->getUserID();
  633. //属性处理
  634. $flag = isset($flags) ? join(',', $flags) : '';
  635. if (!empty($flag)) {
  636. if (preg_match("#p#", $oldflag)) $flag .= ',p';
  637. if (preg_match("#j#", $oldflag)) $flag .= ',j';
  638. }
  639. $query = "UPDATE `#@__archives` SET
  640. typeid = '$typeid',
  641. flag = '$flag',
  642. arcrank = '$arcrank',
  643. money = '$money',
  644. title = '$title',
  645. shorttitle = '$shorttitle',
  646. keywords = '$keywords',
  647. dutyadmin = '$adminid'
  648. WHERE id = '$aid'; ";
  649. //更新主表
  650. $dsql->ExecuteNoneQuery($query);
  651. //更新微表
  652. $dsql->ExecuteNoneQuery(" UPDATE `#@__arctiny` SET typeid='$typeid',arcrank='$arcrank' WHERE id='$aid' ");
  653. //更新附加表
  654. if ($typeid != $oldtypeid) {
  655. $addtable = trim($addtable);
  656. if (empty($addtable)) $addtable = '#@__addonarticle';
  657. else $addtable = preg_replace("#[^a-z0-9__#@-]#i", "", $addtable);
  658. $dsql->ExecuteNoneQuery(" UPDATE `$addtable` SET typeid='$typeid' WHERE aid='$aid' ");
  659. }
  660. //更新HTML
  661. $artUrl = MakeArt($aid, TRUE, TRUE);
  662. $backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : '-1';
  663. ShowMsg('成功更新一篇文档的基本信息', $backurl);
  664. exit();
  665. }
  666. /*--------------------------
  667. 分析并自动获取文档关键词
  668. function makekw(){ }
  669. --------------------------*/
  670. else if ($dopost == "makekw") {
  671. CheckPurview('a_Commend,sys_ArcBatch');
  672. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  673. if ($qstr == '') {
  674. ShowMsg("参数无效", $ENV_GOBACK_URL);
  675. exit();
  676. }
  677. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  678. $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 ";
  679. $dsql->SetQuery($query);
  680. $dsql->Execute();
  681. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  682. $client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port);
  683. $client->appid = $cfg_bizcore_appid;
  684. $client->key = $cfg_bizcore_key;
  685. while ($row = $dsql->GetArray()) {
  686. //跳过已经有关键词的内容
  687. if (trim($row['keywords']) != '') continue;
  688. $aid = $row['id'];
  689. $keywords = '';
  690. $title = $row['title'];
  691. $description = $row['description'];
  692. $body = cn_substr($row['body'], 5000);
  693. $data = $client->Spliteword($title.Html2Text($body));
  694. $keywords = $data->data;
  695. $description = str_replace(' ', ' ', trim($description));
  696. $description = str_replace('[', ' ', $description);
  697. $description = str_replace(']', ' ', $description);
  698. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  699. $description = str_replace('关键词', '', $description);
  700. $description = str_replace('关键词', '', $description);
  701. $description = addslashes($description);
  702. $dsql->ExecuteNoneQuery(" UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  703. }
  704. $client->Close();
  705. } else {
  706. include_once(DEDEINC.'/libraries/splitword.class.php');
  707. $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
  708. while ($row = $dsql->GetArray()) {
  709. //跳过已经有关键词的内容
  710. if (trim($row['keywords']) != '') continue;
  711. $aid = $row['id'];
  712. $keywords = '';
  713. $title = $row['title'];
  714. $description = $row['description'];
  715. $body = cn_substr($row['body'], 5000);
  716. $sp->SetSource($title, $cfg_soft_lang, $cfg_soft_lang);
  717. $sp->StartAnalysis();
  718. $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  719. $sp->SetSource(Html2Text($body), $cfg_soft_lang, $cfg_soft_lang);
  720. $sp->StartAnalysis();
  721. $allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());
  722. if (is_array($allindexs) && is_array($titleindexs)) {
  723. foreach ($titleindexs as $k => $v) {
  724. if (strlen($keywords.$k) >= 60) {
  725. break;
  726. } else {
  727. if (strlen($k) <= 2) continue;
  728. $keywords .= $k.',';
  729. }
  730. }
  731. foreach ($allindexs as $k => $v) {
  732. if (strlen($keywords.$k) >= 60) {
  733. break;
  734. } else if (!in_array($k, $titleindexs)) {
  735. if (strlen($k) <= 2) continue;
  736. $keywords .= $k.',';
  737. }
  738. }
  739. }
  740. $description = str_replace(' ', ' ', trim($description));
  741. $description = str_replace('[', ' ', $description);
  742. $description = str_replace(']', ' ', $description);
  743. $description = preg_replace("#[ \t]{1,}#is", ' ', $description);
  744. $description = str_replace('关键词', '', $description);
  745. $description = str_replace('关键词', '', $description);
  746. $description = addslashes($description);
  747. $dsql->ExecuteNoneQuery(" UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description' WHERE id='{$aid}' ");
  748. }
  749. $sp = null;
  750. }
  751. ShowMsg("成功分析指定文档的关键词", $ENV_GOBACK_URL);
  752. exit();
  753. }
  754. /*--------------------------
  755. //批量增加属性
  756. function attsAdd(){ }
  757. ---------------------------*/
  758. else if ($dopost == 'attsAdd') {
  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
  771. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  772. LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
  773. WHERE arc.id in($arcids) ";
  774. $dsql->SetQuery($query);
  775. $dsql->Execute();
  776. while ($row = $dsql->GetArray()) {
  777. $aid = $row['id'];
  778. if ($row['issystem'] != -1) {
  779. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  780. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  781. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  782. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE id='{$aid}' ");
  783. } else {
  784. $maintable = trim($row['addtable']);
  785. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  786. $flag = ($arr['flag'] == '' ? $flagname : $arr['flag'].','.$flagname);
  787. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE aid='{$aid}' ");
  788. }
  789. }
  790. ShowMsg("成功对选中文档增加指定的属性", $ENV_GOBACK_URL);
  791. exit();
  792. }
  793. /*--------------------------
  794. //批量删除属性
  795. function attsDel(){ }
  796. ---------------------------*/
  797. else if ($dopost == 'attsDel') {
  798. CheckPurview('a_Commend,sys_ArcBatch');
  799. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  800. if ($qstr == '') {
  801. ShowMsg("参数无效", $ENV_GOBACK_URL);
  802. exit();
  803. }
  804. if (empty($flagname)) {
  805. ShowMsg("必须指定要删除的属性", $ENV_GOBACK_URL);
  806. exit();
  807. }
  808. $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
  809. $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
  810. LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
  811. LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
  812. WHERE arc.id in($arcids) ";
  813. $dsql->SetQuery($query);
  814. $dsql->Execute();
  815. while ($row = $dsql->GetArray()) {
  816. $aid = $row['id'];
  817. if ($row['issystem'] != -1) {
  818. $idname = 'id';
  819. $maintable = (trim($row['maintable']) == '' ? '#@__archives' : trim($row['maintable']));
  820. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
  821. } else {
  822. $idname = 'aid';
  823. $maintable = trim($row['addtable']);
  824. $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
  825. }
  826. $flag = $arr['flag'];
  827. if (trim($flag) == '' || !preg_match("#".$flagname."#", $flag)) {
  828. continue;
  829. } else {
  830. $flags = explode(',', $flag);
  831. $okflags = array();
  832. foreach ($flags as $f) {
  833. if ($f != $flagname) $okflags[] = $f;
  834. }
  835. }
  836. $flag = trim(join(',', $okflags));
  837. $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE {$idname}='{$aid}' ");
  838. }
  839. ShowMsg("成功对选中文档删除指定的属性", $ENV_GOBACK_URL);
  840. exit();
  841. }
  842. /*--------------------------
  843. //获得批量属性处理的AJAX窗体
  844. function attsDlg(){ }
  845. ---------------------------*/
  846. else if ($dopost == 'attsDlg') {
  847. if (!empty($aid) && empty($qstr)) $qstr = $aid;
  848. $dojobname = ($dojob == 'attsDel' ? '批量删除属性' : '批量增加属性');
  849. AjaxHead();
  850. //输出AJAX可移动窗体
  851. $divname = 'attsDlg';
  852. echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">";
  853. echo "<div class='titLeft'>{$dojobname}</div>";
  854. echo "<div class='titRight'><img src='../static/web/img/ico-close.gif' style='cursor:pointer' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' title='关闭'></div>";
  855. echo "</div>";
  856. echo "<form name='quickeditform' action='archives_do.php' method='post'>";
  857. echo "<input type='hidden' name='dopost' value='{$dojob}'>";
  858. echo "<input type='hidden' name='qstr' value='{$qstr}'>";
  859. echo "<table width='100%' style='display:inline-block;z-index:9000'>";
  860. ?>
  861. <tr>
  862. <td width="86" height="26" class="bline">&nbsp;属性:</td>
  863. <td class="bline">
  864. <input type='hidden' name='oldflag' value='<?php echo $arcRow['flag']; ?>'>
  865. <?php
  866. $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
  867. $dsql->Execute();
  868. while ($trow = $dsql->GetObject()) {
  869. if ($trow->att == 'j' || $trow->att == 'p') continue;
  870. echo "<label><input class='np' type='radio' name='flagname' id='flags{$trow->att}' value='{$trow->att}'>&nbsp;{$trow->attname}[{$trow->att}]</label>&nbsp;";
  871. }
  872. ?>
  873. </td>
  874. </tr>
  875. <tr>
  876. <td width="86" height="26" class="bline">&nbsp;文档ID:</td>
  877. <td class="bline"><input type="text" name="tmpids" value="<?php echo $qstr; ?>" style='width:320px;overflow:hidden'></td>
  878. </tr>
  879. <tr>
  880. <td colspan="2" align="center" class="py-3">
  881. <button type="submit" class="btn btn-success btn-sm">保存</button>
  882. <button type="button" onclick="HideObj('<?php echo $divname; ?>');ChangeFullDiv('hide');" class="btn btn-success btn-sm">关闭</button>
  883. </td>
  884. </tr>
  885. </table>
  886. </form>
  887. <?php
  888. //AJAX窗体结束
  889. }
  890. /*------------------------
  891. function getCatMap() { }
  892. -------------------------*/
  893. else if ($dopost == 'getCatMap') {
  894. require_once(DEDEINC.'/typelink/typeunit.class.selector.php');
  895. AjaxHead();
  896. //输出AJAX可移动窗体
  897. $divname = 'getCatMap';
  898. echo "<div class='title' style='cursor:default'>";
  899. echo "<div class='titLeft'>栏目快速选择器</div>";
  900. echo "<div class='titRight'><img src='../static/web/img/ico-close.gif' style='cursor:pointer' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' title='关闭'></div>";
  901. echo "</div>";
  902. $tus = new TypeUnitSelector();
  903. ?>
  904. <form name="quicksel" action="javascript:;" method="get">
  905. <div class="quicksel"><?php $tus->ListAllType($channelid); ?></div>
  906. <div align="center" class="quickselfoot">
  907. <button onclick="getSelCat('<?php echo $targetid; ?>');" class="btn btn-success btn-sm">保存</button>
  908. <button type="button" onclick="HideObj('<?php echo $divname; ?>');ChangeFullDiv('hide');" class="btn btn-success btn-sm">关闭</button>
  909. </div>
  910. </form>
  911. <?php
  912. //AJAX窗体结束
  913. }
  914. ?>