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

269 lines
9.7KB

  1. <?php
  2. /**
  3. * 文档发布
  4. *
  5. * @version $Id: archives_add.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/v6
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__).'/config.php');
  12. CheckPurview('a_New,a_AccNew');
  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(DEDEINC.'/dedetag.class.php');
  19. require_once(DEDEADMIN.'/inc/inc_catalog_options.php');
  20. ClearMyAddon();
  21. $channelid = empty($channelid) ? 0 : intval($channelid);
  22. $cid = empty($cid) ? 0 : intval($cid);
  23. //获得频道模型ID
  24. if($cid > 0 && $channelid == 0)
  25. {
  26. $row = $dsql->GetOne("SELECT channeltype FROM `#@__arctype` WHERE id='$cid'; ");
  27. $channelid = $row['channeltype'];
  28. }
  29. else
  30. {
  31. if($channelid==0)
  32. {
  33. ShowMsg('无法识别模型信息,因此无法操作!', '-1');
  34. exit();
  35. }
  36. }
  37. //获得频道模型信息
  38. $cInfos = $dsql->GetOne(" SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  39. $channelid = $cInfos['id'];
  40. //获取文章最大id以确定当前权重
  41. $maxWright = $dsql->GetOne("SELECT COUNT(*) AS cc FROM #@__archives");
  42. include DedeInclude('templets/archives_add.htm');
  43. exit();
  44. }
  45. /*--------------------------------
  46. function __save(){ }
  47. -------------------------------*/
  48. else if($dopost=='save')
  49. {
  50. require_once(DEDEINC.'/image.func.php');
  51. require_once(DEDEINC.'/oxwindow.class.php');
  52. $flag = isset($flags) ? join(',',$flags) : '';
  53. $notpost = isset($notpost) && $notpost == 1 ? 1: 0;
  54. if(empty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click);
  55. if(empty($litpic_b64)) $litpic_b64 = '';
  56. if(empty($typeid2)) $typeid2 = 0;
  57. if(!isset($autokey)) $autokey = 0;
  58. if(!isset($remote)) $remote = 0;
  59. if(!isset($dellink)) $dellink = 0;
  60. if(!isset($autolitpic)) $autolitpic = 0;
  61. if(empty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click);
  62. if($typeid==0)
  63. {
  64. ShowMsg('请指定文档的栏目!', '-1');
  65. exit();
  66. }
  67. if(empty($channelid))
  68. {
  69. ShowMsg('文档为非指定的类型,请检查你发布内容的表单是否合法!', '-1');
  70. exit();
  71. }
  72. if(!CheckChannel($typeid,$channelid) )
  73. {
  74. ShowMsg('你所选择的栏目与当前模型不相符,请选择白色的选项!', '-1');
  75. exit();
  76. }
  77. if(!TestPurview('a_New'))
  78. {
  79. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的权限!");
  80. }
  81. //对保存的内容进行处理
  82. if(empty($writer)) $writer = $cuserLogin->getUserName();
  83. if(empty($source)) $source = '未知';
  84. $pubdate = GetMkTime($pubdate);
  85. $senddate = time();
  86. $sortrank = AddDay($pubdate,$sortup);
  87. $ismake = $ishtml == 0 ? -1 : 0;
  88. $title = preg_replace("#\"#", '"', $title);
  89. $title = cn_substrR($title,$cfg_title_maxlen);
  90. $shorttitle = cn_substrR($shorttitle,36);
  91. $color = cn_substrR($color,7);
  92. $writer = cn_substrR($writer,20);
  93. $source = cn_substrR($source,30);
  94. $description = cn_substrR($description,$cfg_auot_description);
  95. $keywords = cn_substrR($keywords,60);
  96. $filename = trim(cn_substrR($filename,40));
  97. $userip = GetIP();
  98. $isremote = 0;
  99. $voteid = (empty($voteid)? 0 : $voteid);
  100. $serviterm=empty($serviterm)? "" : $serviterm;
  101. if(!TestPurview('a_Check,a_AccCheck,a_MyCheck'))
  102. {
  103. $arcrank = -1;
  104. }
  105. $adminid = $cuserLogin->getUserID();
  106. //处理上传的缩略图
  107. if(empty($ddisremote))
  108. {
  109. $ddisremote = 0;
  110. }
  111. $litpic = GetDDImage('none',$picname,$ddisremote);
  112. // 处理新的缩略图上传
  113. if ($litpic_b64 != "") {
  114. $data = explode( ',', $litpic_b64 );
  115. $ntime = time();
  116. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  117. CreateDir($savepath);
  118. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  119. $fullUrl = $fullUrl.".png";
  120. file_put_contents($cfg_basedir.$fullUrl, base64_decode( $data[ 1 ] ));
  121. // 加水印
  122. WaterImg($cfg_basedir.$fullUrl, 'up');
  123. $litpic = $fullUrl;
  124. }
  125. //生成文档ID
  126. $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$adminid);
  127. if(empty($arcID))
  128. {
  129. ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
  130. exit();
  131. }
  132. //分析处理附加表数据
  133. $inadd_f = $inadd_v = '';
  134. if(!empty($dede_addonfields))
  135. {
  136. $addonfields = explode(';', $dede_addonfields);
  137. if(is_array($addonfields))
  138. {
  139. foreach($addonfields as $v)
  140. {
  141. if($v=='') continue;
  142. $vs = explode(',', $v);
  143. if($vs[1]=='htmltext' || $vs[1]=='textdata')
  144. {
  145. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  146. }
  147. else
  148. {
  149. if(!isset(${$vs[0]})) ${$vs[0]} = '';
  150. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  151. }
  152. $inadd_f .= ','.$vs[0];
  153. $inadd_v .= " ,'".${$vs[0]}."' ";
  154. }
  155. }
  156. }
  157. //处理图片文档的自定义属性
  158. if($litpic!='' && !preg_match("#p#", $flag))
  159. {
  160. $flag = ($flag=='' ? 'p' : $flag.',p');
  161. }
  162. if($redirecturl!='' && !preg_match("#j#", $flag))
  163. {
  164. $flag = ($flag=='' ? 'j' : $flag.',j');
  165. }
  166. //跳转网址的文档强制为动态
  167. if(preg_match("#j#", $flag)) $ismake = -1;
  168. //保存到主表
  169. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  170. color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename,dutyadmin,weight)
  171. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  172. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$voteid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  173. if(!$dsql->ExecuteNoneQuery($query))
  174. {
  175. $gerr = $dsql->GetError();
  176. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  177. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  178. exit();
  179. }
  180. //保存到附加表
  181. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  182. $addtable = trim($cts['addtable']);
  183. if(!empty($addtable))
  184. {
  185. $useip = GetIP();
  186. $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,userip{$inadd_f}) Values('$arcID','$typeid','$redirecturl','$useip'{$inadd_v})";
  187. if(!$dsql->ExecuteNoneQuery($query))
  188. {
  189. $gerr = $dsql->GetError();
  190. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  191. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  192. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  193. exit();
  194. }
  195. }
  196. //生成HTML
  197. InsertTags($tags, $arcID);
  198. if($cfg_remote_site=='Y' && $isremote=="1")
  199. {
  200. if($serviterm!="")
  201. {
  202. list($servurl,$servuser,$servpwd) = explode(',',$serviterm);
  203. $config=array( 'hostname' => $servurl, 'username' => $servuser,
  204. 'password' => $servpwd,'debug' => 'TRUE');
  205. } else {
  206. $config=array();
  207. }
  208. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  209. }
  210. $artUrl = MakeArt($arcID, true, true,$isremote);
  211. if($artUrl=='')
  212. {
  213. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  214. }
  215. ClearMyAddon($arcID, $title);
  216. // 自动更新关联内容
  217. if (is_array($automake)) {
  218. foreach ($automake as $key => $value) {
  219. if (isset(${$key}) && !empty(${$key})) {
  220. $ids = explode(",", ${$key});
  221. foreach ($ids as $id) {
  222. MakeArt($id,true,true,$isremote);
  223. }
  224. }
  225. }
  226. }
  227. //返回成功信息
  228. $msg = "   请选择你的后续操作:
  229. <a href='archives_add.php?cid=$typeid' class='btn btn-secondary btn-sm'>继续发布文档</a>
  230. &nbsp;&nbsp;
  231. <a href='$artUrl' target='_blank' class='btn btn-secondary btn-sm'>查看文档</a>
  232. &nbsp;&nbsp;
  233. <a href='archives_do.php?aid=".$arcID."&dopost=editArchives' class='btn btn-secondary btn-sm'>更改文档</a>
  234. &nbsp;&nbsp;
  235. <a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-secondary btn-sm'>已发布文档管理</a>
  236. &nbsp;&nbsp;
  237. $backurl
  238. ";
  239. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  240. $wintitle = '成功发布文档!';
  241. $wecome_info = '文档管理::发布文档';
  242. $win = new OxWindow();
  243. $win->AddTitle('成功发布文档:');
  244. $win->AddMsgItem($msg);
  245. $winform = $win->GetWindow('hand', '&nbsp;', false);
  246. $win->Display();
  247. }