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

288 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) 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_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-success 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. -------------------------------*/
  80. else if ($dopost == 'save') {
  81. require_once(DEDEINC.'/image.func.php');
  82. require_once(DEDEINC.'/oxwindow.class.php');
  83. $flag = isset($flags) ? join(',', $flags) : '';
  84. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  85. if (empty($typeid2)) $typeid2 = 0;
  86. if (!isset($autokey)) $autokey = 0;
  87. if (!isset($remote)) $remote = 0;
  88. if (!isset($dellink)) $dellink = 0;
  89. if (!isset($autolitpic)) $autolitpic = 0;
  90. if ($typeid == 0) {
  91. ShowMsg("请指定文档的栏目", "-1");
  92. exit();
  93. }
  94. if (empty($channelid)) {
  95. ShowMsg("文档为非指定的类型,请检查您发布内容的表单是否合法", "-1");
  96. exit();
  97. }
  98. if (!CheckChannel($typeid, $channelid)) {
  99. ShowMsg("您所选择的栏目与当前模型不相符,请选择白色的选项", "-1");
  100. exit();
  101. }
  102. if (!TestPurview('a_Edit')) {
  103. if (TestPurview('a_AccEdit')) {
  104. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的文档权限");
  105. } else {
  106. CheckArcAdmin($id, $cuserLogin->getUserID());
  107. }
  108. }
  109. //对保存的内容进行处理
  110. $pubdate = GetMkTime($pubdate);
  111. $senddate = time();
  112. $sortrank = AddDay($pubdate, $sortup);
  113. if ($ishtml == 0) {
  114. $ismake = -1;
  115. } else {
  116. $ismake = 0;
  117. }
  118. $title = cn_substrR($title, $cfg_title_maxlen);
  119. $shorttitle = cn_substrR($shorttitle, 36);
  120. $color = cn_substrR($color, 7);
  121. $writer = cn_substrR($writer, 20);
  122. $source = cn_substrR($source, 30);
  123. $description = cn_substrR($description, $cfg_auot_description);
  124. $keywords = cn_substrR($keywords, 60);
  125. $filename = trim(cn_substrR($filename, 40));
  126. $isremote = 0;
  127. $serviterm = empty($serviterm) ? "" : $serviterm;
  128. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  129. $arcrank = -1;
  130. }
  131. $adminid = $cuserLogin->getUserID();
  132. //处理上传的缩略图
  133. if (empty($ddisremote)) {
  134. $ddisremote = 0;
  135. }
  136. $litpic = GetDDImage('litpic', $picname, $ddisremote);
  137. //处理新的缩略图上传
  138. if ($litpic_b64 != "") {
  139. $data = explode(',', $litpic_b64);
  140. $ntime = time();
  141. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  142. CreateDir($savepath);
  143. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  144. $fullUrl = $fullUrl.".png";
  145. file_put_contents($cfg_basedir.$fullUrl, base64_decode($data[1]));
  146. //加水印
  147. WaterImg($cfg_basedir.$fullUrl, 'up');
  148. $litpic = $fullUrl;
  149. }
  150. //分析处理附加表数据
  151. $inadd_f = '';
  152. $inadd_v = '';
  153. if (!empty($dede_addonfields)) {
  154. $addonfields = explode(';', $dede_addonfields);
  155. $inadd_f = '';
  156. $inadd_v = '';
  157. if (is_array($addonfields)) {
  158. foreach ($addonfields as $v) {
  159. if ($v == '') {
  160. continue;
  161. }
  162. $vs = explode(',', $v);
  163. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') //HTML文本特殊处理
  164. {
  165. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  166. } else {
  167. if (!isset(${$vs[0]})) {
  168. ${$vs[0]} = '';
  169. }
  170. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $id);
  171. }
  172. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  173. }
  174. }
  175. }
  176. //处理图片文档的自定义属性
  177. if ($litpic != '' && !preg_match('#p#', $flag)) {
  178. $flag = ($flag == '' ? 'p' : $flag.',p');
  179. }
  180. if ($redirecturl != '' && !preg_match('#j#', $flag)) {
  181. $flag = ($flag == '' ? 'j' : $flag.',j');
  182. }
  183. //跳转网址的文档强制为动态
  184. if (preg_match('#j#', $flag)) $ismake = -1;
  185. //更改主档案表
  186. $inQuery = "UPDATE `#@__archives` SET
  187. typeid='$typeid',
  188. typeid2='$typeid2',
  189. sortrank='$sortrank',
  190. flag='$flag',
  191. click='$click',
  192. ismake='$ismake',
  193. arcrank='$arcrank',
  194. money='$money',
  195. title='$title',
  196. color='$color',
  197. source='$source',
  198. writer='$writer',
  199. litpic='$litpic',
  200. pubdate='$pubdate',
  201. notpost='$notpost',
  202. description='$description',
  203. keywords='$keywords',
  204. shorttitle='$shorttitle',
  205. filename='$filename',
  206. dutyadmin='$adminid',
  207. weight='$weight'
  208. WHERE id='$id'; ";
  209. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  210. ShowMsg("更新数据库archives表时出错,请检查", "-1");
  211. exit();
  212. }
  213. //软件链接列表
  214. $urls = '';
  215. for ($i = 1; $i <= 30; $i++) {
  216. if (!empty(${'softurl'.$i})) {
  217. $islocal = empty(${'islocal'.$i}) ? '' : 1;
  218. $isneed = empty(${'del'.$i}) ? true : false;
  219. $servermsg = str_replace("'", '', stripslashes(${'servermsg'.$i}));
  220. $softurl = stripslashes(${'softurl'.$i});
  221. if ($servermsg == '') {
  222. $servermsg = '下载地址'.$i;
  223. }
  224. if ($softurl != 'http://') {
  225. if ($islocal == 1) $urls .= "{dede:link islocal='$islocal' text='{$servermsg}'} $softurl {/dede:link}\r\n";
  226. else if ($isneed) $urls .= "{dede:link text='$servermsg'} $softurl {/dede:link}\r\n";
  227. else continue;
  228. }
  229. }
  230. }
  231. $urls = addslashes($urls);
  232. //更新附加表
  233. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  234. $addtable = trim($cts['addtable']);
  235. if ($addtable != '') {
  236. $useip = GetIP();
  237. $inQuery = "UPDATE `$addtable`
  238. SET typeid ='$typeid',
  239. filetype ='$filetype',
  240. language ='$language',
  241. softtype ='$softtype',
  242. accredit ='$accredit',
  243. os ='$os',
  244. softrank ='$softrank',
  245. officialUrl ='$officialUrl',
  246. officialDemo ='$officialDemo',
  247. softsize ='$softsize',
  248. softlinks ='$urls',
  249. redirecturl='$redirecturl',
  250. userip = '$useip',
  251. daccess = '$daccess',
  252. needmoney = '$needmoney',
  253. introduce='$body'
  254. {$inadd_f}
  255. WHERE aid='$id';";
  256. if (!$dsql->ExecuteNoneQuery($inQuery)) {
  257. ShowMsg("更新数据库附加表 addonsoft 时出错,请检查原因", "-1");
  258. exit();
  259. }
  260. }
  261. //生成HTML
  262. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  263. $arcUrl = MakeArt($id, TRUE, TRUE, $isremote);
  264. if ($arcUrl == "") {
  265. $arcUrl = $cfg_phpurl."/view.php?aid=$id";
  266. }
  267. ClearMyAddon($id, $title);
  268. //自动更新关联内容
  269. if (is_array($automake)) {
  270. foreach ($automake as $key => $value) {
  271. if (isset(${$key}) && !empty(${$key})) {
  272. $ids = explode(",", ${$key});
  273. foreach ($ids as $id) {
  274. MakeArt($id, true, true, $isremote);
  275. }
  276. }
  277. }
  278. }
  279. //返回成功信息
  280. $msg = "请选择您的后续操作:<a href='soft_add.php?cid=$typeid' class='btn btn-success btn-sm'>发布新软件</a>&nbsp;&nbsp;<a href='archives_do.php?aid=".$id."&dopost=editArchives' class='btn btn-success btn-sm'>继续修改</a>&nbsp;&nbsp;<a href='$arcUrl' target='_blank' class='btn btn-success btn-sm'>查看软件</a>&nbsp;&nbsp;<a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-success btn-sm'>已发布软件管理</a>&nbsp;&nbsp;<a href='catalog_main.php' class='btn btn-success btn-sm'>网站栏目管理</a>";
  281. $wintitle = "成功修改一个软件";
  282. $wecome_info = "文章管理::修改软件";
  283. $win = new OxWindow();
  284. $win->AddTitle("成功修改软件:");
  285. $win->AddMsgItem($msg);
  286. $winform = $win->GetWindow("hand", "&nbsp;", FALSE);
  287. $win->Display();
  288. }