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

281 lines
12KB

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