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

90 lines
6.4KB

  1. <?php
  2. /**
  3. * 自定义栏目
  4. *
  5. * @version $id:mychannel_add.php 14:46 2010年7月20日 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('c_New');
  13. require_once(DEDEINC."/dedetag.class.php");
  14. if (empty($ismake)) $ismake = 0;
  15. if (empty($isdel)) $isdel = 0;
  16. if (empty($action)) $action = '';
  17. if ($action == 'add') {
  18. //检查输入
  19. if (empty($id) || preg_match("#[^0-9-]#", $id)) {
  20. ShowMsg("<span class='text-primary'>栏目id</span>必须为数字", "-1");
  21. exit();
  22. }
  23. if (preg_match("#[^a-z0-9]#i", $nid) || $nid == "") {
  24. ShowMsg("<span class='text-primary'>栏目名字标识</span>必须为英文字母或与数字混合字符串", "-1");
  25. exit();
  26. }
  27. if ($addtable == "") {
  28. ShowMsg("附加表不能为空", "-1");
  29. exit();
  30. }
  31. $trueTable2 = str_replace("#@__", $cfg_dbprefix, $addtable);
  32. if ($issystem == -1 && $id > 0) $id = $id * -1;
  33. //检查id是否重复
  34. $row = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$id' OR nid LIKE '$nid' OR addtable LIKE '$addtable'");
  35. if (is_array($row)) {
  36. ShowMsg("可能栏目id、栏目名称标识、附加表名称在数据库已存在,不能重复使用", "-1");
  37. exit();
  38. }
  39. $mysql_version = $dsql->GetVersion();
  40. //创建附加表
  41. if ($trueTable2 != '') {
  42. $istb = $dsql->IsTable($trueTable2);
  43. if (!$istb || $isdel == 1) {
  44. //是否需要摘要字段
  45. $dsql->ExecuteNoneQuery("DROP TABLE IF EXISTS `{$trueTable2}`;");
  46. if ($issystem != -1) {
  47. $tabsql = "CREATE TABLE `$trueTable2` (`aid` int(11) NOT NULL default '0',`typeid` int(11) NOT NULL default '0',`redirecturl` varchar(255) NOT NULL default '',`templet` varchar(30) NOT NULL default '',`userip` char(48) NOT NULL default '',";
  48. } else {
  49. $tabsql = "CREATE TABLE `$trueTable2` (`aid` int(11) NOT NULL default '0',`typeid` int(11) NOT NULL default '0',`channel` SMALLINT NOT NULL DEFAULT '0',`arcrank` SMALLINT NOT NULL DEFAULT '0',`mid` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0',`click` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0',`title` varchar(255) NOT NULL default '',`senddate` int(11) NOT NULL default '0',`flag` set('c','h','p','f','s','j','a','b') default NULL,`litpic` varchar(60) NOT NULL default '',`userip` char(48) NOT NULL default '',`lastpost` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0',`scores` MEDIUMINT( 8 ) NOT NULL DEFAULT '0',`goodpost` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0',`badpost` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0',
  50. ";
  51. }
  52. if ($mysql_version < 4.1) {
  53. $tabsql .= " PRIMARY KEY (`aid`), KEY `typeid` (`typeid`)\r\n) TYPE=MyISAM; ";
  54. } else {
  55. $tabsql .= " PRIMARY KEY (`aid`), KEY `typeid` (`typeid`)\r\n) ENGINE=MyISAM DEFAULT CHARSET=".$cfg_db_language."; ";
  56. }
  57. $rs = $dsql->ExecuteNoneQuery($tabsql);
  58. if (!$rs) {
  59. ShowMsg("创建附加表失败".$dsql->GetError(), "javascript:;");
  60. exit();
  61. }
  62. }
  63. }
  64. $listfields = $fieldset = '';
  65. if ($issystem == -1) {
  66. $fieldset = "<field:channel itemname=\"栏目id\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:channel>
  67. <field:arcrank itemname=\"浏览权限\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"5\" page=\"\"></field:arcrank>
  68. <field:mid itemname=\"会员id\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"8\" page=\"\"></field:mid>
  69. <field:click itemname=\"点击\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:click>
  70. <field:title itemname=\"标题\" autofield=\"0\" notsend=\"0\" type=\"text\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"60\" page=\"\"></field:title>
  71. <field:senddate itemname=\"发布时间\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:senddate>
  72. <field:flag itemname=\"推荐属性\" autofield=\"0\" notsend=\"0\" type=\"checkbox\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:flag>
  73. <field:litpic itemname=\"缩略图\" autofield=\"0\" notsend=\"0\" type=\"text\" isnull=\"true\" islist=\"0\" default=\"\" maxlength=\"60\" page=\"\"></field:litpic>
  74. <field:userip itemname=\"会员IP\" autofield=\"0\" notsend=\"0\" type=\"text\" isnull=\"true\" islist=\"0\" default=\"0\" maxlength=\"15\" page=\"\"></field:userip>
  75. <field:lastpost itemname=\"最后评论时间\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:lastpost>
  76. <field:scores itemname=\"评论积分\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"8\" page=\"\"></field:scores>
  77. <field:goodpost itemname=\"好评数\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"8\" page=\"\"></field:goodpost>
  78. <field:badpost itemname=\"差评数\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"8\" page=\"\"></field:badpost>\r\n";
  79. $listfields = 'channel,arcrank,mid,click,title,senddate,flag,listpic,lastpost,scores,goodpost,badpost';
  80. }
  81. $inQuery = "INSERT INTO `#@__channeltype` (id,nid,typename,addtable,addcon,mancon,editcon,useraddcon,usermancon,usereditcon,fieldset,listfields,issystem,issend,arcsta,usertype,sendrank,needdes,needpic,titlename,onlyone,dfcid) VALUES ('$id','$nid','$typename','$addtable','$addcon','$mancon','$editcon','$useraddcon','$usermancon','$usereditcon','$fieldset','$listfields','$issystem','$issend','$arcsta','$usertype','$sendrank','$needdes','$needpic','$titlename','$onlyone','$dfcid');";
  82. $dsql->ExecuteNoneQuery($inQuery);
  83. ShowMsg("成功增加一个栏目模型", "mychannel_edit.php?id=".$id);
  84. exit();
  85. }
  86. $row = $dsql->GetOne("SELECT id FROM `#@__channeltype` ORDER BY id DESC LIMIT 0,1 ");
  87. $newid = $row['id'] + 1;
  88. if ($newid < 10) $newid = $newid + 10;
  89. require_once(DEDEADMIN."/templets/mychannel_add.htm");
  90. ?>