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

305 lines
14KB

  1. <?php
  2. /**
  3. * 图集发布
  4. *
  5. * @version $Id: album_add.php 1 8:26 2010年7月12日Z 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(50, 200) : $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(50, 200) : $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, "对不起,您没有操作栏目 {$typeid} 的权限");
  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(DEDEINC."/libraries/zip.class.php");
  125. include_once(DEDEADMIN."/file_class.php");
  126. $zipfile = $cfg_basedir.str_replace($cfg_mainsite, '', $zipfile);
  127. $tmpzipdir = DEDEDATA.'/ziptmp/'.cn_substr(md5(ExecTime()), 16);
  128. $ntime = time();
  129. if (file_exists($zipfile)) {
  130. @mkdir($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  131. @chmod($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  132. $z = new zip();
  133. $z->ExtractAll($zipfile, $tmpzipdir);
  134. $fm = new FileManagement();
  135. $imgs = array();
  136. $fm->GetMatchFiles($tmpzipdir, "jpg|png|gif", $imgs);
  137. $i = 0;
  138. foreach ($imgs as $imgold) {
  139. $i++;
  140. $savepath = $cfg_image_dir."/".MyDate("Y-m", $ntime);
  141. CreateDir($savepath);
  142. $iurl = $savepath."/".MyDate("d", $ntime).dd2char(MyDate("His", $ntime).'-'.$adminid."-{$i}".mt_rand(1000, 9999));
  143. $iurl = $iurl.substr($imgold, -4, 4);
  144. $imgfile = $cfg_basedir.$iurl;
  145. copy($imgold, $imgfile);
  146. unlink($imgold);
  147. if (is_file($imgfile)) {
  148. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  149. //指定了提取第一张为缩略图的情况强制使用第一张缩略图
  150. if ($i == '1') {
  151. if (!$hasone && $ddisfirst == 1 && $litpic == '' && empty($litpicname)) {
  152. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  153. }
  154. }
  155. $info = '';
  156. $imginfos = GetImageSize($imgfile, $info);
  157. $imgurls .= "{dede:img ddimg='$litpicname' text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  158. //把图片信息保存到媒体文档管理文档中
  159. $inquery = "INSERT INTO `#@__uploads` (title,url,mediatype,width,height,playtime,filesize,uptime,mid) VALUES ('{$title}','{$iurl}','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".$ntime."','$adminid');";
  160. $dsql->ExecuteNoneQuery($inquery);
  161. $fid = $dsql->GetLastID();
  162. AddMyAddon($fid, $iurl);
  163. WaterImg($imgfile, 'up');
  164. if (!$hasone && $ddisfirst == 1 && $litpic == '') {
  165. if (empty($litpicname)) {
  166. $litpicname = $iurl;
  167. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  168. }
  169. $litpic = $litpicname;
  170. $hasone = TRUE;
  171. }
  172. }
  173. }
  174. if ($delzip == 1) unlink($zipfile);
  175. $fm->RmDirFiles($tmpzipdir);
  176. }
  177. }
  178. if ($albums !== "") {
  179. $albumsArr = json_decode(stripslashes($albums), true);
  180. for ($i = 0; $i <= count($albumsArr) - 1; $i++) {
  181. $album = $albumsArr[$i];
  182. $data = explode(',', $album['img']);
  183. $ext = ".png";
  184. if (strpos($data[0], "data:image/jpeg") === 0){
  185. $ext = ".jpg";
  186. } elseif (strpos($data[0], "data:image/gif") === 0) {
  187. $ext = ".gif";
  188. } elseif (strpos($data[0], "data:image/webp") === 0) {
  189. $ext = ".webp";
  190. } elseif (strpos($data[0], "data:image/bmp") === 0) {
  191. $ext = ".bmp";
  192. }
  193. $ntime = time();
  194. $savepath = $cfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  195. CreateDir($savepath);
  196. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  197. $fullUrl = $fullUrl.$ext;
  198. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  199. $info = '';
  200. $imginfos = GetImageSize($cfg_basedir.$fullUrl, $info);
  201. $v = $fullUrl;
  202. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  203. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $v {/dede:img}\r\n";
  204. if ($ddisfirst == 1 && $litpic == '' && !empty($fullUrl)) {
  205. $litpic = $fullUrl;
  206. }
  207. }
  208. }
  209. $imgurls = addslashes($imgurls);
  210. //处理body字段自动摘要、自动提取缩略图等
  211. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  212. //分析处理附加表数据
  213. $inadd_f = '';
  214. $inadd_v = '';
  215. if (!empty($dede_addonfields)) {
  216. $addonfields = explode(';', $dede_addonfields);
  217. $inadd_f = '';
  218. $inadd_v = '';
  219. if (is_array($addonfields)) {
  220. foreach ($addonfields as $v) {
  221. if ($v == '') {
  222. continue;
  223. }
  224. $vs = explode(',', $v);
  225. if (!isset(${$vs[0]})) {
  226. ${$vs[0]} = '';
  227. } else if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  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], $arcID);
  235. }
  236. $inadd_f .= ','.$vs[0];
  237. $inadd_v .= " ,'".${$vs[0]}."' ";
  238. }
  239. }
  240. }
  241. //处理图片文档的自定义属性
  242. if ($litpic != '' && !preg_match("#p#", $flag)) {
  243. $flag = ($flag == '' ? 'p' : $flag.',p');
  244. }
  245. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  246. $flag = ($flag == '' ? 'j' : $flag.',j');
  247. }
  248. //跳转网址的文档强制为动态
  249. if (preg_match("#j#", $flag)) $ismake = -1;
  250. //加入主文档表
  251. $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'); ";
  252. if (!$dsql->ExecuteNoneQuery($query)) {
  253. $gerr = $dsql->GetError();
  254. $dsql->ExecuteNoneQuery(" DELETE FROM `#@__arctiny` WHERE id='$arcID' ");
  255. ShowMsg("数据保存到数据库主表`#@__archives`时出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  256. exit();
  257. }
  258. //加入附加表
  259. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  260. $addtable = trim($cts['addtable']);
  261. if (empty($addtable)) {
  262. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  263. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  264. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作", "javascript:;");
  265. exit();
  266. }
  267. $useip = GetIP();
  268. $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}); ";
  269. if (!$dsql->ExecuteNoneQuery($query)) {
  270. $gerr = $dsql->GetError();
  271. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  272. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  273. ShowMsg("数据保存到数据库附加表时出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  274. exit();
  275. }
  276. //生成网页
  277. InsertTags($tags, $arcID);
  278. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  279. if ($artUrl == '') {
  280. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  281. }
  282. ClearMyAddon($arcID, $title);
  283. //自动更新关联内容
  284. if (is_array($automake)) {
  285. foreach ($automake as $key => $value) {
  286. if (isset(${$key}) && !empty(${$key})) {
  287. $ids = explode(",", ${$key});
  288. foreach ($ids as $id) {
  289. MakeArt($id, true, true, $isremote);
  290. }
  291. }
  292. }
  293. }
  294. //返回成功信息
  295. $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";
  296. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  297. $wintitle = "成功发布一个图集";
  298. $wecome_info = "文档管理::发布图集";
  299. $win = new OxWindow();
  300. $win->AddTitle("成功发布一个图集:");
  301. $win->AddMsgItem($msg);
  302. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  303. $win->Display();
  304. }
  305. ?>