root/trunk/install/php/viewepg.php

リビジョン 46, 10.3 kB (コミッタ: sorshi, コミット時期: 17 年 前)

開始時刻、録画時間、録画局を個別に指定する手動番組予約機能追加。

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 <p align="left"><a href="./m.php">番組手動予約</a ></p>
46 <hr size="4">
47 <p align="left">EPG番組表を表示します。
48 <?php
49
50 $startyear =   substr($start,0,4);
51 $startmonth =   substr($start,4,2);
52 $startday =   substr($start,6,2);
53 $starthour =   substr($start,8,2);
54 $startmin =   substr($start,10,2);
55 print "($startyear/$startmonth/$startday $starthour:$startmin-)<BR>\n";
56
57 $yesterday = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday -1 , $startyear));
58 $today0400 = date ("YmdHi",mktime(4 , 0 , 0, $startmonth , $startday  , $startyear));
59 $today1200 = date ("YmdHi",mktime(12 , 0 , 0, $startmonth , $startday , $startyear));
60 $today2000 = date ("YmdHi",mktime(20 , 0 , 0, $startmonth , $startday , $startyear));
61 $day1after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear));
62 $day1 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear));
63 $day2after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +2 , $startyear));
64 $day2 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +2 , $startyear));
65 $day3after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +3 , $startyear));
66 $day3 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +3 , $startyear));
67 $day4after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +4 , $startyear));
68 $day4 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +4 , $startyear));
69 $day5after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +5 , $startyear));
70 $day5 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +5 , $startyear));
71 $day6after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +6 , $startyear));
72 $day6 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +6 , $startyear));
73 $day7after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +7 , $startyear));
74 $day7 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +7 , $startyear));
75
76
77
78 //表示局選定
79 // $page = 1 ~
80 $maxdisplay = 8;
81
82     $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%'
83     ";
84     $rs = m_query($con, $query, "DBクエリに失敗しました");
85     $maxrows = pg_num_rows($rs);
86
87 if ($maxrows > $maxdisplay){
88     $pages = ceil($maxrows / $maxdisplay) ;
89 }
90
91 $page = getgetnumform(p);
92
93 if (($page == "")|| ($page <= 0) ){
94     $page = 1 ;
95     $offset = ;
96 }else{
97   $page = ereg_replace( "[^0-9]", "", $page);
98   if ($page > $pages){
99       $page = $pages ;
100   }elseif ($page <= 0) {
101   $page = 1 ;
102   }
103   $offset = ($page * $maxdisplay ) - $maxdisplay;
104 }
105
106
107 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";
108
109
110 if ($maxrows > $maxdisplay){
111 //複数ページ
112 //$pages = ceil($maxrows / $maxdisplay) ;
113 if ($page > 1){
114     $beforepage = $page - 1;
115     print "<a href = \"./viewepg.php?p=$beforepage&start=$start\">←</A>";
116 }
117
118 print " $page / $pages (放送局) ";
119
120 if ($page < $pages){
121     $nextpage = $page + 1;
122     print "<a href = \"./viewepg.php?p=$nextpage&start=$start\">→</A>";
123 }
124 }
125 //ココから新コード
126 //・局リスト
127 $query = "SELECT stationid, stationname, stationrecch, ontvcode
128 FROM foltia_station
129 WHERE \"ontvcode\" ~~ '%ontvjapan%' 
130 ORDER BY stationid ASC , stationrecch
131 OFFSET $offset LIMIT $maxdisplay
132 ";
133 $slistrs = m_query($con, $query, "DBクエリに失敗しました");
134 $stations pg_num_rows($slistrs);
135 for ($i=0 ; $i < $stations ; $i++){
136     $rowdata = pg_fetch_row($slistrs, $i);
137     $stationhash[$i] = $rowdata[3] ;
138 }
139
140 //・時間と全順番のハッシュ作る
141 $epgstart = $start ;
142 $epgend = calcendtime($start , (8*60));
143
144 $query = "SELECT DISTINCT startdatetime   
145 FROM foltia_epg
146 WHERE foltia_epg.ontvchannel in (
147     SELECT ontvcode
148     FROM foltia_station
149     WHERE \"ontvcode\" ~~ '%ontvjapan%' 
150     ORDER BY stationid ASC , stationrecch
151     OFFSET $offset LIMIT $maxdisplay
152     )
153 AND startdatetime  >= $start 
154 AND startdatetime  < $epgend 
155 ORDER BY foltia_epg.startdatetime  ASC    ";
156
157 $rs = m_query($con, $query, "DBクエリに失敗しました");
158
159 //print "$query<br>\n";
160
161 $colmnums pg_num_rows($rs);
162 if ($colmnums == 0){
163 //番組データがない
164 $colmnums = 2;
165 }else{
166     for ($i=0 ; $i < $colmnums ; $i++){
167         $rowdata = pg_fetch_row($rs, $i);
168         $timetablehash["$rowdata[0]"] = ($i + 1);
169 //        print "$rowdata[0]:$i+1 <br>\n";
170     }
171 }
172 //print "colmnums $colmnums <br>\n";
173
174 //・局ごとに縦に配列入れていく
175 for ($j=0 ; $j < $stations ; $j++){
176     $rowdata = pg_fetch_row($slistrs, $j);
177     $stationname = $rowdata[3];
178
179 $epgstart = $start ;
180 $epgend = calcendtime($start , (8*60));
181 $query = "
182 SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory  ,ontvchannel  ,epgid ,    epgcategory
183 FROM foltia_epg
184 WHERE foltia_epg.ontvchannel = '$stationname' AND
185 enddatetime  > $epgstart  AND
186 startdatetime  < $epgend 
187 ORDER BY foltia_epg.startdatetime  ASC
188     ";
189     $statiodh = m_query($con, $query, "DBクエリに失敗しました");
190     $maxrowsstation = pg_num_rows($statiodh);
191
192 //print "maxrowsstation $maxrowsstation  stationname $stationname<br>\n";
193
194 if ($maxrowsstation == 0) {
195         //print("番組データがありません<BR>");
196         $item[0]["$stationname"] =  ">番組データがありません";
197 }else{
198
199 for ($srow = 0; $srow < $maxrowsstation ; $srow++) {
200     
201 $stationrowdata = pg_fetch_row($statiodh, $srow);
202
203 $printstarttime = substr($stationrowdata[0],8,2) . ":" substr($stationrowdata[0],10,2);
204 $tdclass = "t".substr($stationrowdata[0],8,2) .  substr($stationrowdata[0],10,2);
205 $title = $stationrowdata[3];
206 $title = htmlspecialchars(z2h($title));
207 $desc = $stationrowdata[4];
208 $desc = htmlspecialchars(z2h($desc));
209 $height htmlspecialchars($stationrowdata[2]) * 3;
210 $epgid htmlspecialchars($stationrowdata[7]);
211 $epgcategory = htmlspecialchars($stationrowdata[8]);
212
213 if (isset($timetablehash["$stationrowdata[0]"])){
214     $number = $timetablehash["$stationrowdata[0]"];
215 //print "$stationname $stationrowdata[0] [$number] $printstarttime $title $desc<br>\n";
216 }else{
217     $number = 0;
218 //print "$stationname $stationrowdata[0] 現在番組 $printstarttime $title $desc<br>\n";
219 }
220 if ($epgcategory == ""){
221 $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>";
222 }else{
223 $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>";
224 }//if
225
226 }//for
227 }//if
228
229 //・局ごとに間隔決定
230 //$item[$i][NHK] はヌルかどうか判定
231 $dataplace = 0 ; //初期化
232 $rowspan = 0;
233
234 for ($i=1; $i <= $colmnums ; $i++){
235     if ($i === ($colmnums )){//最終行
236         $rowspan = $i - $dataplace ;
237         //そして自分自身にタグを
238             if ($item[$i][$stationname] == ""){
239             $item[$i][$stationname]  = "";
240             }else{
241             $item[$i][$stationname]  = "<td ". $item[$i][$stationname] . "</td>";
242             $rowspan--;
243             }
244             //ROWSPAN
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 //            $item[$dataplace][$stationname]  = "<td ". $item[$dataplace][$stationname] . "$rowspan </td>";
250             }
251
252     }elseif ($item[$i][$stationname] == ""){
253     //ヌルなら
254         $item[$i][$stationname]  =  $item[$i][$stationname] ;
255 //        $item[$i][$stationname]  =  "<td><br></td>" ;
256     }else{
257     //なんか入ってるなら
258         $rowspan = $i - $dataplace;
259             if ($rowspan === 1 ){
260             $item[$dataplace][$stationname]  = "<td ". $item[$dataplace][$stationname] . "</td>";
261             }else{
262             $item[$dataplace][$stationname]  = "<td rowspan = $rowspan ". $item[$dataplace][$stationname] . "</td>";
263 //            $item[$dataplace][$stationname]  = "<td ". $item[$dataplace][$stationname] . "$rowspan </td>";
264             }
265         $dataplace = $i;
266         
267     }
268 }//for
269 }// end of for://・局ごとに縦に配列入れていく
270
271 //・テーブルレンダリング
272 print "<table>\n<tr>";
273
274 //ヘッダ
275 for ($i=0;$i<$stations;$i++){
276     $rowdata = pg_fetch_row($slistrs, $i);
277     print "<th>".htmlspecialchars($rowdata[1])."</th>" ;
278 }
279 //本体
280 for ($l = 0 ;$l $colmnums; $l++){
281     print "<tr>";
282     for ($m = 0 ; $m < $stations ; $m++ ){
283         $stationname = $stationhash[$m];
284         print_r($item[$l]["$stationname"]);
285     }
286     print "</tr>\n";
287 }
288 print "</table>\n";
289  ?>
290
291 <hr>
292 凡例
293 <table>
294 <tr>
295 <td id="information">情報</td>
296 <td id="anime">アニメ・特撮</td>
297 <td id="news">ニュース・報道</td>
298 <td id="drama">ドラマ</td>
299 <td id="variety">バラエティ</td>
300 <td id="documentary">ドキュメンタリー・教養</td>
301 <td id="education">教育</td>
302 <td id="music">音楽</td>
303 <td id="cinema">映画</td>
304 <td id="hobby">趣味・実用</td>
305 <td id="kids">キッズ</td>
306 <td id="sports">スポーツ</td>
307 <td id="etc">その他</td>
308 <td id="stage">演劇</td>
309
310 </tr>
311 </table>
312 </body>
313 </html>
314
315
316
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed