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

285 lines
9.7KB

  1. <?php
  2. require_once(dirname(__FILE__).'/config.php');
  3. CheckPurview('a_New,a_AccNew');
  4. require_once(DEDEINC.'/customfields.func.php');
  5. require_once(DEDEADMIN.'/inc/inc_archives_functions.php');
  6. if(file_exists(DEDEDATA.'/template.rand.php'))
  7. {
  8. require_once(DEDEDATA.'/template.rand.php');
  9. }
  10. if(empty($dopost)) $dopost = '';
  11. if($dopost!='save')
  12. {
  13. require_once(DEDEINC."/dedetag.class.php");
  14. require_once(DEDEADMIN."/inc/inc_catalog_options.php");
  15. ClearMyAddon();
  16. $channelid = empty($channelid) ? 0 : intval($channelid);
  17. $cid = empty($cid) ? 0 : intval($cid);
  18. if(empty($geturl)) $geturl = '';
  19. $keywords = $writer = $source = $body = $description = $title = '';
  20. //采集单个网页
  21. if(preg_match("#^http:\/\/#", $geturl))
  22. {
  23. require_once(DEDEADMIN."/inc/inc_coonepage.php");
  24. $redatas = CoOnePage($geturl);
  25. extract($redatas);
  26. }
  27. //获得频道模型ID
  28. if($cid>0 && $channelid==0)
  29. {
  30. $row = $dsql->GetOne("Select channeltype From `#@__arctype` where id='$cid'; ");
  31. $channelid = $row['channeltype'];
  32. }
  33. else
  34. {
  35. if($channelid==0)
  36. {
  37. $channelid = 1;
  38. }
  39. }
  40. //获得频道模型信息
  41. $cInfos = $dsql->GetOne(" Select * From `#@__channeltype` where id='$channelid' ");
  42. //获取文章最大id以确定当前权重
  43. $maxWright = $dsql->GetOne("SELECT COUNT(*) AS cc FROM #@__archives");
  44. include DedeInclude("templets/article_add.htm");
  45. exit();
  46. }
  47. /*--------------------------------
  48. function __save(){ }
  49. -------------------------------*/
  50. else if($dopost=='save')
  51. {
  52. require_once(DEDEINC.'/image.func.php');
  53. require_once(DEDEINC.'/oxwindow.class.php');
  54. $flag = isset($flags) ? join(',',$flags) : '';
  55. $notpost = isset($notpost) && $notpost == 1 ? 1: 0;
  56. if(empty($typeid2)) $typeid2 = '';
  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(empty($typeid))
  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 = dede_htmlspecialchars(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 = (empty($isremote)? 0 : $isremote);
  99. $serviterm=empty($serviterm)? "" : $serviterm;
  100. if(!TestPurview('a_Check,a_AccCheck,a_MyCheck'))
  101. {
  102. $arcrank = -1;
  103. }
  104. $adminid = $cuserLogin->getUserID();
  105. //处理上传的缩略图
  106. if(empty($ddisremote))
  107. {
  108. $ddisremote = 0;
  109. }
  110. $litpic = GetDDImage('none', $picname, $ddisremote);
  111. //生成文档ID
  112. $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$adminid);
  113. if(empty($arcID))
  114. {
  115. ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
  116. exit();
  117. }
  118. if(trim($title) == '')
  119. {
  120. ShowMsg('标题不能为空', '-1');
  121. exit();
  122. }
  123. //处理body字段自动摘要、自动提取缩略图等
  124. $body = AnalyseHtmlBody($body,$description,$litpic,$keywords,'htmltext');
  125. //自动分页
  126. if($sptype=='auto')
  127. {
  128. $body = SpLongBody($body,$spsize*1024,"#p#分页标题#e#");
  129. }
  130. //分析处理附加表数据
  131. $inadd_f = $inadd_v = '';
  132. if(!empty($dede_addonfields))
  133. {
  134. $addonfields = explode(';',$dede_addonfields);
  135. if(is_array($addonfields))
  136. {
  137. foreach($addonfields as $v)
  138. {
  139. if($v=='') continue;
  140. $vs = explode(',',$v);
  141. if($vs[1]=='htmltext'||$vs[1]=='textdata')
  142. {
  143. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);
  144. }
  145. else
  146. {
  147. if(!isset(${$vs[0]})) ${$vs[0]} = '';
  148. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$arcID);
  149. }
  150. $inadd_f .= ','.$vs[0];
  151. $inadd_v .= " ,'".${$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. //保存到主表
  167. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  168. color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename,dutyadmin,weight)
  169. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money',
  170. '$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate',
  171. '$adminid','$voteid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  172. if(!$dsql->ExecuteNoneQuery($query))
  173. {
  174. $gerr = $dsql->GetError();
  175. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  176. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  177. exit();
  178. }
  179. //保存到附加表
  180. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  181. $addtable = trim($cts['addtable']);
  182. if(empty($addtable))
  183. {
  184. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  185. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  186. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。","javascript:;");
  187. exit();
  188. }
  189. $useip = GetIP();
  190. $templet = empty($templet) ? '' : $templet;
  191. $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,templet,userip,body{$inadd_f}) Values('$arcID','$typeid','$redirecturl','$templet','$useip','$body'{$inadd_v})";
  192. if(!$dsql->ExecuteNoneQuery($query))
  193. {
  194. $gerr = $dsql->GetError();
  195. $dsql->ExecuteNoneQuery("Delete From `#@__archives` where id='$arcID'");
  196. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
  197. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  198. exit();
  199. }
  200. //生成HTML
  201. InsertTags($tags,$arcID);
  202. if($cfg_remote_site=='Y' && $isremote=="1")
  203. {
  204. if($serviterm!=""){
  205. list($servurl,$servuser,$servpwd) = explode(',',$serviterm);
  206. $config=array( 'hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd,'debug' => 'TRUE');
  207. }else{
  208. $config=array();
  209. }
  210. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  211. }
  212. $picTitle = false;
  213. if(count($_SESSION['bigfile_info']) > 0)
  214. {
  215. foreach ($_SESSION['bigfile_info'] as $k => $v)
  216. {
  217. if(!empty($v))
  218. {
  219. $pictitle = ${'picinfook'.$k};
  220. $titleSet = '';
  221. if(!empty($pictitle))
  222. {
  223. $picTitle = TRUE;
  224. $titleSet = ",title='{$pictitle}'";
  225. }
  226. $dsql->ExecuteNoneQuery("UPDATE `#@__uploads` SET arcid='{$arcID}'{$titleSet} WHERE url LIKE '{$v}'; ");
  227. }
  228. }
  229. }
  230. $artUrl = MakeArt($arcID,true,true,$isremote);
  231. if($artUrl=='')
  232. {
  233. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  234. }
  235. ClearMyAddon($arcID, $title);
  236. //返回成功信息
  237. $msg = "   请选择你的后续操作:
  238. <a href='article_add.php?cid=$typeid'><u>继续发布文章</u></a>
  239. &nbsp;&nbsp;
  240. <a href='$artUrl' target='_blank'><u>查看文章</u></a>
  241. &nbsp;&nbsp;
  242. <a href='archives_do.php?aid=".$arcID."&dopost=editArchives'><u>更改文章</u></a>
  243. &nbsp;&nbsp;
  244. <a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>已发布文章管理</u></a>
  245. &nbsp;&nbsp;
  246. $backurl
  247. ";
  248. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  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. }
  257. ?>