root/trunk/install/php/index.php

リビジョン 70, 7.4 kB (コミッタ: sorshi, コミット時期: 16 年 前)

環境ポリシー機能搭載

Line 
1 <?php
2 /*
3  Anime recording system foltia
4  http://www.dcc-jpl.com/soft/foltia/
5
6 index.php
7
8 目的
9 全番組放映予定を表示します。
10 録画予約されている番組は別色でわかりやすく表現されています。
11
12
13 オプション
14 mode:"new"を指定すると、新番組(第1話)のみの表示となる。
15
16  DCC-JPL Japan/foltia project
17
18 */
19
20 include("./foltialib.php");
21 $con = m_connect();
22
23 if ($useenvironmentpolicy == 1){
24     if (!isset($_SERVER['PHP_AUTH_USER'])) {
25         header("WWW-Authenticate: Basic realm=\"foltia\"");
26         header("HTTP/1.0 401 Unauthorized");
27         redirectlogin();
28         exit;
29     } else {
30     login($con,$_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']);
31     }
32 }//end if login
33
34 $now = date("YmdHi");   
35
36 function printtitle(){
37
38 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
39 <html lang=\"ja\">
40 <head>
41 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-JP\">
42 <meta http-equiv=\"Content-Style-Type\" content=\"text/css\">
43 <link rel=\"stylesheet\" type=\"text/css\" href=\"graytable.css\"> ";
44 //ディスク空き容量によって背景色表示変更
45 warndiskfreearea();
46 print "<title>foltia:放映予定</title>
47 </head>";
48
49
50 }//end function printtitle()
51
52 //同一番組他局検索
53 $query = "
54 SELECT
55 foltia_program .tid,
56 foltia_program .title,
57 foltia_subtitle.countno,
58 foltia_subtitle.subtitle,
59 foltia_subtitle.startdatetime ,
60 foltia_subtitle.lengthmin ,
61 foltia_tvrecord.bitrate ,
62 foltia_subtitle.pid 
63 FROM foltia_subtitle , foltia_program  ,foltia_tvrecord
64 WHERE foltia_tvrecord.tid = foltia_program.tid
65 AND foltia_program.tid = foltia_subtitle.tid
66 AND foltia_subtitle.enddatetime >= '$now'
67  ORDER BY \"startdatetime\" ASC
68     ";
69     $reservedrssametid = m_query($con, $query, "DBクエリに失敗しました");
70     $reservedmaxrowssameid = pg_num_rows($reservedrssametid);
71     
72     if ($reservedmaxrowssameid > 0 ){
73     for ($rrow = 0; $rrow < $reservedmaxrowssameid ; $rrow++) {
74         $rowdata = pg_fetch_row($reservedrssametid, $rrow);
75         $reservedpidsametid[] = $rowdata[7];
76     }
77     $rowdata = "";
78     $rrow = "";
79     }else{
80     $reservedpidsametid = "" ;
81     }//end if
82
83 //録画番組検索
84 $query = "
85 SELECT
86 foltia_program .tid,
87 stationname,
88 foltia_program .title,
89 foltia_subtitle.countno,
90 foltia_subtitle.subtitle,
91 foltia_subtitle.startdatetime ,
92 foltia_subtitle.lengthmin ,
93 foltia_tvrecord.bitrate ,
94 foltia_subtitle.pid 
95 FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord
96 WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid
97 AND foltia_subtitle.enddatetime >= '$now'
98 UNION
99 SELECT
100 foltia_program .tid,
101 stationname,
102 foltia_program .title,
103 foltia_subtitle.countno,
104 foltia_subtitle.subtitle,
105 foltia_subtitle.startdatetime ,
106 foltia_subtitle.lengthmin ,
107 foltia_tvrecord.bitrate ,
108 foltia_subtitle.pid 
109 FROM foltia_tvrecord
110 LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid )
111 LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid )
112 LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid )
113 WHERE foltia_tvrecord.stationid = 0 AND
114 foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC
115     ";
116
117     $reservedrs = m_query($con, $query, "DBクエリに失敗しました");
118     $reservedmaxrows = pg_num_rows($reservedrs);
119     
120     if ($reservedmaxrows > 0 ){
121     for ($rrow = 0; $rrow < $reservedmaxrows ; $rrow++) {
122         $rowdata = pg_fetch_row($reservedrs, $rrow);
123         $reservedpid[] = $rowdata[8];
124     }
125     }else{
126     $reservedpid = "";
127     }//end if
128
129 $mode = getgetform(mode);
130
131 if ($mode == "new"){
132 //新番組表示モード
133     $query = "
134     SELECT
135 foltia_program .tid,
136 stationname,
137 foltia_program .title,
138 foltia_subtitle.countno,
139 foltia_subtitle.subtitle,
140 foltia_subtitle.startdatetime ,
141 foltia_subtitle.lengthmin  ,
142 foltia_subtitle.pid ,
143 foltia_subtitle.startoffset   
144 FROM foltia_subtitle , foltia_program ,foltia_station 
145 WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid
146  AND foltia_subtitle.enddatetime >= '$now'  AND foltia_subtitle.countno = '1'
147 ORDER BY foltia_subtitle.startdatetime  ASC
148     ";
149     $rs = m_query($con, $query, "DBクエリに失敗しました");
150     $maxrows = pg_num_rows($rs);
151
152
153 }else{
154     $query = "
155     SELECT
156 foltia_program .tid,
157 stationname,
158 foltia_program .title,
159 foltia_subtitle.countno,
160 foltia_subtitle.subtitle,
161 foltia_subtitle.startdatetime ,
162 foltia_subtitle.lengthmin ,
163 foltia_subtitle.pid  ,
164 foltia_subtitle.startoffset   
165 FROM foltia_subtitle , foltia_program ,foltia_station 
166 WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid
167  AND foltia_subtitle.enddatetime >= '$now' 
168 ORDER BY foltia_subtitle.startdatetime  ASC
169     ";
170     $rs = m_query($con, $query, "DBクエリに失敗しました");
171     $maxrows = pg_num_rows($rs);
172
173 }//end if
174
175 if ($maxrows == 0) {
176 header("Status: 404 Not Found",TRUE,404);
177 printtitle();
178 print "<body BGCOLOR=\"#ffffff\" TEXT=\"#494949\" LINK=\"#0047ff\" VLINK=\"#000000\" ALINK=\"#c6edff\" >
179 <div align=\"center\">\n";
180 printhtmlpageheader();
181 print "<hr size=\"4\">\n";
182         die_exit("番組データがありません<BR>");
183 }//endif
184
185 printtitle();
186 ?>
187 <body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" >
188 <div align="center">
189 <?php
190 printhtmlpageheader();
191 ?>
192   <p align="left"><font color="#494949" size="6">
193 <?php
194 if ($mode == "new"){
195     print "新番組放映予定";
196 }else{
197     print "放映予定";
198 }
199 ?>
200 </font></p>
201   <hr size="4">
202 <p align="left">放映番組リストを表示します。</p>
203
204 <?
205         /* フィールド数 */
206         $maxcols = pg_num_fields($rs);
207         ?>
208   <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%">
209     <thead>
210         <tr>
211             <th align="left">TID</th>
212             <th align="left">放映局</th>
213             <th align="left">タイトル</th>
214             <th align="left">話数</th>
215             <th align="left">サブタイトル</th>
216             <th align="left">開始時刻(ズレ)</th>
217             <th align="left">総尺</th>
218
219         </tr>
220     </thead>
221
222     <tbody>
223         <?php
224             /* テーブルのデータを出力 */
225             for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */
226                 /* pg_fetch_row で一行取り出す */
227                 $rowdata = pg_fetch_row($rs, $row);
228
229 //他局で同一番組録画済みなら色変え
230 if (in_array($rowdata[7], $reservedpidsametid)) {
231 $rclass = "reservedtitle";
232 }else{
233 $rclass = "";
234 }
235 //録画予約済みなら色変え
236 if (in_array($rowdata[7], $reservedpid)) {
237 $rclass = "reserved";
238 }
239 $pid = htmlspecialchars($rowdata[7]);
240
241 $tid = htmlspecialchars($rowdata[0]);
242 $title = htmlspecialchars($rowdata[2]);
243 $subtitle htmlspecialchars($rowdata[4]);
244
245                 echo("<tr class=\"$rclass\">\n");
246                     // TID
247                     print "<td>";
248                     if ($tid == 0 ){
249                     print "$tid";
250                     }else{
251                     print "<a href=\"reserveprogram.php?tid=$tid\">$tid</a>";
252                     }
253                     print "</td>\n";
254                      // 放映局
255                      echo("<td>".htmlspecialchars($rowdata[1])."<br></td>\n");
256                      // タイトル
257                     print "<td>";
258                     if ($tid == 0 ){
259                     print "$title";
260                     }else{
261                     print "<a href=\"http://cal.syoboi.jp/tid/$tid\" target=\"_blank\">$title</a>";
262                     }
263                     print "</td>\n";
264                      // 話数
265                     echo("<td>".htmlspecialchars($rowdata[3])."<br></td>\n");
266                     // サブタイ
267                     if ($pid > 0 ){
268                     print "<td><a href=\"http://cal.syoboi.jp/tid/$tid/time#$pid\" target=\"_blank\">$subtitle<br></td>\n";
269                     }else{
270                     print "<td>$subtitle<br></td>\n";
271                     }
272                     // 開始時刻(ズレ)
273                     echo("<td>".htmlspecialchars(foldate2print($rowdata[5]))."<br>(".htmlspecialchars($rowdata[8]).")</td>\n");
274                     // 総尺
275                     echo("<td>".htmlspecialchars($rowdata[6])."<br></td>\n");
276
277                 echo("</tr>\n");
278             }
279         ?>
280     </tbody>
281 </table>
282
283
284 </body>
285 </html>
286
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed