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

309 lines
11KB

  1. <?php
  2. /**
  3. * 图集发布
  4. *
  5. * @version $Id: album_add.php 1 13:52 2010年7月9日Z tianya $
  6. * @package DedeCMS.Member
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. //考虑安全原因不管是否开启游客投稿功能,都不允许用户对图集投稿
  13. CheckRank(0,0);
  14. if($cfg_mb_lit=='Y')
  15. {
  16. ShowMsg("由于系统开启了精简版会员空间,你访问的功能不可用!","-1");
  17. exit();
  18. }
  19. if($cfg_mb_album=='N')
  20. {
  21. ShowMsg("对不起,由于系统关闭了图集功能,你访问的功能不可用!","-1");
  22. exit();
  23. }
  24. require_once(DEDEINC."/dedetag.class.php");
  25. require_once(DEDEINC."/userlogin.class.php");
  26. require_once(DEDEINC."/customfields.func.php");
  27. require_once(DEDEMEMBER."/inc/inc_catalog_options.php");
  28. require_once(DEDEMEMBER."/inc/inc_archives_functions.php");
  29. $channelid = isset($channelid) && is_numeric($channelid) ? $channelid : 2;
  30. $typeid = isset($typeid) && is_numeric($typeid) ? $typeid : 0;
  31. $menutype = 'content';
  32. if(empty($formhtml)) $formhtml = 0;
  33. /*-------------
  34. function _ShowForm(){ }
  35. --------------*/
  36. if(empty($dopost))
  37. {
  38. $query = "SELECT * FROM `#@__channeltype` WHERE id='$channelid'; ";
  39. $cInfos = $dsql->GetOne($query);
  40. if(!is_array($cInfos))
  41. {
  42. ShowMsg('模型参数不正确', '-1');
  43. exit();
  44. }
  45. //检查会员等级和类型限制
  46. if($cInfos['sendrank'] > $cfg_ml->M_Rank)
  47. {
  48. $row = $dsql->GetOne("Select membername From `#@__arcrank` where rank='".$cInfos['sendrank']."' ");
  49. ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档!","-1","0",5000);
  50. exit();
  51. }
  52. if($cInfos['usertype']!='' && $cInfos['usertype'] != $cfg_ml->M_MbType)
  53. {
  54. ShowMsg("对不起,需要[".$cInfos['usertype']."帐号]才能在这个频道发布文档!","-1","0",5000);
  55. exit();
  56. }
  57. include(DEDEMEMBER."/templets/album_add.htm");
  58. exit();
  59. }
  60. /*------------------------------
  61. function _SaveArticle(){ }
  62. ------------------------------*/
  63. else if($dopost=='save')
  64. {
  65. include(DEDEMEMBER.'/inc/archives_check.php');
  66. $svali = GetCkVdValue();
  67. if(preg_match("/1/",$safe_gdopen)){
  68. if(strtolower($vdcode)!=$svali || $svali=='')
  69. {
  70. ResetVdValue();
  71. ShowMsg('验证码错误!', '-1');
  72. exit();
  73. }
  74. }
  75. $cInfos = $dsql->GetOne("Select * From `#@__channeltype` where id='$channelid'; ");
  76. $maxwidth = isset($maxwidth) && is_numeric($maxwidth) ? $maxwidth : 800;
  77. $pagepicnum = isset($pagepicnum) && is_numeric($pagepicnum) ? $pagepicnum : 12;
  78. $ddmaxwidth = isset($ddmaxwidth) && is_numeric($ddmaxwidth) ? $ddmaxwidth : 200;
  79. $prow = isset($prow) && is_numeric($prow) ? $prow : 3;
  80. $pcol = isset($pcol) && is_numeric($pcol) ? $pcol : 3;
  81. $pagestyle = in_array($pagestyle,array('1','2','3')) ? $pagestyle : 2;
  82. include(DEDEMEMBER.'/inc/archives_check.php');
  83. $imgurls = "{dede:pagestyle maxwidth='$maxwidth' pagepicnum='$pagepicnum' ddmaxwidth='$ddmaxwidth' row='$prow' col='$pcol' value='$pagestyle'/}\r\n";
  84. $hasone = false;
  85. $ddisfirst=1;
  86. //处理并保存所指定的图片从网上复制
  87. if($formhtml==1)
  88. {
  89. $imagebody = stripslashes($imagebody);
  90. $imgurls .= GetCurContentAlbum($imagebody,$copysource,$litpicname);
  91. if($ddisfirst==1 && $litpic=='' && !empty($litpicname))
  92. {
  93. $litpic = $litpicname;
  94. $hasone = true;
  95. }
  96. }
  97. $info = '';
  98. //正常上传
  99. for($i=1;$i<=120;$i++)
  100. {
  101. //含有图片的条件
  102. if(isset($_FILES['imgfile'.$i]['tmp_name']) && is_uploaded_file($_FILES['imgfile'.$i]['tmp_name']) )
  103. {
  104. $iinfo = str_replace("'","`",stripslashes(${'imgmsg'.$i}));
  105. if(!is_uploaded_file($_FILES['imgfile'.$i]['tmp_name']))
  106. {
  107. continue;
  108. }
  109. else
  110. {
  111. $sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png","image/xpng","image/wbmp");
  112. if(!in_array($_FILES['imgfile'.$i]['type'],$sparr))
  113. {
  114. continue;
  115. }
  116. $filename = MemberUploads('imgfile'.$i,'',$cfg_ml->M_ID,'image','',0,0,false);
  117. if($filename!='')
  118. {
  119. SaveUploadInfo($title,$filename,1);
  120. }
  121. //缩图
  122. if($pagestyle > 2)
  123. {
  124. $litpicname = GetImageMapDD($filename,$ddmaxwidth);
  125. if($litpicname != '')
  126. {
  127. SaveUploadInfo($title.' 小图',$litpicname,1);
  128. }
  129. }
  130. else
  131. {
  132. $litpicname = $filename;
  133. }
  134. $imgfile = $cfg_basedir.$filename;
  135. if(is_file($imgfile))
  136. {
  137. $iurl = $filename;
  138. $info = '';
  139. $imginfos = @getimagesize($imgfile,$info);
  140. $imgurls .= "{dede:img ddimg='$litpicname' text='$iinfo' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  141. }
  142. }
  143. if(!$hasone && $litpic=='' && !empty($litpicname))
  144. {
  145. $litpic = $litpicname;
  146. $hasone = true;
  147. }
  148. }
  149. }//循环结束
  150. $imgurls = addslashes($imgurls);
  151. //分析处理附加表数据
  152. $isrm = 1;
  153. if(!isset($formhtml))
  154. {
  155. $formhtml = 0;
  156. }
  157. $inadd_f = $inadd_v = '';
  158. if(!empty($dede_addonfields))
  159. {
  160. $addonfields = explode(';',$dede_addonfields);
  161. $inadd_f = '';
  162. $inadd_v = '';
  163. if(is_array($addonfields))
  164. {
  165. foreach($addonfields as $v)
  166. {
  167. if($v=='')
  168. {
  169. continue;
  170. }
  171. $vs = explode(',',$v);
  172. if(!isset(${$vs[0]}))
  173. {
  174. ${$vs[0]} = '';
  175. }
  176. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],0);
  177. $inadd_f .= ','.$vs[0];
  178. $inadd_v .= " ,'".${$vs[0]}."' ";
  179. }
  180. }
  181. if (empty($dede_fieldshash) || $dede_fieldshash != md5($dede_addonfields.$cfg_cookie_encode))
  182. {
  183. showMsg('数据校验不对,程序返回', '-1');
  184. exit();
  185. }
  186. // 这里对前台提交的附加数据进行一次校验
  187. $fontiterm = PrintAutoFieldsAdd($cInfos['fieldset'],'autofield', FALSE);
  188. if ($fontiterm != $inadd_f)
  189. {
  190. ShowMsg("提交表单同系统配置不相符,请重新提交!", "-1");
  191. exit();
  192. }
  193. }
  194. //处理图片文档的自定义属性
  195. if($litpic!='')
  196. {
  197. $flag = 'p';
  198. }
  199. //生成文档ID
  200. $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$mid);
  201. if(empty($arcID))
  202. {
  203. ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
  204. exit();
  205. }
  206. $description = HtmlReplace($description, -1);
  207. //保存到主表
  208. $inQuery = "INSERT INTO `#@__archives`(id,typeid,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  209. color,writer,source,litpic,pubdate,senddate,mid,description,keywords,mtype)
  210. VALUES ('$arcID','$typeid','$sortrank','$flag','$ismake','$channelid','$arcrank','0','$money','$title','$shorttitle',
  211. '$color','$writer','$source','$litpic','$pubdate','$senddate','$mid','$description','$keywords','$mtypesid'); ";
  212. if(!$dsql->ExecuteNoneQuery($inQuery))
  213. {
  214. $gerr = $dsql->GetError();
  215. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID' ");
  216. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请联系管理员。","javascript:;");
  217. exit();
  218. }
  219. //保存到附加表
  220. $addtable = trim($cInfos['addtable']);
  221. if(empty($addtable))
  222. {
  223. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  224. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  225. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。","javascript:;");
  226. exit();
  227. }
  228. else
  229. {
  230. $query = "INSERT INTO `$addtable`(aid,typeid,userip,redirecturl,templet,pagestyle,maxwidth,imgurls,row,col,isrm,ddmaxwidth,pagepicnum{$inadd_f})
  231. Values('$arcID','$typeid','$userip','','','$pagestyle','$maxwidth','$imgurls','$prow','$pcol','$isrm','$ddmaxwidth','$pagepicnum'{$inadd_v}); ";
  232. if(!$dsql->ExecuteNoneQuery($query))
  233. {
  234. $gerr = $dsql->GetError();
  235. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  236. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  237. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请联系管理员!".$gerr,"javascript:;");
  238. exit();
  239. }
  240. }
  241. //增加积分
  242. $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET scores=scores+{$cfg_sendarc_scores} WHERE mid='".$cfg_ml->M_ID."' ; ");
  243. //更新统计
  244. countArchives($channelid);
  245. //生成HTML
  246. InsertTags($tags,$arcID);
  247. $artUrl = MakeArt($arcID,true);
  248. if($artUrl=='') $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  249. #api{{
  250. if(defined('UC_API') && @include_once DEDEROOT.'/api/uc.func.php')
  251. {
  252. //推送事件
  253. $feed['icon'] = 'thread';
  254. $feed['title_template'] = '<b>{username} 在网站发布了一篇图集</b>';
  255. $feed['title_data'] = array('username' => $cfg_ml->M_UserName);
  256. $feed['body_template'] = '<b>{subject}</b><br>{message}';
  257. $url = !strstr($artUrl,'http://') ? ($cfg_basehost.$artUrl) : $artUrl;
  258. $feed['body_data'] = array('subject' => "<a href=\"".$url."\">$title</a>", 'message' => cn_substr(strip_tags(preg_replace("/\[.+?\]/is", '', $description)), 150));
  259. $feed['images'][] = array('url' => $cfg_basehost.'/images/scores.gif', 'link'=> $cfg_basehost);
  260. uc_feed_note($cfg_ml->M_LoginID,$feed);
  261. $row = $dsql->GetOne("SELECT `scores`,`userid` FROM `#@__member` WHERE `mid`='".$cfg_ml->M_ID."' AND `matt`<>10");
  262. uc_credit_note($row['userid'], $cfg_sendarc_scores);
  263. }
  264. #/aip}}
  265. //会员动态记录
  266. $cfg_ml->RecordFeeds('add', $title, $description, $arcID);
  267. ClearMyAddon($arcID, $title);
  268. //返回成功信息
  269. $msg = "
  270.   请选择你的后续操作:
  271. <a href='album_add.php?cid=$typeid'><u>继续发布图集</u></a>
  272. &nbsp;&nbsp;
  273. <a href='$artUrl' target='_blank'><u>查看图集</u></a>
  274. &nbsp;&nbsp;
  275. <a href='album_edit.php?aid=".$arcID."&channelid=$channelid'><u>更改图集</u></a>
  276. &nbsp;&nbsp;
  277. <a href='content_list.php?channelid={$channelid}'><u>已发布图集管理</u></a>
  278. ";
  279. $wintitle = "成功发布图集!";
  280. $wecome_info = "图集管理::发布图集";
  281. $win = new OxWindow();
  282. $win->AddTitle("成功发布图集:");
  283. $win->AddMsgItem($msg);
  284. $winform = $win->GetWindow("hand","&nbsp;",false);
  285. $win->Display();
  286. }