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

367 lines
15KB

  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) 2020, 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以确定当前权重
  33. $maxWright = $dsql->GetOne("SELECT COUNT(*) AS cc FROM #@__archives");
  34. include DedeInclude("templets/album_add.htm");
  35. exit();
  36. }
  37. /*--------------------------------
  38. function __save(){ }
  39. -------------------------------*/ else if ($dopost == 'save') {
  40. require_once(DEDEINC . '/image.func.php');
  41. require_once(DEDEINC . '/oxwindow.class.php');
  42. $flag = isset($flags) ? join(',', $flags) : '';
  43. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  44. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  45. if (!isset($typeid2)) $typeid2 = 0;
  46. if (!isset($autokey)) $autokey = 0;
  47. if (!isset($remote)) $remote = 0;
  48. if (!isset($dellink)) $dellink = 0;
  49. if (!isset($autolitpic)) $autolitpic = 0;
  50. if (!isset($formhtml)) $formhtml = 0;
  51. if (!isset($formzip)) $formzip = 0;
  52. if (!isset($ddisfirst)) $ddisfirst = 0;
  53. if (!isset($albums)) $albums = "";
  54. if (!isset($delzip)) $delzip = 0;
  55. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  56. if ($typeid == 0) {
  57. ShowMsg("请指定文档的栏目!", "-1");
  58. exit();
  59. }
  60. if (empty($channelid)) {
  61. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!", "-1");
  62. exit();
  63. }
  64. if (!CheckChannel($typeid, $channelid)) {
  65. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!", "-1");
  66. exit();
  67. }
  68. if (!TestPurview('a_New')) {
  69. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的权限!");
  70. }
  71. //对保存的内容进行处理
  72. if (empty($writer)) $writer = $cuserLogin->getUserName();
  73. if (empty($source)) $source = '未知';
  74. $pubdate = GetMkTime($pubdate);
  75. $senddate = time();
  76. $sortrank = AddDay($pubdate, $sortup);
  77. $ismake = $ishtml == 0 ? -1 : 0;
  78. $title = preg_replace("#\"#", '"', $title);
  79. $title = cn_substrR($title, $cfg_title_maxlen);
  80. $shorttitle = cn_substrR($shorttitle, 36);
  81. $color = cn_substrR($color, 7);
  82. $writer = cn_substrR($writer, 20);
  83. $source = cn_substrR($source, 30);
  84. $description = cn_substrR($description, $cfg_auot_description);
  85. $keywords = cn_substrR($keywords, 60);
  86. $filename = trim(cn_substrR($filename, 40));
  87. $userip = GetIP();
  88. $isremote = 0;
  89. $serviterm = empty($serviterm) ? "" : $serviterm;
  90. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  91. $arcrank = -1;
  92. }
  93. $adminid = $cuserLogin->getUserID();
  94. //处理上传的缩略图
  95. if (empty($ddisremote)) $ddisremote = 0;
  96. $litpic = GetDDImage('none', $picname, $ddisremote);
  97. // 处理新的缩略图上传
  98. if ($litpic_b64 != "") {
  99. $data = explode(',', $litpic_b64);
  100. $ntime = time();
  101. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  102. CreateDir($savepath);
  103. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  104. $fullUrl = $fullUrl . ".png";
  105. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  106. // 加水印
  107. WaterImg($cfg_basedir . $fullUrl, 'up');
  108. $litpic = $fullUrl;
  109. }
  110. //生成文档ID
  111. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  112. if (empty($arcID)) {
  113. ShowMsg("无法获得主键,因此无法进行后续操作!", "-1");
  114. exit();
  115. }
  116. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$row' col='$col' value='$pagestyle'/}\r\n";
  117. $hasone = FALSE;
  118. //处理并保存从网上复制的图片
  119. /*---------------------
  120. function _getformhtml()
  121. ------------------*/
  122. if ($formhtml == 1) {
  123. $imagebody = stripslashes($imagebody);
  124. $imgurls .= GetCurContentAlbum($imagebody, $copysource, $litpicname);
  125. if ($ddisfirst == 1 && $litpic == '' && !empty($litpicname)) {
  126. $litpic = $litpicname;
  127. $hasone = TRUE;
  128. }
  129. }
  130. /*---------------------
  131. function _getformzip()
  132. 处理从ZIP中解压的图片
  133. ---------------------*/
  134. if ($formzip == 1) {
  135. include_once(DEDEINC . "/zip.class.php");
  136. include_once(DEDEADMIN . "/file_class.php");
  137. $zipfile = $cfg_basedir . str_replace($cfg_mainsite, '', $zipfile);
  138. $tmpzipdir = DEDEDATA . '/ziptmp/' . cn_substr(md5(ExecTime()), 16);
  139. $ntime = time();
  140. if (file_exists($zipfile)) {
  141. @mkdir($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  142. @chmod($tmpzipdir, $GLOBALS['cfg_dir_purview']);
  143. $z = new zip();
  144. $z->ExtractAll($zipfile, $tmpzipdir);
  145. $fm = new FileManagement();
  146. $imgs = array();
  147. $fm->GetMatchFiles($tmpzipdir, "jpg|png|gif", $imgs);
  148. $i = 0;
  149. foreach ($imgs as $imgold) {
  150. $i++;
  151. $savepath = $cfg_image_dir . "/" . MyDate("Y-m", $ntime);
  152. CreateDir($savepath);
  153. $iurl = $savepath . "/" . MyDate("d", $ntime) . dd2char(MyDate("His", $ntime) . '-' . $adminid . "-{$i}" . mt_rand(1000, 9999));
  154. $iurl = $iurl . substr($imgold, -4, 4);
  155. $imgfile = $cfg_basedir . $iurl;
  156. copy($imgold, $imgfile);
  157. unlink($imgold);
  158. if (is_file($imgfile)) {
  159. $litpicname = $pagestyle > 2 ? GetImageMapDD($iurl, $cfg_ddimg_width) : $iurl;
  160. //指定了提取第一张为缩略图的情况强制使用第一张缩略图
  161. if ($i == '1') {
  162. if (!$hasone && $ddisfirst == 1 && $litpic == '' && empty($litpicname)) {
  163. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  164. }
  165. }
  166. $info = '';
  167. $imginfos = GetImageSize($imgfile, $info);
  168. $imgurls .= "{dede:img ddimg='$litpicname' text='' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} $iurl {/dede:img}\r\n";
  169. //把图片信息保存到媒体文档管理档案中
  170. $inquery = "
  171. INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  172. VALUES ('{$title}','{$iurl}','1','" . $imginfos[0] . "','" . $imginfos[1] . "','0','" . filesize($imgfile) . "','" . $ntime . "','$adminid');
  173. ";
  174. $dsql->ExecuteNoneQuery($inquery);
  175. $fid = $dsql->GetLastID();
  176. AddMyAddon($fid, $iurl);
  177. WaterImg($imgfile, 'up');
  178. if (!$hasone && $ddisfirst == 1 && $litpic == '') {
  179. if (empty($litpicname)) {
  180. $litpicname = $iurl;
  181. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  182. }
  183. $litpic = $litpicname;
  184. $hasone = TRUE;
  185. }
  186. }
  187. }
  188. if ($delzip == 1) unlink($zipfile);
  189. $fm->RmDirFiles($tmpzipdir);
  190. }
  191. }
  192. if ($albums !== "") {
  193. $albumsArr = json_decode(stripslashes($albums), true);
  194. for ($i = 0; $i <= count($albumsArr) - 1; $i++) {
  195. $album = $albumsArr[$i];
  196. $data = explode(',', $album['img']);
  197. $ntime = time();
  198. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  199. CreateDir($savepath);
  200. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  201. $fullUrl = $fullUrl . ".png";
  202. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  203. $info = '';
  204. $imginfos = GetImageSize($cfg_basedir . $fullUrl, $info);
  205. $v = $fullUrl;
  206. $imginfo = !empty($album['txt']) ? $album['txt'] : '';
  207. $imgurls .= "{dede:img ddimg='$v' text='$imginfo' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} $v {/dede:img}\r\n";
  208. if ($ddisfirst == 1 && $litpic == '' && !empty($fullUrl)) {
  209. $litpic = $fullUrl;
  210. }
  211. }
  212. }
  213. $imgurls = addslashes($imgurls);
  214. //处理body字段自动摘要、自动提取缩略图等
  215. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  216. //分析处理附加表数据
  217. $inadd_f = '';
  218. $inadd_v = '';
  219. if (!empty($dede_addonfields)) {
  220. $addonfields = explode(';', $dede_addonfields);
  221. $inadd_f = '';
  222. $inadd_v = '';
  223. if (is_array($addonfields)) {
  224. foreach ($addonfields as $v) {
  225. if ($v == '') {
  226. continue;
  227. }
  228. $vs = explode(',', $v);
  229. if (!isset(${$vs[0]})) {
  230. ${$vs[0]} = '';
  231. } else if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  232. {
  233. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  234. } else {
  235. if (!isset(${$vs[0]})) {
  236. ${$vs[0]} = '';
  237. }
  238. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  239. }
  240. $inadd_f .= ',' . $vs[0];
  241. $inadd_v .= " ,'" . ${$vs[0]} . "' ";
  242. }
  243. }
  244. }
  245. //处理图片文档的自定义属性
  246. if ($litpic != '' && !preg_match("#p#", $flag)) {
  247. $flag = ($flag == '' ? 'p' : $flag . ',p');
  248. }
  249. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  250. $flag = ($flag == '' ? 'j' : $flag . ',j');
  251. }
  252. //跳转网址的文档强制为动态
  253. if (preg_match("#j#", $flag)) $ismake = -1;
  254. //加入主档案表
  255. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  256. color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight)
  257. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  258. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename','$adminid','$weight'); ";
  259. if (!$dsql->ExecuteNoneQuery($query)) {
  260. $gerr = $dsql->GetError();
  261. $dsql->ExecuteNoneQuery(" DELETE FROM `#@__arctiny` WHERE id='$arcID' ");
  262. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCMS官方。" . str_replace('"', '', $gerr), "javascript:;");
  263. exit();
  264. }
  265. //加入附加表
  266. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  267. $addtable = trim($cts['addtable']);
  268. if (empty($addtable)) {
  269. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  270. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  271. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。", "javascript:;");
  272. exit();
  273. }
  274. $useip = GetIP();
  275. $query = "INSERT INTO `$addtable`(aid,typeid,redirecturl,userip,pagestyle,maxwidth,imgurls,`row`,col,isrm,ddmaxwidth,pagepicnum,body{$inadd_f})
  276. Values('$arcID','$typeid','$redirecturl','$useip','$pagestyle','$maxwidth','$imgurls','$row','$col','$isrm','$ddmaxwidth','$pagepicnum','$body'{$inadd_v}); ";
  277. if (!$dsql->ExecuteNoneQuery($query)) {
  278. $gerr = $dsql->GetError();
  279. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  280. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  281. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。" . str_replace('"', '', $gerr), "javascript:;");
  282. exit();
  283. }
  284. //生成HTML
  285. InsertTags($tags, $arcID);
  286. if ($cfg_remote_site == 'Y' && $isremote == "1") {
  287. if ($serviterm != "") {
  288. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  289. $config = array('hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd, 'debug' => 'TRUE');
  290. } else {
  291. $config = array();
  292. }
  293. if (!$ftp->connect($config)) exit('Error:None FTP Connection!');
  294. }
  295. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  296. if ($artUrl == '') {
  297. $artUrl = $cfg_phpurl . "/view.php?aid=$arcID";
  298. }
  299. ClearMyAddon($arcID, $title);
  300. // 自动更新关联内容
  301. if (is_array($automake)) {
  302. foreach ($automake as $key => $value) {
  303. if (isset(${$key}) && !empty(${$key})) {
  304. $ids = explode(",", ${$key});
  305. foreach ($ids as $id) {
  306. MakeArt($id, true, true, $isremote);
  307. }
  308. }
  309. }
  310. }
  311. //返回成功信息
  312. $msg = "
  313.   请选择你的后续操作:
  314. <a href='album_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>继续发布图片</a>
  315. &nbsp;&nbsp;
  316. <a href='archives_do.php?aid=" . $arcID . "&dopost=editArchives' class='btn btn-secondary btn-sm'>更改图集</a>
  317. &nbsp;&nbsp;
  318. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>预览文档</a>
  319. &nbsp;&nbsp;
  320. <a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-secondary btn-sm'>已发布图片管理</a>
  321. &nbsp;&nbsp;
  322. $backurl
  323. ";
  324. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>" . GetUpdateTest();
  325. $wintitle = "成功发布一个图集!";
  326. $wecome_info = "文章管理::发布图集";
  327. $win = new OxWindow();
  328. $win->AddTitle("成功发布一个图集:");
  329. $win->AddMsgItem($msg);
  330. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  331. $win->Display();
  332. }