1 |
<?php |
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
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 |
} |
---|
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 |
|
---|
51 |
?> |
---|
52 |
<body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" > |
---|
53 |
<div align="center"> |
---|
54 |
<?php |
---|
55 |
printhtmlpageheader(); |
---|
56 |
?> |
---|
57 |
<p align="left"><font color="#494949" size="6">EPG番組表</font></p> |
---|
58 |
<p align="left"><a href="./m.php">番組手動予約</a ></p> |
---|
59 |
<hr size="4"> |
---|
60 |
<p align="left">EPG番組表を表示します。 |
---|
61 |
<?php |
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|
65 |
$begin = date("YmdHi"); |
---|
66 |
$beginyear = substr($begin,0,4); |
---|
67 |
$beginmonth = substr($begin,4,2); |
---|
68 |
$beginday = substr($begin,6,2); |
---|
69 |
$beginhour = substr($begin,8,2); |
---|
70 |
$beginmin = substr($begin,10,2); |
---|
71 |
|
---|
72 |
|
---|
73 |
$startyear = substr($start,0,4); |
---|
74 |
$startmonth = substr($start,4,2); |
---|
75 |
$startday = substr($start,6,2); |
---|
76 |
$starthour = substr($start,8,2); |
---|
77 |
$startmin = substr($start,10,2); |
---|
78 |
$day_of_the_week = date ("(D)",mktime($starthour , 0 , 0, $startmonth , $startday , $startyear)); |
---|
79 |
|
---|
80 |
print "($startyear/$startmonth/$startday $day_of_the_week $starthour:$startmin-)<BR>\n"; |
---|
81 |
|
---|
82 |
|
---|
83 |
$yesterday = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday -1 , $startyear)); |
---|
84 |
$dayyesterday = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday -1 , $startyear)); |
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 |
$tomorrow = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear)); |
---|
89 |
|
---|
90 |
|
---|
91 |
$daytomorrow = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear)); |
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 |
$today0400 = date ("YmdHi",mktime(4 , 0 , 0, $startmonth , $startday , $startyear)); |
---|
96 |
$today0800 = date ("YmdHi",mktime(8 , 0 , 0, $startmonth , $startday , $startyear)); |
---|
97 |
$today1200 = date ("YmdHi",mktime(12 , 0 , 0, $startmonth , $startday , $startyear)); |
---|
98 |
$today1600 = date ("YmdHi",mktime(16 , 0 , 0, $startmonth , $startday , $startyear)); |
---|
99 |
$today2000 = date ("YmdHi",mktime(20 , 0 , 0, $startmonth , $startday , $startyear)); |
---|
100 |
$today2359 = date ("YmdHi",mktime(23 , 59 , 0, $startmonth , $startday , $startyear)); |
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 |
$day0after = date ("YmdHi",mktime($beginhour , 0 , 0, $beginmonth , $beginday , $beginyear)); |
---|
106 |
$day0 = date ("m/d(D)",mktime($beginhour , 0 , 0, $beginmonth , $beginday , $beginyear)); |
---|
107 |
$day1after = date ("YmdHi",mktime($beginhour , 0 , 0, $beginmonth , $beginday +1 , $beginyear)); |
---|
108 |
$day1 = date ("m/d(D)",mktime($beginhour , 0 , 0, $beginmonth , $beginday +1 , $beginyear)); |
---|
109 |
$day2after = date ("YmdHi",mktime($beginhour , 0 , 0, $beginmonth , $beginday +2 , $beginyear)); |
---|
110 |
$day2 = date ("m/d(D)",mktime($beginhour , 0 , 0, $beginmonth , $beginday +2 , $beginyear)); |
---|
111 |
$day3after = date ("YmdHi",mktime($beginhour , 0 , 0, $beginmonth , $beginday +3 , $beginyear)); |
---|
112 |
$day3 = date ("m/d(D)",mktime($beginhour , 0 , 0, $beginmonth , $beginday +3 , $beginyear)); |
---|
113 |
$day4after = date ("YmdHi",mktime($beginhour , 0 , 0, $beginmonth , $beginday +4 , $beginyear)); |
---|
114 |
$day4 = date ("m/d(D)",mktime($beginhour , 0 , 0, $beginmonth , $beginday +4 , $beginyear)); |
---|
115 |
$day5after = date ("YmdHi",mktime($beginhour , 0 , 0, $beginmonth , $beginday +5 , $beginyear)); |
---|
116 |
$day5 = date ("m/d(D)",mktime($beginhour , 0 , 0, $beginmonth , $beginday +5 , $beginyear)); |
---|
117 |
$day6after = date ("YmdHi",mktime($beginhour , 0 , 0, $beginmonth , $beginday +6 , $beginyear)); |
---|
118 |
$day6 = date ("m/d(D)",mktime($beginhour , 0 , 0, $beginmonth , $beginday +6 , $beginyear)); |
---|
119 |
$day7after = date ("YmdHi",mktime($beginhour , 0 , 0, $beginmonth , $beginday +7 , $beginyear)); |
---|
120 |
$day7 = date ("m/d(D)",mktime($beginhour , 0 , 0, $beginmonth , $beginday +7 , $beginyear)); |
---|
121 |
|
---|
122 |
|
---|
123 |
|
---|
124 |
|
---|
125 |
|
---|
126 |
$maxdisplay = 8; |
---|
127 |
|
---|
128 |
$query = "SELECT count(*) FROM foltia_station WHERE \"ontvcode\" LIKE '%ontvjapan%'"; |
---|
129 |
|
---|
130 |
$rs = sql_query($con, $query, "DBクエリに失敗しました"); |
---|
131 |
$maxrows = $rs->fetchColumn(0); |
---|
132 |
if ($maxrows > $maxdisplay){ |
---|
133 |
$pages = ceil($maxrows / $maxdisplay) ; |
---|
134 |
} |
---|
135 |
|
---|
136 |
$page = getgetnumform("p"); |
---|
137 |
|
---|
138 |
if (($page == "")|| ($page <= 0) ){ |
---|
139 |
$page = 1 ; |
---|
140 |
$offset = 0 ; |
---|
141 |
}else{ |
---|
142 |
$page = ereg_replace( "[^0-9]", "", $page); |
---|
143 |
if ($page > $pages){ |
---|
144 |
$page = $pages ; |
---|
145 |
}elseif ($page <= 0) { |
---|
146 |
$page = 1 ; |
---|
147 |
} |
---|
148 |
$offset = ($page * $maxdisplay ) - $maxdisplay; |
---|
149 |
} |
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 |
print " |
---|
155 |
|
---|
156 |
[<A HREF=\"./viewepg.php\">現在</A>] | |
---|
157 |
<A HREF=\"./viewepg.php?p=$page&start=$yesterday\">$dayyesterday [前日]</A> | |
---|
158 |
当日( |
---|
159 |
<A HREF=\"./viewepg.php?p=$page&start=$today0400\">4:00</A> |
---|
160 |
<A HREF=\"./viewepg.php?p=$page&start=$today0800\">8:00</A> |
---|
161 |
<A HREF=\"./viewepg.php?p=$page&start=$today1200\">12:00</A> |
---|
162 |
<A HREF=\"./viewepg.php?p=$page&start=$today1600\">16:00</A> |
---|
163 |
<A HREF=\"./viewepg.php?p=$page&start=$today2000\">20:00</A> |
---|
164 |
<A HREF=\"./viewepg.php?p=$page&start=$today2359\">24:00</A>) | |
---|
165 |
<A HREF=\"./viewepg.php?p=$page&start=$tomorrow\">$daytomorrow [翌日]</A> |
---|
166 |
<br> |
---|
167 |
| |
---|
168 |
<A HREF=\"./viewepg.php?p=$page&start=$day0after\">$day0</A> | |
---|
169 |
<A HREF=\"./viewepg.php?p=$page&start=$day1after\">$day1</A> | |
---|
170 |
<A HREF=\"./viewepg.php?p=$page&start=$day2after\">$day2</A> | |
---|
171 |
<A HREF=\"./viewepg.php?p=$page&start=$day3after\">$day3</A> | |
---|
172 |
<A HREF=\"./viewepg.php?p=$page&start=$day4after\">$day4</A> | |
---|
173 |
<A HREF=\"./viewepg.php?p=$page&start=$day5after\">$day5</A> | |
---|
174 |
<A HREF=\"./viewepg.php?p=$page&start=$day6after\">$day6</A> | |
---|
175 |
<A HREF=\"./viewepg.php?p=$page&start=$day7after\">$day7</A> | <BR>\n"; |
---|
176 |
|
---|
177 |
|
---|
178 |
if ($maxrows > $maxdisplay){ |
---|
179 |
|
---|
180 |
|
---|
181 |
if ($page > 1){ |
---|
182 |
$beforepage = $page - 1; |
---|
183 |
print "<a href = \"./viewepg.php?p=$beforepage&start=$start\">←</A>"; |
---|
184 |
} |
---|
185 |
|
---|
186 |
print " $page / $pages (放送局) "; |
---|
187 |
for ($i=1;$i<=$pages;$i++){ |
---|
188 |
print "<a href = \"./viewepg.php?p=$i&start=$start\">$i</a>・"; |
---|
189 |
} |
---|
190 |
|
---|
191 |
|
---|
192 |
if ($page < $pages){ |
---|
193 |
$nextpage = $page + 1; |
---|
194 |
print "<a href = \"./viewepg.php?p=$nextpage&start=$start\">→</a>"; |
---|
195 |
} |
---|
196 |
} |
---|
197 |
|
---|
198 |
|
---|
199 |
$query = "SELECT stationid, stationname, stationrecch, ontvcode |
---|
200 |
FROM foltia_station |
---|
201 |
WHERE \"ontvcode\" LIKE '%ontvjapan%' |
---|
202 |
ORDER BY stationid ASC , stationrecch |
---|
203 |
LIMIT ? OFFSET ? |
---|
204 |
"; |
---|
205 |
|
---|
206 |
|
---|
207 |
$slistrs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset)); |
---|
208 |
while ($rowdata = $slistrs->fetch()) { |
---|
209 |
$stationhash[] = $rowdata[3]; |
---|
210 |
$snames[] = $rowdata[1]; |
---|
211 |
} |
---|
212 |
|
---|
213 |
|
---|
214 |
$epgstart = $start ; |
---|
215 |
$epgend = calcendtime($start , (8*60)); |
---|
216 |
|
---|
217 |
$query = "SELECT DISTINCT startdatetime |
---|
218 |
FROM foltia_epg |
---|
219 |
WHERE foltia_epg.ontvchannel in ( |
---|
220 |
SELECT ontvcode |
---|
221 |
FROM foltia_station |
---|
222 |
WHERE \"ontvcode\" LIKE '%ontvjapan%' |
---|
223 |
ORDER BY stationid ASC , stationrecch |
---|
224 |
LIMIT ? OFFSET ? |
---|
225 |
) |
---|
226 |
AND startdatetime >= ? |
---|
227 |
AND startdatetime < ? |
---|
228 |
ORDER BY foltia_epg.startdatetime ASC "; |
---|
229 |
|
---|
230 |
|
---|
231 |
$rs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset,$start,$epgend)); |
---|
232 |
|
---|
233 |
|
---|
234 |
|
---|
235 |
$rowdata = $rs->fetch(); |
---|
236 |
if (! $rowdata) { |
---|
237 |
|
---|
238 |
$colmnums = 2; |
---|
239 |
}else{ |
---|
240 |
$colmnums = 0; |
---|
241 |
do { |
---|
242 |
$colmnums++; |
---|
243 |
$timetablehash[$rowdata[0]] = $colmnums; |
---|
244 |
|
---|
245 |
} while ($rowdata = $rs->fetch()); |
---|
246 |
|
---|
247 |
|
---|
248 |
|
---|
249 |
|
---|
250 |
foreach ($stationhash as $stationname) { |
---|
251 |
$epgstart = $start ; |
---|
252 |
$epgend = calcendtime($start , (8*60)); |
---|
253 |
$query = " |
---|
254 |
SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid , epgcategory |
---|
255 |
FROM foltia_epg |
---|
256 |
WHERE foltia_epg.ontvchannel = ? AND |
---|
257 |
enddatetime > ? AND |
---|
258 |
startdatetime < ? |
---|
259 |
ORDER BY foltia_epg.startdatetime ASC |
---|
260 |
"; |
---|
261 |
|
---|
262 |
|
---|
263 |
$statiodh = sql_query($con, $query, "DBクエリに失敗しました",array($stationname,$epgstart,$epgend)); |
---|
264 |
$stationrowdata = $statiodh->fetch(); |
---|
265 |
$stationrowdata) { |
---|
266 |
|
---|
267 |
$item[0]["$stationname"] = ">番組データがありません"; |
---|
268 |
|
---|
269 |
|
---|
270 |
$printstarttime = substr($stationrowdata[0],8,2) . ":" . substr($stationrowdata[0],10,2); |
---|
271 |
$tdclass = "t".substr($stationrowdata[0],8,2) . substr($stationrowdata[0],10,2); |
---|
272 |
$title = $stationrowdata[3]; |
---|
273 |
$title = htmlspecialchars(z2h($title)); |
---|
274 |
$desc = $stationrowdata[4]; |
---|
275 |
$desc = htmlspecialchars(z2h($desc)); |
---|
276 |
$height = htmlspecialchars($stationrowdata[2]) * 3; |
---|
277 |
$epgid = htmlspecialchars($stationrowdata[7]); |
---|
278 |
$epgcategory = htmlspecialchars($stationrowdata[8]); |
---|
279 |
|
---|
280 |
if (isset($timetablehash["$stationrowdata[0]"])){ |
---|
281 |
$number = $timetablehash["$stationrowdata[0]"]; |
---|
282 |
|
---|
283 |
}else{ |
---|
284 |
$number = 0; |
---|
285 |
|
---|
286 |
} |
---|
287 |
if ($epgcategory == ""){ |
---|
288 |
$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>"; |
---|
289 |
}else{ |
---|
290 |
$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>"; |
---|
291 |
} |
---|
292 |
|
---|
293 |
} while ($stationrowdata = $statiodh->fetch()); |
---|
294 |
} |
---|
295 |
|
---|
296 |
//・局ごとに間隔決定 |
---|
297 |
//$item[$i][NHK] はヌルかどうか判定 |
---|
298 |
$dataplace = 0 ; |
---|
299 |
$rowspan = 0; |
---|
300 |
|
---|
301 |
for ($i=1; $i <= $colmnums ; $i++){ |
---|
302 |
if ($i === ($colmnums )){ |
---|
303 |
$rowspan = $i - $dataplace ; |
---|
304 |
|
---|
305 |
//if ((!isset($item[$i][$stationname])) && ($item[$i][$stationname] == "")){ |
---|
306 |
if (!isset($item[$i][$stationname])){ |
---|
307 |
$item[$i][$stationname] = null ; |
---|
308 |
}else{ |
---|
309 |
$item[$i][$stationname] = "<td ". $item[$i][$stationname] . "</td>"; |
---|
310 |
$rowspan--; |
---|
311 |
} |
---|
312 |
|
---|
313 |
if ($rowspan === 1 ){ |
---|
314 |
$item[$dataplace][$stationname] = "<td ". $item[$dataplace][$stationname] . "</td>"; |
---|
315 |
}else{ |
---|
316 |
$item[$dataplace][$stationname] = "<td rowspan = $rowspan ". $item[$dataplace][$stationname] . "</td>"; |
---|
317 |
|
---|
318 |
} |
---|
319 |
|
---|
320 |
|
---|
321 |
}elseif (!isset($item[$i][$stationname])){ |
---|
322 |
|
---|
323 |
|
---|
324 |
$item[$i][$stationname] = null ; |
---|
325 |
|
---|
326 |
}else{ |
---|
327 |
|
---|
328 |
$rowspan = $i - $dataplace; |
---|
329 |
$itemDataplaceStationname = null; |
---|
330 |
$item[$dataplace][$stationname])){ |
---|
331 |
$itemDataplaceStationname = $item[$dataplace][$stationname]; |
---|
332 |
|
---|
333 |
$rowspan === 1 ){ |
---|
334 |
$item[$dataplace][$stationname] = "<td ". $itemDataplaceStationname . "</td>"; |
---|
335 |
|
---|
336 |
$item[$dataplace][$stationname] = "<td rowspan = $rowspan ". $itemDataplaceStationname . "</td>"; |
---|
337 |
|
---|
338 |
} |
---|
339 |
$dataplace = $i; |
---|
340 |
|
---|
341 |
|
---|
342 |
|
---|
343 |
} |
---|
344 |
|
---|
345 |
//・テーブルレンダリング |
---|
346 |
print "<table>\n<tr>"; |
---|
347 |
|
---|
348 |
|
---|
349 |
foreach ($snames as $s) { |
---|
350 |
print "<th>".htmlspecialchars($s)."</th>" ; |
---|
351 |
} |
---|
352 |
|
---|
353 |
for ($l = 0 ;$l < $colmnums; $l++){ |
---|
354 |
print "<tr>"; |
---|
355 |
foreach ($stationhash as $stationname) { |
---|
356 |
print_r($item[$l]["$stationname"]); |
---|
357 |
} |
---|
358 |
print "</tr>\n"; |
---|
359 |
} |
---|
360 |
print "</table>\n"; |
---|
361 |
|
---|
362 |
?> |
---|
363 |
|
---|
364 |
<hr> |
---|
365 |
凡例 |
---|
366 |
<table> |
---|
367 |
<tr> |
---|
368 |
<td id="information">情報</td> |
---|
369 |
<td id="anime">アニメ・特撮</td> |
---|
370 |
<td id="news">ニュース・報道</td> |
---|
371 |
<td id="drama">ドラマ</td> |
---|
372 |
<td id="variety">バラエティ</td> |
---|
373 |
<td id="documentary">ドキュメンタリー・教養</td> |
---|
374 |
<td id="education">教育</td> |
---|
375 |
<td id="music">音楽</td> |
---|
376 |
<td id="cinema">映画</td> |
---|
377 |
<td id="hobby">趣味・実用</td> |
---|
378 |
<td id="kids">キッズ</td> |
---|
379 |
<td id="sports">スポーツ</td> |
---|
380 |
<td id="etc">その他</td> |
---|
381 |
<td id="stage">演劇</td> |
---|
382 |
|
---|
383 |
</tr> |
---|
384 |
</table> |
---|
385 |
</body> |
---|
386 |
</html> |
---|
387 |
|
---|
388 |
|
---|
389 |
|
---|