root/trunk/install/php/index.php

リビジョン 32, 7.1 kB (コミッタ: sorshi, コミット時期: 17 年 前)

 録画ディスクの空き容量が少なくなってくると一部ページの背景を色変えて警告する機能追加。
 100GB以下:黄灰
 50GB以下:赤灰
 30GB以下:赤

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