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

213 lines
7.3KB

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