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

383 line
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) 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. 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.'/libraries/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. for ($i = 1; $i <= 120; $i++) {
  171. if (!isset(${'imgurl'.$i})) continue;
  172. $info = '';
  173. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg'.$i}));
  174. $iurl = stripslashes(${'imgurl'.$i});
  175. $ddurl = stripslashes(${'imgddurl'.$i});
  176. if (preg_match("#swfupload#i", $ddurl)) $ddurl = '';
  177. $imgfile = $cfg_basedir.$iurl;
  178. $litimgfile = $cfg_basedir.$ddurl;
  179. //有上传文件的情况
  180. if (isset(${'imgfile'.$i}) && is_uploaded_file(${'imgfile'.$i})) {
  181. $tmpFile = ${'imgfile'.$i};
  182. //检测上传的图片, 如果类型不对,保留原来图片
  183. $imginfos = @GetImageSize($tmpFile, $info);
  184. if (!is_array($imginfos)) {
  185. $imginfos = @GetImageSize($imgfile, $info);
  186. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  187. continue;
  188. }
  189. $mime = get_mime_type($tmpFile);
  190. if (preg_match("#^unknow#", $mime)) {
  191. ShowMsg("系统不支持fileinfo组件,建议php.ini中开启", -1);
  192. exit;
  193. }
  194. if (!preg_match("#^image#i", $mime)) {
  195. ShowMsg("非图片格式文件,无法正常上传", -1);
  196. exit;
  197. }
  198. move_uploaded_file($tmpFile, $imgfile);
  199. $imginfos = @GetImageSize($imgfile, $info);
  200. if ($ddurl == $iurl) {
  201. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  202. $litimgfile = $cfg_basedir.$litpicname;
  203. } else {
  204. if ($cfg_ddimg_full == 'Y') ImageResizeNew($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  205. else ImageResize($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  206. $litpicname = $ddurl;
  207. }
  208. $imgurls .= "{dede:img ddimg='$litpicname' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  209. }
  210. //没上传图片(只修改msg信息)
  211. else {
  212. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg'.$i}));
  213. $iurl = stripslashes(${'imgurl'.$i});
  214. $ddurl = stripslashes(${'imgddurl'.$i});
  215. if (preg_match("#swfupload#i", $ddurl)) {
  216. $ddurl = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  217. }
  218. $imginfos = @GetImageSize($imgfile, $info);
  219. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  220. }
  221. }
  222. //从HTML中获取新图片
  223. if ($formhtml == 1 && !empty($imagebody)) {
  224. $imagebody = stripslashes($imagebody);
  225. $imgurls .= GetCurContentAlbum($imagebody, $copysource, $litpicname);
  226. if ($ddisfirst == 1 && $litpic == "" && !empty($litpicname)) {
  227. $litpic = $litpicname;
  228. $hasone = true;
  229. }
  230. }
  231. /*---------------------
  232. function _getformzip()
  233. 从ZIP文件中获取新图片
  234. ---------------------*/
  235. if ($formzip == 1) {
  236. include_once(DEDEINC."/libraries/zip.class.php");
  237. include_once(DEDEADMIN."/file_class.php");
  238. $zipfile = $cfg_basedir.str_replace($cfg_mainsite, '', $zipfile);
  239. $tmpzipdir = DEDEDATA.'/ziptmp/'.cn_substr(md5(ExecTime()), 16);
  240. $ntime = time();
  241. if (file_exists($zipfile)) {
  242. @mkdir($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  243. @chmod($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  244. $z = new zip();
  245. $z->ExtractAll($zipfile, $tmpzipdir);
  246. $fm = new FileManagement();
  247. $imgs = array();
  248. $fm->GetMatchFiles($tmpzipdir, "jpg|png|gif", $imgs);
  249. $i = 0;
  250. foreach ($imgs as $imgold) {
  251. $i++;
  252. $savepath = $cfg_image_dir."/".MyDate("Y-m", $ntime);
  253. CreateDir($savepath);
  254. $iurl = $savepath."/".MyDate("d", $ntime).dd2char(MyDate("His", $ntime).'-'.$adminid."-{$i}".mt_rand(1000, 9999));
  255. $iurl = $iurl.substr($imgold, -4, 4);
  256. $imgfile = $cfg_basedir.$iurl;
  257. copy($imgold, $imgfile);
  258. unlink($imgold);
  259. if (is_file($imgfile)) {
  260. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  261. $info = '';
  262. $imginfos = GetImageSize($imgfile, $info);
  263. $imgurls .= "{dede:img ddimg='$litpicname' text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  264. //把图片信息保存到媒体文档管理档案中
  265. $inquery = "
  266. INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  267. VALUES ('{$title}','{$iurl}','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".$ntime."','$adminid');";
  268. $dsql->ExecuteNoneQuery($inquery);
  269. if (
  270. !$hasone && $ddisfirst == 1
  271. && $litpic == "" && !empty($litpicname)
  272. ) {
  273. if (file_exists($cfg_basedir.$litpicname)) {
  274. $litpic = $litpicname;
  275. $hasone = true;
  276. }
  277. }
  278. }
  279. }
  280. if ($delzip == 1) {
  281. unlink($zipfile);
  282. }
  283. $fm->RmDirFiles($tmpzipdir);
  284. }
  285. }
  286. if ($albums !== "") {
  287. $albumsArr = json_decode(stripslashes($albums), true);
  288. //var_dump($albumsArr);exit;
  289. for ($i = 0; $i <= count($albumsArr) - 1; $i++) {
  290. $album = $albumsArr[$i];
  291. $data = explode(',', $album['img']);
  292. $ntime = time();
  293. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  294. CreateDir($savepath);
  295. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  296. $fullUrl = $fullUrl.".png";
  297. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  298. $info = '';
  299. $imginfos = GetImageSize($cfg_basedir.$fullUrl, $info);
  300. $v = $fullUrl;
  301. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  302. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $v {/dede:img}\r\n";
  303. }
  304. }
  305. $imgurls = addslashes($imgurls);
  306. //分析处理附加表数据
  307. $inadd_f = '';
  308. $inadd_v = '';
  309. if (!empty($dede_addonfields)) {
  310. $addonfields = explode(';', $dede_addonfields);
  311. $inadd_f = '';
  312. $inadd_v = '';
  313. if (is_array($addonfields)) {
  314. foreach ($addonfields as $v) {
  315. if ($v == '') {
  316. continue;
  317. }
  318. $vs = explode(',', $v);
  319. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  320. {
  321. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  322. } else {
  323. if (!isset(${$vs[0]})) {
  324. ${$vs[0]} = '';
  325. }
  326. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  327. }
  328. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  329. }
  330. }
  331. }
  332. //更新附加表
  333. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  334. $addtable = trim($cts['addtable']);
  335. if ($addtable != '') {
  336. $useip = GetIP();
  337. $query = "Update `$addtable`
  338. set typeid='$typeid',
  339. pagestyle='$pagestyle',
  340. body='$body',
  341. maxwidth = '$maxwidth',
  342. ddmaxwidth = '$ddmaxwidth',
  343. pagepicnum = '$pagepicnum',
  344. imgurls='$imgurls',
  345. `row`='$row',
  346. col='$col',
  347. isrm='$isrm'{$inadd_f},
  348. redirecturl='$redirecturl',
  349. userip = '$useip'
  350. WHERE aid='$id'; ";
  351. if (!$dsql->ExecuteNoneQuery($query)) {
  352. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因".$dsql->GetError(), "javascript:;");
  353. exit();
  354. }
  355. }
  356. //生成HTML
  357. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  358. $arcUrl = MakeArt($id, true, true, $isremote);
  359. if ($arcUrl == '') {
  360. $arcUrl = $cfg_phpurl."/view.php?aid=$id";
  361. }
  362. ClearMyAddon($id, $title);
  363. //自动更新关联内容
  364. if (is_array($automake)) {
  365. foreach ($automake as $key => $value) {
  366. if (isset(${$key}) && !empty(${$key})) {
  367. $ids = explode(",", ${$key});
  368. foreach ($ids as $id) {
  369. MakeArt($id, true, true, $isremote);
  370. }
  371. }
  372. }
  373. }
  374. //返回成功信息
  375. $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";
  376. $wintitle = "成功修改图集";
  377. $wecome_info = "文章管理::修改图集";
  378. $win = new OxWindow();
  379. $win->AddTitle("成功修改一个图集:");
  380. $win->AddMsgItem($msg);
  381. $winform = $win->GetWindow("hand", "&nbsp;", false);
  382. $win->Display();
  383. }