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

266 lines
8.4KB

  1. <?php
  2. /**
  3. * 文档编辑
  4. *
  5. * @version $Id: article_edit.php 1 14:12 2010年7月12日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2019, 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(file_exists(DEDEDATA.'/template.rand.php'))
  16. {
  17. require_once(DEDEDATA.'/template.rand.php');
  18. }
  19. if(empty($dopost)) $dopost = '';
  20. $aid = isset($aid) && is_numeric($aid) ? $aid : 0;
  21. if($dopost!='save')
  22. {
  23. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  24. require_once(DEDEINC."/dedetag.class.php");
  25. ClearMyAddon();
  26. //读取归档信息
  27. $query = "SELECT ch.typename AS channelname,ar.membername AS rankname,arc.*
  28. FROM `#@__archives` arc
  29. LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
  30. LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id='$aid' ";
  31. $arcRow = $dsql->GetOne($query);
  32. if(!is_array($arcRow))
  33. {
  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. {
  41. ShowMsg("读取频道配置信息出错!","javascript:;");
  42. exit();
  43. }
  44. $addtable = $cInfos['addtable'];
  45. $addRow = $dsql->GetOne("SELECT * FROM `$addtable` WHERE aid='$aid'");
  46. if(!is_array($addRow))
  47. {
  48. ShowMsg("读取附加信息出错!","javascript:;");
  49. exit();
  50. }
  51. $channelid = $arcRow['channel'];
  52. $tags = GetTags($aid);
  53. include DedeInclude("templets/article_edit.htm");
  54. exit();
  55. }
  56. /*--------------------------------
  57. function __save(){ }
  58. -------------------------------*/
  59. else if($dopost=='save')
  60. {
  61. require_once(DEDEINC.'/image.func.php');
  62. require_once(DEDEINC.'/oxwindow.class.php');
  63. $flag = isset($flags) ? join(',',$flags) : '';
  64. $notpost = isset($notpost) && $notpost == 1 ? 1: 0;
  65. if(empty($typeid2)) $typeid2 = 0;
  66. if(!isset($autokey)) $autokey = 0;
  67. if(!isset($remote)) $remote = 0;
  68. if(!isset($dellink)) $dellink = 0;
  69. if(!isset($autolitpic)) $autolitpic = 0;
  70. if(empty($typeid))
  71. {
  72. ShowMsg("请指定文档的栏目!", "-1");
  73. exit();
  74. }
  75. if(empty($channelid))
  76. {
  77. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!", "-1");
  78. exit();
  79. }
  80. if(!CheckChannel($typeid, $channelid))
  81. {
  82. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!", "-1");
  83. exit();
  84. }
  85. if(!TestPurview('a_Edit'))
  86. {
  87. if(TestPurview('a_AccEdit'))
  88. {
  89. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的文档权限!");
  90. }
  91. else
  92. {
  93. CheckArcAdmin($id, $cuserLogin->getUserID());
  94. }
  95. }
  96. //对保存的内容进行处理
  97. $pubdate = GetMkTime($pubdate);
  98. $sortrank = AddDay($pubdate,$sortup);
  99. $ismake = $ishtml==0 ? -1 : 0;
  100. $autokey = 1;
  101. $title = dede_htmlspecialchars(cn_substrR($title,$cfg_title_maxlen));
  102. $shorttitle = cn_substrR($shorttitle,36);
  103. $color = cn_substrR($color,7);
  104. $writer = cn_substrR($writer,20);
  105. $source = cn_substrR($source,30);
  106. $description = cn_substrR($description,250);
  107. $keywords = trim(cn_substrR($keywords,60));
  108. $filename = trim(cn_substrR($filename,40));
  109. $isremote = (empty($isremote)? 0 : $isremote);
  110. $serviterm=empty($serviterm)? "" : $serviterm;
  111. if(!TestPurview('a_Check,a_AccCheck,a_MyCheck'))
  112. {
  113. $arcrank = -1;
  114. }
  115. $adminid = $cuserLogin->getUserID();
  116. //处理上传的缩略图
  117. if(empty($ddisremote))
  118. {
  119. $ddisremote = 0;
  120. }
  121. $litpic = GetDDImage('none',$picname,$ddisremote);
  122. //分析body里的内容
  123. $body = AnalyseHtmlBody($body,$description,$litpic,$keywords,'htmltext');
  124. //分析处理附加表数据
  125. $inadd_f = '';
  126. $inadd_v = '';
  127. if(!empty($dede_addonfields))
  128. {
  129. $addonfields = explode(';',$dede_addonfields);
  130. $inadd_f = '';
  131. $inadd_v = '';
  132. if(is_array($addonfields))
  133. {
  134. foreach($addonfields as $v)
  135. {
  136. if($v=='')
  137. {
  138. continue;
  139. }
  140. $vs = explode(',',$v);
  141. if($vs[1]=='htmltext'||$vs[1]=='textdata') //HTML文本特殊处理
  142. {
  143. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);
  144. }else
  145. {
  146. if(!isset(${$vs[0]}))
  147. {
  148. ${$vs[0]} = '';
  149. }
  150. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$id);
  151. }
  152. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  153. }
  154. }
  155. }
  156. //处理图片文档的自定义属性
  157. if($litpic!='' && !preg_match("#p#", $flag))
  158. {
  159. $flag = ($flag=='' ? 'p' : $flag.',p');
  160. }
  161. if($redirecturl!='' && !preg_match("#j#", $flag))
  162. {
  163. $flag = ($flag=='' ? 'j' : $flag.',j');
  164. }
  165. //跳转网址的文档强制为动态
  166. if(preg_match("#j#", $flag)) $ismake = -1;
  167. //更新数据库的SQL语句
  168. $query = "UPDATE #@__archives SET
  169. typeid='$typeid',
  170. typeid2='$typeid2',
  171. sortrank='$sortrank',
  172. flag='$flag',
  173. click='$click',
  174. ismake='$ismake',
  175. arcrank='$arcrank',
  176. money='$money',
  177. title='$title',
  178. color='$color',
  179. writer='$writer',
  180. source='$source',
  181. litpic='$litpic',
  182. pubdate='$pubdate',
  183. voteid='$voteid',
  184. notpost='$notpost',
  185. description='$description',
  186. keywords='$keywords',
  187. shorttitle='$shorttitle',
  188. filename='$filename',
  189. dutyadmin='$adminid',
  190. weight='$weight'
  191. WHERE id='$id'; ";
  192. if(!$dsql->ExecuteNoneQuery($query))
  193. {
  194. ShowMsg('更新数据库archives表时出错,请检查',-1);
  195. exit();
  196. }
  197. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  198. $addtable = trim($cts['addtable']);
  199. if($addtable!='')
  200. {
  201. $useip = GetIP();
  202. $templet = empty($templet) ? '' : $templet;
  203. $iquery = "UPDATE `$addtable` SET typeid='$typeid',body='$body'{$inadd_f},redirecturl='$redirecturl',templet='$templet',userip='$useip' WHERE aid='$id'";
  204. if(!$dsql->ExecuteNoneQuery($iquery))
  205. {
  206. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因!","javascript:;");
  207. exit();
  208. }
  209. }
  210. //生成HTML
  211. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  212. if($cfg_remote_site=='Y' && $isremote=="1")
  213. {
  214. if($serviterm!=""){
  215. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  216. $config=array( 'hostname' => $servurl, 'username' => $servuser,
  217. 'password' => $servpwd,'debug' => 'TRUE');
  218. } else {
  219. $config=array();
  220. }
  221. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  222. }
  223. $artUrl = MakeArt($id,true,true,$isremote);
  224. if($artUrl=='')
  225. {
  226. $artUrl = $cfg_phpurl."/view.php?aid=$id";
  227. }
  228. ClearMyAddon($id, $title);
  229. //返回成功信息
  230. $msg = "
  231.   请选择你的后续操作:
  232. <a href='article_add.php?cid=$typeid'><u>发布新文章</u></a>
  233. &nbsp;&nbsp;
  234. <a href='archives_do.php?aid=".$id."&dopost=editArchives'><u>查看更改</u></a>
  235. &nbsp;&nbsp;
  236. <a href='$artUrl' target='_blank'><u>查看文章</u></a>
  237. &nbsp;&nbsp;
  238. <a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>管理文章</u></a>
  239. &nbsp;&nbsp;
  240. $backurl
  241. ";
  242. $wintitle = "成功更改文章!";
  243. $wecome_info = "文章管理::更改文章";
  244. $win = new OxWindow();
  245. $win->AddTitle("成功更改文章:");
  246. $win->AddMsgItem($msg);
  247. $winform = $win->GetWindow("hand","&nbsp;",false);
  248. $win->Display();
  249. }