Mercurial > epgrec.yaz
annotate index.php @ 120:cb04c9ca1cb0
add: チャンネルスキップの追加途中(改造中)
author | yoneda <epgrec@park.mda.or.jp> |
---|---|
date | Sun, 14 Mar 2010 23:49:11 +0900 |
parents | cb7da56c4198 |
children | ea54c3128da3 |
rev | line source |
---|---|
50 | 1 <?php |
2 | |
3 include_once("config.php"); | |
4 include_once( INSTALL_PATH . "/DBRecord.class.php" ); | |
5 include_once( INSTALL_PATH . "/Smarty/Smarty.class.php" ); | |
6 include_once( INSTALL_PATH . "/reclib.php" ); | |
7 include_once( INSTALL_PATH . "/Settings.class.php" ); | |
8 | |
9 // 荐絎<ゃ<罎祉 | |
10 if( ! file_exists( INSTALL_PATH."/settings/config.xml") ) { | |
11 header( "Content-Type: text/html;charset=utf-8" ); | |
12 exit( "<script type=\"text/javascript\">\n" . | |
13 "<!--\n". | |
14 "window.open(\"install/step1.php\",\"_self\");". | |
15 "// -->\n</script>" ); | |
16 } | |
17 | |
18 $settings = Settings::factory(); | |
19 | |
20 $DAY_OF_WEEK = array( "()","()","()","(羂)","()","()","()" ); | |
21 | |
22 // <若帥 | |
23 // 茵腓冴激鐚鐚 | |
24 $program_length = $settings->program_length; | |
25 if( isset( $_GET['length']) ) $program_length = (int) $_GET['length']; | |
26 // 遺=GR/BS=BS | |
27 $type = "GR"; | |
28 if( isset( $_GET['type'] ) ) $type = $_GET['type']; | |
29 // 憜 | |
30 $top_time = mktime( date("H"), 0 , 0 ); | |
31 if( isset( $_GET['time'] ) ) { | |
32 if( sscanf( $_GET['time'] , "%04d%2d%2d%2d", $y, $mon, $day, $h ) == 4 ) { | |
33 $tmp_time = mktime( $h, 0, 0, $mon, $day, $y ); | |
34 if( ($tmp_time < ($top_time + 3600 * 24 * 8)) && ($tmp_time > ($top_time - 3600 * 24 * 8)) ) | |
35 $top_time = $tmp_time; | |
36 } | |
37 } | |
38 $last_time = $top_time + 3600 * $program_length; | |
39 | |
120 | 40 // 紙 |
41 for( $i = 0 ; $i < $program_length; $i++ ) { | |
50 | 42 $tvtimes[$i] = date("H", $top_time + 3600 * $i ); |
120 | 43 } |
44 | |
45 | |
46 // 腟茵 | |
47 $programs = array(); | |
48 if( $type == "BS" ) $channel_map = $BS_CHANNEL_MAP; | |
49 else if( $type == "GR" ) $channel_map = $GR_CHANNEL_MAP; | |
50 else if( $type == "CS" ) $channel_map = $CS_CHANNEL_MAP; | |
51 $st = 0; | |
52 $prec = null; | |
53 try { | |
54 $prec = new DBRecord(PROGRAM_TBL); | |
55 } | |
56 catch( Exception $e ) { | |
76
69e0dabc765a
fixed: Reservation.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
67
diff
changeset
|
57 exit('違若絖сゃ潟鴻若眼.'); |
120 | 58 } |
59 $num_ch = 0; | |
60 foreach( $channel_map as $channel_disc => $channel ) { | |
50 | 61 $prev_end = $top_time; |
62 try { | |
63 $crec = new DBRecord( CHANNEL_TBL, "channel_disc", $channel_disc ); | |
120 | 64 $programs[$st]["skip"] = $crec->skip; |
65 if( $crec->skip == 0 ) $num_ch++; | |
66 | |
50 | 67 $programs[$st]["station_name"] = $crec->name; |
77 | 68 $programs[$st]["channel_disc"] = $crec->channel_disc; |
50 | 69 |
70 $reca = $prec->fetch_array( "channel_disc", $channel_disc, | |
71 "endtime > '".toDatetime($top_time)."' ". | |
72 "AND starttime < '". toDatetime($last_time)."' ". | |
73 "ORDER BY starttime ASC " | |
74 ); | |
75 $programs[$st]['list'] = array(); | |
76 $num = 0; | |
77 foreach( $reca as $prg ) { | |
78 // 違腥冴茯帥鴻 | |
79 $start = toTimestamp( $prg['starttime'] ); | |
51 | 80 if( ($start - $prev_end) > 0 ) { |
50 | 81 $height = ($start-$prev_end) * $settings->height_per_hour / 3600; |
82 $height = $height; | |
83 $programs[$st]['list'][$num]['category_none'] = "none"; | |
84 $programs[$st]['list'][$num]['height'] = $height; | |
85 $programs[$st]['list'][$num]['title'] = ""; | |
86 $programs[$st]['list'][$num]['starttime'] = ""; | |
87 $programs[$st]['list'][$num]['description'] = ""; | |
88 $num++; | |
89 } | |
90 $prev_end = toTimestamp( $prg['endtime'] ); | |
91 | |
92 $height = ((toTimestamp($prg['endtime']) - toTimestamp($prg['starttime'])) * $settings->height_per_hour / 3600); | |
93 // $top_time 鎈障c腟 | |
94 if( toTimestamp($prg['starttime']) <$top_time ) { | |
95 $height = ((toTimestamp($prg['endtime']) - $top_time ) * $settings->height_per_hour / 3600); | |
96 } | |
97 // $last_time 靚腟 | |
98 if( toTimestamp($prg['endtime']) > $last_time ) { | |
99 $height = (($last_time - toTimestamp($prg['starttime'])) * $settings->height_per_hour / 3600); | |
100 } | |
101 | |
102 // 違 | |
103 $cat = new DBRecord( CATEGORY_TBL, "id", $prg['category_id'] ); | |
104 $programs[$st]['list'][$num]['category_name'] = $cat->name_en; | |
105 $programs[$st]['list'][$num]['height'] = $height; | |
106 $programs[$st]['list'][$num]['title'] = $prg['title']; | |
107 $programs[$st]['list'][$num]['starttime'] = date("H:i", $start )."" ; | |
108 $programs[$st]['list'][$num]['description'] = $prg['description']; | |
109 $programs[$st]['list'][$num]['prg_start'] = str_replace( "-", "/", $prg['starttime']); | |
110 $programs[$st]['list'][$num]['duration'] = "" . (toTimestamp($prg['endtime']) - toTimestamp($prg['starttime'])); | |
111 $programs[$st]['list'][$num]['channel'] = ($prg['type'] == "GR" ? "遺D" : "BS" ) . ":". $prg['channel'] . "ch"; | |
112 $programs[$st]['list'][$num]['id'] = "" . ($prg['id']); | |
113 $programs[$st]['list'][$num]['rec'] = DBRecord::countRecords(RESERVE_TBL, "WHERE complete = '0' AND program_id = '".$prg['id']."'" ); | |
114 $num++; | |
115 } | |
116 } | |
117 catch( exception $e ) { | |
76
69e0dabc765a
fixed: Reservation.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
67
diff
changeset
|
118 // exit( $e->getMessage() ); |
69e0dabc765a
fixed: Reservation.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
67
diff
changeset
|
119 // 篏 |
50 | 120 } |
121 // 腥冴 | |
51 | 122 if( ($last_time - $prev_end) > 0 ) { |
50 | 123 $height = ($last_time - $prev_end) * $settings->height_per_hour / 3600; |
124 $height = $height; | |
125 $programs[$st]['list'][$num]['category_name'] = "none"; | |
126 $programs[$st]['list'][$num]['height'] = $height; | |
127 $programs[$st]['list'][$num]['title'] = ""; | |
128 $programs[$st]['list'][$num]['starttime'] = ""; | |
129 $programs[$st]['list'][$num]['description'] = ""; | |
130 $num++; | |
131 } | |
132 $st++; | |
120 | 133 } |
134 $prec = null; | |
50 | 135 |
120 | 136 // 絮綛 |
137 $ch_set_width = (int)($settings->ch_set_width); | |
138 // 篏綛 | |
139 $chs_width = $ch_set_width * $num_ch; | |
140 | |
141 // GET< | |
142 $get_param = $_SERVER['SCRIPT_NAME'] . "?type=".$type."&length=".$program_length.""; | |
143 | |
144 $smarty = new Smarty(); | |
145 | |
146 // 眼筝荀 | |
147 $crec = DBRecord::createRecords( CATEGORY_TBL ); | |
148 $cats = array(); | |
149 $num = 0; | |
150 foreach( $crec as $val ) { | |
50 | 151 $cats[$num]['name_en'] = $val->name_en; |
152 $cats[$num]['name_jp'] = $val->name_jp; | |
153 $num++; | |
120 | 154 } |
155 $smarty->assign( "cats", $cats ); | |
50 | 156 |
157 | |
120 | 158 // 帥ゃ御 |
159 $types = array(); | |
160 $i = 0; | |
161 if( $settings->bs_tuners != 0 ) { | |
50 | 162 $types[$i]['selected'] = $type == "BS" ? 'class="selected"' : ""; |
163 $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=BS&length=".$program_length."&time=".date( "YmdH", $top_time); | |
164 $types[$i]['name'] = "BS"; | |
165 $i++; | |
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
58
diff
changeset
|
166 |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
58
diff
changeset
|
167 // CS |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
58
diff
changeset
|
168 if ($settings->cs_rec_flg != 0) { |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
58
diff
changeset
|
169 $types[$i]['selected'] = $type == "CS" ? 'class="selected"' : ""; |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
58
diff
changeset
|
170 $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=CS&length=".$program_length."&time=".date( "YmdH", $top_time); |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
58
diff
changeset
|
171 $types[$i]['name'] = "CS"; |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
58
diff
changeset
|
172 $i++; |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
58
diff
changeset
|
173 } |
120 | 174 } |
175 if( $settings->gr_tuners != 0 ) { | |
50 | 176 $types[$i]['selected'] = $type == "GR" ? 'class="selected"' : ""; |
177 $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=GR&length=".$program_length."&time=".date( "YmdH", $top_time); | |
178 $types[$i]['name'] = "遺吾帥"; | |
179 $i++; | |
120 | 180 } |
181 $smarty->assign( "types", $types ); | |
182 | |
183 // ヤ御 | |
184 $days = array(); | |
185 $day = array(); | |
186 $day['d'] = ""; | |
187 $day['link'] = $get_param . "&time=". date( "YmdH", time() - 3600 *24 ); | |
188 $day['ofweek'] = ""; | |
189 $day['selected'] = $top_time < mktime( 0, 0 , 0) ? 'class="selected"' : ''; | |
190 | |
191 array_push( $days , $day ); | |
192 $day['d'] = "憜"; | |
193 $day['link'] = $get_param; | |
194 $day['ofweek'] = ""; | |
195 $day['selected'] = ""; | |
196 array_push( $days, $day ); | |
197 for( $i = 0 ; $i < 8 ; $i++ ) { | |
50 | 198 $day['d'] = "".date("d", time() + 24 * 3600 * $i ) . ""; |
199 $day['link'] = $get_param . "&time=".date( "Ymd", time() + 24 * 3600 * $i) . date("H" , $top_time ); | |
200 $day['ofweek'] = $DAY_OF_WEEK[(int)date( "w", time() + 24 * 3600 * $i )]; | |
201 $day['selected'] = date("d", $top_time) == date("d", time() + 24 * 3600 * $i ) ? 'class="selected"' : ''; | |
202 array_push( $days, $day ); | |
120 | 203 } |
204 $smarty->assign( "days" , $days ); | |
205 | |
206 // 御 | |
207 $toptimes = array(); | |
208 for( $i = 0 ; $i < 24; $i+=4 ) { | |
50 | 209 $tmp = array(); |
210 $tmp['hour'] = sprintf( "%02d:00", $i ); | |
211 $tmp['link'] = $get_param . "&time=".date("Ymd", $top_time ) . sprintf("%02d", $i ); | |
212 array_push( $toptimes, $tmp ); | |
120 | 213 } |
214 $smarty->assign( "toptimes" , $toptimes ); | |
215 | |
216 $smarty->assign( "tvtimes", $tvtimes ); | |
217 $smarty->assign( "programs", $programs ); | |
218 $smarty->assign( "ch_set_width", (int)($settings->ch_set_width) ); | |
219 $smarty->assign( "chs_width", $chs_width ); | |
220 $smarty->assign( "height_per_hour", $settings->height_per_hour ); | |
221 $smarty->assign( "height_per_min", $settings->height_per_hour / 60 ); | |
222 $smarty->assign( "num_ch", $num_ch ); | |
223 $smarty->assign( "num_all_ch" , count( $channel_map ) ); | |
50 | 224 |
225 // date("Y-m-d H:i:s", $timestamp); | |
120 | 226 |
227 $sitetitle = date( "Y", $top_time ) . "綛" . date( "m", $top_time ) . "" . date( "d", $top_time ) . "". date( "H", $top_time ) . | |
50 | 228 "鐔".( $type == "GR" ? "遺吾帥" : "BS吾帥" )."腟茵"; |
120 | 229 |
230 $smarty->assign("sitetitle", $sitetitle ); | |
231 | |
232 $smarty->assign("top_time", str_replace( "-", "/" ,toDatetime($top_time)) ); | |
233 $smarty->assign("last_time", str_replace( "-", "/" ,toDatetime($last_time)) ); | |
234 | |
235 | |
236 $smarty->display("index.html"); | |
76
69e0dabc765a
fixed: Reservation.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
67
diff
changeset
|
237 ?> |