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

421 lines
16KB

  1. <?php
  2. /**
  3. * 图集编辑
  4. *
  5. * @version $Id: album_edit.php 1 8:26 2010年7月12日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2021, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__) . "/config.php");
  12. CheckPurview('a_Edit,a_AccEdit,a_MyEdit');
  13. require_once(DEDEINC . "/customfields.func.php");
  14. require_once(DEDEADMIN . "/inc/inc_archives_functions.php");
  15. if (empty($dopost)) $dopost = '';
  16. if ($dopost != 'save') {
  17. require_once(DEDEADMIN . "/inc/inc_catalog_options.php");
  18. require_once(DEDEINC . "/dedetag.class.php");
  19. ClearMyAddon();
  20. $aid = intval($aid);
  21. //读取归档信息
  22. $arcQuery = "SELECT ch.typename as channelname,ar.membername as rankname,arc.*
  23. FROM `#@__archives` arc
  24. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  25. LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id='$aid' ";
  26. $arcRow = $dsql->GetOne($arcQuery);
  27. if (!is_array($arcRow)) {
  28. ShowMsg("读取档案基本信息出错!", "-1");
  29. exit();
  30. }
  31. $query = "SELECT * FROM `#@__channeltype` WHERE id='" . $arcRow['channel'] . "'";
  32. $cInfos = $dsql->GetOne($query);
  33. if (!is_array($cInfos)) {
  34. ShowMsg("读取频道配置信息出错!", "javascript:;");
  35. exit();
  36. }
  37. $addtable = $cInfos['addtable'];
  38. $addRow = $dsql->GetOne("SELECT * FROM `$addtable` WHERE aid='$aid'");
  39. $channelid = $arcRow['channel'];
  40. $imgurls = $addRow["imgurls"];
  41. $maxwidth = $addRow["maxwidth"];
  42. $pagestyle = $addRow["pagestyle"];
  43. $irow = $addRow["row"];
  44. $icol = $addRow["col"];
  45. $isrm = $addRow["isrm"];
  46. $body = $addRow["body"];
  47. $ddmaxwidth = $addRow["ddmaxwidth"];
  48. $pagepicnum = $addRow["pagepicnum"];
  49. $tags = GetTags($aid);
  50. $arcRow = XSSClean($arcRow);
  51. $addRow = XSSClean($addRow);
  52. include DedeInclude("templets/album_edit.htm");
  53. exit();
  54. }
  55. /*--------------------------------
  56. function __save(){ }
  57. -------------------------------*/ else if ($dopost == 'save') {
  58. require_once(DEDEINC . '/image.func.php');
  59. require_once(DEDEINC . '/oxwindow.class.php');
  60. $flag = isset($flags) ? join(',', $flags) : '';
  61. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  62. if (empty($typeid2)) $typeid2 = 0;
  63. if (!isset($autokey)) $autokey = 0;
  64. if (!isset($remote)) $remote = 0;
  65. if (!isset($dellink)) $dellink = 0;
  66. if (!isset($autolitpic)) $autolitpic = 0;
  67. if (!isset($formhtml)) $formhtml = 0;
  68. if (!isset($albums)) $albums = "";
  69. if (!isset($formzip)) $formzip = 0;
  70. if (!isset($ddisfirst)) $ddisfirst = 0;
  71. if (!isset($delzip)) $delzip = 0;
  72. if ($typeid == 0) {
  73. ShowMsg("请指定文档的栏目!", "-1");
  74. exit();
  75. }
  76. if (empty($channelid)) {
  77. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!", "-1");
  78. exit();
  79. }
  80. if (!CheckChannel($typeid, $channelid)) {
  81. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!", "-1");
  82. exit();
  83. }
  84. if (!TestPurview('a_Edit')) {
  85. if (TestPurview('a_AccEdit')) {
  86. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的文档权限!");
  87. } else {
  88. CheckArcAdmin($id, $cuserLogin->getUserID());
  89. }
  90. }
  91. //对保存的内容进行处理
  92. $pubdate = GetMkTime($pubdate);
  93. $sortrank = AddDay($pubdate, $sortup);
  94. $ismake = $ishtml == 0 ? -1 : 0;
  95. $title = cn_substrR($title, $cfg_title_maxlen);
  96. $shorttitle = cn_substrR($shorttitle, 36);
  97. $color = cn_substrR($color, 7);
  98. $writer = cn_substrR($writer, 20);
  99. $source = cn_substrR($source, 30);
  100. $description = cn_substrR($description, 250);
  101. $keywords = trim(cn_substrR($keywords, 60));
  102. $filename = trim(cn_substrR($filename, 40));
  103. $isremote = 0;
  104. $serviterm = empty($serviterm) ? "" : $serviterm;
  105. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  106. $arcrank = -1;
  107. }
  108. $adminid = $cuserLogin->getUserID();
  109. //处理上传的缩略图
  110. if (empty($ddisremote)) {
  111. $ddisremote = 0;
  112. }
  113. $litpic = GetDDImage('none', $picname, $ddisremote);
  114. // 处理新的缩略图上传
  115. if ($litpic_b64 != "") {
  116. $data = explode(',', $litpic_b64);
  117. $ntime = time();
  118. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  119. CreateDir($savepath);
  120. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  121. $fullUrl = $fullUrl . ".png";
  122. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  123. // 加水印
  124. WaterImg($cfg_basedir . $fullUrl, 'up');
  125. $litpic = $fullUrl;
  126. }
  127. //分析body里的内容
  128. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  129. //处理图片文档的自定义属性
  130. if ($litpic != '' && !preg_match("#p#", $flag)) {
  131. $flag = ($flag == '' ? 'p' : $flag . ',p');
  132. }
  133. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  134. $flag = ($flag == '' ? 'j' : $flag . ',j');
  135. }
  136. //跳转网址的文档强制为动态
  137. if (preg_match("#j#", $flag)) $ismake = -1;
  138. //更新数据库的SQL语句
  139. $query = "
  140. UPDATE `#@__archives` SET
  141. typeid='$typeid',
  142. typeid2='$typeid2',
  143. sortrank='$sortrank',
  144. flag='$flag',
  145. click='$click',
  146. ismake='$ismake',
  147. arcrank='$arcrank',
  148. money='$money',
  149. title='$title',
  150. color='$color',
  151. source='$source',
  152. writer='$writer',
  153. litpic='$litpic',
  154. pubdate='$pubdate',
  155. notpost='$notpost',
  156. description='$description',
  157. keywords='$keywords',
  158. shorttitle='$shorttitle',
  159. filename='$filename',
  160. dutyadmin='$adminid'
  161. WHERE id='$id'; ";
  162. if (!$dsql->ExecuteNoneQuery($query)) {
  163. ShowMsg("更新数据库archives表时出错,请检查!" . $dsql->GetError(), "javascript:;");
  164. exit();
  165. }
  166. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$row' col='$col' value='$pagestyle'/}\r\n";
  167. $hasone = false;
  168. //----------------------------------------
  169. //检查旧的图片是否有更新,并保存
  170. //-----------------------------------------
  171. for ($i = 1; $i <= 120; $i++) {
  172. if (!isset(${'imgurl' . $i})) continue;
  173. $info = '';
  174. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg' . $i}));
  175. $iurl = stripslashes(${'imgurl' . $i});
  176. $ddurl = stripslashes(${'imgddurl' . $i});
  177. if (preg_match("#swfupload#i", $ddurl)) $ddurl = '';
  178. $imgfile = $cfg_basedir . $iurl;
  179. $litimgfile = $cfg_basedir . $ddurl;
  180. //有上传文件的情况
  181. if (isset(${'imgfile' . $i}) && is_uploaded_file(${'imgfile' . $i})) {
  182. $tmpFile = ${'imgfile' . $i};
  183. //检测上传的图片, 如果类型不对,保留原来图片
  184. $imginfos = @GetImageSize($tmpFile, $info);
  185. if (!is_array($imginfos)) {
  186. $imginfos = @GetImageSize($imgfile, $info);
  187. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} $iurl {/dede:img}\r\n";
  188. continue;
  189. }
  190. move_uploaded_file($tmpFile, $imgfile);
  191. $imginfos = @GetImageSize($imgfile, $info);
  192. if ($ddurl == $iurl) {
  193. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  194. $litimgfile = $cfg_basedir . $litpicname;
  195. } else {
  196. if ($cfg_ddimg_full == 'Y') ImageResizeNew($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  197. else ImageResize($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  198. $litpicname = $ddurl;
  199. }
  200. $imgurls .= "{dede:img ddimg='$litpicname' text='$iinfo' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} $iurl {/dede:img}\r\n";
  201. }
  202. //没上传图片(只修改msg信息)
  203. else {
  204. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg' . $i}));
  205. $iurl = stripslashes(${'imgurl' . $i});
  206. $ddurl = stripslashes(${'imgddurl' . $i});
  207. if (preg_match("#swfupload#i", $ddurl)) {
  208. $ddurl = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  209. }
  210. $imginfos = @GetImageSize($imgfile, $info);
  211. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} $iurl {/dede:img}\r\n";
  212. }
  213. }
  214. //----------------------------
  215. //从HTML中获取新图片
  216. //----------------------------
  217. if ($formhtml == 1 && !empty($imagebody)) {
  218. $imagebody = stripslashes($imagebody);
  219. $imgurls .= GetCurContentAlbum($imagebody, $copysource, $litpicname);
  220. if ($ddisfirst == 1 && $litpic == "" && !empty($litpicname)) {
  221. $litpic = $litpicname;
  222. $hasone = true;
  223. }
  224. }
  225. /*---------------------
  226. function _getformzip()
  227. 从ZIP文件中获取新图片
  228. ---------------------*/
  229. if ($formzip == 1) {
  230. include_once(DEDEINC . "/zip.class.php");
  231. include_once(DEDEADMIN . "/file_class.php");
  232. $zipfile = $cfg_basedir . str_replace($cfg_mainsite, '', $zipfile);
  233. $tmpzipdir = DEDEDATA . '/ziptmp/' . cn_substr(md5(ExecTime()), 16);
  234. $ntime = time();
  235. if (file_exists($zipfile)) {
  236. @mkdir($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  237. @chmod($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  238. $z = new zip();
  239. $z->ExtractAll($zipfile, $tmpzipdir);
  240. $fm = new FileManagement();
  241. $imgs = array();
  242. $fm->GetMatchFiles($tmpzipdir, "jpg|png|gif", $imgs);
  243. $i = 0;
  244. foreach ($imgs as $imgold) {
  245. $i++;
  246. $savepath = $cfg_image_dir . "/" . MyDate("Y-m", $ntime);
  247. CreateDir($savepath);
  248. $iurl = $savepath . "/" . MyDate("d", $ntime) . dd2char(MyDate("His", $ntime) . '-' . $adminid . "-{$i}" . mt_rand(1000, 9999));
  249. $iurl = $iurl . substr($imgold, -4, 4);
  250. $imgfile = $cfg_basedir . $iurl;
  251. copy($imgold, $imgfile);
  252. unlink($imgold);
  253. if (is_file($imgfile)) {
  254. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  255. $info = '';
  256. $imginfos = GetImageSize($imgfile, $info);
  257. $imgurls .= "{dede:img ddimg='$litpicname' text='' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} $iurl {/dede:img}\r\n";
  258. //把图片信息保存到媒体文档管理档案中
  259. $inquery = "
  260. INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  261. VALUES ('{$title}','{$iurl}','1','" . $imginfos[0] . "','" . $imginfos[1] . "','0','" . filesize($imgfile) . "','" . $ntime . "','$adminid');
  262. ";
  263. $dsql->ExecuteNoneQuery($inquery);
  264. if (
  265. !$hasone && $ddisfirst == 1
  266. && $litpic == "" && !empty($litpicname)
  267. ) {
  268. if (file_exists($cfg_basedir . $litpicname)) {
  269. $litpic = $litpicname;
  270. $hasone = true;
  271. }
  272. }
  273. }
  274. }
  275. if ($delzip == 1) {
  276. unlink($zipfile);
  277. }
  278. $fm->RmDirFiles($tmpzipdir);
  279. }
  280. }
  281. if ($albums !== "") {
  282. $albumsArr = json_decode(stripslashes($albums), true);
  283. // var_dump($albumsArr);exit;
  284. for ($i = 0; $i <= count($albumsArr) - 1; $i++) {
  285. $album = $albumsArr[$i];
  286. $data = explode(',', $album['img']);
  287. $ntime = time();
  288. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  289. CreateDir($savepath);
  290. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  291. $fullUrl = $fullUrl . ".png";
  292. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  293. $info = '';
  294. $imginfos = GetImageSize($cfg_basedir . $fullUrl, $info);
  295. $v = $fullUrl;
  296. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  297. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} $v {/dede:img}\r\n";
  298. }
  299. }
  300. $imgurls = addslashes($imgurls);
  301. //分析处理附加表数据
  302. $inadd_f = '';
  303. $inadd_v = '';
  304. if (!empty($dede_addonfields)) {
  305. $addonfields = explode(';', $dede_addonfields);
  306. $inadd_f = '';
  307. $inadd_v = '';
  308. if (is_array($addonfields)) {
  309. foreach ($addonfields as $v) {
  310. if ($v == '') {
  311. continue;
  312. }
  313. $vs = explode(',', $v);
  314. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  315. {
  316. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  317. } else {
  318. if (!isset(${$vs[0]})) {
  319. ${$vs[0]} = '';
  320. }
  321. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  322. }
  323. $inadd_f .= ",`{$vs[0]}` = '" . ${$vs[0]} . "'";
  324. }
  325. }
  326. }
  327. //更新附加表
  328. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  329. $addtable = trim($cts['addtable']);
  330. if ($addtable != '') {
  331. $useip = GetIP();
  332. $query = "Update `$addtable`
  333. set typeid='$typeid',
  334. pagestyle='$pagestyle',
  335. body='$body',
  336. maxwidth = '$maxwidth',
  337. ddmaxwidth = '$ddmaxwidth',
  338. pagepicnum = '$pagepicnum',
  339. imgurls='$imgurls',
  340. `row`='$row',
  341. col='$col',
  342. isrm='$isrm'{$inadd_f},
  343. redirecturl='$redirecturl',
  344. userip = '$useip'
  345. WHERE aid='$id'; ";
  346. if (!$dsql->ExecuteNoneQuery($query)) {
  347. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因!" . $dsql->GetError(), "javascript:;");
  348. exit();
  349. }
  350. }
  351. //生成HTML
  352. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  353. $arcUrl = MakeArt($id, true, true, $isremote);
  354. if ($arcUrl == '') {
  355. $arcUrl = $cfg_phpurl . "/view.php?aid=$id";
  356. }
  357. ClearMyAddon($id, $title);
  358. // 自动更新关联内容
  359. if (is_array($automake)) {
  360. foreach ($automake as $key => $value) {
  361. if (isset(${$key}) && !empty(${$key})) {
  362. $ids = explode(",", ${$key});
  363. foreach ($ids as $id) {
  364. MakeArt($id, true, true, $isremote);
  365. }
  366. }
  367. }
  368. }
  369. //返回成功信息
  370. $msg =
  371. "   请选择你的后续操作:
  372. <a href='album_add.php?cid=$typeid' class='btn btn-success btn-sm'>继续发布图片</a>
  373. &nbsp;&nbsp;
  374. <a href='archives_do.php?aid=" . $id . "&dopost=editArchives' class='btn btn-success btn-sm'>查看更改</a>
  375. &nbsp;&nbsp;
  376. <a href='$arcUrl' target='_blank' class='btn btn-success btn-sm'>预览文档</a>
  377. &nbsp;&nbsp;
  378. <a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-success btn-sm'>管理已发布图片</a>
  379. &nbsp;&nbsp;
  380. $backurl
  381. ";
  382. $wintitle = "成功更改图集!";
  383. $wecome_info = "文章管理::更改图集";
  384. $win = new OxWindow();
  385. $win->AddTitle("成功更改一个图集:");
  386. $win->AddMsgItem($msg);
  387. $winform = $win->GetWindow("hand", "&nbsp;", false);
  388. $win->Display();
  389. }