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

248 lines
7.9KB

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