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

282 lines
9.0KB

  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 - 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(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($litpic_b64)) $litpic_b64 = '';
  71. if(empty($typeid))
  72. {
  73. ShowMsg("请指定文档的栏目!", "-1");
  74. exit();
  75. }
  76. if(empty($channelid))
  77. {
  78. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!", "-1");
  79. exit();
  80. }
  81. if(!CheckChannel($typeid, $channelid))
  82. {
  83. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!", "-1");
  84. exit();
  85. }
  86. if(!TestPurview('a_Edit'))
  87. {
  88. if(TestPurview('a_AccEdit'))
  89. {
  90. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的文档权限!");
  91. }
  92. else
  93. {
  94. CheckArcAdmin($id, $cuserLogin->getUserID());
  95. }
  96. }
  97. //对保存的内容进行处理
  98. $pubdate = GetMkTime($pubdate);
  99. $sortrank = AddDay($pubdate,$sortup);
  100. $ismake = $ishtml==0 ? -1 : 0;
  101. $autokey = 1;
  102. $title = dede_htmlspecialchars(cn_substrR($title,$cfg_title_maxlen));
  103. $shorttitle = cn_substrR($shorttitle,36);
  104. $color = cn_substrR($color,7);
  105. $writer = cn_substrR($writer,20);
  106. $source = cn_substrR($source,30);
  107. $description = cn_substrR($description,250);
  108. $keywords = trim(cn_substrR($keywords,60));
  109. $filename = trim(cn_substrR($filename,40));
  110. $isremote = (empty($isremote)? 0 : $isremote);
  111. $serviterm=empty($serviterm)? "" : $serviterm;
  112. if(!TestPurview('a_Check,a_AccCheck,a_MyCheck'))
  113. {
  114. $arcrank = -1;
  115. }
  116. $adminid = $cuserLogin->getUserID();
  117. //处理上传的缩略图
  118. if(empty($ddisremote))
  119. {
  120. $ddisremote = 0;
  121. }
  122. $litpic = GetDDImage('none',$picname,$ddisremote);
  123. //分析body里的内容
  124. $body = AnalyseHtmlBody($body,$description,$litpic,$keywords,'htmltext');
  125. //分析处理附加表数据
  126. $inadd_f = '';
  127. $inadd_v = '';
  128. if(!empty($dede_addonfields))
  129. {
  130. $addonfields = explode(';',$dede_addonfields);
  131. $inadd_f = '';
  132. $inadd_v = '';
  133. if(is_array($addonfields))
  134. {
  135. foreach($addonfields as $v)
  136. {
  137. if($v=='')
  138. {
  139. continue;
  140. }
  141. $vs = explode(',',$v);
  142. if($vs[1]=='htmltext'||$vs[1]=='textdata') //HTML文本特殊处理
  143. {
  144. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);
  145. }else
  146. {
  147. if(!isset(${$vs[0]}))
  148. {
  149. ${$vs[0]} = '';
  150. }
  151. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$id);
  152. }
  153. $inadd_f .= ",`{$vs[0]}` = '".${$vs[0]}."'";
  154. }
  155. }
  156. }
  157. // 处理新的缩略图上传
  158. if ($litpic_b64 != "") {
  159. $data = explode( ',', $litpic_b64 );
  160. $ntime = time();
  161. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  162. CreateDir($savepath);
  163. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  164. $fullUrl = $fullUrl.".png";
  165. file_put_contents($cfg_basedir.$fullUrl, base64_decode( $data[ 1 ] ));
  166. // 加水印
  167. WaterImg($cfg_basedir.$fullUrl, 'up');
  168. $litpic = $fullUrl;
  169. }
  170. //处理图片文档的自定义属性
  171. if($litpic!='' && !preg_match("#p#", $flag))
  172. {
  173. $flag = ($flag=='' ? 'p' : $flag.',p');
  174. }
  175. if($redirecturl!='' && !preg_match("#j#", $flag))
  176. {
  177. $flag = ($flag=='' ? 'j' : $flag.',j');
  178. }
  179. //跳转网址的文档强制为动态
  180. if(preg_match("#j#", $flag)) $ismake = -1;
  181. //更新数据库的SQL语句
  182. $query = "UPDATE #@__archives SET
  183. typeid='$typeid',
  184. typeid2='$typeid2',
  185. sortrank='$sortrank',
  186. flag='$flag',
  187. click='$click',
  188. ismake='$ismake',
  189. arcrank='$arcrank',
  190. money='$money',
  191. title='$title',
  192. color='$color',
  193. writer='$writer',
  194. source='$source',
  195. litpic='$litpic',
  196. pubdate='$pubdate',
  197. notpost='$notpost',
  198. description='$description',
  199. keywords='$keywords',
  200. shorttitle='$shorttitle',
  201. filename='$filename',
  202. dutyadmin='$adminid',
  203. weight='$weight'
  204. WHERE id='$id'; ";
  205. if(!$dsql->ExecuteNoneQuery($query))
  206. {
  207. ShowMsg('更新数据库archives表时出错,请检查',-1);
  208. exit();
  209. }
  210. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  211. $addtable = trim($cts['addtable']);
  212. if($addtable!='')
  213. {
  214. $useip = GetIP();
  215. $templet = empty($templet) ? '' : $templet;
  216. $iquery = "UPDATE `$addtable` SET typeid='$typeid',body='$body'{$inadd_f},redirecturl='$redirecturl',templet='$templet',userip='$useip' WHERE aid='$id'";
  217. if(!$dsql->ExecuteNoneQuery($iquery))
  218. {
  219. ShowMsg("更新附加表 `$addtable` 时出错,请检查原因!","javascript:;");
  220. exit();
  221. }
  222. }
  223. //生成HTML
  224. UpIndexKey($id, $arcrank, $typeid, $sortrank, $tags);
  225. if($cfg_remote_site=='Y' && $isremote=="1")
  226. {
  227. if($serviterm!=""){
  228. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  229. $config=array( 'hostname' => $servurl, 'username' => $servuser,
  230. 'password' => $servpwd,'debug' => 'TRUE');
  231. } else {
  232. $config=array();
  233. }
  234. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  235. }
  236. $artUrl = MakeArt($id,true,true,$isremote);
  237. if($artUrl=='')
  238. {
  239. $artUrl = $cfg_phpurl."/view.php?aid=$id";
  240. }
  241. ClearMyAddon($id, $title);
  242. //返回成功信息
  243. $msg = "
  244.   请选择你的后续操作:
  245. <a href='article_add.php?cid=$typeid'><u>发布新文章</u></a>
  246. &nbsp;&nbsp;
  247. <a href='archives_do.php?aid=".$id."&dopost=editArchives'><u>查看更改</u></a>
  248. &nbsp;&nbsp;
  249. <a href='$artUrl' target='_blank'><u>查看文章</u></a>
  250. &nbsp;&nbsp;
  251. <a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>管理文章</u></a>
  252. &nbsp;&nbsp;
  253. $backurl
  254. ";
  255. $wintitle = "成功更改文章!";
  256. $wecome_info = "文章管理::更改文章";
  257. $win = new OxWindow();
  258. $win->AddTitle("成功更改文章:");
  259. $win->AddMsgItem($msg);
  260. $winform = $win->GetWindow("hand","&nbsp;",false);
  261. $win->Display();
  262. }