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

259 lines
9.4KB

  1. <?php
  2. require_once(dirname(__FILE__)."/config.php");
  3. //考虑安全原因不管是否开启游客投稿功能,都不允许用户投稿
  4. CheckRank(0, 0);
  5. if($cfg_mb_lit=='Y')
  6. {
  7. ShowMsg("由于系统开启了精简版会员空间,你访问的功能不可用!","-1");
  8. exit();
  9. }
  10. require_once(DEDEINC."/dedetag.class.php");
  11. require_once(DEDEINC."/userlogin.class.php");
  12. require_once(DEDEINC."/customfields.func.php");
  13. require_once(DEDEMEMBER."/inc/inc_catalog_options.php");
  14. require_once(DEDEMEMBER."/inc/inc_archives_functions.php");
  15. $channelid = isset($channelid) && is_numeric($channelid) ? $channelid : 3;
  16. $typeid = isset($typeid) && is_numeric($typeid) ? $typeid : 0;
  17. $menutype = 'content';
  18. /*-------------
  19. function _ShowForm(){ }
  20. --------------*/
  21. if(empty($dopost))
  22. {
  23. $cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$channelid'; ");
  24. if(!is_array($cInfos))
  25. {
  26. ShowMsg('模型不正确', '-1');
  27. exit();
  28. }
  29. //如果限制了会员级别或类型,则允许游客投稿选项无效
  30. if($cInfos['sendrank']>0 || $cInfos['usertype']!='')
  31. {
  32. CheckRank(0, 0);
  33. }
  34. //检查会员等级和类型限制
  35. if($cInfos['sendrank'] > $cfg_ml->M_Rank)
  36. {
  37. $row = $dsql->GetOne("Select membername From `#@__arcrank` where rank='".$cInfos['sendrank']."' ");
  38. ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档!","-1","0",5000);
  39. exit();
  40. }
  41. if($cInfos['usertype']!='' && $cInfos['usertype'] != $cfg_ml->M_MbType)
  42. {
  43. ShowMsg("对不起,需要[".$cInfos['usertype']."帐号]才能在这个频道发布文档!","-1","0",5000);
  44. exit();
  45. }
  46. include(DEDEMEMBER."/templets/soft_add.htm");
  47. exit();
  48. }
  49. /*------------------------------
  50. function _SaveArticle(){ }
  51. ------------------------------*/
  52. else if($dopost=='save')
  53. {
  54. $description = '';
  55. include(DEDEMEMBER.'/inc/archives_check.php');
  56. //生成文档ID
  57. $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$mid);
  58. if(empty($arcID))
  59. {
  60. ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
  61. exit();
  62. }
  63. //分析处理附加表数据
  64. $inadd_f = '';
  65. $inadd_v = '';
  66. if(!empty($dede_addonfields))
  67. {
  68. $addonfields = explode(';',$dede_addonfields);
  69. $inadd_f = '';
  70. $inadd_v = '';
  71. if(is_array($addonfields))
  72. {
  73. foreach($addonfields as $v)
  74. {
  75. if($v=='')
  76. {
  77. continue;
  78. }else if($v == 'templet')
  79. {
  80. ShowMsg("你保存的字段有误,请检查!","-1");
  81. exit();
  82. }
  83. $vs = explode(',',$v);
  84. if(!isset(${$vs[0]}))
  85. {
  86. ${$vs[0]} = '';
  87. }
  88. else if($vs[1]=='htmltext'||$vs[1]=='textdata')
  89. //HTML文本特殊处理
  90. {
  91. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);
  92. }
  93. else
  94. {
  95. if(!isset(${$vs[0]}))
  96. {
  97. ${$vs[0]} = '';
  98. }
  99. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$arcID);
  100. }
  101. $inadd_f .= ','.$vs[0];
  102. $inadd_v .= " ,'".${$vs[0]}."' ";
  103. }
  104. }
  105. if (empty($dede_fieldshash) || $dede_fieldshash != md5($dede_addonfields.$cfg_cookie_encode))
  106. {
  107. showMsg('数据校验不对,程序返回', '-1');
  108. exit();
  109. }
  110. // 这里对前台提交的附加数据进行一次校验
  111. $fontiterm = PrintAutoFieldsAdd($cInfos['fieldset'],'autofield', FALSE);
  112. if ($fontiterm != $inadd_f)
  113. {
  114. ShowMsg("提交表单同系统配置不相符,请重新提交!", "-1");
  115. exit();
  116. }
  117. }
  118. //处理图片文档的自定义属性
  119. if($litpic!='')
  120. {
  121. $flag = 'p';
  122. }
  123. $body = HtmlReplace($body,-1);
  124. //保存到主表
  125. $inQuery = "INSERT INTO `#@__archives`(id,typeid,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  126. color,writer,source,litpic,pubdate,senddate,mid,description,keywords)
  127. VALUES ('$arcID','$typeid','$sortrank','$flag','$ismake','$channelid','$arcrank','0','$money','$title','$shorttitle',
  128. '$color','$writer','$source','$litpic','$pubdate','$senddate','$mid','$description','$keywords'); ";
  129. if(!$dsql->ExecuteNoneQuery($inQuery))
  130. {
  131. $gerr = $dsql->GetError();
  132. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID' ");
  133. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请联系管理员。","javascript:;");
  134. exit();
  135. }
  136. //软件链接列表
  137. $softurl1 = stripslashes($softurl1);
  138. $softurl1 = str_replace(array("{dede:","{/dede:","}"), "#", $softurl1);
  139. $servermsg1 = str_replace(array("{dede:","{/dede:","}"), "#", $servermsg1);
  140. $urls = '';
  141. if($softurl1!='')
  142. {
  143. $urls .= "{dede:link islocal='1' text='{$servermsg1}'} $softurl1 {/dede:link}\r\n";
  144. }
  145. for($i=2; $i<=12; $i++)
  146. {
  147. if(!empty(${'softurl'.$i}))
  148. {
  149. $servermsg = str_replace("'","",stripslashes(${'servermsg'.$i}));
  150. $softurl = stripslashes(${'softurl'.$i});
  151. $softurl = str_replace(array("{dede:","{/dede:","}"), "#", $softurl);
  152. $servermsg = str_replace(array("{dede:","{/dede:","}"), "#", $servermsg);
  153. if($servermsg=='')
  154. {
  155. $servermsg = '下载地址'.$i;
  156. }
  157. if($softurl!='' && $softurl!='http://')
  158. {
  159. $urls .= "{dede:link text='$servermsg'} $softurl {/dede:link}\r\n";
  160. }
  161. }
  162. }
  163. $urls = addslashes($urls);
  164. $softsize = $softsize.$unit;
  165. //保存到附加表
  166. $needmoney = @intval($needmoney);
  167. if($needmoney > 100) $needmoney = 100;
  168. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  169. $addtable = trim($cts['addtable']);
  170. if(empty($addtable))
  171. {
  172. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  173. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  174. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。","javascript:;");
  175. exit();
  176. }
  177. $inQuery = "INSERT INTO `$addtable`(aid,typeid,filetype,language,softtype,accredit,
  178. os,softrank,officialUrl,officialDemo,softsize,softlinks,introduce,userip,templet,redirecturl,daccess,needmoney{$inadd_f})
  179. VALUES ('$arcID','$typeid','$filetype','$language','$softtype','$accredit',
  180. '$os','$softrank','$officialUrl','$officialDemo','$softsize','$urls','$body','$userip','','','0','$needmoney'{$inadd_v});";
  181. if(!$dsql->ExecuteNoneQuery($inQuery))
  182. {
  183. $gerr = $dsql->GetError();
  184. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  185. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  186. echo $inQuery;
  187. exit();
  188. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  189. exit();
  190. }
  191. //增加积分
  192. $cfg_sendarc_scores = intval($cfg_sendarc_scores);
  193. $dsql->ExecuteNoneQuery("UPDATE `#@__member` set scores=scores+{$cfg_sendarc_scores} WHERE mid='".$cfg_ml->M_ID."' ; ");
  194. //更新统计
  195. countArchives($channelid);
  196. //生成HTML
  197. InsertTags($tags,$arcID);
  198. $artUrl = MakeArt($arcID, TRUE);
  199. if($artUrl=='')
  200. {
  201. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  202. }
  203. #api{{
  204. if(defined('UC_API') && @include_once DEDEROOT.'/api/uc.func.php')
  205. {
  206. //推送事件
  207. $feed['icon'] = 'thread';
  208. $feed['title_template'] = '<b>{username} 在网站共享了一软件</b>';
  209. $feed['title_data'] = array('username' => $cfg_ml->M_UserName);
  210. $feed['body_template'] = '<b>{subject}</b><br>{message}';
  211. $url = !strstr($artUrl,'http://') ? ($cfg_basehost.$artUrl) : $artUrl;
  212. $feed['body_data'] = array('subject' => "<a href=\"".$url."\">$title</a>", 'message' => cn_substr(strip_tags(preg_replace("/\[.+?\]/is", '', $description)), 150));
  213. $feed['images'][] = array('url' => $cfg_basehost.'/images/scores.gif', 'link'=> $cfg_basehost);
  214. uc_feed_note($cfg_ml->M_LoginID,$feed);
  215. //同步积分
  216. uc_credit_note($cfg_ml->M_LoginID, $cfg_sendarc_scores);
  217. }
  218. #/aip}}
  219. //会员动态记录
  220. $cfg_ml->RecordFeeds('addsoft',$title,$description,$arcID);
  221. ClearMyAddon($arcID, $title);
  222. //返回成功信息
  223. $msg = "
  224. 请选择你的后续操作:
  225. <a href='soft_add.php?cid=$typeid'><u>继续发布软件</u></a>
  226. &nbsp;&nbsp;
  227. <a href='$artUrl' target='_blank'><u>查看软件</u></a>
  228. &nbsp;&nbsp;
  229. <a href='soft_edit.php?channelid=$channelid&aid=$arcID'><u>更改软件</u></a>
  230. &nbsp;&nbsp;
  231. <a href='content_list.php?channelid={$channelid}'><u>已发布软件管理</u></a>
  232. ";
  233. $wintitle = "成功发布文章!";
  234. $wecome_info = "软件管理::发布软件";
  235. $win = new OxWindow();
  236. $win->AddTitle("成功发布软件:");
  237. $win->AddMsgItem($msg);
  238. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  239. $win->Display();
  240. }