国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

archives_edit.php 9.0KB

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