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

315 lines
12KB

  1. <?php
  2. /**
  3. * 软件发布
  4. *
  5. * @version $Id: soft_add.php 1 16:09 2010年7月20日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2019, 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. 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. {
  18. require_once(DEDEINC.'/dedetag.class.php');
  19. require_once(DEDEADMIN.'/inc/inc_catalog_options.php');
  20. ClearMyAddon();
  21. $channelid = empty($channelid) ? 0 : intval($channelid);
  22. $cid = empty($cid) ? 0 : intval($cid);
  23. //获得频道模型ID
  24. if($cid>0 && $channelid==0)
  25. {
  26. $row = $dsql->GetOne("SELECT channeltype FROM `#@__arctype` WHERE id='$cid'; ");
  27. $channelid = $row['channeltype'];
  28. } else {
  29. if($channelid==0) $channelid = 1;
  30. }
  31. $softconfig = $dsql->GetOne("SELECT * FROM `#@__softconfig` ");
  32. //获得频道模型信息
  33. $cInfos = $dsql->GetOne(" SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  34. $channelid = $cInfos['id'];
  35. //获取文章最大id以确定当前权重
  36. $maxWright = $dsql->GetOne("SELECT COUNT(*) AS cc FROM #@__archives");
  37. include DedeInclude("templets/soft_add.htm");
  38. exit();
  39. }
  40. /*--------------------------------
  41. function __save(){ }
  42. -------------------------------*/
  43. else if($dopost=='save')
  44. {
  45. require_once(DEDEINC.'/image.func.php');
  46. require_once(DEDEINC.'/oxwindow.class.php');
  47. $flag = isset($flags) ? join(',',$flags) : '';
  48. $notpost = isset($notpost) && $notpost == 1 ? 1: 0;
  49. if(empty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click);
  50. if(!isset($typeid2)) $typeid2 = 0;
  51. if(!isset($autokey)) $autokey = 0;
  52. if(!isset($remote)) $remote = 0;
  53. if(!isset($dellink)) $dellink = 0;
  54. if(!isset($autolitpic)) $autolitpic = 0;
  55. if($typeid==0)
  56. {
  57. ShowMsg("请指定文档的栏目!","-1");
  58. exit();
  59. }
  60. if(empty($channelid))
  61. {
  62. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!","-1");
  63. exit();
  64. }
  65. if(!CheckChannel($typeid,$channelid) )
  66. {
  67. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!","-1");
  68. exit();
  69. }
  70. if(!TestPurview('a_New'))
  71. {
  72. CheckCatalog($typeid,"对不起,你没有操作栏目 {$typeid} 的权限!");
  73. }
  74. //对保存的内容进行处理
  75. if(empty($writer))$writer=$cuserLogin->getUserName();
  76. if(empty($source))$source='未知';
  77. $pubdate = GetMkTime($pubdate);
  78. $senddate = time();
  79. $sortrank = AddDay($pubdate,$sortup);
  80. if($ishtml==0) $ismake = -1;
  81. else $ismake = 0;
  82. if(empty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click);
  83. $title = preg_replace('#"#', '"', $title);
  84. $title = cn_substrR($title, $cfg_title_maxlen);
  85. $shorttitle = cn_substrR($shorttitle, 36);
  86. $color = cn_substrR($color, 7);
  87. $writer = cn_substrR($writer, 20);
  88. $source = cn_substrR($source, 30);
  89. $description = cn_substrR($description, $cfg_auot_description);
  90. $keywords = cn_substrR($keywords, 60);
  91. $filename = trim(cn_substrR($filename, 40));
  92. $userip = GetIP();
  93. $isremote = (empty($isremote)? 0 : $isremote);
  94. $serviterm=empty($serviterm)? "" : $serviterm;
  95. if(!TestPurview('a_Check,a_AccCheck,a_MyCheck'))
  96. {
  97. $arcrank = -1;
  98. }
  99. $adminid = $cuserLogin->getUserID();
  100. //处理上传的缩略图
  101. if(empty($ddisremote)) $ddisremote = 0;
  102. $litpic = GetDDImage('none', $picname, $ddisremote);
  103. //生成文档ID
  104. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  105. if(empty($arcID))
  106. {
  107. ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
  108. exit();
  109. }
  110. //处理body字段自动摘要、自动提取缩略图等
  111. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  112. //分析处理附加表数据
  113. $inadd_f = '';
  114. $inadd_v = '';
  115. if(!empty($dede_addonfields))
  116. {
  117. $addonfields = explode(';', $dede_addonfields);
  118. $inadd_f = '';
  119. $inadd_v = '';
  120. if(is_array($addonfields))
  121. {
  122. foreach($addonfields as $v)
  123. {
  124. if($v=='')
  125. {
  126. continue;
  127. }
  128. $vs = explode(',',$v);
  129. if(!isset(${$vs[0]}))
  130. {
  131. ${$vs[0]} = '';
  132. }
  133. else if($vs[1]=='htmltext'||$vs[1]=='textdata') //HTML文本特殊处理
  134. {
  135. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);
  136. }
  137. else
  138. {
  139. if(!isset(${$vs[0]}))
  140. {
  141. ${$vs[0]} = '';
  142. }
  143. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$arcID);
  144. }
  145. $inadd_f .= ','.$vs[0];
  146. $inadd_v .= " ,'".${$vs[0]}."' ";
  147. }
  148. }
  149. }
  150. //处理图片文档的自定义属性
  151. if($litpic!='' && !preg_match('#p#', $flag))
  152. {
  153. $flag = ($flag=='' ? 'p' : $flag.',p');
  154. }
  155. if($redirecturl!='' && !preg_match('#j#', $flag))
  156. {
  157. $flag = ($flag=='' ? 'j' : $flag.',j');
  158. }
  159. //跳转网址的文档强制为动态
  160. if(preg_match('#j#', $flag)) $ismake = -1;
  161. //保存到主表
  162. $inQuery = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  163. color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight)
  164. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  165. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  166. if(!$dsql->ExecuteNoneQuery($inQuery))
  167. {
  168. $gerr = $dsql->GetError();
  169. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  170. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  171. exit();
  172. }
  173. //软件链接列表
  174. $urls = '';
  175. //本地链接处理
  176. $softurl1 = stripslashes($softurl1);
  177. $nsoftsize = '';
  178. if($softurl1 != '')
  179. {
  180. $urls .= "{dede:link islocal='1' text='{$servermsg1}'} $softurl1 {/dede:link}\r\n";
  181. $autosize = empty($autosize) ? FALSE : TRUE;
  182. if($autosize && empty($softsize))
  183. {
  184. $nsoftsize = @filesize($cfg_basedir.$softurl1);
  185. if(empty($nsoftsize)) $nsoftsize = '未知';
  186. else
  187. {
  188. $nsoftsize = trim(sprintf("%0.2f", $nsoftsize / 1024 / 1024));
  189. $nsoftsize = $nsoftsize." MB";
  190. }
  191. }
  192. }
  193. //软件大小
  194. if(!empty($nsoftsize)) $softsize = $nsoftsize;
  195. else if(empty($softsize)) $softsize = '未知';
  196. else $softsize = $softsize.' '.$unit;
  197. //其它链接处理
  198. for($i=2; $i<=30; $i++)
  199. {
  200. if(!empty(${'softurl'.$i}))
  201. {
  202. $forconfig = empty(${'forconfig'.$i}) ? FALSE : TRUE;
  203. if($forconfig)
  204. {
  205. if(empty(${'need'.$i})) continue;
  206. $serverUrl = stripslashes(${'softurlfirst'.$i});
  207. $serverUrl = preg_replace("#\/$#", "", $serverUrl);
  208. $softurl = stripslashes(${'softurl'.$i});
  209. if( cn_substr($softurl, 1) != '/' ) $softurl = '/'.$softurl;
  210. $softurl = $serverUrl.$softurl;
  211. }
  212. else
  213. {
  214. $softurl = stripslashes(${'softurl'.$i});
  215. }
  216. $servermsg = str_replace("'", "", stripslashes(${'servermsg'.$i}));
  217. if($servermsg=='') $servermsg = '下载地址'.$i;
  218. if($softurl != 'http://')
  219. {
  220. $urls .= "{dede:link text='$servermsg'} $softurl {/dede:link}\r\n";
  221. }
  222. }
  223. }
  224. $urls = addslashes($urls);
  225. //保存到附加表
  226. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  227. $addtable = trim($cts['addtable']);
  228. if(empty($addtable))
  229. {
  230. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  231. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  232. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。","javascript:;");
  233. exit();
  234. }
  235. $daccess = isset($daccess) && is_numeric($daccess) ? $daccess : 0;
  236. $useip = GetIP();
  237. $inQuery = "INSERT INTO `$addtable`(aid,typeid,redirecturl,userip,filetype,language,softtype,accredit,
  238. os,softrank,officialUrl,officialDemo,softsize,softlinks,introduce,daccess,needmoney{$inadd_f})
  239. VALUES ('$arcID','$typeid','$redirecturl','$useip','$filetype','$language','$softtype','$accredit',
  240. '$os','$softrank','$officialUrl','$officialDemo','$softsize','$urls','$body','$daccess','$needmoney'{$inadd_v});";
  241. if(!$dsql->ExecuteNoneQuery($inQuery))
  242. {
  243. $gerr = $dsql->GetError();
  244. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  245. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  246. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  247. exit();
  248. }
  249. //生成HTML
  250. InsertTags($tags, $arcID);
  251. if($cfg_remote_site=='Y' && $isremote=="1")
  252. {
  253. if($serviterm!="")
  254. {
  255. list($servurl, $servuser, $servpwd) = explode(',',$serviterm);
  256. $config = array( 'hostname' => $servurl, 'username' => $servuser,
  257. 'password' => $servpwd,'debug' => 'TRUE');
  258. } else {
  259. $config = array();
  260. }
  261. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  262. }
  263. $arcUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  264. if($arcUrl=='')
  265. {
  266. $arcUrl = $cfg_phpurl."/view.php?aid=$arcID";
  267. }
  268. ClearMyAddon($arcID, $title);
  269. //返回成功信息
  270. $msg = "
  271.   请选择你的后续操作:
  272. <a href='soft_add.php?cid=$typeid'><u>继续发布软件</u></a>
  273. &nbsp;&nbsp;
  274. <a href='$arcUrl' target='_blank'><u>查看软件</u></a>
  275. &nbsp;&nbsp;
  276. <a href='archives_do.php?aid=".$arcID."&dopost=editArchives'><u>更改软件</u></a>
  277. &nbsp;&nbsp;
  278. <a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>已发布软件管理</u></a>
  279. &nbsp;&nbsp;
  280. <a href='catalog_main.php'><u>网站栏目管理</u></a>
  281. ";
  282. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  283. $wintitle = "成功发布一个软件!";
  284. $wecome_info = "文章管理::发布软件";
  285. $win = new OxWindow();
  286. $win->AddTitle("成功发布软件:");
  287. $win->AddMsgItem($msg);
  288. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  289. $win->Display();
  290. }