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

240 lines
8.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) 2007 - 2019, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.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($typeid2)) $typeid2 = 0;
  56. if(!isset($autokey)) $autokey = 0;
  57. if(!isset($remote)) $remote = 0;
  58. if(!isset($dellink)) $dellink = 0;
  59. if(!isset($autolitpic)) $autolitpic = 0;
  60. if(empty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click);
  61. if($typeid==0)
  62. {
  63. ShowMsg('请指定文档的栏目!', '-1');
  64. exit();
  65. }
  66. if(empty($channelid))
  67. {
  68. ShowMsg('文档为非指定的类型,请检查你发布内容的表单是否合法!', '-1');
  69. exit();
  70. }
  71. if(!CheckChannel($typeid,$channelid) )
  72. {
  73. ShowMsg('你所选择的栏目与当前模型不相符,请选择白色的选项!', '-1');
  74. exit();
  75. }
  76. if(!TestPurview('a_New'))
  77. {
  78. CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的权限!");
  79. }
  80. //对保存的内容进行处理
  81. if(empty($writer)) $writer = $cuserLogin->getUserName();
  82. if(empty($source)) $source = '未知';
  83. $pubdate = GetMkTime($pubdate);
  84. $senddate = time();
  85. $sortrank = AddDay($pubdate,$sortup);
  86. $ismake = $ishtml == 0 ? -1 : 0;
  87. $title = preg_replace("#\"#", '"', $title);
  88. $title = cn_substrR($title,$cfg_title_maxlen);
  89. $shorttitle = cn_substrR($shorttitle,36);
  90. $color = cn_substrR($color,7);
  91. $writer = cn_substrR($writer,20);
  92. $source = cn_substrR($source,30);
  93. $description = cn_substrR($description,$cfg_auot_description);
  94. $keywords = cn_substrR($keywords,60);
  95. $filename = trim(cn_substrR($filename,40));
  96. $userip = GetIP();
  97. $isremote = (empty($isremote)? 0 : $isremote);
  98. $voteid = (empty($voteid)? 0 : $voteid);
  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. //分析处理附加表数据
  119. $inadd_f = $inadd_v = '';
  120. if(!empty($dede_addonfields))
  121. {
  122. $addonfields = explode(';', $dede_addonfields);
  123. if(is_array($addonfields))
  124. {
  125. foreach($addonfields as $v)
  126. {
  127. if($v=='') continue;
  128. $vs = explode(',', $v);
  129. if($vs[1]=='htmltext' || $vs[1]=='textdata')
  130. {
  131. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  132. }
  133. else
  134. {
  135. if(!isset(${$vs[0]})) ${$vs[0]} = '';
  136. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  137. }
  138. $inadd_f .= ','.$vs[0];
  139. $inadd_v .= " ,'".${$vs[0]}."' ";
  140. }
  141. }
  142. }
  143. //处理图片文档的自定义属性
  144. if($litpic!='' && !preg_match("#p#", $flag))
  145. {
  146. $flag = ($flag=='' ? 'p' : $flag.',p');
  147. }
  148. if($redirecturl!='' && !preg_match("#j#", $flag))
  149. {
  150. $flag = ($flag=='' ? 'j' : $flag.',j');
  151. }
  152. //跳转网址的文档强制为动态
  153. if(preg_match("#j#", $flag)) $ismake = -1;
  154. //保存到主表
  155. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
  156. color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename,dutyadmin,weight)
  157. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  158. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$voteid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  159. if(!$dsql->ExecuteNoneQuery($query))
  160. {
  161. $gerr = $dsql->GetError();
  162. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  163. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  164. exit();
  165. }
  166. //保存到附加表
  167. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  168. $addtable = trim($cts['addtable']);
  169. if(!empty($addtable))
  170. {
  171. $useip = GetIP();
  172. $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,userip{$inadd_f}) Values('$arcID','$typeid','$redirecturl','$useip'{$inadd_v})";
  173. if(!$dsql->ExecuteNoneQuery($query))
  174. {
  175. $gerr = $dsql->GetError();
  176. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  177. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  178. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  179. exit();
  180. }
  181. }
  182. //生成HTML
  183. InsertTags($tags, $arcID);
  184. if($cfg_remote_site=='Y' && $isremote=="1")
  185. {
  186. if($serviterm!="")
  187. {
  188. list($servurl,$servuser,$servpwd) = explode(',',$serviterm);
  189. $config=array( 'hostname' => $servurl, 'username' => $servuser,
  190. 'password' => $servpwd,'debug' => 'TRUE');
  191. } else {
  192. $config=array();
  193. }
  194. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  195. }
  196. $artUrl = MakeArt($arcID, true, true,$isremote);
  197. if($artUrl=='')
  198. {
  199. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  200. }
  201. ClearMyAddon($arcID, $title);
  202. //返回成功信息
  203. $msg = "   请选择你的后续操作:
  204. <a href='archives_add.php?cid=$typeid'><u>继续发布文档</u></a>
  205. &nbsp;&nbsp;
  206. <a href='$artUrl' target='_blank'><u>查看文档</u></a>
  207. &nbsp;&nbsp;
  208. <a href='archives_do.php?aid=".$arcID."&dopost=editArchives'><u>更改文档</u></a>
  209. &nbsp;&nbsp;
  210. <a href='catalog_do.php?cid=$typeid&dopost=listArchives'><u>已发布文档管理</u></a>
  211. &nbsp;&nbsp;
  212. $backurl
  213. ";
  214. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  215. $wintitle = '成功发布文档!';
  216. $wecome_info = '文档管理::发布文档';
  217. $win = new OxWindow();
  218. $win->AddTitle('成功发布文档:');
  219. $win->AddMsgItem($msg);
  220. $winform = $win->GetWindow('hand', '&nbsp;', false);
  221. $win->Display();
  222. }