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

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