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 |
<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 |
|
---|
91 |
$maxdisplay = 8; |
---|
92 |
|
---|
93 |
$query = "SELECT count(*) FROM foltia_station WHERE \"ontvcode\" LIKE '%ontvjapan%'"; |
---|
94 |
|
---|
95 |
$rs = sql_query($con, $query, "DBクエリに失敗しました"); |
---|
96 |
$maxrows = $rs->fetchColumn(0); |
---|
97 |
if ($maxrows > $maxdisplay){ |
---|
98 |
$pages = ceil($maxrows / $maxdisplay) ; |
---|
99 |
} |
---|
100 |
|
---|
101 |
$page = getgetnumform("p"); |
---|
102 |
|
---|
103 |
if (($page == "")|| ($page <= 0) ){ |
---|
104 |
$page = 1 ; |
---|
105 |
$offset = 0 ; |
---|
106 |
}else{ |
---|
107 |
$page = ereg_replace( "[^0-9]", "", $page); |
---|
108 |
if ($page > $pages){ |
---|
109 |
$page = $pages ; |
---|
110 |
}elseif ($page <= 0) { |
---|
111 |
$page = 1 ; |
---|
112 |
} |
---|
113 |
$offset = ($page * $maxdisplay ) - $maxdisplay; |
---|
114 |
} |
---|
115 |
|
---|
116 |
|
---|
117 |
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"; |
---|
118 |
|
---|
119 |
|
---|
120 |
if ($maxrows > $maxdisplay){ |
---|
121 |
|
---|
122 |
|
---|
123 |
if ($page > 1){ |
---|
124 |
$beforepage = $page - 1; |
---|
125 |
print "<a href = \"./viewepg.php?p=$beforepage&start=$start\">←</A>"; |
---|
126 |
} |
---|
127 |
|
---|
128 |
print " $page / $pages (放送局) "; |
---|
129 |
|
---|
130 |
if ($page < $pages){ |
---|
131 |
$nextpage = $page + 1; |
---|
132 |
print "<a href = \"./viewepg.php?p=$nextpage&start=$start\">→</A>"; |
---|
133 |
} |
---|
134 |
} |
---|
135 |
|
---|
136 |
|
---|
137 |
$query = "SELECT stationid, stationname, stationrecch, ontvcode |
---|
138 |
FROM foltia_station |
---|
139 |
WHERE \"ontvcode\" LIKE '%ontvjapan%' |
---|
140 |
ORDER BY stationid ASC , stationrecch |
---|
141 |
LIMIT ? OFFSET ? |
---|
142 |
"; |
---|
143 |
|
---|
144 |
|
---|
145 |
$slistrs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset)); |
---|
146 |
while ($rowdata = $slistrs->fetch()) { |
---|
147 |
$stationhash[] = $rowdata[3]; |
---|
148 |
$snames[] = $rowdata[1]; |
---|
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\" LIKE '%ontvjapan%' |
---|
161 |
ORDER BY stationid ASC , stationrecch |
---|
162 |
LIMIT ? OFFSET ? |
---|
163 |
) |
---|
164 |
AND startdatetime >= ? |
---|
165 |
AND startdatetime < ? |
---|
166 |
ORDER BY foltia_epg.startdatetime ASC "; |
---|
167 |
|
---|
168 |
|
---|
169 |
$rs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset,$start,$epgend)); |
---|
170 |
|
---|
171 |
|
---|
172 |
|
---|
173 |
$rowdata = $rs->fetch(); |
---|
174 |
if (! $rowdata) { |
---|
175 |
|
---|
176 |
$colmnums = 2; |
---|
177 |
}else{ |
---|
178 |
$colmnums = 0; |
---|
179 |
do { |
---|
180 |
$colmnums++; |
---|
181 |
$timetablehash[$rowdata[0]] = $colmnums; |
---|
182 |
|
---|
183 |
} while ($rowdata = $rs->fetch()); |
---|
184 |
|
---|
185 |
|
---|
186 |
|
---|
187 |
|
---|
188 |
foreach ($stationhash as $stationname) { |
---|
189 |
$epgstart = $start ; |
---|
190 |
$epgend = calcendtime($start , (8*60)); |
---|
191 |
$query = " |
---|
192 |
SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid , epgcategory |
---|
193 |
FROM foltia_epg |
---|
194 |
WHERE foltia_epg.ontvchannel = ? AND |
---|
195 |
enddatetime > ? AND |
---|
196 |
startdatetime < ? |
---|
197 |
ORDER BY foltia_epg.startdatetime ASC |
---|
198 |
"; |
---|
199 |
|
---|
200 |
|
---|
201 |
$statiodh = sql_query($con, $query, "DBクエリに失敗しました",array($stationname,$epgstart,$epgend)); |
---|
202 |
$stationrowdata = $statiodh->fetch(); |
---|
203 |
$stationrowdata) { |
---|
204 |
|
---|
205 |
$item[0]["$stationname"] = ">番組データがありません"; |
---|
206 |
|
---|
207 |
|
---|
208 |
$printstarttime = substr($stationrowdata[0],8,2) . ":" . substr($stationrowdata[0],10,2); |
---|
209 |
$tdclass = "t".substr($stationrowdata[0],8,2) . substr($stationrowdata[0],10,2); |
---|
210 |
$title = $stationrowdata[3]; |
---|
211 |
$title = htmlspecialchars(z2h($title)); |
---|
212 |
$desc = $stationrowdata[4]; |
---|
213 |
$desc = htmlspecialchars(z2h($desc)); |
---|
214 |
$height = htmlspecialchars($stationrowdata[2]) * 3; |
---|
215 |
$epgid = htmlspecialchars($stationrowdata[7]); |
---|
216 |
$epgcategory = htmlspecialchars($stationrowdata[8]); |
---|
217 |
|
---|
218 |
if (isset($timetablehash["$stationrowdata[0]"])){ |
---|
219 |
$number = $timetablehash["$stationrowdata[0]"]; |
---|
220 |
|
---|
221 |
}else{ |
---|
222 |
$number = 0; |
---|
223 |
|
---|
224 |
} |
---|
225 |
if ($epgcategory == ""){ |
---|
226 |
$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>"; |
---|
227 |
}else{ |
---|
228 |
$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>"; |
---|
229 |
} |
---|
230 |
|
---|
231 |
} while ($stationrowdata = $statiodh->fetch()); |
---|
232 |
} |
---|
233 |
|
---|
234 |
//・局ごとに間隔決定 |
---|
235 |
//$item[$i][NHK] はヌルかどうか判定 |
---|
236 |
$dataplace = 0 ; |
---|
237 |
$rowspan = 0; |
---|
238 |
|
---|
239 |
for ($i=1; $i <= $colmnums ; $i++){ |
---|
240 |
if ($i === ($colmnums )){ |
---|
241 |
$rowspan = $i - $dataplace ; |
---|
242 |
|
---|
243 |
//if ((!isset($item[$i][$stationname])) && ($item[$i][$stationname] == "")){ |
---|
244 |
if (!isset($item[$i][$stationname])){ |
---|
245 |
$item[$i][$stationname] = null ; |
---|
246 |
}else{ |
---|
247 |
$item[$i][$stationname] = "<td ". $item[$i][$stationname] . "</td>"; |
---|
248 |
$rowspan--; |
---|
249 |
} |
---|
250 |
|
---|
251 |
if ($rowspan === 1 ){ |
---|
252 |
$item[$dataplace][$stationname] = "<td ". $item[$dataplace][$stationname] . "</td>"; |
---|
253 |
}else{ |
---|
254 |
$item[$dataplace][$stationname] = "<td rowspan = $rowspan ". $item[$dataplace][$stationname] . "</td>"; |
---|
255 |
|
---|
256 |
} |
---|
257 |
|
---|
258 |
|
---|
259 |
}elseif (!isset($item[$i][$stationname])){ |
---|
260 |
|
---|
261 |
|
---|
262 |
$item[$i][$stationname] = null ; |
---|
263 |
|
---|
264 |
}else{ |
---|
265 |
|
---|
266 |
$rowspan = $i - $dataplace; |
---|
267 |
$itemDataplaceStationname = null; |
---|
268 |
$item[$dataplace][$stationname])){ |
---|
269 |
$itemDataplaceStationname = $item[$dataplace][$stationname]; |
---|
270 |
|
---|
271 |
$rowspan === 1 ){ |
---|
272 |
$item[$dataplace][$stationname] = "<td ". $itemDataplaceStationname . "</td>"; |
---|
273 |
|
---|
274 |
$item[$dataplace][$stationname] = "<td rowspan = $rowspan ". $itemDataplaceStationname . "</td>"; |
---|
275 |
|
---|
276 |
} |
---|
277 |
$dataplace = $i; |
---|
278 |
|
---|
279 |
|
---|
280 |
|
---|
281 |
} |
---|
282 |
|
---|
283 |
//・テーブルレンダリング |
---|
284 |
print "<table>\n<tr>"; |
---|
285 |
|
---|
286 |
|
---|
287 |
foreach ($snames as $s) { |
---|
288 |
print "<th>".htmlspecialchars($s)."</th>" ; |
---|
289 |
} |
---|
290 |
|
---|
291 |
for ($l = 0 ;$l < $colmnums; $l++){ |
---|
292 |
print "<tr>"; |
---|
293 |
foreach ($stationhash as $stationname) { |
---|
294 |
print_r($item[$l]["$stationname"]); |
---|
295 |
} |
---|
296 |
print "</tr>\n"; |
---|
297 |
} |
---|
298 |
print "</table>\n"; |
---|
299 |
?> |
---|
300 |
|
---|
301 |
<hr> |
---|
302 |
凡例 |
---|
303 |
<table> |
---|
304 |
<tr> |
---|
305 |
<td id="information">情報</td> |
---|
306 |
<td id="anime">アニメ・特撮</td> |
---|
307 |
<td id="news">ニュース・報道</td> |
---|
308 |
<td id="drama">ドラマ</td> |
---|
309 |
<td id="variety">バラエティ</td> |
---|
310 |
<td id="documentary">ドキュメンタリー・教養</td> |
---|
311 |
<td id="education">教育</td> |
---|
312 |
<td id="music">音楽</td> |
---|
313 |
<td id="cinema">映画</td> |
---|
314 |
<td id="hobby">趣味・実用</td> |
---|
315 |
<td id="kids">キッズ</td> |
---|
316 |
<td id="sports">スポーツ</td> |
---|
317 |
<td id="etc">その他</td> |
---|
318 |
<td id="stage">演劇</td> |
---|
319 |
|
---|
320 |
</tr> |
---|
321 |
</table> |
---|
322 |
</body> |
---|
323 |
</html> |
---|
324 |
|
---|
325 |
|
---|
326 |
|
---|