| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 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 |
|
|---|
| 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 = 0 ; |
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
$colmnums = pg_num_rows($rs); |
|---|
| 161 |
if ($colmnums == 0){ |
|---|
| 162 |
|
|---|
| 163 |
$colmnums = 2; |
|---|
| 164 |
}else{ |
|---|
| 165 |
for ($i=0 ; $i < $colmnums ; $i++){ |
|---|
| 166 |
$rowdata = pg_fetch_row($rs, $i); |
|---|
| 167 |
$timetablehash["$rowdata[0]"] = ($i + 1); |
|---|
| 168 |
|
|---|
| 169 |
} |
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
for ($j=0 ; $j < $stations ; $j++){ |
|---|
| 175 |
$rowdata = pg_fetch_row($slistrs, $j); |
|---|
| 176 |
$stationname = $rowdata[3]; |
|---|
| 177 |
|
|---|
| 178 |
$epgstart = $start ; |
|---|
| 179 |
$epgend = calcendtime($start , (8*60)); |
|---|
| 180 |
$query = " |
|---|
| 181 |
SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid , epgcategory |
|---|
| 182 |
FROM foltia_epg |
|---|
| 183 |
WHERE foltia_epg.ontvchannel = '$stationname' AND |
|---|
| 184 |
enddatetime > $epgstart AND |
|---|
| 185 |
startdatetime < $epgend |
|---|
| 186 |
ORDER BY foltia_epg.startdatetime ASC |
|---|
| 187 |
"; |
|---|
| 188 |
$statiodh = m_query($con, $query, "DBクエリに失敗しました"); |
|---|
| 189 |
$maxrowsstation = pg_num_rows($statiodh); |
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
if ($maxrowsstation == 0) { |
|---|
| 194 |
|
|---|
| 195 |
$item[0]["$stationname"] = ">番組データがありません"; |
|---|
| 196 |
}else{ |
|---|
| 197 |
|
|---|
| 198 |
for ($srow = 0; $srow < $maxrowsstation ; $srow++) { |
|---|
| 199 |
|
|---|
| 200 |
$stationrowdata = pg_fetch_row($statiodh, $srow); |
|---|
| 201 |
|
|---|
| 202 |
$printstarttime = substr($stationrowdata[0],8,2) . ":" . substr($stationrowdata[0],10,2); |
|---|
| 203 |
$tdclass = "t".substr($stationrowdata[0],8,2) . substr($stationrowdata[0],10,2); |
|---|
| 204 |
$title = $stationrowdata[3]; |
|---|
| 205 |
$title = htmlspecialchars(z2h($title)); |
|---|
| 206 |
$desc = $stationrowdata[4]; |
|---|
| 207 |
$desc = htmlspecialchars(z2h($desc)); |
|---|
| 208 |
$height = htmlspecialchars($stationrowdata[2]) * 3; |
|---|
| 209 |
$epgid = htmlspecialchars($stationrowdata[7]); |
|---|
| 210 |
$epgcategory = htmlspecialchars($stationrowdata[8]); |
|---|
| 211 |
|
|---|
| 212 |
if (isset($timetablehash["$stationrowdata[0]"])){ |
|---|
| 213 |
$number = $timetablehash["$stationrowdata[0]"]; |
|---|
| 214 |
|
|---|
| 215 |
}else{ |
|---|
| 216 |
$number = 0; |
|---|
| 217 |
|
|---|
| 218 |
} |
|---|
| 219 |
if ($epgcategory == ""){ |
|---|
| 220 |
$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>"; |
|---|
| 221 |
}else{ |
|---|
| 222 |
$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>"; |
|---|
| 223 |
} |
|---|
| 224 |
|
|---|
| 225 |
} |
|---|
| 226 |
} |
|---|
| 227 |
|
|---|
| 228 |
//・局ごとに間隔決定 |
|---|
| 229 |
//$item[$i][NHK] はヌルかどうか判定 |
|---|
| 230 |
$dataplace = 0 ; |
|---|
| 231 |
$rowspan = 0; |
|---|
| 232 |
|
|---|
| 233 |
for ($i=1; $i <= $colmnums ; $i++){ |
|---|
| 234 |
if ($i === ($colmnums )){ |
|---|
| 235 |
$rowspan = $i - $dataplace ; |
|---|
| 236 |
|
|---|
| 237 |
if ($item[$i][$stationname] == ""){ |
|---|
| 238 |
$item[$i][$stationname] = ""; |
|---|
| 239 |
}else{ |
|---|
| 240 |
$item[$i][$stationname] = "<td ". $item[$i][$stationname] . "</td>"; |
|---|
| 241 |
$rowspan--; |
|---|
| 242 |
} |
|---|
| 243 |
|
|---|
| 244 |
if ($rowspan === 1 ){ |
|---|
| 245 |
$item[$dataplace][$stationname] = "<td ". $item[$dataplace][$stationname] . "</td>"; |
|---|
| 246 |
}else{ |
|---|
| 247 |
$item[$dataplace][$stationname] = "<td rowspan = $rowspan ". $item[$dataplace][$stationname] . "</td>"; |
|---|
| 248 |
|
|---|
| 249 |
} |
|---|
| 250 |
|
|---|
| 251 |
$item[$i][$stationname] == ""){ |
|---|
| 252 |
|
|---|
| 253 |
$item[$i][$stationname] = $item[$i][$stationname] ; |
|---|
| 254 |
|
|---|
| 255 |
}else{ |
|---|
| 256 |
|
|---|
| 257 |
$rowspan = $i - $dataplace; |
|---|
| 258 |
$rowspan === 1 ){ |
|---|
| 259 |
$item[$dataplace][$stationname] = "<td ". $item[$dataplace][$stationname] . "</td>"; |
|---|
| 260 |
|
|---|
| 261 |
$item[$dataplace][$stationname] = "<td rowspan = $rowspan ". $item[$dataplace][$stationname] . "</td>"; |
|---|
| 262 |
|
|---|
| 263 |
} |
|---|
| 264 |
$dataplace = $i; |
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
} |
|---|
| 269 |
|
|---|
| 270 |
//・テーブルレンダリング |
|---|
| 271 |
print "<table>\n<tr>"; |
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
for ($i=0;$i<$stations;$i++){ |
|---|
| 275 |
$rowdata = pg_fetch_row($slistrs, $i); |
|---|
| 276 |
print "<th>".htmlspecialchars($rowdata[1])."</th>" ; |
|---|
| 277 |
} |
|---|
| 278 |
|
|---|
| 279 |
for ($l = 0 ;$l < $colmnums; $l++){ |
|---|
| 280 |
print "<tr>"; |
|---|
| 281 |
for ($m = 0 ; $m < $stations ; $m++ ){ |
|---|
| 282 |
$stationname = $stationhash[$m]; |
|---|
| 283 |
print_r($item[$l]["$stationname"]); |
|---|
| 284 |
} |
|---|
| 285 |
print "</tr>\n"; |
|---|
| 286 |
} |
|---|
| 287 |
print "</table>\n"; |
|---|
| 288 |
?> |
|---|
| 289 |
|
|---|
| 290 |
<hr> |
|---|
| 291 |
凡例 |
|---|
| 292 |
<table> |
|---|
| 293 |
<tr> |
|---|
| 294 |
<td id="information">情報</td> |
|---|
| 295 |
<td id="anime">アニメ・特撮</td> |
|---|
| 296 |
<td id="news">ニュース・報道</td> |
|---|
| 297 |
<td id="drama">ドラマ</td> |
|---|
| 298 |
<td id="variety">バラエティ</td> |
|---|
| 299 |
<td id="documentary">ドキュメンタリー・教養</td> |
|---|
| 300 |
<td id="education">教育</td> |
|---|
| 301 |
<td id="music">音楽</td> |
|---|
| 302 |
<td id="cinema">映画</td> |
|---|
| 303 |
<td id="hobby">趣味・実用</td> |
|---|
| 304 |
<td id="kids">キッズ</td> |
|---|
| 305 |
<td id="sports">スポーツ</td> |
|---|
| 306 |
<td id="etc">その他</td> |
|---|
| 307 |
<td id="stage">演劇</td> |
|---|
| 308 |
|
|---|
| 309 |
</tr> |
|---|
| 310 |
</table> |
|---|
| 311 |
</body> |
|---|
| 312 |
</html> |
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|