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

184 lines
8.1KB

  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. $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,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','$notpost','$description','$keywords','$filename','$adminid','$weight');";
  135. if (!$dsql->ExecuteNoneQuery($query)) {
  136. $gerr = $dsql->GetError();
  137. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  138. ShowMsg("数据保存到数据库主表`#@__archives`时出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  139. exit();
  140. }
  141. //保存到附加表
  142. $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' ");
  143. $addtable = trim($cts['addtable']);
  144. if (!empty($addtable)) {
  145. $useip = GetIP();
  146. $query = "INSERT INTO `{$addtable}` (aid,typeid,redirecturl,userip{$inadd_f}) VALUES ('$arcID','$typeid','$redirecturl','$useip'{$inadd_v})";
  147. if (!$dsql->ExecuteNoneQuery($query)) {
  148. $gerr = $dsql->GetError();
  149. $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
  150. $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
  151. ShowMsg("数据保存到数据库附加表时出错,请检查数据库字段".str_replace('"', '', $gerr), "javascript:;");
  152. exit();
  153. }
  154. }
  155. //生成网页
  156. InsertTags($tags, $arcID);
  157. $artUrl = MakeArt($arcID, true, true, $isremote);
  158. if ($artUrl == '') {
  159. $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
  160. }
  161. ClearMyAddon($arcID, $title);
  162. //自动更新关联文档
  163. if (is_array($automake)) {
  164. foreach ($automake as $key => $value) {
  165. if (isset(${$key}) && !empty(${$key})) {
  166. $ids = explode(",", ${$key});
  167. foreach ($ids as $id) {
  168. MakeArt($id, true, true, $isremote);
  169. }
  170. }
  171. }
  172. }
  173. //返回成功信息
  174. $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";
  175. $msg = "<div>{$msg}</div>".GetUpdateTest();
  176. $wintitle = '成功发布商品';
  177. $wecome_info = '文档管理::发布商品';
  178. $win = new OxWindow();
  179. $win->AddTitle('成功发布商品:');
  180. $win->AddMsgItem($msg);
  181. $winform = $win->GetWindow('hand', '&nbsp;', false);
  182. $win->Display();
  183. }
  184. ?>