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

catalog_add.php 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <?php
  2. /**
  3. * 栏目添加
  4. *
  5. * @version $Id: catalog_add.php 1 14:31 2010年7月12日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__) . "/config.php");
  12. require_once(DEDEINC . "/typelink.class.php");
  13. if (empty($listtype)) $listtype = '';
  14. if (empty($dopost)) $dopost = '';
  15. if (empty($upinyin)) $upinyin = 0;
  16. if (empty($channelid)) $channelid = 1;
  17. if (isset($channeltype)) $channelid = $channeltype;
  18. $id = empty($id) ? 0 : intval($id);
  19. $reid = empty($reid) ? 0 : intval($reid);
  20. $nid = 'article';
  21. if ($id == 0 && $reid == 0) {
  22. CheckPurview('t_New');
  23. } else {
  24. $checkID = empty($id) ? $reid : $id;
  25. CheckPurview('t_AccNew');
  26. CheckCatalog($checkID, '你无权在本栏目下创建子类!');
  27. }
  28. if (empty($myrow)) $myrow = array();
  29. $dsql->SetQuery("SELECT id,typename,nid FROM `#@__channeltype` WHERE id<>-1 AND isshow=1 ORDER BY id");
  30. $dsql->Execute();
  31. while ($row = $dsql->GetObject()) {
  32. $channelArray[$row->id]['typename'] = $row->typename;
  33. $channelArray[$row->id]['nid'] = $row->nid;
  34. if ($row->id == $channelid) {
  35. $nid = $row->nid;
  36. }
  37. }
  38. if ($dopost == 'quick') {
  39. $tl = new TypeLink(0);
  40. $typeOptions = $tl->GetOptionArray(0, 0, $channelid);
  41. include DedeInclude('templets/catalog_add_quick.htm');
  42. exit();
  43. }
  44. /*---------------------
  45. function action_savequick(){ }
  46. ---------------------*/ else if ($dopost == 'savequick') {
  47. if (!isset($savetype)) $savetype = '';
  48. $isdefault = isset($isdefault) ? $isdefault : 0;
  49. $tempindex = "{style}/index_{$nid}.htm";
  50. $templist = "{style}/list_{$nid}.htm";
  51. $temparticle = "{style}/article_{$nid}.htm";
  52. $queryTemplate = "INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir,isdefault,defaultname,issend,channeltype,
  53. tempindex,templist,temparticle,modname,namerule,namerule2,ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`)
  54. VALUES('~reid~','~topid~','~rank~','~typename~','~typedir~','$isdefault','$defaultname','$issend','$channeltype',
  55. '$tempindex','$templist','$temparticle','default','$namerule','$namerule2','0','0','','','~typename~','0','','','0','0','0','','')";
  56. if (empty($savetype)) {
  57. foreach ($_POST as $k => $v) {
  58. if (preg_match("#^posttype#", $k)) {
  59. $k = str_replace('posttype', '', $k);
  60. } else {
  61. continue;
  62. }
  63. $rank = ${'rank' . $k};
  64. $toptypename = trim(${'toptype' . $k});
  65. $sontype = trim(${'sontype' . $k});
  66. $toptypedir = GetPinyin(stripslashes($toptypename));
  67. $toptypedir = $referpath == 'parent' ? $nextdir . '/' . $toptypedir : '/' . $toptypedir;
  68. if (empty($toptypename)) {
  69. continue;
  70. }
  71. $sql = str_replace('~reid~', '0', $queryTemplate);
  72. $sql = str_replace('~topid~', '0', $sql);
  73. $sql = str_replace('~rank~', $rank, $sql);
  74. $sql = str_replace('~typename~', $toptypename, $sql);
  75. $sql = str_replace('~typedir~', $toptypedir, $sql);
  76. $dsql->ExecuteNoneQuery($sql);
  77. $tid = $dsql->GetLastID();
  78. if ($tid > 0 && $sontype != '') {
  79. $sontypes = explode(',', $sontype);
  80. foreach ($sontypes as $k => $v) {
  81. $v = trim($v);
  82. if ($v == '') {
  83. continue;
  84. }
  85. $typedir = $toptypedir . '/' . GetPinyin(stripslashes($v));
  86. $sql = str_replace('~reid~', $tid, $queryTemplate);
  87. $sql = str_replace('~topid~', $tid, $sql);
  88. $sql = str_replace('~rank~', $k, $sql);
  89. $sql = str_replace('~typename~', $v, $sql);
  90. $sql = str_replace('~typedir~', $typedir, $sql);
  91. $dsql->ExecuteNoneQuery($sql);
  92. }
  93. }
  94. }
  95. } else {
  96. $row = $dsql->GetOne("SELECT `typedir` FROM `#@__arctype` WHERE `id`={$reid}");
  97. foreach ($_POST as $k => $v) {
  98. if (preg_match("#^posttype#", $k)) {
  99. $k = str_replace('posttype', '', $k);
  100. } else {
  101. continue;
  102. }
  103. $rank = ${'rank' . $k};
  104. $toptypename = trim(${'reltype' . $k});
  105. $toptypedir = GetPinyin(stripslashes($toptypename));
  106. switch ($referpath) {
  107. case 'parent':
  108. $toptypedir = $nextdir . '/' . $toptypedir;
  109. break;
  110. case 'typepath':
  111. $toptypedir = isset($row['typedir']) ? $row['typedir'] . '/' . $toptypedir : '/' . $toptypedir;
  112. break;
  113. default:
  114. $toptypedir = '/' . $toptypedir;
  115. break;
  116. }
  117. if (empty($toptypename)) {
  118. continue;
  119. }
  120. $sql = str_replace('~reid~', $reid, $queryTemplate);
  121. $sql = str_replace('~topid~', $reid, $sql);
  122. $sql = str_replace('~rank~', $rank, $sql);
  123. $sql = str_replace('~typename~', $toptypename, $sql);
  124. $sql = str_replace('~typedir~', $toptypedir, $sql);
  125. $dsql->ExecuteNoneQuery($sql);
  126. }
  127. }
  128. UpDateCatCache();
  129. ShowMsg('成功增加指定栏目!', 'catalog_main.php');
  130. exit();
  131. }
  132. /*---------------------
  133. function action_save(){ }
  134. ---------------------*/ else if ($dopost == 'save') {
  135. $smalltypes = '';
  136. if (empty($smalltype)) $smalltype = '';
  137. if (is_array($smalltype)) $smalltypes = join(',', $smalltype);
  138. if (!isset($sitepath)) $sitepath = '';
  139. if ($topid == 0 && $reid > 0) $topid = $reid;
  140. if ($ispart != 0) $cross = 0;
  141. $description = Html2Text($description, 1);
  142. $keywords = Html2Text($keywords, 1);
  143. if ($ispart != 2) {
  144. //栏目的参照目录
  145. if ($referpath == 'cmspath') $nextdir = '{cmspath}';
  146. if ($referpath == 'basepath') $nextdir = '';
  147. //用拼音命名
  148. if ($upinyin == 1 || $typedir == '') {
  149. $typedir = GetPinyin(stripslashes($typename));
  150. }
  151. $typedir = $nextdir . '/' . $typedir;
  152. $typedir = preg_replace("#\/{1,}#", "/", $typedir);
  153. }
  154. //开启多站点时的设置(仅针对顶级栏目)
  155. if ($reid == 0 && $moresite == 1) {
  156. $sitepath = $typedir;
  157. //检测二级网址
  158. if ($siteurl != '') {
  159. $siteurl = preg_replace("#\/$#", "", $siteurl);
  160. if (!preg_match("#http:\/\/#i", $siteurl)) {
  161. ShowMsg("你绑定的二级域名无效,请用(http://host)的形式!", "-1");
  162. exit();
  163. }
  164. if (preg_match("#" . $cfg_basehost . "#i", $siteurl)) {
  165. ShowMsg("你绑定的二级域名与当前站点是同一个域,不需要绑定!", "-1");
  166. exit();
  167. }
  168. }
  169. }
  170. //创建目录
  171. if ($ispart != 2) {
  172. $true_typedir = str_replace("{cmspath}", $cfg_cmspath, $typedir);
  173. $true_typedir = preg_replace("#\/{1,}#", "/", $true_typedir);
  174. if (!CreateDir($true_typedir)) {
  175. ShowMsg("创建目录 {$true_typedir} 失败,请检查你的路径是否存在问题!", "-1");
  176. exit();
  177. }
  178. }
  179. $in_query = "INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir,isdefault,defaultname,issend,channeltype,
  180. tempindex,templist,temparticle,modname,namerule,namerule2,
  181. ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`)
  182. VALUES('$reid','$topid','$sortrank','$typename','$typedir','$isdefault','$defaultname','$issend','$channeltype',
  183. '$tempindex','$templist','$temparticle','default','$namerule','$namerule2',
  184. '$ispart','$corank','$description','$keywords','$seotitle','$moresite','$siteurl','$sitepath','$ishidden','$cross','$crossid','$content','$smalltypes')";
  185. if (!$dsql->ExecuteNoneQuery($in_query)) {
  186. ShowMsg("保存目录数据时失败,请检查你的输入资料是否存在问题!", "-1");
  187. exit();
  188. }
  189. UpDateCatCache();
  190. if ($reid > 0) {
  191. PutCookie('lastCid', GetTopid($reid), 3600 * 24, '/');
  192. }
  193. ShowMsg("成功创建一个分类!", "catalog_main.php");
  194. exit();
  195. } //End dopost==save
  196. //获取从父目录继承的默认参数
  197. if ($dopost == '') {
  198. $channelid = 1;
  199. $issend = 1;
  200. $corank = 0;
  201. $reid = 0;
  202. $topid = 0;
  203. $typedir = '';
  204. $moresite = 0;
  205. if ($id > 0) {
  206. $myrow = $dsql->GetOne(" SELECT tp.*,ch.typename AS ctypename FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id=$id ");
  207. $channelid = $myrow['channeltype'];
  208. $issennd = $myrow['issend'];
  209. $corank = $myrow['corank'];
  210. $topid = $myrow['topid'];
  211. $typedir = $myrow['typedir'];
  212. }
  213. //父栏目是否为二级站点
  214. $moresite = empty($myrow['moresite']) ? 0 : $myrow['moresite'];
  215. }
  216. include DedeInclude('templets/catalog_add.htm');