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

378 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. -------------------------------*/
  58. else if ($dopost == 'save') {
  59. require_once(DEDEINC.'/image.func.php');
  60. require_once(DEDEINC.'/oxwindow.class.php');
  61. $flag = isset($flags) ? join(',', $flags) : '';
  62. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  63. if (empty($typeid2)) $typeid2 = 0;
  64. if (!isset($autokey)) $autokey = 0;
  65. if (!isset($remote)) $remote = 0;
  66. if (!isset($dellink)) $dellink = 0;
  67. if (!isset($autolitpic)) $autolitpic = 0;
  68. if (!isset($formhtml)) $formhtml = 0;
  69. if (!isset($albums)) $albums = "";
  70. if (!isset($formzip)) $formzip = 0;
  71. if (!isset($ddisfirst)) $ddisfirst = 0;
  72. if (!isset($delzip)) $delzip = 0;
  73. if ($typeid == 0) {
  74. ShowMsg("请指定文档的栏目", "-1");
  75. exit();
  76. }
  77. if (empty($channelid)) {
  78. ShowMsg("文档为非指定的类型,请检查您发布内容的表单是否合法", "-1");
  79. exit();
  80. }
  81. if (!CheckChannel($typeid, $channelid)) {
  82. ShowMsg("您所选择的栏目与当前模型不相符,请选择白色的选项", "-1");
  83. exit();
  84. }
  85. if (!TestPurview('a_Edit')) {
  86. if (TestPurview('a_AccEdit')) {
  87. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的文档权限");
  88. } else {
  89. CheckArcAdmin($id, $cuserLogin->getUserID());
  90. }
  91. }
  92. //对保存的内容进行处理
  93. $pubdate = GetMkTime($pubdate);
  94. $sortrank = AddDay($pubdate, $sortup);
  95. $ismake = $ishtml == 0 ? -1 : 0;
  96. $title = cn_substrR($title, $cfg_title_maxlen);
  97. $shorttitle = cn_substrR($shorttitle, 36);
  98. $color = cn_substrR($color, 7);
  99. $writer = cn_substrR($writer, 20);
  100. $source = cn_substrR($source, 30);
  101. $description = cn_substrR($description, 250);
  102. $keywords = trim(cn_substrR($keywords, 60));
  103. $filename = trim(cn_substrR($filename, 40));
  104. $isremote = 0;
  105. $serviterm = empty($serviterm) ? "" : $serviterm;
  106. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  107. $arcrank = -1;
  108. }
  109. $adminid = $cuserLogin->getUserID();
  110. //处理上传的缩略图
  111. if (empty($ddisremote)) {
  112. $ddisremote = 0;
  113. }
  114. $litpic = GetDDImage('none', $picname, $ddisremote);
  115. // 处理新的缩略图上传
  116. if ($litpic_b64 != "") {
  117. $data = explode(',', $litpic_b64);
  118. $ntime = time();
  119. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  120. CreateDir($savepath);
  121. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  122. $fullUrl = $fullUrl.".png";
  123. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  124. //加水印
  125. WaterImg($cfg_basedir.$fullUrl, 'up');
  126. $litpic = $fullUrl;
  127. }
  128. //分析body里的内容
  129. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  130. //处理图片文档的自定义属性
  131. if ($litpic != '' && !preg_match("#p#", $flag)) {
  132. $flag = ($flag == '' ? 'p' : $flag.',p');
  133. }
  134. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  135. $flag = ($flag == '' ? 'j' : $flag.',j');
  136. }
  137. //跳转网址的文档强制为动态
  138. if (preg_match("#j#", $flag)) $ismake = -1;
  139. //更新数据库的SQL语句
  140. $query = "
  141. UPDATE `#@__archives` SET
  142. typeid='$typeid',
  143. typeid2='$typeid2',
  144. sortrank='$sortrank',
  145. flag='$flag',
  146. click='$click',
  147. ismake='$ismake',
  148. arcrank='$arcrank',
  149. money='$money',
  150. title='$title',
  151. color='$color',
  152. source='$source',
  153. writer='$writer',
  154. litpic='$litpic',
  155. pubdate='$pubdate',
  156. notpost='$notpost',
  157. description='$description',
  158. keywords='$keywords',
  159. shorttitle='$shorttitle',
  160. filename='$filename',
  161. dutyadmin='$adminid'
  162. WHERE id='$id'; ";
  163. if (!$dsql->ExecuteNoneQuery($query)) {
  164. ShowMsg("更新数据库archives表时出错,请检查".$dsql->GetError(), "javascript:;");
  165. exit();
  166. }
  167. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$row' col='$col' value='$pagestyle'/}\r\n";
  168. $hasone = false;
  169. //----------------------------------------
  170. //检查旧的图片是否有更新,并保存
  171. //-----------------------------------------
  172. for ($i = 1; $i <= 120; $i++) {
  173. if (!isset(${'imgurl'.$i})) continue;
  174. $info = '';
  175. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg'.$i}));
  176. $iurl = stripslashes(${'imgurl'.$i});
  177. $ddurl = stripslashes(${'imgddurl'.$i});
  178. if (preg_match("#swfupload#i", $ddurl)) $ddurl = '';
  179. $imgfile = $cfg_basedir.$iurl;
  180. $litimgfile = $cfg_basedir.$ddurl;
  181. //有上传文件的情况
  182. if (isset(${'imgfile'.$i}) && is_uploaded_file(${'imgfile'.$i})) {
  183. $tmpFile = ${'imgfile'.$i};
  184. //检测上传的图片, 如果类型不对,保留原来图片
  185. $imginfos = @GetImageSize($tmpFile, $info);
  186. if (!is_array($imginfos)) {
  187. $imginfos = @GetImageSize($imgfile, $info);
  188. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  189. continue;
  190. }
  191. move_uploaded_file($tmpFile, $imgfile);
  192. $imginfos = @GetImageSize($imgfile, $info);
  193. if ($ddurl == $iurl) {
  194. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  195. $litimgfile = $cfg_basedir.$litpicname;
  196. } else {
  197. if ($cfg_ddimg_full == 'Y') ImageResizeNew($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  198. else ImageResize($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  199. $litpicname = $ddurl;
  200. }
  201. $imgurls .= "{dede:img ddimg='$litpicname' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  202. }
  203. //没上传图片(只修改msg信息)
  204. else {
  205. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg'.$i}));
  206. $iurl = stripslashes(${'imgurl'.$i});
  207. $ddurl = stripslashes(${'imgddurl'.$i});
  208. if (preg_match("#swfupload#i", $ddurl)) {
  209. $ddurl = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  210. }
  211. $imginfos = @GetImageSize($imgfile, $info);
  212. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  213. }
  214. }
  215. //----------------------------
  216. //从HTML中获取新图片
  217. //----------------------------
  218. if ($formhtml == 1 && !empty($imagebody)) {
  219. $imagebody = stripslashes($imagebody);
  220. $imgurls .= GetCurContentAlbum($imagebody, $copysource, $litpicname);
  221. if ($ddisfirst == 1 && $litpic == "" && !empty($litpicname)) {
  222. $litpic = $litpicname;
  223. $hasone = true;
  224. }
  225. }
  226. /*---------------------
  227. function _getformzip()
  228. 从ZIP文件中获取新图片
  229. ---------------------*/
  230. if ($formzip == 1) {
  231. include_once(DEDEINC."/zip.class.php");
  232. include_once(DEDEADMIN."/file_class.php");
  233. $zipfile = $cfg_basedir.str_replace($cfg_mainsite, '', $zipfile);
  234. $tmpzipdir = DEDEDATA.'/ziptmp/'.cn_substr(md5(ExecTime()), 16);
  235. $ntime = time();
  236. if (file_exists($zipfile)) {
  237. @mkdir($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  238. @chmod($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  239. $z = new zip();
  240. $z->ExtractAll($zipfile, $tmpzipdir);
  241. $fm = new FileManagement();
  242. $imgs = array();
  243. $fm->GetMatchFiles($tmpzipdir, "jpg|png|gif", $imgs);
  244. $i = 0;
  245. foreach ($imgs as $imgold) {
  246. $i++;
  247. $savepath = $cfg_image_dir."/".MyDate("Y-m", $ntime);
  248. CreateDir($savepath);
  249. $iurl = $savepath."/".MyDate("d", $ntime).dd2char(MyDate("His", $ntime).'-'.$adminid."-{$i}".mt_rand(1000, 9999));
  250. $iurl = $iurl.substr($imgold, -4, 4);
  251. $imgfile = $cfg_basedir.$iurl;
  252. copy($imgold, $imgfile);
  253. unlink($imgold);
  254. if (is_file($imgfile)) {
  255. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  256. $info = '';
  257. $imginfos = GetImageSize($imgfile, $info);
  258. $imgurls .= "{dede:img ddimg='$litpicname' text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  259. //把图片信息保存到媒体文档管理档案中
  260. $inquery = "
  261. INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  262. VALUES ('{$title}','{$iurl}','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".$ntime."','$adminid');";
  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 = "请选择您的后续操作:<a href='album_add.php?cid=$typeid' class='btn btn-success btn-sm'>继续发布图片</a>&nbsp;&nbsp;<a href='archives_do.php?aid=".$id."&dopost=editArchives' class='btn btn-success btn-sm'>查看更改</a>&nbsp;&nbsp;<a href='$arcUrl' target='_blank' class='btn btn-success btn-sm'>预览文档</a>&nbsp;&nbsp;<a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-success btn-sm'>管理已发布图片</a>&nbsp;&nbsp;$backurl";
  371. $wintitle = "成功更改图集";
  372. $wecome_info = "文章管理::更改图集";
  373. $win = new OxWindow();
  374. $win->AddTitle("成功更改一个图集:");
  375. $win->AddMsgItem($msg);
  376. $winform = $win->GetWindow("hand", "&nbsp;", false);
  377. $win->Display();
  378. }