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

93 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 GNU GPL v2 (https://www.dedebiz.com/license)
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. if (DEDEBIZ_SAFE_MODE) {
  13. die(DedeAlert("系统已启用安全模式,无法使用当前功能",ALERT_DANGER));
  14. }
  15. CheckPurview('c_New');
  16. require_once(DEDEINC."/dedetag.class.php");
  17. if (empty($ismake)) $ismake = 0;
  18. if (empty($isdel)) $isdel = 0;
  19. if (empty($action)) $action = '';
  20. if ($action == 'add') {
  21. //检查输入
  22. if (empty($id) || preg_match("#[^0-9-]#", $id)) {
  23. ShowMsg("模型id必须为数字", "-1");
  24. exit();
  25. }
  26. if (preg_match("#[^a-z0-9]#i", $nid) || $nid == "") {
  27. ShowMsg("模型名字必须为英文字母或与数字混合字符串", "-1");
  28. exit();
  29. }
  30. if ($addtable == "") {
  31. ShowMsg("附加表不能为空", "-1");
  32. exit();
  33. }
  34. $trueTable2 = str_replace("#@__", $cfg_dbprefix, $addtable);
  35. if ($issystem == -1 && $id > 0) $id = $id * -1;
  36. //检查id是否重复
  37. $row = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$id' OR nid LIKE '$nid' OR addtable LIKE '$addtable'");
  38. if (is_array($row)) {
  39. ShowMsg("模型id和模型名称及附加表名称数据库已存在,请重新填写", "-1");
  40. exit();
  41. }
  42. $mysql_version = $dsql->GetVersion();
  43. //创建附加表
  44. if ($trueTable2 != '') {
  45. $istb = $dsql->IsTable($trueTable2);
  46. if (!$istb || $isdel == 1) {
  47. //是否需要摘要字段
  48. $dsql->ExecuteNoneQuery("DROP TABLE IF EXISTS `{$trueTable2}`;");
  49. if ($issystem != -1) {
  50. $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 '',";
  51. } else {
  52. $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',
  53. ";
  54. }
  55. if ($mysql_version < 4.1) {
  56. $tabsql .= "PRIMARY KEY (`aid`), KEY `typeid` (`typeid`)\r\n) TYPE=MyISAM;";
  57. } else {
  58. $tabsql .= "PRIMARY KEY (`aid`), KEY `typeid` (`typeid`)\r\n) ENGINE=MyISAM DEFAULT CHARSET=".$cfg_db_language.";";
  59. }
  60. $rs = $dsql->ExecuteNoneQuery($tabsql);
  61. if (!$rs) {
  62. ShowMsg("创建附加表失败".$dsql->GetError(), "javascript:;");
  63. exit();
  64. }
  65. }
  66. }
  67. $listfields = $fieldset = '';
  68. if ($issystem == -1) {
  69. $fieldset = "<field:channel itemname=\"模型id\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:channel>
  70. <field:arcrank itemname=\"浏览权限\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"5\" page=\"\"></field:arcrank>
  71. <field:mid itemname=\"会员id\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"8\" page=\"\"></field:mid>
  72. <field:click itemname=\"点击\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:click>
  73. <field:title itemname=\"标题\" autofield=\"0\" notsend=\"0\" type=\"text\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"60\" page=\"\"></field:title>
  74. <field:senddate itemname=\"发布时间\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:senddate>
  75. <field:flag itemname=\"推荐属性\" autofield=\"0\" notsend=\"0\" type=\"checkbox\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:flag>
  76. <field:litpic itemname=\"缩略图\" autofield=\"0\" notsend=\"0\" type=\"text\" isnull=\"true\" islist=\"0\" default=\"\" maxlength=\"60\" page=\"\"></field:litpic>
  77. <field:userip itemname=\"会员IP\" autofield=\"0\" notsend=\"0\" type=\"text\" isnull=\"true\" islist=\"0\" default=\"0\" maxlength=\"15\" page=\"\"></field:userip>
  78. <field:lastpost itemname=\"最后评论时间\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"10\" page=\"\"></field:lastpost>
  79. <field:scores itemname=\"评论积分\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"8\" page=\"\"></field:scores>
  80. <field:goodpost itemname=\"好评数\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"8\" page=\"\"></field:goodpost>
  81. <field:badpost itemname=\"差评数\" autofield=\"0\" notsend=\"0\" type=\"int\" isnull=\"true\" islist=\"1\" default=\"0\" maxlength=\"8\" page=\"\"></field:badpost>\r\n";
  82. $listfields = 'channel,arcrank,mid,click,title,senddate,flag,listpic,lastpost,scores,goodpost,badpost';
  83. }
  84. $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');";
  85. $dsql->ExecuteNoneQuery($inQuery);
  86. ShowMsg("成功创建一个文档模型", "mychannel_edit.php?id=".$id);
  87. exit();
  88. }
  89. $row = $dsql->GetOne("SELECT id FROM `#@__channeltype` ORDER BY id DESC LIMIT 0,1 ");
  90. $newid = $row['id'] + 1;
  91. if ($newid < 10) $newid = $newid + 10;
  92. require_once(DEDEADMIN."/templets/mychannel_add.htm");
  93. ?>