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

310 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 = "
  160. INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  161. VALUES ('{$title}','{$iurl}','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".$ntime."','$adminid');";
  162. $dsql->ExecuteNoneQuery($inquery);
  163. $fid = $dsql->GetLastID();
  164. AddMyAddon($fid, $iurl);
  165. WaterImg($imgfile, 'up');
  166. if (!$hasone && $ddisfirst == 1 && $litpic == '') {
  167. if (empty($litpicname)) {
  168. $litpicname = $iurl;
  169. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  170. }
  171. $litpic = $litpicname;
  172. $hasone = TRUE;
  173. }
  174. }
  175. }
  176. if ($delzip == 1) unlink($zipfile);
  177. $fm->RmDirFiles($tmpzipdir);
  178. }
  179. }
  180. if ($albums !== "") {
  181. $albumsArr = json_decode(stripslashes($albums), true);
  182. for ($i = 0; $i <= count($albumsArr) - 1; $i++) {
  183. $album = $albumsArr[$i];
  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. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  205. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $v {/dede:img}\r\n";
  206. if ($ddisfirst == 1 && $litpic == '' && !empty($fullUrl)) {
  207. $litpic = $fullUrl;
  208. }
  209. }
  210. }
  211. $imgurls = addslashes($imgurls);
  212. //处理body字段自动摘要、自动提取缩略图等
  213. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  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 (!isset(${$vs[0]})) {
  228. ${$vs[0]} = '';
  229. } else if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  230. {
  231. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  232. } else {
  233. if (!isset(${$vs[0]})) {
  234. ${$vs[0]} = '';
  235. }
  236. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  237. }
  238. $inadd_f .= ','.$vs[0];
  239. $inadd_v .= " ,'".${$vs[0]}."' ";
  240. }
  241. }
  242. }
  243. //处理图片文档的自定义属性
  244. if ($litpic != '' && !preg_match("#p#", $flag)) {
  245. $flag = ($flag == '' ? 'p' : $flag.',p');
  246. }
  247. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  248. $flag = ($flag == '' ? 'j' : $flag.',j');
  249. }
  250. //跳转网址的文档强制为动态
  251. if (preg_match("#j#", $flag)) $ismake = -1;
  252. //加入主档案表
  253. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  254. color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight)
  255. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  256. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename','$adminid','$weight'); ";
  257. if (!$dsql->ExecuteNoneQuery($query)) {
  258. $gerr = $dsql->GetError();
  259. $dsql->ExecuteNoneQuery(" DELETE FROM `#@__arctiny` WHERE id='$arcID' ");
  260. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeBIZ官方".str_replace('"', '', $gerr), "javascript:;");
  261. exit();
  262. }
  263. //加入附加表
  264. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  265. $addtable = trim($cts['addtable']);
  266. if (empty($addtable)) {
  267. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  268. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  269. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作", "javascript:;");
  270. exit();
  271. }
  272. $useip = GetIP();
  273. $query = "INSERT INTO `$addtable`(aid,typeid,redirecturl,userip,pagestyle,maxwidth,imgurls,`row`,col,isrm,ddmaxwidth,pagepicnum,body{$inadd_f})
  274. Values('$arcID','$typeid','$redirecturl','$useip','$pagestyle','$maxwidth','$imgurls','$row','$col','$isrm','$ddmaxwidth','$pagepicnum','$body'{$inadd_v}); ";
  275. if (!$dsql->ExecuteNoneQuery($query)) {
  276. $gerr = $dsql->GetError();
  277. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  278. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  279. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeBIZ官方".str_replace('"', '', $gerr), "javascript:;");
  280. exit();
  281. }
  282. //生成HTML
  283. InsertTags($tags, $arcID);
  284. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  285. if ($artUrl == '') {
  286. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  287. }
  288. ClearMyAddon($arcID, $title);
  289. //自动更新关联内容
  290. if (is_array($automake)) {
  291. foreach ($automake as $key => $value) {
  292. if (isset(${$key}) && !empty(${$key})) {
  293. $ids = explode(",", ${$key});
  294. foreach ($ids as $id) {
  295. MakeArt($id, true, true, $isremote);
  296. }
  297. }
  298. }
  299. }
  300. //返回成功信息
  301. $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";
  302. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  303. $wintitle = "成功发布一个图集";
  304. $wecome_info = "文章管理::发布图集";
  305. $win = new OxWindow();
  306. $win->AddTitle("成功发布一个图集:");
  307. $win->AddMsgItem($msg);
  308. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  309. $win->Display();
  310. }