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

album_add.php 11KB

2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
1 jaar geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
2 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  2. /**
  3. * 图片发布
  4. *
  5. * @version $id:album_add.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_New,a_AccNew');
  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(DEDEINC."/dedetag.class.php");
  18. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  19. ClearMyAddon();
  20. $channelid = empty($channelid) ? 0 : intval($channelid);
  21. $cid = empty($cid) ? 0 : intval($cid);
  22. //获得栏目模型id
  23. if ($cid > 0 && $channelid == 0) {
  24. $row = $dsql->GetOne("SELECT channeltype FROM `#@__arctype` WHERE id='$cid'; ");
  25. $channelid = $row['channeltype'];
  26. } else {
  27. if ($channelid == 0) $channelid = 2;
  28. }
  29. //获得栏目模型信息
  30. $cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  31. $channelid = $cInfos['id'];
  32. //获取文档最大id+1以确定当前权重
  33. $maxWright = $dsql->GetOne("SELECT id+1 AS cc FROM `#@__archives` ORDER BY id DESC LIMIT 1");
  34. $maxWright = empty($maxWright)? array('cc'=>1) : $maxWright;
  35. include DedeInclude("templets/album_add.htm");
  36. exit();
  37. }
  38. /*--------------------------------
  39. function __save(){ }
  40. -------------------------------*/
  41. else if ($dopost == 'save') {
  42. require_once(DEDEINC.'/image.func.php');
  43. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  44. $flag = isset($flags) ? join(',', $flags) : '';
  45. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  46. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(200, 1000) : $cfg_arc_click);
  47. if (!isset($typeid2)) $typeid2 = 0;
  48. if (!isset($autokey)) $autokey = 0;
  49. if (!isset($remote)) $remote = 0;
  50. if (!isset($dellink)) $dellink = 0;
  51. if (!isset($autolitpic)) $autolitpic = 0;
  52. if (!isset($formhtml)) $formhtml = 0;
  53. if (!isset($formzip)) $formzip = 0;
  54. if (!isset($ddisfirst)) $ddisfirst = 0;
  55. if (!isset($albums)) $albums = "";
  56. if (!isset($delzip)) $delzip = 0;
  57. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(200, 1000) : $cfg_arc_click);
  58. if ($typeid == 0) {
  59. ShowMsg("请指定文档的栏目", "-1");
  60. exit();
  61. }
  62. if (empty($channelid)) {
  63. ShowMsg("文档为非指定的类型,请检查您发布文档的表单是否合法", "-1");
  64. exit();
  65. }
  66. if (!CheckChannel($typeid, $channelid)) {
  67. ShowMsg("您所选择的栏目与当前模型不相符,请重新选择", "-1");
  68. exit();
  69. }
  70. if (!TestPurview('a_New')) {
  71. CheckCatalog($typeid, "您没有操作栏目<span class='text-primary'>{$typeid}</span>权限");
  72. }
  73. //对保存的文档进行处理
  74. if (empty($writer)) $writer = $cuserLogin->getUserName();
  75. if (empty($source)) $source = '未知';
  76. $pubdate = GetMkTime($pubdate);
  77. $senddate = time();
  78. $sortrank = AddDay($pubdate, $sortup);
  79. $ismake = $ishtml == 0 ? -1 : 0;
  80. $title = preg_replace("#\"#", '"', $title);
  81. $title = cn_substrR($title, $cfg_title_maxlen);
  82. $shorttitle = cn_substrR($shorttitle, 36);
  83. $color = cn_substrR($color, 7);
  84. $writer = cn_substrR($writer, 20);
  85. $source = cn_substrR($source, 30);
  86. $description = cn_substrR($description, $cfg_auot_description);
  87. $keywords = cn_substrR($keywords, 60);
  88. $filename = trim(cn_substrR($filename, 40));
  89. $userip = GetIP();
  90. $isremote = 0;
  91. $serviterm = empty($serviterm) ? "" : $serviterm;
  92. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  93. $arcrank = -1;
  94. }
  95. $adminid = $cuserLogin->getUserID();
  96. //处理上传的缩略图
  97. if (empty($ddisremote)) $ddisremote = 0;
  98. $litpic = GetDDImage('none', $picname, $ddisremote);
  99. //生成文档id
  100. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  101. if (empty($arcID)) {
  102. ShowMsg("无法获得主键,因此无法进行后续操作", "-1");
  103. exit();
  104. }
  105. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$row' col='$col' value='$pagestyle'/}\r\n";
  106. $hasone = FALSE;
  107. //处理并保存从网上复制的图片
  108. /*---------------------
  109. function _getformhtml()
  110. ------------------*/
  111. if ($formhtml == 1) {
  112. $imagebody = stripslashes($imagebody);
  113. $imgurls .= GetCurContentAlbum($imagebody, $copysource, $litpicname);
  114. if ($ddisfirst == 1 && $litpic == '' && !empty($litpicname)) {
  115. $litpic = $litpicname;
  116. $hasone = TRUE;
  117. }
  118. }
  119. /*---------------------
  120. function _getformzip()
  121. 处理从ZIP中解压的图片
  122. ---------------------*/
  123. if ($formzip == 1) {
  124. include_once(DEDEADMIN."/file_class.php");
  125. $zipfile = $cfg_basedir.str_replace($cfg_mainsite, '', $zipfile);
  126. $tmpzipdir = DEDEDATA.'/ziptmp/'.cn_substr(md5(ExecTime()), 16);
  127. $ntime = time();
  128. }
  129. if ($albums !== "") {
  130. $albumsArr = json_decode(stripslashes($albums), true);
  131. for ($i = 0; $i <= count($albumsArr) - 1; $i++) {
  132. $album = $albumsArr[$i];
  133. $data = explode(',', $album['img']);
  134. $ext = ".png";
  135. if (strpos($data[0], "data:image/jpeg") === 0){
  136. $ext = ".jpg";
  137. } elseif (strpos($data[0], "data:image/gif") === 0) {
  138. $ext = ".gif";
  139. } elseif (strpos($data[0], "data:image/webp") === 0) {
  140. $ext = ".webp";
  141. } elseif (strpos($data[0], "data:image/bmp") === 0) {
  142. $ext = ".bmp";
  143. }
  144. $ntime = time();
  145. $savepath = $cfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  146. CreateDir($savepath);
  147. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  148. $fullUrl = $fullUrl.$ext;
  149. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  150. $info = '';
  151. $imginfos = GetImageSize($cfg_basedir.$fullUrl, $info);
  152. $v = $fullUrl;
  153. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  154. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $v {/dede:img}\r\n";
  155. if ($ddisfirst == 1 && $litpic == '' && !empty($fullUrl)) {
  156. $litpic = $fullUrl;
  157. }
  158. }
  159. }
  160. $imgurls = addslashes($imgurls);
  161. //处理body字段自动摘要、自动提取缩略图等
  162. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  163. //分析处理附加表数据
  164. $inadd_f = '';
  165. $inadd_v = '';
  166. if (!empty($dede_addonfields)) {
  167. $addonfields = explode(';', $dede_addonfields);
  168. $inadd_f = '';
  169. $inadd_v = '';
  170. if (is_array($addonfields)) {
  171. foreach ($addonfields as $v) {
  172. if ($v == '') {
  173. continue;
  174. }
  175. $vs = explode(',', $v);
  176. if (!isset(${$vs[0]})) {
  177. ${$vs[0]} = '';
  178. } else if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //网页文本特殊处理
  179. {
  180. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  181. } else {
  182. if (!isset(${$vs[0]})) {
  183. ${$vs[0]} = '';
  184. }
  185. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  186. }
  187. $inadd_f .= ','.$vs[0];
  188. $inadd_v .= " ,'".${$vs[0]}."' ";
  189. }
  190. }
  191. }
  192. //处理图片文档的自定义属性
  193. if ($litpic != '' && !preg_match("#p#", $flag)) {
  194. $flag = ($flag == '' ? 'p' : $flag.',p');
  195. }
  196. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  197. $flag = ($flag == '' ? 'j' : $flag.',j');
  198. }
  199. //跳转网址的文档强制为动态
  200. if (preg_match("#j#", $flag)) $ismake = -1;
  201. //加入主文档表
  202. $query = "INSERT INTO `#@__archives` (id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight) VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename','$adminid','$weight'); ";
  203. if (!$dsql->ExecuteNoneQuery($query)) {
  204. $gerr = $dsql->GetError();
  205. $dsql->ExecuteNoneQuery(" DELETE FROM `#@__arctiny` WHERE id='$arcID' ");
  206. ShowMsg("数据保存到数据库主表`#@__archives`时出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  207. exit();
  208. }
  209. //加入附加表
  210. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  211. $addtable = trim($cts['addtable']);
  212. if (empty($addtable)) {
  213. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  214. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  215. ShowMsg("没找到当前模型<span class='text-primary'>{$channelid}</span>主表信息,无法完成操作", "javascript:;");
  216. exit();
  217. }
  218. $useip = GetIP();
  219. $query = "INSERT INTO `$addtable` (aid,typeid,redirecturl,userip,pagestyle,maxwidth,imgurls,`row`,col,isrm,ddmaxwidth,pagepicnum,body{$inadd_f}) VALUES ('$arcID','$typeid','$redirecturl','$useip','$pagestyle','$maxwidth','$imgurls','$row','$col','$isrm','$ddmaxwidth','$pagepicnum','$body'{$inadd_v}); ";
  220. if (!$dsql->ExecuteNoneQuery($query)) {
  221. $gerr = $dsql->GetError();
  222. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  223. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  224. ShowMsg("数据保存到数据库附加表时出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  225. exit();
  226. }
  227. //生成网页
  228. InsertTags($tags, $arcID);
  229. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  230. if ($artUrl == '') {
  231. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  232. }
  233. ClearMyAddon($arcID, $title);
  234. //自动更新关联文档
  235. if (is_array($automake)) {
  236. foreach ($automake as $key => $value) {
  237. if (isset(${$key}) && !empty(${$key})) {
  238. $ids = explode(",", ${$key});
  239. foreach ($ids as $id) {
  240. MakeArt($id, true, true, $isremote);
  241. }
  242. }
  243. }
  244. }
  245. //返回成功信息
  246. $msg = "请选择您的后续操作:<a href='album_add.php?cid=$typeid' class='btn btn-success btn-sm'>继续发布图片</a><a href='archives_do.php?aid=".$arcID."&dopost=editArchives' class='btn btn-success btn-sm'>修改图片</a><a href='$artUrl' 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";
  247. $msg = "<div>{$msg}</div>".GetUpdateTest();
  248. $wintitle = "成功发布一个图片";
  249. $wecome_info = "文档管理::发布图片";
  250. $win = new OxWindow();
  251. $win->AddTitle("成功发布一个图片");
  252. $win->AddMsgItem($msg);
  253. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  254. $win->Display();
  255. }
  256. ?>