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

185 lines
8.2KB

  1. <?php
  2. /**
  3. * 文档发布
  4. *
  5. * @version $Id: archives_add.php 1 8:26 2010年7月12日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.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. require_once(DEDEINC.'/dedetag.class.php');
  18. require_once(DEDEADMIN.'/inc/inc_catalog_options.php');
  19. ClearMyAddon();
  20. $channelid = empty($channelid) ? 0 : intval($channelid);
  21. $cid = empty($cid) ? 0 : intval($cid);
  22. //获得频道模型ID
  23. if ($cid > 0 && $channelid == 0) {
  24. $row = $dsql->GetOne("SELECT channeltype FROM `#@__arctype` WHERE id='$cid'; ");
  25. $channelid = $row['channeltype'];
  26. } else {
  27. if ($channelid == 0) {
  28. ShowMsg('无法识别模型信息,因此无法操作', '-1');
  29. exit();
  30. }
  31. }
  32. //获得频道模型信息
  33. $cInfos = $dsql->GetOne(" SELECT * FROM `#@__channeltype` WHERE id='$channelid' ");
  34. $channelid = $cInfos['id'];
  35. //获取文章最大id+1以确定当前权重
  36. $maxWright = $dsql->GetOne("SELECT id+1 AS cc FROM `#@__archives` ORDER BY id DESC LIMIT 1");
  37. include DedeInclude('templets/archives_add.htm');
  38. exit();
  39. }
  40. /*--------------------------------
  41. function __save(){ }
  42. -------------------------------*/
  43. else if ($dopost == 'save') {
  44. require_once(DEDEINC.'/image.func.php');
  45. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  46. $flag = isset($flags) ? join(',', $flags) : '';
  47. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  48. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  49. if (empty($typeid2)) $typeid2 = 0;
  50. if (!isset($autokey)) $autokey = 0;
  51. if (!isset($remote)) $remote = 0;
  52. if (!isset($dellink)) $dellink = 0;
  53. if (!isset($autolitpic)) $autolitpic = 0;
  54. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(50, 200) : $cfg_arc_click);
  55. if ($typeid == 0) {
  56. ShowMsg('请指定文档的栏目', '-1');
  57. exit();
  58. }
  59. if (empty($channelid)) {
  60. ShowMsg('文档为非指定的类型,请检查您发布内容的表单是否合法', '-1');
  61. exit();
  62. }
  63. if (!CheckChannel($typeid, $channelid)) {
  64. ShowMsg('您所选择的栏目与当前模型不相符,请选择白色的选项', '-1');
  65. exit();
  66. }
  67. if (!TestPurview('a_New')) {
  68. CheckCatalog($typeid, "对不起,您没有操作栏目 {$typeid} 的权限");
  69. }
  70. //对保存的内容进行处理
  71. if (empty($writer)) $writer = $cuserLogin->getUserName();
  72. if (empty($source)) $source = '未知';
  73. $pubdate = GetMkTime($pubdate);
  74. $senddate = time();
  75. $sortrank = AddDay($pubdate, $sortup);
  76. $ismake = $ishtml == 0 ? -1 : 0;
  77. $title = preg_replace("#\"#", '"', $title);
  78. $title = cn_substrR($title, $cfg_title_maxlen);
  79. $shorttitle = cn_substrR($shorttitle, 36);
  80. $color = cn_substrR($color, 7);
  81. $writer = cn_substrR($writer, 20);
  82. $source = cn_substrR($source, 30);
  83. $description = cn_substrR($description, $cfg_auot_description);
  84. $keywords = cn_substrR($keywords, 60);
  85. $filename = trim(cn_substrR($filename, 40));
  86. $userip = GetIP();
  87. $isremote = 0;
  88. $voteid = (empty($voteid) ? 0 : $voteid);
  89. $serviterm = empty($serviterm) ? "" : $serviterm;
  90. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  91. $arcrank = -1;
  92. }
  93. $adminid = $cuserLogin->getUserID();
  94. //处理上传的缩略图
  95. if (empty($ddisremote)) {
  96. $ddisremote = 0;
  97. }
  98. $litpic = GetDDImage('none', $picname, $ddisremote);
  99. //生成文档ID
  100. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  101. if (empty($arcID)) {
  102. ShowMsg("无法获得主键,因此无法进行后续操作", "-1");
  103. exit();
  104. }
  105. //分析处理附加表数据
  106. $inadd_f = $inadd_v = '';
  107. if (!empty($dede_addonfields)) {
  108. $addonfields = explode(';', $dede_addonfields);
  109. if (is_array($addonfields)) {
  110. foreach ($addonfields as $v) {
  111. if ($v == '') continue;
  112. $vs = explode(',', $v);
  113. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') {
  114. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  115. } else {
  116. if (!isset(${$vs[0]})) ${$vs[0]} = '';
  117. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  118. }
  119. $inadd_f .= ','.$vs[0];
  120. $inadd_v .= " ,'".${$vs[0]}."' ";
  121. }
  122. }
  123. }
  124. //处理图片文档的自定义属性
  125. if ($litpic != '' && !preg_match("#p#", $flag)) {
  126. $flag = ($flag == '' ? 'p' : $flag.',p');
  127. }
  128. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  129. $flag = ($flag == '' ? 'j' : $flag.',j');
  130. }
  131. //跳转网址的文档强制为动态
  132. if (preg_match("#j#", $flag)) $ismake = -1;
  133. //保存到主表
  134. $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename,dutyadmin,weight)
  135. VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle',
  136. '$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$voteid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  137. if (!$dsql->ExecuteNoneQuery($query)) {
  138. $gerr = $dsql->GetError();
  139. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  140. ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeBIZ官方".str_replace('"', '', $gerr), "javascript:;");
  141. exit();
  142. }
  143. //保存到附加表
  144. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  145. $addtable = trim($cts['addtable']);
  146. if (!empty($addtable)) {
  147. $useip = GetIP();
  148. $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,userip{$inadd_f}) Values('$arcID','$typeid','$redirecturl','$useip'{$inadd_v})";
  149. if (!$dsql->ExecuteNoneQuery($query)) {
  150. $gerr = $dsql->GetError();
  151. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  152. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  153. ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeBIZ官方".str_replace('"', '', $gerr), "javascript:;");
  154. exit();
  155. }
  156. }
  157. //生成HTML
  158. InsertTags($tags, $arcID);
  159. $artUrl = MakeArt($arcID, true, true, $isremote);
  160. if ($artUrl == '') {
  161. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  162. }
  163. ClearMyAddon($arcID, $title);
  164. //自动更新关联内容
  165. if (is_array($automake)) {
  166. foreach ($automake as $key => $value) {
  167. if (isset(${$key}) && !empty(${$key})) {
  168. $ids = explode(",", ${$key});
  169. foreach ($ids as $id) {
  170. MakeArt($id, true, true, $isremote);
  171. }
  172. }
  173. }
  174. }
  175. //返回成功信息
  176. $msg = "请选择您的后续操作:<a href='archives_add.php?cid=$typeid' class='btn btn-success btn-sm'>继续发布商品</a><a href='$artUrl' target='_blank' class='btn btn-success btn-sm'>查看商品</a><a href='archives_do.php?aid=".$arcID."&dopost=editArchives' class='btn btn-success btn-sm'>修改商品</a><a href='catalog_do.php?cid=$typeid&dopost=listArchives' class='btn btn-success btn-sm'>已发布商品管理</a>$backurl";
  177. $msg = "<div style=\"line-height:36px;height:36px\">{$msg}</div>".GetUpdateTest();
  178. $wintitle = '成功发布商品';
  179. $wecome_info = '文档管理::发布商品';
  180. $win = new OxWindow();
  181. $win->AddTitle('成功发布商品:');
  182. $win->AddMsgItem($msg);
  183. $winform = $win->GetWindow('hand', '&nbsp;', false);
  184. $win->Display();
  185. }