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

353 lines
12KB

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