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

299 lines
13KB

  1. <?php
  2. /**
  3. * 图片编辑
  4. *
  5. * @version $id:album_edit.php 8:26 2010年7月12日 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.* 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' ";
  23. $arcRow = $dsql->GetOne($arcQuery);
  24. if (!is_array($arcRow)) {
  25. ShowMsg("读取文档基本信息出错", "-1");
  26. exit();
  27. }
  28. $query = "SELECT * FROM `#@__channeltype` WHERE id='".$arcRow['channel']."'";
  29. $cInfos = $dsql->GetOne($query);
  30. if (!is_array($cInfos)) {
  31. ShowMsg("读取栏目配置信息出错", "javascript:;");
  32. exit();
  33. }
  34. $addtable = $cInfos['addtable'];
  35. $addRow = $dsql->GetOne("SELECT * FROM `$addtable` WHERE aid='$aid'");
  36. $channelid = $arcRow['channel'];
  37. $imgurls = $addRow["imgurls"];
  38. $maxwidth = $addRow["maxwidth"];
  39. $pagestyle = $addRow["pagestyle"];
  40. $irow = $addRow["row"];
  41. $icol = $addRow["col"];
  42. $isrm = $addRow["isrm"];
  43. $body = $addRow["body"];
  44. $ddmaxwidth = $addRow["ddmaxwidth"];
  45. $pagepicnum = $addRow["pagepicnum"];
  46. $tags = GetTags($aid);
  47. $arcRow = XSSClean($arcRow);
  48. $addRow = XSSClean($addRow);
  49. include DedeInclude("templets/album_edit.htm");
  50. exit();
  51. }
  52. /*--------------------------------
  53. function __save(){ }
  54. -------------------------------*/
  55. else if ($dopost == 'save') {
  56. require_once(DEDEINC.'/image.func.php');
  57. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  58. $flag = isset($flags) ? join(',', $flags) : '';
  59. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  60. if (empty($typeid2)) $typeid2 = 0;
  61. if (!isset($autokey)) $autokey = 0;
  62. if (!isset($remote)) $remote = 0;
  63. if (!isset($dellink)) $dellink = 0;
  64. if (!isset($autolitpic)) $autolitpic = 0;
  65. if (!isset($formhtml)) $formhtml = 0;
  66. if (!isset($albums)) $albums = "";
  67. if (!isset($formzip)) $formzip = 0;
  68. if (!isset($ddisfirst)) $ddisfirst = 0;
  69. if (!isset($delzip)) $delzip = 0;
  70. if ($typeid == 0) {
  71. ShowMsg("请指定文档的栏目", "-1");
  72. exit();
  73. }
  74. if (empty($channelid)) {
  75. ShowMsg("文档为非指定的类型,请检查您发布文档的表单是否合法", "-1");
  76. exit();
  77. }
  78. if (!CheckChannel($typeid, $channelid)) {
  79. ShowMsg("您所选择的栏目与当前模型不相符,请选择白色的选项", "-1");
  80. exit();
  81. }
  82. if (!TestPurview('a_Edit')) {
  83. if (TestPurview('a_AccEdit')) {
  84. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的文档权限");
  85. } else {
  86. CheckArcAdmin($id, $cuserLogin->getUserID());
  87. }
  88. }
  89. //对保存的文档进行处理
  90. $pubdate = GetMkTime($pubdate);
  91. $sortrank = AddDay($pubdate, $sortup);
  92. $ismake = $ishtml == 0 ? -1 : 0;
  93. $title = cn_substrR($title, $cfg_title_maxlen);
  94. $shorttitle = cn_substrR($shorttitle, 36);
  95. $color = cn_substrR($color, 7);
  96. $writer = cn_substrR($writer, 20);
  97. $source = cn_substrR($source, 30);
  98. $description = cn_substrR($description, 250);
  99. $keywords = trim(cn_substrR($keywords, 60));
  100. $filename = trim(cn_substrR($filename, 40));
  101. $isremote = 0;
  102. $serviterm = empty($serviterm) ? "" : $serviterm;
  103. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  104. $arcrank = -1;
  105. }
  106. $adminid = $cuserLogin->getUserID();
  107. //处理上传的缩略图
  108. if (empty($ddisremote)) {
  109. $ddisremote = 0;
  110. }
  111. $litpic = GetDDImage('none', $picname, $ddisremote);
  112. //分析body里的文档
  113. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  114. //处理图片文档的自定义属性
  115. if ($litpic != '' && !preg_match("#p#", $flag)) {
  116. $flag = ($flag == '' ? 'p' : $flag.',p');
  117. }
  118. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  119. $flag = ($flag == '' ? 'j' : $flag.',j');
  120. }
  121. //跳转网址的文档强制为动态
  122. if (preg_match("#j#", $flag)) $ismake = -1;
  123. //更新数据库的SQL语句
  124. $query = "
  125. UPDATE `#@__archives` SET typeid='$typeid',typeid2='$typeid2',sortrank='$sortrank',flag='$flag',click='$click',ismake='$ismake',arcrank='$arcrank',money='$money',title='$title',color='$color',source='$source',writer='$writer',litpic='$litpic',pubdate='$pubdate',notpost='$notpost',description='$description',keywords='$keywords',shorttitle='$shorttitle',filename='$filename',dutyadmin='$adminid' WHERE id='$id'; ";
  126. if (!$dsql->ExecuteNoneQuery($query)) {
  127. ShowMsg("数据保存到数据库主表`#@__archives`时出错,请检查数据库字段".$dsql->GetError(), "javascript:;");
  128. exit();
  129. }
  130. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$row' col='$col' value='$pagestyle'/}\r\n";
  131. $hasone = false;
  132. //检查旧的图片是否有更新,并保存
  133. for ($i = 1; $i <= 120; $i++) {
  134. if (!isset(${'imgurl'.$i})) continue;
  135. $info = '';
  136. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg'.$i}));
  137. $iurl = stripslashes(${'imgurl'.$i});
  138. $ddurl = stripslashes(${'imgddurl'.$i});
  139. if (preg_match("#swfupload#i", $ddurl)) $ddurl = '';
  140. $imgfile = $cfg_basedir.$iurl;
  141. $litimgfile = $cfg_basedir.$ddurl;
  142. //有上传文件的情况
  143. if (isset(${'imgfile'.$i}) && is_uploaded_file(${'imgfile'.$i})) {
  144. $tmpFile = ${'imgfile'.$i};
  145. //检测上传的图片,如果类型不对,保留原来图片
  146. $imginfos = @GetImageSize($tmpFile, $info);
  147. if (!is_array($imginfos)) {
  148. $imginfos = @GetImageSize($imgfile, $info);
  149. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  150. continue;
  151. }
  152. $mime = get_mime_type($tmpFile);
  153. if (preg_match("#^unknow#", $mime)) {
  154. ShowMsg("系统不支持fileinfo组件,建议php.ini中开启", -1);
  155. exit;
  156. }
  157. if (!preg_match("#^image#i", $mime)) {
  158. ShowMsg("非图片格式文件,无法正常上传", -1);
  159. exit;
  160. }
  161. move_uploaded_file($tmpFile, $imgfile);
  162. $imginfos = @GetImageSize($imgfile, $info);
  163. if ($ddurl == $iurl) {
  164. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  165. $litimgfile = $cfg_basedir.$litpicname;
  166. } else {
  167. if ($cfg_ddimg_full == 'Y') ImageResizeNew($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  168. else ImageResize($imgfile, $cfg_ddimg_width, $cfg_ddimg_height, $litimgfile);
  169. $litpicname = $ddurl;
  170. }
  171. $imgurls .= "{dede:img ddimg='$litpicname' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  172. }
  173. //没上传图片(只修改msg信息)
  174. else {
  175. $iinfo = str_replace("'", "`", stripslashes(${'imgmsg'.$i}));
  176. $iurl = stripslashes(${'imgurl'.$i});
  177. $ddurl = stripslashes(${'imgddurl'.$i});
  178. if (preg_match("#swfupload#i", $ddurl)) {
  179. $ddurl = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  180. }
  181. $imginfos = @GetImageSize($imgfile, $info);
  182. $imgurls .= "{dede:img ddimg='$ddurl' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  183. }
  184. }
  185. //从HTML中获取新图片
  186. if ($formhtml == 1 && !empty($imagebody)) {
  187. $imagebody = stripslashes($imagebody);
  188. $imgurls .= GetCurContentAlbum($imagebody, $copysource, $litpicname);
  189. if ($ddisfirst == 1 && $litpic == "" && !empty($litpicname)) {
  190. $litpic = $litpicname;
  191. $hasone = true;
  192. }
  193. }
  194. /*---------------------
  195. function _getformzip()
  196. 从ZIP文件中获取新图片
  197. ---------------------*/
  198. if ($formzip == 1) {
  199. include_once(DEDEADMIN."/file_class.php");
  200. $zipfile = $cfg_basedir.str_replace($cfg_mainsite, '', $zipfile);
  201. $tmpzipdir = DEDEDATA.'/ziptmp/'.cn_substr(md5(ExecTime()), 16);
  202. $ntime = time();
  203. }
  204. if ($albums !== "") {
  205. $albumsArr = json_decode(stripslashes($albums), true);
  206. //var_dump($albumsArr);exit;
  207. for ($i = 0; $i <= count($albumsArr) - 1; $i++) {
  208. $album = $albumsArr[$i];
  209. $data = explode(',', $album['img']);
  210. $ext = ".png";
  211. if (strpos($data[0], "data:image/jpeg") === 0){
  212. $ext = ".jpg";
  213. } elseif (strpos($data[0], "data:image/gif") === 0) {
  214. $ext = ".gif";
  215. } elseif (strpos($data[0], "data:image/webp") === 0) {
  216. $ext = ".webp";
  217. } elseif (strpos($data[0], "data:image/bmp") === 0) {
  218. $ext = ".bmp";
  219. }
  220. $ntime = time();
  221. $savepath = $cfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  222. CreateDir($savepath);
  223. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  224. $fullUrl = $fullUrl.$ext;
  225. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  226. $info = '';
  227. $imginfos = GetImageSize($cfg_basedir.$fullUrl, $info);
  228. $v = $fullUrl;
  229. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  230. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $v {/dede:img}\r\n";
  231. }
  232. }
  233. $imgurls = addslashes($imgurls);
  234. //分析处理附加表数据
  235. $inadd_f = '';
  236. $inadd_v = '';
  237. if (!empty($dede_addonfields)) {
  238. $addonfields = explode(';', $dede_addonfields);
  239. $inadd_f = '';
  240. $inadd_v = '';
  241. if (is_array($addonfields)) {
  242. foreach ($addonfields as $v) {
  243. if ($v == '') {
  244. continue;
  245. }
  246. $vs = explode(',', $v);
  247. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //网页文本特殊处理
  248. {
  249. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  250. } else {
  251. if (!isset(${$vs[0]})) {
  252. ${$vs[0]} = '';
  253. }
  254. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  255. }
  256. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  257. }
  258. }
  259. }
  260. //更新附加表
  261. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  262. $addtable = trim($cts['addtable']);
  263. if ($addtable != '') {
  264. $useip = GetIP();
  265. $query = "UPDATE `$addtable` SET typeid='$typeid',pagestyle='$pagestyle',body='$body',maxwidth='$maxwidth',ddmaxwidth='$ddmaxwidth',pagepicnum='$pagepicnum',imgurls='$imgurls',`row`='$row',col='$col',isrm='$isrm'{$inadd_f},redirecturl='$redirecturl',userip='$useip' WHERE aid='$id'; ";
  266. if (!$dsql->ExecuteNoneQuery($query)) {
  267. ShowMsg("数据保存到数据库附加表时出错,请检查数据库字段".$dsql->GetError(), "javascript:;");
  268. exit();
  269. }
  270. }
  271. //生成网页
  272. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  273. $arcUrl = MakeArt($id, true, true, $isremote);
  274. if ($arcUrl == '') {
  275. $arcUrl = $cfg_phpurl."/view.php?aid=$id";
  276. }
  277. ClearMyAddon($id, $title);
  278. //自动更新关联文档
  279. if (is_array($automake)) {
  280. foreach ($automake as $key => $value) {
  281. if (isset(${$key}) && !empty(${$key})) {
  282. $ids = explode(",", ${$key});
  283. foreach ($ids as $id) {
  284. MakeArt($id, true, true, $isremote);
  285. }
  286. }
  287. }
  288. }
  289. //返回成功信息
  290. $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";
  291. $wintitle = "成功修改图片";
  292. $wecome_info = "文档管理::修改图片";
  293. $win = new OxWindow();
  294. $win->AddTitle("成功修改一个图片");
  295. $win->AddMsgItem($msg);
  296. $winform = $win->GetWindow("hand", "&nbsp;", false);
  297. $win->Display();
  298. }
  299. ?>