root/trunk/install/php/viewepg.php

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