database.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /*creates*/
  3. if(empty($col_list[$pre.'annex'])){
  4. $sql .= "CREATE TABLE `mac_annex` ( `annex_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `annex_time` int(10) unsigned NOT NULL DEFAULT '0', `annex_file` varchar(255) NOT NULL DEFAULT '', `annex_size` int(10) unsigned NOT NULL DEFAULT '0', `annex_type` varchar(8) NOT NULL DEFAULT '', PRIMARY KEY (`annex_id`), KEY `annex_time` (`annex_time`), KEY `annex_file` (`annex_file`), KEY `annex_type` (`annex_type`)) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ;";
  5. $sql .="\r";
  6. }
  7. if(empty($col_list[$pre.'website'])){
  8. $sql .= "CREATE TABLE `mac_website` ( `website_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `type_id` smallint(5) unsigned NOT NULL DEFAULT '0', `type_id_1` smallint(5) unsigned NOT NULL DEFAULT '0', `website_name` varchar(60) NOT NULL DEFAULT '', `website_sub` varchar(255) NOT NULL DEFAULT '', `website_en` varchar(255) NOT NULL DEFAULT '', `website_status` tinyint(1) unsigned NOT NULL DEFAULT '0', `website_letter` char(1) NOT NULL DEFAULT '', `website_color` varchar(6) NOT NULL DEFAULT '', `website_lock` tinyint(1) unsigned NOT NULL DEFAULT '0', `website_sort` int(10) NOT NULL DEFAULT '0', `website_jumpurl` varchar(255) NOT NULL DEFAULT '', `website_pic` varchar(255) NOT NULL DEFAULT '', `website_logo` varchar(255) NOT NULL DEFAULT '', `website_area` varchar(20) NOT NULL DEFAULT '', `website_lang` varchar(10) NOT NULL DEFAULT '', `website_level` tinyint(1) unsigned NOT NULL DEFAULT '0', `website_time` int(10) unsigned NOT NULL DEFAULT '0', `website_time_add` int(10) unsigned NOT NULL DEFAULT '0', `website_time_hits` int(10) unsigned NOT NULL DEFAULT '0', `website_time_make` int(10) unsigned NOT NULL DEFAULT '0', `website_hits` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_hits_day` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_hits_week` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_hits_month` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_score` decimal(3,1) unsigned NOT NULL DEFAULT '0.0', `website_score_all` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_score_num` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_up` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_down` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_referer` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_referer_day` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_referer_week` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_referer_month` mediumint(8) unsigned NOT NULL DEFAULT '0', `website_tag` varchar(100) NOT NULL DEFAULT '', `website_class` varchar(255) NOT NULL DEFAULT '', `website_remarks` varchar(100) NOT NULL DEFAULT '', `website_tpl` varchar(30) NOT NULL DEFAULT '', `website_blurb` varchar(255) NOT NULL DEFAULT '', `website_content` mediumtext NOT NULL, PRIMARY KEY (`website_id`), KEY `type_id` (`type_id`), KEY `type_id_1` (`type_id_1`), KEY `website_name` (`website_name`), KEY `website_en` (`website_en`), KEY `website_letter` (`website_letter`), KEY `website_sort` (`website_sort`), KEY `website_lock` (`website_lock`), KEY `website_time` (`website_time`), KEY `website_time_add` (`website_time_add`), KEY `website_hits` (`website_hits`), KEY `website_hits_day` (`website_hits_day`), KEY `website_hits_week` (`website_hits_week`), KEY `website_hits_month` (`website_hits_month`), KEY `website_time_make` (`website_time_make`), KEY `website_score` (`website_score`), KEY `website_score_all` (`website_score_all`), KEY `website_score_num` (`website_score_num`), KEY `website_up` (`website_up`), KEY `website_down` (`website_down`), KEY `website_level` (`website_level`), KEY `website_tag` (`website_tag`), KEY `website_class` (`website_class`), KEY `website_referer` (`website_referer`), KEY `website_referer_day` (`website_referer_day`), KEY `website_referer_week` (`website_referer_week`), KEY `website_referer_month` (`website_referer_month`)) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ;";
  9. $sql .="\r";
  10. }
  11. /*updates*/
  12. if(empty($col_list[$pre.'art']['art_pic_screenshot'])){
  13. $sql .= "ALTER TABLE `mac_art` ADD `art_pic_screenshot` text;";
  14. $sql .="\r";
  15. }
  16. if(empty($col_list[$pre.'vod']['vod_pic_screenshot'])){
  17. $sql .= "ALTER TABLE `mac_vod` ADD `vod_pic_screenshot` text;";
  18. $sql .="\r";
  19. }
  20. if(empty($col_list[$pre.'actor']['type_id'])){
  21. $sql .= "ALTER TABLE `mac_actor` ADD `type_id` INT( 10 ) unsigned NOT NULL DEFAULT '0',ADD `type_id_1` INT( 10 ) unsigned NOT NULL DEFAULT '0',ADD `actor_tag` VARCHAR( 255 ) NOT NULL DEFAULT '',ADD `actor_class` VARCHAR( 255 ) NOT NULL DEFAULT '';";
  22. $sql .="\r";
  23. }
  24. if(empty($col_list[$pre.'website']['website_pic_screenshot'])){
  25. $sql .= "ALTER TABLE `mac_website` ADD `website_pic_screenshot` text;";
  26. $sql .="\r";
  27. }
  28. if(empty($col_list[$pre.'website']['website_time_referer'])){
  29. $sql .= "ALTER TABLE `mac_website` ADD `website_time_referer` INT( 10 ) unsigned NOT NULL DEFAULT '0';";
  30. $sql .="\r";
  31. }
  32. if(empty($col_list[$pre.'type']['type_logo'])){
  33. $sql .= "ALTER TABLE `mac_type` ADD `type_logo` VARCHAR( 255 ) NOT NULL DEFAULT '',ADD `type_pic` VARCHAR( 255 ) NOT NULL DEFAULT '',ADD `type_jumpurl` VARCHAR( 150 ) NOT NULL DEFAULT '';";
  34. $sql .="\r";
  35. }
  36. if(empty($col_list[$pre.'collect']['collect_filter'])){
  37. $sql .= "ALTER TABLE `mac_collect` ADD `collect_filter` tinyint( 1 ) NOT NULL DEFAULT '0',ADD `collect_filter_from` VARCHAR( 255 ) NOT NULL DEFAULT '',ADD `collect_opt` tinyint( 1 ) NOT NULL DEFAULT '0';";
  38. $sql .="\r";
  39. }
  40. if(empty($col_list[$pre.'vod']['vod_plot'])){
  41. $sql .= "ALTER TABLE `mac_vod` ADD `vod_plot` tinyint( 1 ) NOT NULL DEFAULT '0',ADD `vod_plot_name` mediumtext NOT NULL ,ADD `vod_plot_detail` mediumtext NOT NULL ;";
  42. $sql .="\r";
  43. }
  44. if(empty($col_list[$pre.'user']['user_reg_ip'])){
  45. $sql .= "ALTER TABLE `mac_user` ADD `user_reg_ip` INT( 10 ) unsigned NOT NULL DEFAULT '0' AFTER `user_reg_time`;";
  46. $sql .="\r";
  47. }
  48. if(empty($col_list[$pre.'vod']['vod_behind'])){
  49. $sql .= "ALTER TABLE `mac_vod` ADD `vod_behind` VARCHAR( 100 ) NOT NULL DEFAULT '' AFTER `vod_writer`;";
  50. $sql .="\r";
  51. }
  52. if(empty($col_list[$pre.'user']['user_points_froze'])){
  53. $sql .= "ALTER TABLE `mac_user` ADD `user_points_froze` INT( 10 ) unsigned NOT NULL DEFAULT '0' AFTER `user_points`;";
  54. $sql .="\r";
  55. }
  56. if(empty($col_list[$pre.'art']['art_points'])){
  57. $sql .= "ALTER TABLE `mac_art` ADD `art_points` SMALLINT(6) unsigned NOT NULL DEFAULT '0',ADD `art_points_detail` SMALLINT( 6 ) unsigned NOT NULL DEFAULT '0',ADD `art_pwd` VARCHAR( 10 ) NOT NULL DEFAULT '',ADD `art_pwd_url` VARCHAR(255) NOT NULL DEFAULT '' ;";
  58. $sql .="\r";
  59. }
  60. if(empty($col_list[$pre.'vod']['vod_pwd'])){
  61. $sql .= "ALTER TABLE `mac_vod` ADD `vod_pwd` VARCHAR( 10 ) NOT NULL DEFAULT '',ADD `vod_pwd_url` VARCHAR(255) NOT NULL DEFAULT '',ADD `vod_pwd_play` VARCHAR( 10 ) NOT NULL DEFAULT '',ADD `vod_pwd_play_url` VARCHAR(255) NOT NULL DEFAULT '',ADD `vod_pwd_down` VARCHAR( 10 ) NOT NULL DEFAULT '',ADD `vod_pwd_down_url` VARCHAR(255) NOT NULL DEFAULT '',ADD `vod_copyright` tinyint(1) unsigned NOT NULL DEFAULT '0',ADD `vod_points` SMALLINT( 6 ) unsigned NOT NULL DEFAULT '0' ;";
  62. $sql .="\r";
  63. }
  64. if(empty($col_list[$pre.'user']['user_pid'])){
  65. $sql .= "ALTER TABLE `mac_user` ADD `user_pid` INT( 10 ) unsigned NOT NULL DEFAULT '0',ADD `user_pid_2` INT( 10) unsigned NOT NULL DEFAULT '0' ,ADD `user_pid_3` INT( 10) unsigned NOT NULL DEFAULT '0' ;";
  66. $sql .="\r";
  67. }
  68. if(empty($col_list[$pre.'plog'])){
  69. $sql .= "CREATE TABLE `mac_plog` ( `plog_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned NOT NULL DEFAULT '0', `user_id_1` int(10) unsigned NOT NULL DEFAULT '0', `plog_type` tinyint(1) unsigned NOT NULL DEFAULT '1', `plog_points` smallint(6) unsigned NOT NULL DEFAULT '0', `plog_time` int(10) unsigned NOT NULL DEFAULT '0', `plog_remarks` varchar(100) NOT NULL DEFAULT '', PRIMARY KEY (`plog_id`), KEY `user_id` (`user_id`), KEY `plog_type` (`plog_type`) USING BTREE) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
  70. $sql .="\r";
  71. }
  72. if(empty($col_list[$pre.'cash'])){
  73. $sql .= "CREATE TABLE `mac_cash` ( `cash_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned NOT NULL DEFAULT '0', `cash_status` tinyint(1) unsigned NOT NULL DEFAULT '0', `cash_points` smallint(6) unsigned NOT NULL DEFAULT '0', `cash_money` decimal(12,2) unsigned NOT NULL DEFAULT '0.00', `cash_bank_name` varchar(60) NOT NULL DEFAULT '', `cash_bank_no` varchar(30) NOT NULL DEFAULT '', `cash_payee_name` varchar(30) NOT NULL DEFAULT '', `cash_time` int(10) unsigned NOT NULL DEFAULT '0', `cash_time_audit` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`cash_id`), KEY `user_id` (`user_id`), KEY `cash_status` (`cash_status`) USING BTREE) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
  74. $sql .="\r";
  75. }
  76. // 采集时,不同资源站,独立配置同步图片选项
  77. if(empty($col_list[$pre.'collect']['collect_sync_pic_opt'])){
  78. $sql .= "ALTER TABLE `mac_collect` ADD `collect_sync_pic_opt` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '同步图片选项,0-跟随全局,1-开启,2-关闭';";
  79. $sql .="\r";
  80. }
  81. // 图片和内容字段采集时长度不够报错
  82. if (version_compare(config('version.code'),'2022.1000.3027','<=')) {
  83. $sql .= "ALTER TABLE `mac_vod` CHANGE `vod_pic` `vod_pic` varchar(1024) COLLATE 'utf8_general_ci' NOT NULL DEFAULT '' AFTER `vod_class`, CHANGE `vod_pic_thumb` `vod_pic_thumb` varchar(1024) COLLATE 'utf8_general_ci' NOT NULL DEFAULT '' AFTER `vod_pic`, CHANGE `vod_pic_slide` `vod_pic_slide` varchar(1024) COLLATE 'utf8_general_ci' NOT NULL DEFAULT '' AFTER `vod_pic_thumb`, CHANGE `vod_content` `vod_content` mediumtext COLLATE 'utf8_general_ci' NOT NULL AFTER `vod_pwd_down_url`;";
  84. $sql .="\r";
  85. }
  86. // 优化LIKE查询-vod搜索缓存表
  87. if (empty($col_list[$pre.'vod_search'])) {
  88. $sql .= "CREATE TABLE `mac_vod_search` ( `search_key` char(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL COMMENT '搜索键(关键词md5)', `search_word` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '搜索关键词', `search_field` varchar(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL COMMENT '搜索字段名(可有多个,用|分隔)', `search_hit_count` bigint unsigned NOT NULL DEFAULT '0' COMMENT '搜索命中次数', `search_last_hit_time` int unsigned NOT NULL DEFAULT '0' COMMENT '最近命中时间', `search_update_time` int unsigned NOT NULL DEFAULT '0' COMMENT '添加时间', `search_result_count` int unsigned NOT NULL DEFAULT '0' COMMENT '结果Id数量', `search_result_ids` mediumtext CHARACTER SET ascii COLLATE ascii_bin NOT NULL COMMENT '搜索结果Id列表,英文半角逗号分隔', PRIMARY KEY (`search_key`), KEY `search_field` (`search_field`), KEY `search_update_time` (`search_update_time`), KEY `search_hit_count` (`search_hit_count`), KEY `search_last_hit_time` (`search_last_hit_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='vod搜索缓存表';";
  89. $sql .="\r";
  90. }
  91. // 采集时,过滤年份
  92. // https://github.com/magicblack/maccms10/issues/1057
  93. if(empty($col_list[$pre.'collect']['collect_filter_year'])){
  94. $sql .= "ALTER TABLE `mac_collect` ADD `collect_filter_year` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '采集时,过滤年份' AFTER `collect_filter_from`;";
  95. $sql .="\r";
  96. }
  97. // 入库重复规则设置名称
  98. if (version_compare(config('version.code'), '2024.1000.4043', '>=')) {
  99. $file = APP_PATH . 'extra/maccms.php';
  100. $backupFile = APP_PATH . 'extra/maccms_backup_' . date('Ymd_His') . '.php';
  101. copy($file, $backupFile);
  102. @chmod($file, 0777);
  103. $config = config('maccms');
  104. if (strpos($config['collect']['vod']['inrule'], 'a') === false && !isset($config['collect']['vod']['inrule_first_change'])) {
  105. $config['collect']['vod']['inrule'] = ',a' . $config['collect']['vod']['inrule'];
  106. $config['collect']['vod']['inrule_first_change']= true;
  107. $res = mac_arr2file($file, $config);
  108. }
  109. }