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

812 line
35KB

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