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

212 lines
7.2KB

  1. <?php
  2. /**
  3. * 单表模型文档发布
  4. *
  5. * @version $Id: archives_sg_add.php 1 8:26 2010年7月12日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2020, 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. include DedeInclude("templets/archives_sg_add.htm");
  41. exit();
  42. }
  43. /*--------------------------------
  44. function __save(){ }
  45. -------------------------------*/
  46. else if($dopost=='save')
  47. {
  48. require_once(DEDEINC.'/image.func.php');
  49. require_once(DEDEINC.'/oxwindow.class.php');
  50. if($typeid==0)
  51. {
  52. ShowMsg("请指定文档的栏目!","-1");
  53. exit();
  54. }
  55. if(empty($channelid))
  56. {
  57. ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!","-1");
  58. exit();
  59. }
  60. if(!CheckChannel($typeid,$channelid) )
  61. {
  62. ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!","-1");
  63. exit();
  64. }
  65. if(!TestPurview('a_New'))
  66. {
  67. CheckCatalog($typeid,"对不起,你没有操作栏目 {$typeid} 的权限!");
  68. }
  69. //对保存的内容进行处理
  70. if(empty($writer))$writer=$cuserLogin->getUserName();
  71. if(empty($source))$source='未知';
  72. if(empty($flags)) $flag = '';
  73. else $flag = join(',', $flags);
  74. $senddate = time();
  75. if(empty($litpic_b64)) $litpic_b64 = '';
  76. $title = cn_substrR($title,$cfg_title_maxlen);
  77. $isremote = 0;
  78. $serviterm=empty($serviterm)? "" : $serviterm;
  79. if(!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;
  80. $adminid = $cuserLogin->getUserID();
  81. $userip = GetIP();
  82. if(empty($ddisremote)) $ddisremote = 0;
  83. $litpic = GetDDImage('none', $picname, $ddisremote);
  84. // 处理新的缩略图上传
  85. if ($litpic_b64 != "") {
  86. $data = explode( ',', $litpic_b64 );
  87. $ntime = time();
  88. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  89. CreateDir($savepath);
  90. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
  91. $fullUrl = $fullUrl.".png";
  92. file_put_contents($cfg_basedir.$fullUrl, base64_decode( $data[ 1 ] ));
  93. // 加水印
  94. WaterImg($cfg_basedir.$fullUrl, 'up');
  95. $litpic = $fullUrl;
  96. }
  97. //生成文档ID
  98. $arcID = GetIndexKey($arcrank, $typeid, $senddate, $channelid, $senddate, $adminid);
  99. if(empty($arcID))
  100. {
  101. ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
  102. exit();
  103. }
  104. //分析处理附加表数据
  105. $inadd_f = '';
  106. $inadd_v = '';
  107. if(!empty($dede_addonfields))
  108. {
  109. $addonfields = explode(';',$dede_addonfields);
  110. $inadd_f = '';
  111. $inadd_v = '';
  112. if(is_array($addonfields))
  113. {
  114. foreach($addonfields as $v)
  115. {
  116. if($v=='')
  117. {
  118. continue;
  119. }
  120. $vs = explode(',',$v);
  121. if($vs[1]=='htmltext'||$vs[1]=='textdata') //HTML文本特殊处理
  122. {
  123. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);
  124. }
  125. else
  126. {
  127. if(!isset(${$vs[0]}))
  128. {
  129. ${$vs[0]} = '';
  130. }
  131. ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$arcID);
  132. }
  133. $inadd_f .= ','.$vs[0];
  134. $inadd_v .= " ,'".${$vs[0]}."' ";
  135. }
  136. }
  137. }
  138. //处理图片文档的自定义属性
  139. if($litpic!='' && !preg_match("#p#", $flag))
  140. {
  141. $flag = ($flag=='' ? 'p' : $flag.',p');
  142. }
  143. //保存到附加表
  144. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  145. $addtable = trim($cts['addtable']);
  146. if(!empty($addtable))
  147. {
  148. $query = "INSERT INTO `{$addtable}`(aid,typeid,channel,arcrank,mid,click,title,senddate,flag,litpic,userip{$inadd_f})
  149. VALUES('$arcID','$typeid','$channelid','$arcrank','$adminid','0','$title','$senddate','$flag','$litpic','$userip'{$inadd_v})";
  150. if(!$dsql->ExecuteNoneQuery($query))
  151. {
  152. $gerr = $dsql->GetError();
  153. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  154. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCMS官方。".str_replace('"','',$gerr),"javascript:;");
  155. exit();
  156. }
  157. }
  158. //生成HTML
  159. if($cfg_remote_site=='Y' && $isremote=="1")
  160. {
  161. if($serviterm!="")
  162. {
  163. list($servurl, $servuser, $servpwd) = explode(',', $serviterm);
  164. $config=array( 'hostname' => $servurl, 'username' => $servuser, 'password' => $servpwd,'debug' => 'TRUE');
  165. } else {
  166. $config=array();
  167. }
  168. if(!$ftp->connect($config)) exit('Error:None FTP Connection!');
  169. }
  170. $artUrl = MakeArt($arcID, TRUE, TRUE, $isremote);
  171. if($artUrl=='')
  172. {
  173. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  174. }
  175. ClearMyAddon($arcID, $title);
  176. //返回成功信息
  177. $msg = "
  178.   请选择你的后续操作:
  179. <a href='archives_sg_add.php?cid=$typeid'><u>继续发布文档</u></a>
  180. &nbsp;&nbsp;
  181. <a href='$artUrl' target='_blank'><u>查看文档</u></a>
  182. &nbsp;&nbsp;
  183. <a href='archives_do.php?aid=".$arcID."&dopost=editArchives'><u>更改文档</u></a>
  184. &nbsp;&nbsp;
  185. <a href='content_sg_list.php?cid=$typeid&channelid={$channelid}&dopost=listArchives'><u>已发布文档管理</u></a>
  186. &nbsp;&nbsp;
  187. <a href='catalog_main.php'><u>网站栏目管理</u></a>
  188. ";
  189. $wintitle = "成功发布文档!";
  190. $wecome_info = "文档管理::发布文档";
  191. $win = new OxWindow();
  192. $win->AddTitle("成功发布文档:");
  193. $win->AddMsgItem($msg);
  194. $winform = $win->GetWindow("hand","&nbsp;",false);
  195. $win->Display();
  196. }