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
|
|
40 // 時刻欄
|
|
41 for( $i = 0 ; $i < $program_length; $i++ ) {
|
|
42 $tvtimes[$i] = date("H", $top_time + 3600 * $i );
|
|
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 $st = 0;
|
|
51 $prec = new DBRecord(PROGRAM_TBL);
|
|
52 foreach( $channel_map as $channel_disc => $channel ) {
|
|
53 $prev_end = $top_time;
|
|
54 try {
|
|
55 $crec = new DBRecord( CHANNEL_TBL, "channel_disc", $channel_disc );
|
|
56 $programs[$st]["station_name"] = $crec->name;
|
|
57
|
|
58 $reca = $prec->fetch_array( "channel_disc", $channel_disc,
|
|
59 "endtime > '".toDatetime($top_time)."' ".
|
|
60 "AND starttime < '". toDatetime($last_time)."' ".
|
|
61 "ORDER BY starttime ASC "
|
|
62 );
|
|
63 $programs[$st]['list'] = array();
|
|
64 $num = 0;
|
|
65 foreach( $reca as $prg ) {
|
|
66 // 前プログラムとの空きを調べる
|
|
67 $start = toTimestamp( $prg['starttime'] );
|
51
|
68 if( ($start - $prev_end) > 0 ) {
|
50
|
69 $height = ($start-$prev_end) * $settings->height_per_hour / 3600;
|
|
70 $height = $height;
|
|
71 $programs[$st]['list'][$num]['category_none'] = "none";
|
|
72 $programs[$st]['list'][$num]['height'] = $height;
|
|
73 $programs[$st]['list'][$num]['title'] = "";
|
|
74 $programs[$st]['list'][$num]['starttime'] = "";
|
|
75 $programs[$st]['list'][$num]['description'] = "";
|
|
76 $num++;
|
|
77 }
|
|
78 $prev_end = toTimestamp( $prg['endtime'] );
|
|
79
|
|
80 $height = ((toTimestamp($prg['endtime']) - toTimestamp($prg['starttime'])) * $settings->height_per_hour / 3600);
|
|
81 // $top_time より早く始まっている番組
|
|
82 if( toTimestamp($prg['starttime']) <$top_time ) {
|
|
83 $height = ((toTimestamp($prg['endtime']) - $top_time ) * $settings->height_per_hour / 3600);
|
|
84 }
|
|
85 // $last_time より遅く終わる番組
|
|
86 if( toTimestamp($prg['endtime']) > $last_time ) {
|
|
87 $height = (($last_time - toTimestamp($prg['starttime'])) * $settings->height_per_hour / 3600);
|
|
88 }
|
|
89
|
|
90 // プログラムを埋める
|
|
91 $cat = new DBRecord( CATEGORY_TBL, "id", $prg['category_id'] );
|
|
92 $programs[$st]['list'][$num]['category_name'] = $cat->name_en;
|
|
93 $programs[$st]['list'][$num]['height'] = $height;
|
|
94 $programs[$st]['list'][$num]['title'] = $prg['title'];
|
|
95 $programs[$st]['list'][$num]['starttime'] = date("H:i", $start )."" ;
|
|
96 $programs[$st]['list'][$num]['description'] = $prg['description'];
|
|
97 $programs[$st]['list'][$num]['prg_start'] = str_replace( "-", "/", $prg['starttime']);
|
|
98 $programs[$st]['list'][$num]['duration'] = "" . (toTimestamp($prg['endtime']) - toTimestamp($prg['starttime']));
|
|
99 $programs[$st]['list'][$num]['channel'] = ($prg['type'] == "GR" ? "地上D" : "BS" ) . ":". $prg['channel'] . "ch";
|
|
100 $programs[$st]['list'][$num]['id'] = "" . ($prg['id']);
|
|
101 $programs[$st]['list'][$num]['rec'] = DBRecord::countRecords(RESERVE_TBL, "WHERE complete = '0' AND program_id = '".$prg['id']."'" );
|
|
102 $num++;
|
|
103 }
|
|
104 }
|
|
105 catch( exception $e ) {
|
|
106 exit( $e->getMessage() );
|
|
107 }
|
|
108 // 空きを埋める
|
51
|
109 if( ($last_time - $prev_end) > 0 ) {
|
50
|
110 $height = ($last_time - $prev_end) * $settings->height_per_hour / 3600;
|
|
111 $height = $height;
|
|
112 $programs[$st]['list'][$num]['category_name'] = "none";
|
|
113 $programs[$st]['list'][$num]['height'] = $height;
|
|
114 $programs[$st]['list'][$num]['title'] = "";
|
|
115 $programs[$st]['list'][$num]['starttime'] = "";
|
|
116 $programs[$st]['list'][$num]['description'] = "";
|
|
117 $num++;
|
|
118 }
|
|
119 $st++;
|
|
120 }
|
|
121 $prec = null;
|
|
122
|
|
123 // 局の幅
|
|
124 $ch_set_width = $settings->ch_set_width;
|
|
125 // 全体の幅
|
|
126 $chs_width = $ch_set_width * count( $channel_map );
|
|
127
|
|
128 // GETパラメタ
|
|
129 $get_param = $_SERVER['SCRIPT_NAME'] . "?type=".$type."&length=".$program_length."";
|
|
130
|
|
131 $smarty = new Smarty();
|
|
132
|
|
133 // カテゴリ一覧
|
|
134 $crec = DBRecord::createRecords( CATEGORY_TBL );
|
|
135 $cats = array();
|
|
136 $num = 0;
|
|
137 foreach( $crec as $val ) {
|
|
138 $cats[$num]['name_en'] = $val->name_en;
|
|
139 $cats[$num]['name_jp'] = $val->name_jp;
|
|
140 $num++;
|
|
141 }
|
|
142 $smarty->assign( "cats", $cats );
|
|
143
|
|
144
|
|
145
|
|
146 // タイプ選択
|
|
147 $types = array();
|
|
148 $i = 0;
|
57
|
149 if( $settings->bs_tuners != 0 ) {
|
50
|
150 $types[$i]['selected'] = $type == "BS" ? 'class="selected"' : "";
|
|
151 $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=BS&length=".$program_length."&time=".date( "YmdH", $top_time);
|
|
152 $types[$i]['name'] = "BS";
|
|
153 $i++;
|
|
154 }
|
57
|
155 if( $settings->gr_tuners != 0 ) {
|
50
|
156 $types[$i]['selected'] = $type == "GR" ? 'class="selected"' : "";
|
|
157 $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=GR&length=".$program_length."&time=".date( "YmdH", $top_time);
|
|
158 $types[$i]['name'] = "地上デジタル";
|
|
159 $i++;
|
|
160 }
|
|
161 $smarty->assign( "types", $types );
|
|
162
|
|
163 // 日付選択
|
|
164 $days = array();
|
|
165 $day = array();
|
|
166 $day['d'] = "昨日";
|
|
167 $day['link'] = $get_param . "&time=". date( "YmdH", time() - 3600 *24 );
|
|
168 $day['ofweek'] = "";
|
|
169 $day['selected'] = $top_time < mktime( 0, 0 , 0) ? 'class="selected"' : '';
|
|
170
|
|
171 array_push( $days , $day );
|
|
172 $day['d'] = "現在";
|
|
173 $day['link'] = $get_param;
|
|
174 $day['ofweek'] = "";
|
|
175 $day['selected'] = "";
|
|
176 array_push( $days, $day );
|
|
177 for( $i = 0 ; $i < 8 ; $i++ ) {
|
|
178 $day['d'] = "".date("d", time() + 24 * 3600 * $i ) . "日";
|
|
179 $day['link'] = $get_param . "&time=".date( "Ymd", time() + 24 * 3600 * $i) . date("H" , $top_time );
|
|
180 $day['ofweek'] = $DAY_OF_WEEK[(int)date( "w", time() + 24 * 3600 * $i )];
|
|
181 $day['selected'] = date("d", $top_time) == date("d", time() + 24 * 3600 * $i ) ? 'class="selected"' : '';
|
|
182 array_push( $days, $day );
|
|
183 }
|
|
184 $smarty->assign( "days" , $days );
|
|
185
|
|
186 // 時間選択
|
|
187 $toptimes = array();
|
|
188 for( $i = 0 ; $i < 24; $i+=4 ) {
|
|
189 $tmp = array();
|
|
190 $tmp['hour'] = sprintf( "%02d:00", $i );
|
|
191 $tmp['link'] = $get_param . "&time=".date("Ymd", $top_time ) . sprintf("%02d", $i );
|
|
192 array_push( $toptimes, $tmp );
|
|
193 }
|
|
194 $smarty->assign( "toptimes" , $toptimes );
|
|
195
|
|
196 $smarty->assign( "tvtimes", $tvtimes );
|
|
197 $smarty->assign( "programs", $programs );
|
|
198 $smarty->assign( "ch_set_width", $settings->ch_set_width );
|
|
199 $smarty->assign( "chs_width", $chs_width );
|
|
200 $smarty->assign( "height_per_hour", $settings->height_per_hour );
|
|
201
|
|
202 // date("Y-m-d H:i:s", $timestamp);
|
|
203
|
|
204 $sitetitle = date( "Y", $top_time ) . "年" . date( "m", $top_time ) . "月" . date( "d", $top_time ) . "日". date( "H", $top_time ) .
|
|
205 "時~".( $type == "GR" ? "地上デジタル" : "BSデジタル" )."番組表";
|
|
206
|
|
207 $smarty->assign("sitetitle", $sitetitle );
|
|
208
|
|
209 $smarty->assign("top_time", str_replace( "-", "/" ,toDatetime($top_time)) );
|
|
210 $smarty->assign("last_time", str_replace( "-", "/" ,toDatetime($last_time)) );
|
|
211
|
|
212
|
|
213 $smarty->display("index.html");
|
|
214 ?>
|