root/trunk/install/php/listreserve.php

リビジョン 94, 13.2 kB (コミッタ: sorshi, コミット時期: 14 年 前)

SQLite採用

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