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

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