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

239 line
11KB

  1. <?php
  2. /**
  3. * 发布软件模型
  4. *
  5. * @version $id:soft_add.php 16:09 2010年7月20日 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 = 1;
  28. }
  29. $softconfig = $dsql->GetOne("SELECT * FROM `#@__softconfig`");
  30. //获得栏目模型信息
  31. $cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  32. $channelid = $cInfos['id'];
  33. //获取文档最大id+1以确定当前权重
  34. $maxWright = $dsql->GetOne("SELECT id+1 AS cc FROM `#@__archives` ORDER BY id DESC LIMIT 1");
  35. $maxWright = empty($maxWright)? array('cc'=>1) : $maxWright;
  36. include DedeInclude("templets/soft_add.htm");
  37. exit();
  38. } else if ($dopost == 'save') {
  39. require_once(DEDEINC.'/image.func.php');
  40. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  41. $flag = isset($flags) ? join(',', $flags) : '';
  42. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  43. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(1000,6000) : $cfg_arc_click);
  44. if (!isset($typeid2)) $typeid2 = 0;
  45. if (!isset($autokey)) $autokey = 0;
  46. if (!isset($remote)) $remote = 0;
  47. if (!isset($dellink)) $dellink = 0;
  48. if (!isset($autolitpic)) $autolitpic = 0;
  49. if ($typeid == 0) {
  50. ShowMsg("请指定文档的栏目", "-1");
  51. exit();
  52. }
  53. if (empty($channelid)) {
  54. ShowMsg("文档为非指定类型,请检查您发布文档是否正确", "-1");
  55. exit();
  56. }
  57. if (!CheckChannel($typeid, $channelid)) {
  58. ShowMsg("您所选择的栏目与当前模型不相符,请重新选择", "-1");
  59. exit();
  60. }
  61. if (!TestPurview('a_New')) {
  62. CheckCatalog($typeid, "您没有操作栏目<span class='text-primary'>{$typeid}</span>权限");
  63. }
  64. //对保存的文档进行处理
  65. if (empty($writer)) $writer = $cuserLogin->getUserName();
  66. if (empty($source)) $source = '未知';
  67. $pubdate = GetMkTime($pubdate);
  68. $senddate = time();
  69. $sortrank = AddDay($pubdate, $sortup);
  70. if ($ishtml == 0) $ismake = -1;
  71. else $ismake = 0;
  72. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(1000,6000) : $cfg_arc_click);
  73. $title = preg_replace('#"#', '"', $title);
  74. $title = cn_substrR($title, $cfg_title_maxlen);
  75. $shorttitle = cn_substrR($shorttitle, 36);
  76. $color = cn_substrR($color, 7);
  77. $writer = cn_substrR($writer, 20);
  78. $source = cn_substrR($source, 30);
  79. $description = cn_substrR($description, $cfg_auot_description);
  80. $keywords = cn_substrR($keywords, 60);
  81. $filename = trim(cn_substrR($filename, 40));
  82. $userip = GetIP();
  83. $isremote = 0;
  84. $serviterm = empty($serviterm) ? "" : $serviterm;
  85. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  86. $arcrank = -1;
  87. }
  88. $adminid = $cuserLogin->getUserID();
  89. //处理上传的缩略图
  90. if (empty($ddisremote)) {
  91. $ddisremote = 0;
  92. }
  93. $litpic = GetDDImage('none', $picname, $ddisremote);
  94. //生成文档id
  95. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  96. if (empty($arcID)) {
  97. ShowMsg("获取主键失败,无法进行后续操作", "-1");
  98. exit();
  99. }
  100. //处理body字段自动摘要、自动提取缩略图等
  101. $body = AnalyseHtmlBody($body, $description, $litpic, $keywords, 'htmltext');
  102. //分析处理附加表数据
  103. $inadd_f = '';
  104. $inadd_v = '';
  105. if (!empty($dede_addonfields)) {
  106. $addonfields = explode(';', $dede_addonfields);
  107. $inadd_f = '';
  108. $inadd_v = '';
  109. if (is_array($addonfields)) {
  110. foreach ($addonfields as $v) {
  111. if ($v == '') {
  112. continue;
  113. }
  114. $vs = explode(',', $v);
  115. if (!isset(${$vs[0]})) {
  116. ${$vs[0]} = '';
  117. } else if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //网页文本特殊处理
  118. {
  119. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  120. } else {
  121. if (!isset(${$vs[0]})) {
  122. ${$vs[0]} = '';
  123. }
  124. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  125. }
  126. $inadd_f .= ','.$vs[0];
  127. $inadd_v .= " ,'".${$vs[0]}."' ";
  128. }
  129. }
  130. }
  131. //处理图片文档的自定义属性
  132. if ($litpic != '' && !preg_match('#p#', $flag)) {
  133. $flag = ($flag == '' ? 'p' : $flag.',p');
  134. }
  135. if ($redirecturl != '' && !preg_match('#j#', $flag)) {
  136. $flag = ($flag == '' ? 'j' : $flag.',j');
  137. }
  138. //跳转网址的文档强制为动态
  139. if (preg_match('#j#', $flag)) $ismake = -1;
  140. //保存到主表
  141. $inQuery = "INSERT INTO `#@__archives` (id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight) VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  142. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  143. $gerr = $dsql->GetError();
  144. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  145. ShowMsg("数据保存到数据库文档主表出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  146. exit();
  147. }
  148. //软件链接列表
  149. $urls = '';
  150. //本地链接处理
  151. $softurl1 = stripslashes($softurl1);
  152. $nsoftsize = '';
  153. if ($softurl1 != '') {
  154. if (preg_match("#}(.*?){/dede:link}{dede:#sim", $servermsg1) != 1) { $urls .= "{dede:link islocal='1' text='{$servermsg1}'} $softurl1 {/dede:link}\r\n"; }
  155. $autosize = empty($autosize) ? FALSE : TRUE;
  156. if ($autosize && empty($softsize)) {
  157. $nsoftsize = @filesize($cfg_basedir.$softurl1);
  158. if (empty($nsoftsize)) $nsoftsize = '未知';
  159. else {
  160. $nsoftsize = trim(sprintf("%0.2f", $nsoftsize / 1024 / 1024));
  161. $nsoftsize = $nsoftsize." MB";
  162. }
  163. }
  164. }
  165. //软件大小
  166. if (!empty($nsoftsize)) $softsize = $nsoftsize;
  167. else if (empty($softsize)) $softsize = '未知';
  168. else $softsize = $softsize.' '.$unit;
  169. //其它链接处理
  170. for ($i = 2; $i <= 30; $i++) {
  171. if (!empty(${'softurl'.$i})) {
  172. $forconfig = empty(${'forconfig'.$i}) ? FALSE : TRUE;
  173. if ($forconfig) {
  174. if (empty(${'need'.$i})) continue;
  175. $serverUrl = stripslashes(${'softurlfirst'.$i});
  176. $serverUrl = preg_replace("#\/$#", "", $serverUrl);
  177. $softurl = stripslashes(${'softurl'.$i});
  178. if (cn_substr($softurl, 1) != '/') $softurl = '/'.$softurl;
  179. $softurl = $serverUrl.$softurl;
  180. } else {
  181. $softurl = stripslashes(${'softurl'.$i});
  182. }
  183. $servermsg = str_replace("'", "", stripslashes(${'servermsg'.$i}));
  184. if ($servermsg == '') $servermsg = '下载地址'.$i;
  185. if ($softurl != 'http://') {
  186. $urls .= "{dede:link text='$servermsg'} $softurl {/dede:link}\r\n";
  187. }
  188. }
  189. }
  190. $urls = addslashes($urls);
  191. //保存到附加表
  192. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  193. $addtable = trim($cts['addtable']);
  194. if (empty($addtable)) {
  195. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  196. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  197. ShowMsg("没找到模型<span class='text-primary'>{$channelid}</span>主表信息,无法完成操作", "javascript:;");
  198. exit();
  199. }
  200. $daccess = isset($daccess) && is_numeric($daccess) ? $daccess : 0;
  201. $useip = GetIP();
  202. $inQuery = "INSERT INTO `$addtable` (aid,typeid,redirecturl,userip,filetype,language,softtype,accredit,os,softrank,officialUrl,officialDemo,softsize,softlinks,introduce,daccess,needmoney{$inadd_f}) VALUES ('$arcID','$typeid','$redirecturl','$useip','$filetype','$language','$softtype','$accredit','$os','$softrank','$officialUrl','$officialDemo','$softsize','$urls','$body','$daccess','$needmoney'{$inadd_v});";
  203. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  204. $gerr = $dsql->GetError();
  205. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  206. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  207. ShowMsg("数据保存到数据库附加表出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  208. exit();
  209. }
  210. //生成网页
  211. InsertTags($tags, $arcID);
  212. $arcUrl = MakeArt($arcID, TRUE, TRUE, 0);
  213. if ($arcUrl == '') {
  214. $arcUrl = $cfg_phpurl."/view.php?aid=$arcID";
  215. }
  216. ClearMyAddon($arcID, $title);
  217. //自动更新关联文档
  218. if (is_array($automake)) {
  219. foreach ($automake as $key => $value) {
  220. if (isset(${$key}) && !empty(${$key})) {
  221. $ids = explode(",", ${$key});
  222. foreach ($ids as $id) {
  223. MakeArt($id, true, true, $isremote);
  224. }
  225. }
  226. }
  227. }
  228. //返回成功信息
  229. $msg = "<tr><td>请选择后续操作:<a href='soft_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='$arcUrl' 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></td></tr>";
  230. $msg = "{$msg}".GetUpdateTest();
  231. $wintitle = "成功发布软件文档";
  232. $wecome_info = "文档管理 - 发布软件文档";
  233. $win = new OxWindow();
  234. $win->AddTitle("成功发布软件文档");
  235. $win->AddMsgItem($msg);
  236. $winform = $win->GetWindow("hand", FALSE);
  237. $win->Display();
  238. }
  239. ?>