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

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