root/trunk/install/php/listreserve.php

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

環境ポリシー機能搭載

Line 
1 <?php
2 /*
3  Anime recording system foltia
4  http://www.dcc-jpl.com/soft/foltia/
5
6 listreserve.php
7
8 目的
9 録画予約番組放映予定と予約番組名を表示します。
10
11 引数
12 r:録画デバイス数
13 startdate:特定日付からの予約状況。YYYYmmddHHii形式で。表示数に限定かけてないのでレコード数が大量になると重くなるかも知れません。
14
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 $userclass = getuserclass($con);
34
35 ?>
36 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
37 <html lang="ja">
38 <head>
39 <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
40 <meta http-equiv="Content-Style-Type" content="text/css">
41 <link rel="stylesheet" type="text/css" href="graytable.css">
42 <title>foltia:record plan</title>
43 </head>
44
45 <?php
46 $mymemberid = getmymemberid($con);
47 $now = getgetnumform(startdate);
48
49 if ($now > 200501010000){
50 }else{
51     $now = date("YmdHi");   
52 }
53     $query = "
54 SELECT
55 foltia_program .tid,
56 stationname,
57 foltia_program .title,
58 foltia_subtitle.countno,
59 foltia_subtitle.subtitle,
60 foltia_subtitle.startdatetime ,
61 foltia_subtitle.lengthmin ,
62 foltia_tvrecord.bitrate  ,
63 foltia_subtitle.startoffset ,
64 foltia_subtitle.pid ,
65 foltia_subtitle.epgaddedby
66 FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord
67 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
68 AND foltia_subtitle.enddatetime >= '$now'
69 UNION
70 SELECT
71 foltia_program .tid,
72 stationname,
73 foltia_program .title,
74 foltia_subtitle.countno,
75 foltia_subtitle.subtitle,
76 foltia_subtitle.startdatetime ,
77 foltia_subtitle.lengthmin ,
78 foltia_tvrecord.bitrate ,
79 foltia_subtitle.startoffset ,
80 foltia_subtitle.pid ,
81 foltia_subtitle.epgaddedby
82 FROM foltia_tvrecord
83 LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid )
84 LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid )
85 LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid )
86 WHERE foltia_tvrecord.stationid = 0 AND
87 foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC
88     ";
89
90     $rs = m_query($con, $query, "DBクエリに失敗しました");
91     $maxrows = pg_num_rows($rs);
92             
93
94 //チューナー数
95 if (getgetnumform(r) != ""){
96     $recunits = getgetnumform(r);
97 }elseif($recunits == ""){
98     $recunits = 2;
99 }
100
101 ?>
102
103 <body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" >
104 <div align="center">
105 <?php
106 printhtmlpageheader();
107 ?>
108   <p align="left"><font color="#494949" size="6">予約一覧</font></p>
109   <hr size="4">
110 <p align="left">録画予約番組放映予定と予約番組名を表示します。</p>
111
112 <?
113     if ($maxrows == 0) {
114         print "番組データがありません<BR>\n";           
115         }else{
116
117
118         /* フィールド数 */
119         $maxcols = pg_num_fields($rs);
120         ?>
121   <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%">
122     <thead>
123         <tr>
124             <th align="left">TID</th>
125             <th align="left">放映局</th>
126             <th align="left">タイトル</th>
127             <th align="left">話数</th>
128             <th align="left">サブタイトル</th>
129             <th align="left">開始時刻</th>
130             <th align="left">総尺</th>
131             <th align="left">画質</th>
132
133         </tr>
134     </thead>
135
136     <tbody>
137         <?php
138             /* テーブルのデータを出力 */
139             for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */
140                 echo("<tr>\n");
141                 /* pg_fetch_row で一行取り出す */
142                 $rowdata = pg_fetch_row($rs, $row);
143 $pid = htmlspecialchars($rowdata[9]);
144
145 $tid = htmlspecialchars($rowdata[0]);
146 $title = htmlspecialchars($rowdata[2]);
147 $subtitle = htmlspecialchars($rowdata[4]);
148 $dbepgaddedby = htmlspecialchars($rowdata[10]);
149
150 //重複検出
151 //開始時刻 $rowdata[5]
152 //終了時刻
153 $endtime = calcendtime($rowdata[5],$rowdata[6]);
154 //番組の開始時刻より遅い時刻に終了し、終了時刻より前にはじまる番組があるかどうか
155 //オンボードチューナー録画
156 $query = "
157 SELECT
158 foltia_program .tid,
159 stationname,
160 foltia_program .title,
161 foltia_subtitle.countno,
162 foltia_subtitle.subtitle,
163 foltia_subtitle.startdatetime ,
164 foltia_subtitle.lengthmin ,
165 foltia_tvrecord.bitrate  ,
166 foltia_subtitle.startoffset ,
167 foltia_subtitle.pid 
168 FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord
169 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
170 AND foltia_subtitle.enddatetime > '$rowdata[5]'
171 AND foltia_subtitle.startdatetime < '$endtime' 
172 UNION
173 SELECT
174 foltia_program .tid,
175 stationname,
176 foltia_program .title,
177 foltia_subtitle.countno,
178 foltia_subtitle.subtitle,
179 foltia_subtitle.startdatetime ,
180 foltia_subtitle.lengthmin ,
181 foltia_tvrecord.bitrate  ,
182 foltia_subtitle.startoffset ,
183 foltia_subtitle.pid 
184 FROM foltia_tvrecord
185 LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid )
186 LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid )
187 LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid )
188 WHERE foltia_tvrecord.stationid = 0 AND
189 foltia_subtitle.enddatetime > '$rowdata[5]' 
190 AND foltia_subtitle.startdatetime < '$endtime' 
191     ";
192     $rclass = "";
193     $overlap = m_query($con, $query, "DBクエリに失敗しました");
194     $overlapmaxrows = pg_num_rows($overlap);
195     if ($overlapmaxrows > ($recunits) ){
196         for ($rrow = 0; $rrow < $overlapmaxrows ; $rrow++) {
197             $owrowdata = pg_fetch_row($overlap, $rrow);
198             $overlappid[] = $owrowdata[9];
199         }
200     if (in_array($rowdata[9], $overlappid)) {
201         $rclass = "overwraped";
202     }
203     }else{
204     $overlappid = "";
205     }//end if
206
207 //外部チューナー録画
208 $externalinputs = 1; //現状一系統のみ
209 $query = "
210 SELECT
211 foltia_program .tid,
212 stationname,
213 foltia_program .title,
214 foltia_subtitle.countno,
215 foltia_subtitle.subtitle,
216 foltia_subtitle.startdatetime ,
217 foltia_subtitle.lengthmin ,
218 foltia_tvrecord.bitrate  ,
219 foltia_subtitle.startoffset ,
220 foltia_subtitle.pid 
221 FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord
222 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
223 AND foltia_subtitle.enddatetime > '$rowdata[5]'
224 AND foltia_subtitle.startdatetime < '$endtime' 
225 AND  (foltia_station.stationrecch = '0' OR  foltia_station.stationrecch = '-1' )
226 UNION
227 SELECT
228 foltia_program .tid,
229 stationname,
230 foltia_program .title,
231 foltia_subtitle.countno,
232 foltia_subtitle.subtitle,
233 foltia_subtitle.startdatetime ,
234 foltia_subtitle.lengthmin ,
235 foltia_tvrecord.bitrate  ,
236 foltia_subtitle.startoffset ,
237 foltia_subtitle.pid 
238 FROM foltia_tvrecord
239 LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid )
240 LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid )
241 LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid )
242 WHERE foltia_tvrecord.stationid = 0 AND
243 foltia_subtitle.enddatetime > '$rowdata[5]' 
244 AND foltia_subtitle.startdatetime < '$endtime' 
245 AND  (foltia_station.stationrecch = '0' OR  foltia_station.stationrecch = '-1' )
246
247     ";
248     $eoverlap = m_query($con, $query, "DBクエリに失敗しました");
249     $eoverlapmaxrows = pg_num_rows($eoverlap);
250     if ($eoverlapmaxrows > ($externalinputs) ){
251         for ($erow = 0; $erow < $eoverlapmaxrows ; $erow++) {
252             $eowrowdata = pg_fetch_row($eoverlap, $erow);
253             $eoverlappid[] = $eowrowdata[9];
254         }
255
256         if (in_array($rowdata[9], $eoverlappid)) {
257             $rclass = "exoverwraped";
258         }
259     }else{
260     $eoverlappid = "";
261     }
262                 echo("<tr class=\"$rclass\">\n");
263                     // TID
264                     print "<td>";
265                     if ($tid == 0 ){
266                     print "$tid";
267                     }else{
268                     print "<a href=\"reserveprogram.php?tid=$tid\">$tid</a>";
269                     }
270                     print "</td>\n";
271                      // 放映局
272                      echo("<td>".htmlspecialchars($rowdata[1])."<br></td>\n");
273                      // タイトル
274                     print "<td>";
275                     if ($tid == 0 ){
276                     print "$title";
277                     }else{
278                     print "<a href=\"http://cal.syoboi.jp/tid/$tid\" target=\"_blank\">$title</a>";
279                     }
280                     print "</td>\n";
281                      // 話数
282                     echo("<td>".htmlspecialchars($rowdata[3])."<br></td>\n");
283                     // サブタイ
284                     if ($pid > 0 ){
285                     print "<td><a href=\"http://cal.syoboi.jp/tid/$tid/time#$pid\" target=\"_blank\">$subtitle<br></td>\n";
286                     }else{
287                     //if ( $userclass <= 2){
288                     if (($mymemberid == $dbepgaddedby)||($userclass <= 1)){
289                         if ($userclass <= 1 ){//管理者なら
290                             $membername = getmemberid2name($con,$dbepgaddedby);
291                             $membername = ":" . $membername ;
292                         }else{
293                         $membername = "";
294                         }
295                     print "<td>$subtitle [<a href=\"delepgp.php?pid=$pid\">予約解除</a>$membername]<br></td>\n";
296                     }else{
297                     print "<td>$subtitle [解除不能]<br></td>\n";
298                     }
299                     }
300                     // 開始時刻(ズレ)
301                     echo("<td>".htmlspecialchars(foldate2print($rowdata[5]))."<br>(".htmlspecialchars($rowdata[8]).")</td>\n");
302                     // 総尺
303                     echo("<td>".htmlspecialchars($rowdata[6])."<br></td>\n");
304                     
305                     //録画レート
306                     echo("<td>".htmlspecialchars($rowdata[7])."<br></td>\n");
307                 echo("</tr>\n");
308             }
309         ?>
310     </tbody>
311 </table>
312
313
314 <table>
315     <tr><td>エンコーダ数</td><td><?=$recunits ?></td></tr>
316     <tr class="overwraped"><td>チューナー重複</td><td><br /></td></tr>
317     <tr class="exoverwraped"><td>外部入力重複</td><td><br /></td></tr>
318 </table>
319
320
321 <?php
322 } //if ($maxrows == 0) {
323
324
325     $query = "
326 SELECT
327 foltia_program.tid,
328 stationname,
329 foltia_program .title ,
330 foltia_tvrecord.bitrate ,
331 foltia_tvrecord.stationid 
332 FROM  foltia_tvrecord , foltia_program , foltia_station
333 WHERE foltia_tvrecord.tid = foltia_program.tid  AND foltia_tvrecord.stationid = foltia_station .stationid   
334 ORDER BY foltia_program.tid  DESC
335 ";
336     $rs = m_query($con, $query, "DBクエリに失敗しました");
337     $maxrows = pg_num_rows($rs);
338             
339         if ($maxrows == 0) {
340 //なければなにもしない
341             
342         }else{
343         $maxcols = pg_num_fields($rs);
344
345 ?>
346 <p align="left">録画予約番組タイトルを表示します。</p>
347   <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%">
348     <thead>
349         <tr>
350             <th align="left">予約解除</th>
351             <th align="left">TID</th>
352             <th align="left">放映局</th>
353             <th align="left">タイトル</th>
354             <th align="left">録画リスト</th>
355             <th align="left">画質</th>
356         </tr>
357     </thead>
358
359     <tbody>
360         <?php
361             /* テーブルのデータを出力 */
362             for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */
363                 /* pg_fetch_row で一行取り出す */
364                 $rowdata = pg_fetch_row($rs, $row);
365
366                 $tid = htmlspecialchars($rowdata[0]);
367                 
368                 if ($tid > 0){
369                 echo("<tr>\n");
370                 //予約解除
371                 if ( $userclass <= 1){
372                     echo("<td><a href=\"delreserve.php?tid=$tid&sid=" .
373                     htmlspecialchars($rowdata[4])  . "\">解除</a></td>\n");
374                 }else{
375                 echo("<td>−</td>");       
376                 }
377                 //TID
378                     echo("<td><a href=\"reserveprogram.php?tid=$tid\">$tid</a></td>\n");
379                      //放映局
380                      echo("<td>".htmlspecialchars($rowdata[1])."<br></td>\n");
381                      //タイトル
382                      echo("<td><a href=\"http://cal.syoboi.jp/tid/$tid\" target=\"_blank\">" .
383                      htmlspecialchars($rowdata[2]) . "</a></td>\n");
384
385                     //MP4
386                     echo("<td><a href=\"showlibc.php?tid=$tid\">mp4</a></td>\n");
387
388                     echo("<td>".htmlspecialchars($rowdata[3])."<br></td>\n");
389     
390                 echo("</tr>\n");
391                 }else{
392                 print "<tr>
393                 <td>−</td><td>0</td>
394                 <td>[全局]<br></td>
395                 <td>EPG録画</td>
396                 <td><a href=\"showlibc.php?tid=0\">mp4</a></td>";
397                 echo("<td>".htmlspecialchars($rowdata[3])."<br></td>\n</tr>");
398                 }//if tid 0
399             }//for
400         }//else
401         ?>
402     </tbody>
403 </table>
404
405
406 </body>
407 </html>
408
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed