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

320 lines
11KB

  1. <?php
  2. /**
  3. * 软件编辑
  4. *
  5. * @version $Id: soft_edit.php 1 16:09 2010年7月20日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2020, 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_Edit,a_AccEdit,a_MyEdit');
  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(DEDEADMIN . "/inc/inc_catalog_options.php");
  18. require_once(DEDEINC . "/dedetag.class.php");
  19. ClearMyAddon();
  20. $aid = preg_replace("#[^0-9]#", '', $aid);
  21. $channelid = "3";
  22. //读取归档信息
  23. $arcQuery = "SELECT
  24. #@__channeltype.typename as channelname,
  25. #@__arcrank.membername as rankname,
  26. #@__archives.*
  27. FROM #@__archives
  28. LEFT JOIN #@__channeltype ON #@__channeltype.id=#@__archives.channel
  29. LEFT JOIN #@__arcrank ON #@__arcrank.rank=#@__archives.arcrank
  30. WHERE #@__archives.id='$aid'";
  31. $dsql->SetQuery($arcQuery);
  32. $arcRow = $dsql->GetOne($arcQuery);
  33. if (!is_array($arcRow)) {
  34. ShowMsg("读取档案基本信息出错!", "-1");
  35. exit();
  36. }
  37. $query = "SELECT * FROM `#@__channeltype` WHERE id='" . $arcRow['channel'] . "'";
  38. $cInfos = $dsql->GetOne($query);
  39. if (!is_array($cInfos)) {
  40. ShowMsg("读取频道配置信息出错!", "javascript:;");
  41. exit();
  42. }
  43. $addtable = $cInfos['addtable'];
  44. $addQuery = "SELECT * FROM `$addtable` WHERE aid='$aid'";
  45. $addRow = $dsql->GetOne($addQuery);
  46. $newRowStart = 1;
  47. $nForm = '';
  48. $daccess = $addRow['daccess'];
  49. $needmoney = $addRow['needmoney'];
  50. if ($addRow['softlinks'] != '') {
  51. $dtp = new DedeTagParse();
  52. $dtp->LoadSource($addRow['softlinks']);
  53. if (is_array($dtp->CTags)) {
  54. foreach ($dtp->CTags as $ctag) {
  55. if ($ctag->GetName() == 'link') {
  56. $islocal = $ctag->GetAtt('islocal');
  57. if ($islocal != 1) $needmsg = "<input type='checkbox' name='del{$newRowStart}' value='1' />删除";
  58. else $needmsg = '<button name="sel1" class="btn btn-secondary btn-sm" type="button" id="sel1" onClick="SelectSoft(\'form1.softurl' . $newRowStart . '\')">选取</button>';
  59. $nForm .= "<div style='line-height:36px'>软件地址{$newRowStart}:<input type='text' name='softurl{$newRowStart}' style='width:280px' value='" . trim($ctag->GetInnerText()) . "' />
  60. 服务器名称:<input type='text' name='servermsg{$newRowStart}' value='" . $ctag->GetAtt("text") . "' style='width:150px' />
  61. <input type='hidden' name='islocal{$newRowStart}' value='{$islocal}' />
  62. $needmsg
  63. </div>\r\n";
  64. $newRowStart++;
  65. }
  66. }
  67. }
  68. $dtp->Clear();
  69. }
  70. $channelid = $arcRow['channel'];
  71. $tags = GetTags($aid);
  72. $arcRow = XSSClean($arcRow);
  73. $addRow = XSSClean($addRow);
  74. include DedeInclude("templets/soft_edit.htm");
  75. exit();
  76. }
  77. /*--------------------------------
  78. function __save(){ }
  79. -------------------------------*/ else if ($dopost == 'save') {
  80. require_once(DEDEINC . '/image.func.php');
  81. require_once(DEDEINC . '/oxwindow.class.php');
  82. $flag = isset($flags) ? join(',', $flags) : '';
  83. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  84. if (empty($typeid2)) $typeid2 = 0;
  85. if (!isset($autokey)) $autokey = 0;
  86. if (!isset($remote)) $remote = 0;
  87. if (!isset($dellink)) $dellink = 0;
  88. if (!isset($autolitpic)) $autolitpic = 0;
  89. if ($typeid == 0) {
  90. ShowMsg("请指定文档的栏目!", "-1");
  91. exit();
  92. }
  93. if (empty($channelid)) {
  94. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!", "-1");
  95. exit();
  96. }
  97. if (!CheckChannel($typeid, $channelid)) {
  98. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!", "-1");
  99. exit();
  100. }
  101. if (!TestPurview('a_Edit')) {
  102. if (TestPurview('a_AccEdit')) {
  103. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的文档权限!");
  104. } else {
  105. CheckArcAdmin($id, $cuserLogin->getUserID());
  106. }
  107. }
  108. //对保存的内容进行处理
  109. $pubdate = GetMkTime($pubdate);
  110. $senddate = time();
  111. $sortrank = AddDay($pubdate, $sortup);
  112. if ($ishtml == 0) {
  113. $ismake = -1;
  114. } else {
  115. $ismake = 0;
  116. }
  117. $title = cn_substrR($title, $cfg_title_maxlen);
  118. $shorttitle = cn_substrR($shorttitle, 36);
  119. $color = cn_substrR($color, 7);
  120. $writer = cn_substrR($writer, 20);
  121. $source = cn_substrR($source, 30);
  122. $description = cn_substrR($description, $cfg_auot_description);
  123. $keywords = cn_substrR($keywords, 60);
  124. $filename = trim(cn_substrR($filename, 40));
  125. $isremote = 0;
  126. $serviterm = empty($serviterm) ? "" : $serviterm;
  127. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  128. $arcrank = -1;
  129. }
  130. $adminid = $cuserLogin->getUserID();
  131. //处理上传的缩略图
  132. if (empty($ddisremote)) {
  133. $ddisremote = 0;
  134. }
  135. $litpic = GetDDImage('litpic', $picname, $ddisremote);
  136. // 处理新的缩略图上传
  137. if ($litpic_b64 != "") {
  138. $data = explode(',', $litpic_b64);
  139. $ntime = time();
  140. $savepath = $ddcfg_image_dir . '/' . MyDate($cfg_addon_savetype, $ntime);
  141. CreateDir($savepath);
  142. $fullUrl = $savepath . '/' . dd2char(MyDate('mdHis', $ntime) . $cuserLogin->getUserID() . mt_rand(1000, 9999));
  143. $fullUrl = $fullUrl . ".png";
  144. file_put_contents($cfg_basedir . $fullUrl, base64_decode($data[1]));
  145. // 加水印
  146. WaterImg($cfg_basedir . $fullUrl, 'up');
  147. $litpic = $fullUrl;
  148. }
  149. //分析处理附加表数据
  150. $inadd_f = '';
  151. $inadd_v = '';
  152. if (!empty($dede_addonfields)) {
  153. $addonfields = explode(';', $dede_addonfields);
  154. $inadd_f = '';
  155. $inadd_v = '';
  156. if (is_array($addonfields)) {
  157. foreach ($addonfields as $v) {
  158. if ($v == '') {
  159. continue;
  160. }
  161. $vs = explode(',', $v);
  162. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  163. {
  164. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  165. } else {
  166. if (!isset(${$vs[0]})) {
  167. ${$vs[0]} = '';
  168. }
  169. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  170. }
  171. $inadd_f .= ",`{$vs[0]}` = '" . ${$vs[0]} . "'";
  172. }
  173. }
  174. }
  175. //处理图片文档的自定义属性
  176. if ($litpic != '' && !preg_match('#p#', $flag)) {
  177. $flag = ($flag == '' ? 'p' : $flag . ',p');
  178. }
  179. if ($redirecturl != '' && !preg_match('#j#', $flag)) {
  180. $flag = ($flag == '' ? 'j' : $flag . ',j');
  181. }
  182. //跳转网址的文档强制为动态
  183. if (preg_match('#j#', $flag)) $ismake = -1;
  184. //更改主档案表
  185. $inQuery = "UPDATE `#@__archives` SET
  186. typeid='$typeid',
  187. typeid2='$typeid2',
  188. sortrank='$sortrank',
  189. flag='$flag',
  190. click='$click',
  191. ismake='$ismake',
  192. arcrank='$arcrank',
  193. money='$money',
  194. title='$title',
  195. color='$color',
  196. source='$source',
  197. writer='$writer',
  198. litpic='$litpic',
  199. pubdate='$pubdate',
  200. notpost='$notpost',
  201. description='$description',
  202. keywords='$keywords',
  203. shorttitle='$shorttitle',
  204. filename='$filename',
  205. dutyadmin='$adminid',
  206. weight='$weight'
  207. WHERE id='$id'; ";
  208. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  209. ShowMsg("更新数据库archives表时出错,请检查!", "-1");
  210. exit();
  211. }
  212. //软件链接列表
  213. $urls = '';
  214. for ($i = 1; $i <= 30; $i++) {
  215. if (!empty(${'softurl' . $i})) {
  216. $islocal = empty(${'islocal' . $i}) ? '' : 1;
  217. $isneed = empty(${'del' . $i}) ? true : false;
  218. $servermsg = str_replace("'", '', stripslashes(${'servermsg' . $i}));
  219. $softurl = stripslashes(${'softurl' . $i});
  220. if ($servermsg == '') {
  221. $servermsg = '下载地址' . $i;
  222. }
  223. if ($softurl != 'http://') {
  224. if ($islocal == 1) $urls .= "{dede:link islocal='$islocal' text='{$servermsg}'} $softurl {/dede:link}\r\n";
  225. else if ($isneed) $urls .= "{dede:link text='$servermsg'} $softurl {/dede:link}\r\n";
  226. else continue;
  227. }
  228. }
  229. }
  230. $urls = addslashes($urls);
  231. //更新附加表
  232. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  233. $addtable = trim($cts['addtable']);
  234. if ($addtable != '') {
  235. $useip = GetIP();
  236. $inQuery = "UPDATE `$addtable`
  237. SET typeid ='$typeid',
  238. filetype ='$filetype',
  239. language ='$language',
  240. softtype ='$softtype',
  241. accredit ='$accredit',
  242. os ='$os',
  243. softrank ='$softrank',
  244. officialUrl ='$officialUrl',
  245. officialDemo ='$officialDemo',
  246. softsize ='$softsize',
  247. softlinks ='$urls',
  248. redirecturl='$redirecturl',
  249. userip = '$useip',
  250. daccess = '$daccess',
  251. needmoney = '$needmoney',
  252. introduce='$body'
  253. {$inadd_f}
  254. WHERE aid='$id';";
  255. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  256. ShowMsg("更新数据库附加表 addonsoft 时出错,请检查原因!", "-1");
  257. exit();
  258. }
  259. }
  260. //生成HTML
  261. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  262. $arcUrl = MakeArt($id, TRUE, TRUE, $isremote);
  263. if ($arcUrl == "") {
  264. $arcUrl = $cfg_phpurl . "/view.php?aid=$id";
  265. }
  266. ClearMyAddon($id, $title);
  267. // 自动更新关联内容
  268. if (is_array($automake)) {
  269. foreach ($automake as $key => $value) {
  270. if (isset(${$key}) && !empty(${$key})) {
  271. $ids = explode(",", ${$key});
  272. foreach ($ids as $id) {
  273. MakeArt($id, true, true, $isremote);
  274. }
  275. }
  276. }
  277. }
  278. //返回成功信息
  279. $msg = "
  280.   请选择你的后续操作:
  281. <a href='soft_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>发布新软件</a>
  282. &nbsp;&nbsp;
  283. <a href='archives_do.php?aid=" . $id . "&dopost=editArchives' class='btn btn-secondary btn-sm'>继续修改</a>
  284. &nbsp;&nbsp;
  285. <a href='$arcUrl' target='_blank' class='btn btn-secondary btn-sm'>查看软件</a>
  286. &nbsp;&nbsp;
  287. <a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-secondary btn-sm'>已发布软件管理</a>
  288. &nbsp;&nbsp;
  289. <a href='catalog_main.php' class='btn btn-secondary btn-sm'>网站栏目管理</a>
  290. ";
  291. $wintitle = "成功修改一个软件!";
  292. $wecome_info = "文章管理::修改软件";
  293. $win = new OxWindow();
  294. $win->AddTitle("成功修改软件:");
  295. $win->AddMsgItem($msg);
  296. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  297. $win->Display();
  298. }