国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

soft_add.php 12KB

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