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

301 lines
10KB

  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($litpic_b64)) $litpic_b64 = '';
  19. if(empty($geturl)) $geturl = '';
  20. $keywords = $writer = $source = $body = $description = $title = '';
  21. //采集单个网页
  22. if(preg_match("#^http:\/\/#", $geturl))
  23. {
  24. require_once(DEDEADMIN."/inc/inc_coonepage.php");
  25. $redatas = CoOnePage($geturl);
  26. extract($redatas);
  27. }
  28. //获得频道模型ID
  29. if($cid>0 && $channelid==0)
  30. {
  31. $row = $dsql->GetOne("Select channeltype From `#@__arctype` where id='$cid'; ");
  32. $channelid = $row['channeltype'];
  33. }
  34. else
  35. {
  36. if($channelid==0)
  37. {
  38. $channelid = 1;
  39. }
  40. }
  41. //获得频道模型信息
  42. $cInfos = $dsql->GetOne(" Select * From `#@__channeltype` where id='$channelid' ");
  43. //获取文章最大id以确定当前权重
  44. $maxWright = $dsql->GetOne("SELECT COUNT(*) AS cc FROM #@__archives");
  45. include DedeInclude("templets/article_add.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 = '';
  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(empty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click);
  63. if(empty($typeid))
  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_New'))
  79. {
  80. CheckCatalog($typeid,"对不起,你没有操作栏目 {$typeid} 的权限!");
  81. }
  82. //对保存的内容进行处理
  83. if(empty($writer))$writer=$cuserLogin->getUserName();
  84. if(empty($source))$source='未知';
  85. $pubdate = GetMkTime($pubdate);
  86. $senddate = time();
  87. $sortrank = AddDay($pubdate,$sortup);
  88. $ismake = $ishtml==0 ? -1 : 0;
  89. $title = preg_replace("#\"#", '"', $title);
  90. $title = dede_htmlspecialchars(cn_substrR($title,$cfg_title_maxlen));
  91. $shorttitle = cn_substrR($shorttitle,36);
  92. $color = cn_substrR($color,7);
  93. $writer = cn_substrR($writer,20);
  94. $source = cn_substrR($source,30);
  95. $description = cn_substrR($description,$cfg_auot_description);
  96. $keywords = cn_substrR($keywords,60);
  97. $filename = trim(cn_substrR($filename,40));
  98. $userip = GetIP();
  99. $isremote = (empty($isremote)? 0 : $isremote);
  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. if(trim($title) == '')
  133. {
  134. ShowMsg('标题不能为空', '-1');
  135. exit();
  136. }
  137. //处理body字段自动摘要、自动提取缩略图等
  138. $body = AnalyseHtmlBody($body,$description,$litpic,$keywords,'htmltext');
  139. //自动分页
  140. if($sptype=='auto')
  141. {
  142. $body = SpLongBody($body,$spsize*1024,"#p#分页标题#e#");
  143. }
  144. //分析处理附加表数据
  145. $inadd_f = $inadd_v = '';
  146. if(!empty($dede_addonfields))
  147. {
  148. $addonfields = explode(';',$dede_addonfields);
  149. if(is_array($addonfields))
  150. {
  151. foreach($addonfields as $v)
  152. {
  153. if($v=='') continue;
  154. $vs = explode(',',$v);
  155. if($vs[1]=='htmltext'||$vs[1]=='textdata')
  156. {
  157. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);
  158. }
  159. else
  160. {
  161. if(!isset(${$vs[0]})) ${$vs[0]} = '';
  162. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$arcID);
  163. }
  164. $inadd_f .= ','.$vs[0];
  165. $inadd_v .= " ,'".${$vs[0]}."' ";
  166. }
  167. }
  168. }
  169. //处理图片文档的自定义属性
  170. if($litpic!='' && !preg_match("#p#", $flag))
  171. {
  172. $flag = ($flag=='' ? 'p' : $flag.',p');
  173. }
  174. if($redirecturl!='' && !preg_match("#j#", $flag))
  175. {
  176. $flag = ($flag=='' ? 'j' : $flag.',j');
  177. }
  178. //跳转网址的文档强制为动态
  179. if(preg_match("#j#", $flag)) $ismake = -1;
  180. //保存到主表
  181. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  182. color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename,dutyadmin,weight)
  183. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money',
  184. '$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate',
  185. '$adminid','0','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  186. if(!$dsql->ExecuteNoneQuery($query))
  187. {
  188. $gerr = $dsql->GetError();
  189. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  190. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  191. exit();
  192. }
  193. //保存到附加表
  194. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  195. $addtable = trim($cts['addtable']);
  196. if(empty($addtable))
  197. {
  198. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  199. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  200. ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。","javascript:;");
  201. exit();
  202. }
  203. $useip = GetIP();
  204. $templet = empty($templet) ? '' : $templet;
  205. $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,templet,userip,body{$inadd_f}) Values('$arcID','$typeid','$redirecturl','$templet','$useip','$body'{$inadd_v})";
  206. if(!$dsql->ExecuteNoneQuery($query))
  207. {
  208. $gerr = $dsql->GetError();
  209. $dsql->ExecuteNoneQuery("Delete From `#@__archives` where id='$arcID'");
  210. $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
  211. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  212. exit();
  213. }
  214. //生成HTML
  215. InsertTags($tags,$arcID);
  216. if($cfg_remote_site=='Y' && $isremote=="1")
  217. {
  218. if($serviterm!=""){
  219. list($servurl,$servuser,$servpwd) = explode(',',$serviterm);
  220. $config=array( 'hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd,'debug' => 'TRUE');
  221. }else{
  222. $config=array();
  223. }
  224. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  225. }
  226. $picTitle = false;
  227. if(count($_SESSION['bigfile_info']) > 0)
  228. {
  229. foreach ($_SESSION['bigfile_info'] as $k => $v)
  230. {
  231. if(!empty($v))
  232. {
  233. $pictitle = ${'picinfook'.$k};
  234. $titleSet = '';
  235. if(!empty($pictitle))
  236. {
  237. $picTitle = TRUE;
  238. $titleSet = ",title='{$pictitle}'";
  239. }
  240. $dsql->ExecuteNoneQuery("UPDATE `#@__uploads` SET arcid='{$arcID}'{$titleSet} WHERE url LIKE '{$v}'; ");
  241. }
  242. }
  243. }
  244. $artUrl = MakeArt($arcID,true,true,$isremote);
  245. if($artUrl=='')
  246. {
  247. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  248. }
  249. ClearMyAddon($arcID, $title);
  250. //返回成功信息
  251. $msg = "   请选择你的后续操作:
  252. <a href='article_add.php?cid=$typeid'><u>继续发布文章</u></a>
  253. &nbsp;&nbsp;
  254. <a href='$artUrl' target='_blank'><u>查看文章</u></a>
  255. &nbsp;&nbsp;
  256. <a href='archives_do.php?aid=".$arcID."&dopost=editArchives'><u>更改文章</u></a>
  257. &nbsp;&nbsp;
  258. <a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>已发布文章管理</u></a>
  259. &nbsp;&nbsp;
  260. $backurl
  261. ";
  262. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  263. $wintitle = "成功发布文章!";
  264. $wecome_info = "文章管理::发布文章";
  265. $win = new OxWindow();
  266. $win->AddTitle("成功发布文章:");
  267. $win->AddMsgItem($msg);
  268. $winform = $win->GetWindow("hand","&nbsp;",false);
  269. $win->Display();
  270. }
  271. ?>