国内流行的内容管理系统(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 8:26 2010年7月12日 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. $maxWright = empty($maxWright)? array('cc'=>1) : $maxWright;
  38. include DedeInclude('templets/archives_add.htm');
  39. exit();
  40. }
  41. /*--------------------------------
  42. function __save(){ }
  43. -------------------------------*/
  44. else if ($dopost == 'save') {
  45. require_once(DEDEINC.'/image.func.php');
  46. require_once(DEDEINC.'/libraries/oxwindow.class.php');
  47. $flag = isset($flags) ? join(',', $flags) : '';
  48. $notpost = isset($notpost) && $notpost == 1 ? 1 : 0;
  49. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(200, 1000) : $cfg_arc_click);
  50. if (empty($typeid2)) $typeid2 = 0;
  51. if (!isset($autokey)) $autokey = 0;
  52. if (!isset($remote)) $remote = 0;
  53. if (!isset($dellink)) $dellink = 0;
  54. if (!isset($autolitpic)) $autolitpic = 0;
  55. if (empty($click)) $click = ($cfg_arc_click == '-1' ? mt_rand(200, 1000) : $cfg_arc_click);
  56. if ($typeid == 0) {
  57. ShowMsg('请指定文档的栏目', '-1');
  58. exit();
  59. }
  60. if (empty($channelid)) {
  61. ShowMsg('文档为非指定的类型,请检查您发布文档的表单是否合法', '-1');
  62. exit();
  63. }
  64. if (!CheckChannel($typeid, $channelid)) {
  65. ShowMsg('您所选择的栏目与当前模型不相符,请重新选择', '-1');
  66. exit();
  67. }
  68. if (!TestPurview('a_New')) {
  69. CheckCatalog($typeid, "对不起,您没有操作栏目<span class='text-primary'>{$typeid}</span>权限");
  70. }
  71. //对保存的文档进行处理
  72. if (empty($writer)) $writer = $cuserLogin->getUserName();
  73. if (empty($source)) $source = '未知';
  74. $pubdate = GetMkTime($pubdate);
  75. $senddate = time();
  76. $sortrank = AddDay($pubdate, $sortup);
  77. $ismake = $ishtml == 0 ? -1 : 0;
  78. $title = preg_replace("#\"#", '"', $title);
  79. $title = cn_substrR($title, $cfg_title_maxlen);
  80. $shorttitle = cn_substrR($shorttitle, 36);
  81. $color = cn_substrR($color, 7);
  82. $writer = cn_substrR($writer, 20);
  83. $source = cn_substrR($source, 30);
  84. $description = cn_substrR($description, $cfg_auot_description);
  85. $keywords = cn_substrR($keywords, 60);
  86. $filename = trim(cn_substrR($filename, 40));
  87. $userip = GetIP();
  88. $isremote = 0;
  89. $voteid = (empty($voteid) ? 0 : $voteid);
  90. $serviterm = empty($serviterm) ? "" : $serviterm;
  91. if (!TestPurview('a_Check,a_AccCheck,a_MyCheck')) {
  92. $arcrank = -1;
  93. }
  94. $adminid = $cuserLogin->getUserID();
  95. //处理上传的缩略图
  96. if (empty($ddisremote)) {
  97. $ddisremote = 0;
  98. }
  99. $litpic = GetDDImage('none', $picname, $ddisremote);
  100. //生成文档id
  101. $arcID = GetIndexKey($arcrank, $typeid, $sortrank, $channelid, $senddate, $adminid);
  102. if (empty($arcID)) {
  103. ShowMsg("无法获得主键,因此无法进行后续操作", "-1");
  104. exit();
  105. }
  106. //分析处理附加表数据
  107. $inadd_f = $inadd_v = '';
  108. if (!empty($dede_addonfields)) {
  109. $addonfields = explode(';', $dede_addonfields);
  110. if (is_array($addonfields)) {
  111. foreach ($addonfields as $v) {
  112. if ($v == '') continue;
  113. $vs = explode(',', $v);
  114. if ($vs[1] == 'htmltext' || $vs[1] == 'textdata') {
  115. ${$vs[0]} = AnalyseHtmlBody(${$vs[0]}, $description, $litpic, $keywords, $vs[1]);
  116. } else {
  117. if (!isset(${$vs[0]})) ${$vs[0]} = '';
  118. ${$vs[0]} = GetFieldValueA(${$vs[0]}, $vs[1], $arcID);
  119. }
  120. $inadd_f .= ','.$vs[0];
  121. $inadd_v .= " ,'".${$vs[0]}."' ";
  122. }
  123. }
  124. }
  125. //处理图片文档的自定义属性
  126. if ($litpic != '' && !preg_match("#p#", $flag)) {
  127. $flag = ($flag == '' ? 'p' : $flag.',p');
  128. }
  129. if ($redirecturl != '' && !preg_match("#j#", $flag)) {
  130. $flag = ($flag == '' ? 'j' : $flag.',j');
  131. }
  132. //跳转网址的文档强制为动态
  133. if (preg_match("#j#", $flag)) $ismake = -1;
  134. //保存到主表
  135. $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) VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money','$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate','$adminid','$voteid','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  136. if (!$dsql->ExecuteNoneQuery($query)) {
  137. $gerr = $dsql->GetError();
  138. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  139. ShowMsg("数据保存到数据库主表`#@__archives`时出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  140. exit();
  141. }
  142. //保存到附加表
  143. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  144. $addtable = trim($cts['addtable']);
  145. if (!empty($addtable)) {
  146. $useip = GetIP();
  147. $query = "INSERT INTO `{$addtable}` (aid,typeid,redirecturl,userip{$inadd_f}) VALUES ('$arcID','$typeid','$redirecturl','$useip'{$inadd_v})";
  148. if (!$dsql->ExecuteNoneQuery($query)) {
  149. $gerr = $dsql->GetError();
  150. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  151. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  152. ShowMsg("数据保存到数据库附加表时出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  153. exit();
  154. }
  155. }
  156. //生成网页
  157. InsertTags($tags, $arcID);
  158. $artUrl = MakeArt($arcID, true, true, $isremote);
  159. if ($artUrl == '') {
  160. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  161. }
  162. ClearMyAddon($arcID, $title);
  163. //自动更新关联文档
  164. if (is_array($automake)) {
  165. foreach ($automake as $key => $value) {
  166. if (isset(${$key}) && !empty(${$key})) {
  167. $ids = explode(",", ${$key});
  168. foreach ($ids as $id) {
  169. MakeArt($id, true, true, $isremote);
  170. }
  171. }
  172. }
  173. }
  174. //返回成功信息
  175. $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";
  176. $msg = "<div>{$msg}</div>".GetUpdateTest();
  177. $wintitle = '成功发布商品';
  178. $wecome_info = '文档管理::发布商品';
  179. $win = new OxWindow();
  180. $win->AddTitle('成功发布商品:');
  181. $win->AddMsgItem($msg);
  182. $winform = $win->GetWindow('hand', '&nbsp;', false);
  183. $win->Display();
  184. }
  185. ?>