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

283 lines
9.1KB

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