root/trunk/install/php/viewepg.php

リビジョン 39, 9.7 kB (コミッタ: sorshi, コミット時期: 18 年 前)

EPG番組表のセル内どこをクリックしても予約出来るように改良。

Line 
1 <?php
2 /*
3  Anime recording system foltia
4  http://www.dcc-jpl.com/soft/foltia/
5
6 viewepg.php
7
8 目的
9 番組録画予約ページを表示します。
10
11 オプション
12 start:表示タイムスタンプ(Ex.200512281558)
13  省略時、現在時刻。
14
15  DCC-JPL Japan/foltia project
16
17 */
18 ?>
19 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
20 <html lang="ja">
21 <head>
22 <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
23 <meta http-equiv="Content-Style-Type" content="text/css">
24 <link rel="stylesheet" type="text/css" href="graytable.css">
25 <title>foltia:EPG</title>
26 </head>
27 <?php
28 include("./foltialib.php");
29  
30 $con = m_connect();
31 $start = getgetnumform(start);
32
33 if ($start == ""){
34     $start date("YmdHi");
35 }else{
36   $start = ereg_replace( "[^0-9]", "", $start);
37 }
38 ?>
39 <body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" >
40 <div align="center">
41 <?php
42 printhtmlpageheader();
43 ?>
44   <p align="left"><font color="#494949" size="6">EPG番組表</font></p>
45   <hr size="4">
46 <p align="left">EPG番組表を表示します。
47 <?php
48
49 $startyear =   substr($start,0,4);
50 $startmonth =   substr($start,4,2);
51 $startday =   substr($start,6,2);
52 $starthour =   substr($start,8,2);
53 $startmin =   substr($start,10,2);
54 print "($startyear/$startmonth/$startday $starthour:$startmin-)<BR>\n";
55
56 $yesterday = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday -1 , $startyear));
57 $today0400 = date ("YmdHi",mktime(4 , 0 , 0, $startmonth , $startday  , $startyear));
58 $today1200 = date ("YmdHi",mktime(12 , 0 , 0, $startmonth , $startday , $startyear));
59 $today2000 = date ("YmdHi",mktime(20 , 0 , 0, $startmonth , $startday , $startyear));
60 $day1after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear));
61 $day1 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear));
62 $day2after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +2 , $startyear));
63 $day2 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +2 , $startyear));
64 $day3after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +3 , $startyear));
65 $day3 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +3 , $startyear));
66 $day4after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +4 , $startyear));
67 $day4 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +4 , $startyear));
68 $day5after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +5 , $startyear));
69 $day5 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +5 , $startyear));
70 $day6after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +6 , $startyear));
71 $day6 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +6 , $startyear));
72 $day7after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +7 , $startyear));
73 $day7 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +7 , $startyear));
74
75
76
77 //表示局選定
78 // $page = 1 ~
79 $maxdisplay = 8;
80
81     $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%'
82     ";
83     $rs = m_query($con, $query, "DBクエリに失敗しました");
84     $maxrows = pg_num_rows($rs);
85
86 if ($maxrows > $maxdisplay){
87     $pages = ceil($maxrows / $maxdisplay) ;
88 }
89
90 $page = getgetnumform(p);
91
92 if (($page == "")|| ($page <= 0) ){
93     $page = 1 ;
94     $offset = ;
95 }else{
96   $page = ereg_replace( "[^0-9]", "", $page);
97   if ($page > $pages){
98       $page = $pages ;
99   }elseif ($page <= 0) {
100   $page = 1 ;
101   }
102   $offset = ($page * $maxdisplay ) - $maxdisplay;
103 }
104
105
106 print "←<A HREF=\"./viewepg.php?p=$page&start=$yesterday\">前の日</A> <A HREF=\"./viewepg.php\">現在</A> 当日(<A HREF=\"./viewepg.php?p=$page&start=$today0400\">4:00</A> <A HREF=\"./viewepg.php?p=$page&start=$today1200\">12:00</A> <A HREF=\"./viewepg.php?p=$page&start=$today2000\">20:00</A>) <A HREF=\"./viewepg.php?p=$page&start=$day1after\">次の日</A> <A HREF=\"./viewepg.php?p=$page&start=$day2after\">$day2</A> <A HREF=\"./viewepg.php?p=$page&start=$day3after\">$day3</A> <A HREF=\"./viewepg.php?p=$page&start=$day4after\">$day4</A> <A HREF=\"./viewepg.php?p=$page&start=$day5after\">$day5</A> <A HREF=\"./viewepg.php?p=$page&start=$day6after\">$day6</A> <A HREF=\"./viewepg.php?p=$page&start=$day7after\">$day7</A>→<BR>\n";
107
108
109 if ($maxrows > $maxdisplay){
110 //複数ページ
111 //$pages = ceil($maxrows / $maxdisplay) ;
112 if ($page > 1){
113     $beforepage = $page - 1;
114     print "<a href = \"./viewepg.php?p=$beforepage&start=$start\">←</A>";
115 }
116
117 print " $page / $pages (放送局) ";
118
119 if ($page < $pages){
120     $nextpage = $page + 1;
121     print "<a href = \"./viewepg.php?p=$nextpage&start=$start\">→</A>";
122 }
123 }
124 //ココから新コード
125 //・局リスト
126 $query = "SELECT stationid, stationname, stationrecch, ontvcode
127 FROM foltia_station
128 WHERE \"ontvcode\" ~~ '%ontvjapan%' 
129 ORDER BY stationid ASC , stationrecch
130 OFFSET $offset LIMIT $maxdisplay
131 ";
132 $slistrs = m_query($con, $query, "DBクエリに失敗しました");
133 $stations pg_num_rows($slistrs);
134 for ($i=0 ; $i < $stations ; $i++){
135     $rowdata = pg_fetch_row($slistrs, $i);
136     $stationhash[$i] = $rowdata[3] ;
137 }
138
139 //・時間と全順番のハッシュ作る
140 $epgstart = $start ;
141 $epgend = calcendtime($start , (8*60));
142
143 $query = "SELECT DISTINCT startdatetime   
144 FROM foltia_epg
145 WHERE foltia_epg.ontvchannel in (
146     SELECT ontvcode
147     FROM foltia_station
148     WHERE \"ontvcode\" ~~ '%ontvjapan%' 
149     ORDER BY stationid ASC , stationrecch
150     OFFSET $offset LIMIT $maxdisplay
151     )
152 AND startdatetime  >= $start 
153 AND startdatetime  < $epgend 
154 ORDER BY foltia_epg.startdatetime  ASC    ";
155
156 $rs = m_query($con, $query, "DBクエリに失敗しました");
157 $colmnums pg_num_rows($rs);
158 if ($colmnums == 0){
159 //番組データがない
160 $colmnums = 2;
161 }else{
162     for ($i=0 ; $i < $colmnums ; $i++){
163         $rowdata = pg_fetch_row($rs, $i);
164         $timetablehash["$rowdata[0]"] = $i;
165     }
166 }
167 //・局ごとに縦に配列入れていく
168 for ($j=0 ; $j < $stations ; $j++){
169     $rowdata = pg_fetch_row($slistrs, $j);
170     $stationname = $rowdata[3];
171
172 $epgstart = $start ;
173 $epgend = calcendtime($start , (8*60));
174 $query = "
175 SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory  ,ontvchannel  ,epgid ,    epgcategory
176 FROM foltia_epg
177 WHERE foltia_epg.ontvchannel = '$stationname' AND
178 enddatetime  > $epgstart  AND
179 startdatetime  < $epgend 
180 ORDER BY foltia_epg.startdatetime  ASC
181     ";
182     $statiodh = m_query($con, $query, "DBクエリに失敗しました");
183     $maxrowsstation = pg_num_rows($statiodh);
184 if ($maxrowsstation == 0) {
185         //print("番組データがありません<BR>");
186         $item[0]["$stationname"] =  ">番組データがありません";
187 }else{
188
189 for ($srow = 0; $srow < $maxrowsstation ; $srow++) {
190     
191 $stationrowdata = pg_fetch_row($statiodh, $srow);
192
193 $printstarttime = substr($stationrowdata[0],8,2) . ":" substr($stationrowdata[0],10,2);
194 $tdclass = "t".substr($stationrowdata[0],8,2) .  substr($stationrowdata[0],10,2);
195 $title = $stationrowdata[3];
196 $title = htmlspecialchars(z2h($title));
197 $desc = $stationrowdata[4];
198 $desc = htmlspecialchars(z2h($desc));
199 $height htmlspecialchars($stationrowdata[2]) * 3;
200 $epgid htmlspecialchars($stationrowdata[7]);
201 $epgcategory = htmlspecialchars($stationrowdata[8]);
202
203 if (isset($timetablehash["$stationrowdata[0]"])){
204     $number = $timetablehash["$stationrowdata[0]"];
205 }else{
206     $number = 0;
207 }
208 if ($epgcategory == ""){
209 $item["$number"]["$stationname"] =  " onClick=\"location = './reserveepg.php?epgid=$epgid'\"><span id=\"epgstarttime\">$printstarttime</span> <A HREF=\"./reserveepg.php?epgid=$epgid\"><span id=\"epgtitle\">$title</span></A> <span id=\"epgdesc\">$desc</span>";
210 }else{
211 $item["$number"]["$stationname"] =  " id=\"$epgcategory\" onClick=\"location = './reserveepg.php?epgid=$epgid'\"><span id=\"epgstarttime\">$printstarttime</span> <A HREF=\"./reserveepg.php?epgid=$epgid\"><span id=\"epgtitle\">$title</span></A> <span id=\"epgdesc\">$desc</span></span>";
212 }//if
213
214 }//for
215 }//if
216
217 //・局ごとに間隔決定
218 //$item[$i][NHK] はヌルかどうか判定
219 $dataplace = 0 ; //初期化
220 $rowspan = 0;
221
222 for ($i=1; $i <= $colmnums ; $i++){
223     if ($i === ($colmnums - 1)){//最終行
224         $rowspan = $i - $dataplace + 1;
225         //そして自分自身にタグを
226             if ($item[$i][$stationname] == ""){
227             $item[$i][$stationname]  = "";
228             }else{
229             $item[$i][$stationname]  = "<td ". $item[$i][$stationname] . "</td>";
230             $rowspan--;
231             }
232             //ROWSPAN
233             if ($rowspan === 1 ){
234             $item[$dataplace][$stationname]  = "<td ". $item[$dataplace][$stationname] . "</td>";
235             }else{
236             $item[$dataplace][$stationname]  = "<td  rowspan = $rowspan ". $item[$dataplace][$stationname] . "</td>";
237             }
238
239     }elseif ($item[$i][$stationname] == ""){
240     //ヌルなら
241         $item[$i][$stationname]  =  $item[$i][$stationname] ;
242     }else{
243     //なんか入ってるなら
244         $rowspan = $i - $dataplace;
245             if ($rowspan === 1 ){
246             $item[$dataplace][$stationname]  = "<td ". $item[$dataplace][$stationname] . "</td>";
247             }else{
248             $item[$dataplace][$stationname]  = "<td rowspan = $rowspan ". $item[$dataplace][$stationname] . "</td>";
249             }
250         $dataplace = $i;
251         
252     }
253 }//for
254 }// end of for://・局ごとに縦に配列入れていく
255
256 //・テーブルレンダリング
257 print "<table>\n<tr>";
258
259 //ヘッダ
260 for ($i=0;$i<$stations;$i++){
261     $rowdata = pg_fetch_row($slistrs, $i);
262     print "<th>".htmlspecialchars($rowdata[1])."</th>" ;
263 }
264 //本体
265 for ($l = 0 ;$l $colmnums; $l++){
266     print "<tr>";
267     for ($m = 0 ; $m < $stations ; $m++ ){
268         $stationname = $stationhash[$m];
269         print_r($item[$l]["$stationname"]);
270     }
271     print "</tr>\n";
272 }
273 print "</table>\n";
274  ?>
275
276 <hr>
277 凡例
278 <table>
279 <tr>
280 <td id="information">情報</td>
281 <td id="anime">アニメ・特撮</td>
282 <td id="news">ニュース・報道</td>
283 <td id="drama">ドラマ</td>
284 <td id="variety">バラエティ</td>
285 <td id="documentary">ドキュメンタリー・教養</td>
286 <td id="education">教育</td>
287 <td id="music">音楽</td>
288 <td id="cinema">映画</td>
289 <td id="hobby">趣味・実用</td>
290 <td id="kids">キッズ</td>
291 <td id="sports">スポーツ</td>
292 <td id="etc">その他</td>
293 <td id="stage">演劇</td>
294
295 </tr>
296 </table>
297 </body>
298 </html>
299
300
301
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed