107
|
1 #!/usr/bin/php
|
|
2 <?php
|
|
3 include_once('config.php');
|
|
4 include_once(INSTALL_PATH . '/Settings.class.php' );
|
|
5
|
|
6
|
|
7 // mysqli::multi_query篏障<т戎
|
|
8
|
|
9 function multi_query( $sqlstrs, $dbh ) {
|
|
10 $error = false;
|
|
11
|
|
12 foreach( $sqlstrs as $sqlstr ) {
|
|
13 $res = mysql_query( $sqlstr );
|
|
14 if( $res === FALSE ) {
|
|
15 echo "failed: ". $sqlstr . "\n";
|
|
16 $error = true;
|
|
17 }
|
|
18 }
|
|
19 return $error;
|
|
20 }
|
|
21
|
|
22 function column_exists( $tbl, $col, $dbh ) {
|
|
23 $sqlstr = "show fields from ".$tbl." where Field='".$col."'";
|
|
24 $res = mysql_query( $sqlstr, $dbh );
|
|
25 return mysql_num_rows($res);
|
|
26 }
|
|
27
|
|
28 function index_exists( $tbl, $idx, $dbh ) {
|
|
29 $sqlstr = "show index from ".$tbl." where Key_name='".$idx."'";
|
|
30 $res = mysql_query( $sqlstr, $dbh );
|
|
31 return mysql_num_rows($res);
|
|
32 }
|
|
33
|
|
34
|
|
35 $settings = Settings::factory();
|
|
36 $dbh = mysql_connect( $settings->db_host, $settings->db_user, $settings->db_pass );
|
|
37 if( $dbh !== FALSE ) {
|
|
38
|
|
39 $sqlstr = "use ".$settings->db_name;
|
|
40 mysql_query( $sqlstr );
|
|
41
|
|
42 $sqlstr = "set NAMES 'utf8'";
|
|
43 mysql_query( $sqlstr );
|
|
44
|
|
45 // RESERVE_TBL
|
|
46
|
|
47 $sqlstrs = array (
|
|
48 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify channel_disc varchar(128) not null default 'none';", // channel disc
|
|
49 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify channel_id integer not null default '0';", // channel ID
|
|
50 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify program_id integer not null default '0';", // Program ID
|
|
51 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify type varchar(8) not null default 'GR';", // 腮ワGR/BS/CS鐚
|
|
52 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify channel varchar(10) not null default '0';", // c潟
|
|
53 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify title varchar(512) not null default 'none';", // 帥ゃ
|
|
54 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify description varchar(512) not null default 'none';", // 茯 text->varchar
|
|
55 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify category_id integer not null default '0';", // 眼ID
|
|
56 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify starttime datetime not null default '1970-01-01 00:00:00';", // 紮
|
|
57 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify endtime datetime not null default '1970-01-01 00:00:00';", // 腟篋
|
|
58 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify job integer not null default '0';", // job
|
|
59 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify path blob default null;", // 牙祉<ゃ
|
|
60 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify complete boolean not null default '0';", // 絎篋
|
|
61 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify reserve_disc varchar(128) not null default 'none';", // 茘ョhash
|
|
62 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify autorec integer not null default '0';", // 若若ID
|
|
63 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify mode integer not null default '0';", //牙祉≪若
|
|
64 );
|
|
65
|
|
66 if( multi_query( $sqlstrs, $dbh ) ) {
|
|
67 echo "篋膣若≪若紊掩\n";
|
|
68 }
|
|
69
|
|
70 // ゃ潟壕申
|
|
71 $sqlstrs = array();
|
|
72 if( index_exists( $settings->tbl_prefix.RESERVE_TBL, "reserve_ch_idx", $dbh ) ) {
|
|
73 echo "reserve_ch_idxс絖篏障\n";
|
|
74 }
|
|
75 else {
|
|
76 array_push( $sqlstrs, "create index reserve_ch_idx on ".$settings->tbl_prefix.RESERVE_TBL." (channel_disc);" );
|
|
77 }
|
|
78 if( index_exists( $settings->tbl_prefix.RESERVE_TBL, "reserve_st_idx", $dbh ) ) {
|
|
79 echo "reserve_st_idxс絖篏障\n";
|
|
80 }
|
|
81 else {
|
|
82 array_push( $sqlstrs, "create index reserve_st_idx on ".$settings->tbl_prefix.RESERVE_TBL." (starttime);" );
|
|
83 }
|
|
84 if( multi_query( $sqlstrs, $dbh ) ) {
|
|
85 echo "篋膣若ゃ潟鴻篏с障\n";
|
|
86 }
|
|
87
|
|
88 // PROGRAM_TBL
|
|
89
|
|
90 $sqlstrs = array (
|
|
91 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify channel_disc varchar(128) not null default 'none';", // channel disc
|
|
92 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify channel_id integer not null default '0';", // channel ID
|
|
93 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify type varchar(8) not null default 'GR';", // 腮ワGR/BS/CS鐚
|
|
94 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify channel varchar(10) not null default '0';", // c潟
|
|
95 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify title varchar(512) not null default 'none';", // 帥ゃ
|
|
96 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify description varchar(512) not null default 'none';", // 茯 text->varchar
|
|
97 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify category_id integer not null default '0';", // 眼ID
|
|
98 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify starttime datetime not null default '1970-01-01 00:00:00';", // 紮
|
|
99 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify endtime datetime not null default '1970-01-01 00:00:00';", // 腟篋
|
|
100 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify program_disc varchar(128) not null default 'none';", // 茘ョhash
|
|
101 "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify autorec boolean not null default '1';", // 牙紙合≦
|
|
102 );
|
|
103
|
|
104 if( multi_query( $sqlstrs, $dbh ) ) {
|
|
105 echo "腟若≪若紊掩\n";
|
|
106 }
|
|
107
|
|
108 // ゃ潟壕申
|
|
109 $sqlstrs = array();
|
|
110 if( index_exists( $settings->tbl_prefix.PROGRAM_TBL , "program_ch_idx", $dbh ) ) {
|
|
111 echo "program_ch_idxс絖篏障\n";
|
|
112 }
|
|
113 else {
|
|
114 array_push( $sqlstrs, "create index program_ch_idx on ".$settings->tbl_prefix.PROGRAM_TBL." (channel_disc);" );
|
|
115 }
|
|
116 if( index_exists( $settings->tbl_prefix.PROGRAM_TBL , "program_st_idx", $dbh ) ) {
|
|
117 echo "program_st_idxс絖篏障\n";
|
|
118 }
|
|
119 else {
|
|
120 array_push( $sqlstrs, "create index program_st_idx on ".$settings->tbl_prefix.PROGRAM_TBL." (starttime);" );
|
|
121 }
|
|
122 if( multi_query( $sqlstrs, $dbh ) ) {
|
|
123 echo "腟若ゃ潟鴻篏с障\n";
|
|
124 }
|
|
125
|
|
126 // CHANNEL_TBL
|
|
127
|
|
128 $sqlstrs = array(
|
|
129 "alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify type varchar(8) not null default 'GR';", // 腮
|
|
130 "alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify channel varchar(10) not null default '0';", // channel
|
|
131 "alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify name varchar(512) not null default 'none';", // 茵腓阪
|
|
132 "alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify channel_disc varchar(128) not null default 'none';", // 茘ョhash
|
|
133 );
|
|
134 if( column_exists( $settings->tbl_prefix.CHANNEL_TBL, "sid", $dbh ) ) {
|
|
135 echo "sidc若絖т障\n";
|
|
136 }
|
|
137 else {
|
|
138 array_push( $sqlstrs , "alter table ".$settings->tbl_prefix.CHANNEL_TBL." add sid varchar(64) not null default 'hd'" );
|
|
139 }
|
|
140 if( column_exists( $settings->tbl_prefix.CHANNEL_TBL, "skip", $dbh ) ) {
|
|
141 echo "skipc若絖т障\n";
|
|
142 }
|
|
143 else {
|
|
144 array_push( $sqlstrs , "alter table ".$settings->tbl_prefix.CHANNEL_TBL." add skip boolean not null default '0'" );
|
|
145 }
|
|
146 if( multi_query( $sqlstrs, $dbh ) ) {
|
|
147 echo "c潟若≪若紊掩\n";
|
|
148 }
|
|
149
|
|
150 // CATEGORY_TBL
|
|
151
|
|
152 $sqlstrs = array(
|
|
153 "alter table ".$settings->tbl_prefix.CATEGORY_TBL." modify name_jp varchar(512) not null default 'none';", // 茵腓阪
|
|
154 "alter table ".$settings->tbl_prefix.CATEGORY_TBL." modify name_en varchar(512) not null default 'none';", // 筝
|
|
155 "alter table ".$settings->tbl_prefix.CATEGORY_TBL." modify category_disc varchar(128) not null default 'none'", // 茘ョhash
|
|
156 );
|
|
157 if( multi_query( $sqlstrs, $dbh ) ) {
|
|
158 echo "眼若≪若紊掩\n";
|
|
159 }
|
|
160
|
|
161 // KEYWORD_TBL
|
|
162
|
|
163 $sqlstrs = array(
|
|
164 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify keyword varchar(512) not null default '*';", // 茵腓阪
|
|
165 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify type varchar(8) not null default '*';", // 腮
|
|
166 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify channel_id integer not null default '0';", // channel ID
|
|
167 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify category_id integer not null default '0';", // 眼ID
|
|
168 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify use_regexp boolean not null default '0';", // 罩h頫憗篏睡1
|
|
169 );
|
|
170 if( column_exists( $settings->tbl_prefix.KEYWORD_TBL, "autorec_mode", $dbh ) ) {
|
|
171 echo "autorec_mode絖т障\n";
|
|
172 }
|
|
173 else {
|
|
174 array_push( $sqlstrs, "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add autorec_mode integer not null default '0';");
|
|
175 }
|
|
176 if( column_exists( $settings->tbl_prefix.KEYWORD_TBL, "weekofday", $dbh ) ) {
|
|
177 echo "weekofday絖т障\n";
|
|
178 }
|
|
179 else {
|
|
180 array_push( $sqlstrs, "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add weekofday enum ('0','1','2','3','4','5','6','7' ) default '7'" );
|
|
181 }
|
|
182 if( column_exists( $settings->tbl_prefix.KEYWORD_TBL, "prgtime", $dbh ) ) {
|
|
183 echo "prgtime絖т障\n";
|
|
184 }
|
|
185 else {
|
|
186 array_push( $sqlstrs,
|
|
187 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add prgtime enum ('0','1','2','3','4','5','6','7','8','9','10','11','12',".
|
|
188 "'13','14','15','16','17','18','19','20','21','22','23','24') default '24'" );
|
|
189 }
|
|
190
|
|
191 if( multi_query( $sqlstrs, $dbh ) ) {
|
|
192 echo "若若若≪若紊掩\n";
|
|
193 }
|
|
194 }
|
|
195 else
|
|
196 exit( "DB・膓紊掩\n" );
|
|
197 ?> |