国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

370 linhas
15KB

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