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

134 lines
7.1KB

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