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

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