root/trunk/install/php/folcast.php

リビジョン 8, 4.8 kB (コミッタ: sorshi, コミット時期: 19 年 前)

新エンコーダによりH.264対応、
複数同時録画時の信頼性向上、など

Line 
1 <?php
2 /*
3  Anime recording system foltia
4  http://www.dcc-jpl.com/soft/foltia/
5
6 folcast.php
7
8 目的
9 foltia video podcast(folcast)用RSSを出力します。
10
11 オプション
12 tid:タイトルID
13  省略時は新規録画全部
14 max:表示上限
15  省略時は45件
16
17  DCC-JPL Japan/foltia project
18
19 */
20
21 header('Content-Type: application/rss+xml');
22
23
24   include("./foltialib.php");
25 $con = m_connect();
26
27 $now = date("YmdHi");   
28 $nowrfc822 date("r");
29
30 $max = getgetnumform(max);
31
32 if ($max > 0 ){
33     //件数指定があればなにもしない
34 }else{
35     $max = 45;
36 }
37 $tid = getgetnumform(tid);
38 if (($tid >= 0 ) && ($tid != "")){
39
40 $query = "
41 SELECT  foltia_program.tid,foltia_program.title,
42 foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime   FROM foltia_subtitle , foltia_program   WHERE \"pspfilename\" ~~ 'M%%'  AND foltia_program.tid = foltia_subtitle.tid AND foltia_program.tid = $tid   
43 ORDER BY \"enddatetime\" DESC
44 offset 0 limit  $max
45     ";
46
47 $titlequery = "
48 SELECT  foltia_program.tid,foltia_program.title
49 FROM  foltia_program   
50 WHERE foltia_program.tid = $tid   
51 ";
52     $titlers = m_query($con, $query, "DBクエリに失敗しました");
53     $rowdata = pg_fetch_row($titlers, 0);
54     $rsstitle = $rowdata[1];
55 }else{
56
57 $query = "
58 SELECT  foltia_program.tid,foltia_program.title,
59 foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime   FROM foltia_subtitle , foltia_program   WHERE \"pspfilename\" ~~ 'M%%'  AND foltia_program.tid = foltia_subtitle.tid ORDER BY \"enddatetime\" DESC
60 offset 0 limit  $max
61     ";
62     $rsstitle = "新規録画";
63 }//if
64
65 $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
66 <rss xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" version=\"2.0\">
67     <channel>
68         <title>Folcast ($rsstitle)</title>
69         <itunes:author>DCC-JPL Japan/foltia project</itunes:author>
70         <link>http://www.dcc-jpl.com/soft/foltia/</link>
71         <description>フォルティアが未読処理をお助けしちゃいます</description>
72         <itunes:subtitle>foltia video podcast :Folcast ($rsstitle)</itunes:subtitle>
73         <itunes:summary>フォルティアが未読処理をお助けしちゃいます</itunes:summary>
74         <language>ja</language>
75         <copyright>foltia</copyright>
76         <itunes:owner>
77             <itunes:name>Folcast ($rsstitle)</itunes:name>
78             <itunes:email>foltia@dcc-jpl.com</itunes:email>
79         </itunes:owner>         
80         <category>Technology</category>
81         <itunes:category text=\"Technology\"></itunes:category>
82
83 ";
84 $header = mb_convert_encoding($header,"UTF-8", "EUC-JP");
85 print $header;
86
87     $rs = m_query($con, $query, "DBクエリに失敗しました");
88     $maxrows = pg_num_rows($rs);
89
90 if ($maxrows == 0) {
91                 //die_exit("No items");   
92 }else{
93
94 for ($row = 0; $row < $maxrows; $row++) {
95         $rowdata = pg_fetch_row($rs, $row);
96         
97 //$title = mb_convert_encoding($rowdata[1],"UTF-8", "EUC-JP");
98 $tid $rowdata[0];
99 $title = $rowdata[1];
100 $title = htmlspecialchars($title);
101 $countno = $rowdata[2];
102 if ($countno > 0 ){
103     $countprint = "第".$countno."回";
104 }else{
105     $countprint="";
106 }
107 $subtitle = $rowdata[3];
108 $subtitle = htmlspecialchars($subtitle);
109 $onairdate = $rowdata[4];
110 $day = substr($onairdate,0,4)."/".substr($onairdate,4,2)."/".substr($onairdate,6,2);
111 $time = substr($onairdate,8,2).":".substr($onairdate,10,2);
112 $onairdate = "$day $time";
113
114 $starttimerfc822 = foldate2rfc822($rowdata[4]);
115
116 $mp4filename = $rowdata[5];
117 $mp4uri = "http://". getserverfqdn()  .$httpmediamappath ."/$tid.localized/mp4/$mp4filename";
118 $mp4thmname = $rowdata[5];
119 $mp4thmname = ereg_replace(".MP4", ".THM", $mp4thmname);
120 $mp4thmnameuri = "http://". getserverfqdn() . $httpmediamappath ."/$tid.localized/mp4/$mp4thmname";
121
122 if (file_exists("$recfolderpath/$tid.localized/mp4/$mp4filename")) {
123     $mp4filestat = stat("$recfolderpath/$tid.localized/mp4/$mp4filename");
124     $mp4filesize = $mp4filestat[7];
125 } else {
126     $mp4filesize = 0;
127 }
128
129 if ($rowdata[0] == 0 ){//EPG録画
130     $showntitle = "$title $subtitle";
131 }else{
132     $showntitle = "$title $countprint";
133 }
134
135
136 $item ="    <item>
137           <title>$showntitle</title>
138           <itunes:author>foltia</itunes:author>
139           <description>$title $countprint $subtitle</description>
140           <itunes:subtitle>$title $countprint $subtitle</itunes:subtitle>
141           <itunes:summary>$title $countprint $subtitle</itunes:summary>
142           <enclosure url=\"$mp4uri\" length=\"$mp4filesize\" type=\"video/mov\" />
143           <guid isPermaLink=\"true\">$mp4thmnameuri</guid>
144           <pubDate>$starttimerfc822</pubDate>
145           <itunes:explicit>no</itunes:explicit>
146           <itunes:keywords>foltia,Folcast,DCC-JPL Japan,$title,$subtitle</itunes:keywords> 
147           <itunes:image href=\"$mp4thmnameuri\" />
148         </item>
149 ";
150
151 $item = mb_convert_encoding($item,"UTF-8", "EUC-JP");
152 print $item ;
153
154 }//for
155
156 }//if
157         ?>
158    
159     </channel>
160 </rss>
161 tmlspecialchars(pg_field_name($rs, $col));
162                     echo("<th abbr=\"$f_name\">$f_name</th>\n");
163                 }
164             ?>
165         </tr>
166     </thead>
167     <tbody>
168         <?php
169             /* テーブルのデータを出力 */
170             for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */
171                 echo("<tr>\n");
172                 /* pg_fetch_row で一行取り出す */
173                 $rowdata = pg_fetch_row($rs, $row);
174                 /* 1列目にリンクを張る */
175                 echo("<td><a href=\"edit.php?q_code=" .
176                      urlencode($rowdata[0]) . "\">" .
177                      htmlspecialchars($rowdata[1]) . "</a></td>\n");
178                 for ($col = 2; $col < $maxcols; $col++) { /* 列に対応 */
179                     echo("<td>".htmlspecialchars($rowdata[$col])."<br></td>\n");
180                 }
181                 echo("</tr>\n");
182             }
183         ?>
184     </tbody>
185 </table>
186         <?php
187         return $maxrows;
188     }
189
190     /* 指定したコードのデータを表示 */
191     function m_viewdata($con, $code) {
192         /* コードに該当するデータを検索 */
193         $query = "
194 select p.code
195       ,p.name
196       ,p.email
197       ,p.pseudonym
198       ,s.name as job
199       ,p.profile
200       ,to_char(p.editdate, 'YYYY/MM/DD HH24:MI:SS') as editdate
201   from inet_profile p left join inet_job s on p.job = s.code
202  where p.code = $code";
203         $rs = m_query($con, $query, "個人情報の取得に失敗しました。");
204         if (pg_num_rows($rs) == 0) {
205             echo("<p class=\"msg\">データが存在しません</p>\n");
206             return FALSE;
207         }
208         
209         /* フィールド数 */
210         $maxcols = pg_num_fields($rs);
211         /* 先頭行 */
212         $rowdata = pg_fetch_row($rs, 0);
213         ?>
214 <table class="view" summary="データベース上のデータを表示" border="1">
215     <tr>
216         <td class="name"><?= htmlspecialchars(pg_field_name($rs, 1)) ?></td>
217         <td><a href="edit.php?q_code=<?= $rowdata[0] ?>"
218              ><?= htmlspecialchars($rowdata[1]) ?></a></td>
219     </tr>
220     <?php for ($col = 2; $col < $maxcols; $col++) { ?>
221     <tr>
222         <td class="name"><?= htmlspecialchars(pg_field_name($rs, $col)) ?></td>
223         <td><?= htmlspecialchars($rowdata[$col]) ?></td>
224     </tr>
225     <?php } ?>
226 </table>
227         <?php
228         /* クエリーを解放 */
229         pg_free_result($rs);
230         
231         return TRUE;
232     }
233     
234
235 function printhtmlpageheader(){
236
237 $serveruri = getserveruri();
238
239 print "<p align='left'><font color='#494949'><A HREF = 'http://www.dcc-jpl.com/soft/foltia/' target=\"_blank\">foltia</A> | <A HREF = './index.php'>放映予定</A> | <A HREF = './index.php?mode=new'>新番組</A> | <A HREF = './listreserve.php'>予約一覧</A> | <A HREF = './titlelist.php'>番組一覧</A> | <A HREF = './viewepg.php'>番組表</A> | 録画一覧(<A HREF = './showplaylist.php'>録画順</A>・<A HREF = './showplaylist.php?list=title'>番組順</A>・<A HREF = './showplaylist.php?list=raw'>全</A>) | <A HREF = './showlib.php'>録画ライブラリ</A> |  <A HREF = './folcast.php'>Folcast(RSS)</A>[<a href=\"itpc://$serveruri/folcast.php\">iTunesにFolcastを登録</a>] |</font></p>\n";
240
241 }
242
243
244 function renderepgstation($con,$stationname,$start){ //戻り値 なし EPGの局表示
245
246 $now = date("YmdHi");
247 $today = date("Ymd");   
248 $tomorrow = date ("Ymd",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y")));
249 //$today = "20051013";   
250 //$tomorrow = "20051014";
251 //$epgstart = $today . "2000";
252 $epgstart = $start ;
253 //$epgend = $tomorrow . "0400";
254 $epgend = calcendtime($start , (8*60));
255 $query = "
256 SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory  ,ontvchannel  ,epgid
257 FROM foltia_epg
258 WHERE foltia_epg.ontvchannel = '$stationname' AND
259 enddatetime  > $epgstart  AND
260 startdatetime  < $epgend 
261 ORDER BY foltia_epg.startdatetime  ASC
262     ";
263     $rs = m_query($con, $query, "DBクエリに失敗しました");
264     $maxrows = pg_num_rows($rs);
265 if ($maxrows == 0) {
266         print("番組データがありません<BR>");           
267 }else{
268 print "<table width=\"100%\"  border=\"0\">\n";
269 //print "<ul><!-- ($maxrows) $query -->\n";
270
271 for ($row = 0; $row < $maxrows; $row++) {
272     
273 $rowdata = pg_fetch_row($rs, $row);
274
275 $printstarttime = substr($rowdata[0],8,2) . ":" substr($rowdata[0],10,2);
276 $tdclass = "t".substr($rowdata[0],8,2) .  substr($rowdata[0],10,2);
277 $title = htmlspecialchars($rowdata[3]);
278 $title = z2h($title);
279 $desc = htmlspecialchars($rowdata[4]);
280 $desc = z2h($desc);
281 $height htmlspecialchars($rowdata[2]) * 3;
282 $epgid htmlspecialchars($rowdata[7]);
283
284 print"
285       <tr>
286         <td height = \"$height\" >$printstarttime  <A HREF=\"./reserveepg.php?epgid=$epgid\">$title</A> $desc <!-- $rowdata[0] - $rowdata[1] --></td>
287       </tr>
288 ";
289 /*print"<li style=\"height:" . $height ."px;\" class=\"$tdclass\">
290 $printstarttime  <A HREF=\"./reserveepg.php?epgid=$epgid\">$title</A> $desc($rowdata[0] - $rowdata[1])
291 </li>\n";
292 */
293 }//for
294 //print "</ul>\n";
295 print "</table>\n";
296
297 }//if
298 }//end function
299
300 function calcendtime($start,$lengthmin){//戻り値 終了時刻(Ex:200510170130)
301 $startyear =   substr($start,0,4);
302 $startmonth =   substr($start,4,2);
303 $startday =   substr($start,6,2);
304 $starthour =   substr($start,8,2);
305 $startmin =   substr($start,10,2);
306 //int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )
307 $endtime = date ("YmdHi",mktime($starthour  , $startmin + $lengthmin , 0, $startmonth  , $startday, $startyear));
308
309 return ($endtime );
310 }//end function
311
312
313 function z2h($string){ //戻り値 半角化した文字
314     $stringh = mb_convert_kana($string, "a", "EUC-JP");
315  return ($stringh );
316 }
317
318 function foldate2rfc822($start){//戻り値 RFC822スタイルの時刻表記
319     $startyear =   substr($start,0,4);
320     $startmonth =   substr($start,4,2);
321     $startday =   substr($start,6,2);
322     $starthour =   substr($start,8,2);
323     $startmin =   substr($start,10,2);
324
325     $rfc822 = date ("r",mktime($starthour  , $startmin , 0, $startmonth  , $startday, $startyear));
326     
327     return ($rfc822);
328 }//end sub
329
330 function foldate2print($start){//戻り値 日本語風時刻表記
331     $startyear =   substr($start,0,4);
332     $startmonth =   substr($start,4,2);
333     $startday =   substr($start,6,2);
334     $starthour =   substr($start,8,2);
335     $startmin =   substr($start,10,2);
336
337     $printabledate = date ("Y/m/d H:i",mktime($starthour  , $startmin , 0, $startmonth  , $startday, $startyear));   
338     return ($printabledate);
339 }//end sub
340
341 function getserveruri(){//戻り値 サーバアドレス Ex.www.dcc-jpl.com:8800/soft/foltia/
342
343 //リンクURI組み立て
344 $sv6 = $_SERVER['SCRIPT_NAME'];///dameNews/sarasorjyu/archives.php
345 $sv8 = $_SERVER['SERVER_NAME'];//sync.dcc-jpl.com
346 $sv9 = $_SERVER['SERVER_PORT'];
347 if ($sv9 == 80){
348     $port = "";
349 }else{
350     $port = ":$sv9";
351 }
352 $a = split("/", $sv6);
353 array_pop($a);
354
355 $scriptpath = implode("/", $a);
356
357 $serveruri = "$sv8$port$scriptpath";
358 return ($serveruri );
359 }//end sub
360
361
362 function getserverfqdn(){//戻り値 サーバアドレス Ex.www.dcc-jpl.com:8800
363
364 //リンクURI組み立て
365 $sv6 = $_SERVER['SCRIPT_NAME'];///dameNews/sarasorjyu/archives.php
366 $sv8 = $_SERVER['SERVER_NAME'];//sync.dcc-jpl.com
367 $sv9 = $_SERVER['SERVER_PORT'];
368 if ($sv9 == 80){
369     $port = "";
370 }else{
371     $port = ":$sv9";
372 }
373 $a = split("/", $sv6);
374 array_pop($a);
375
376 $scriptpath = implode("/", $a);
377
378 $serveruri = "$sv8$port";
379 return ($serveruri );
380 }//end sub
381
382
383 function printdiskusage(){//戻り値 なし
384
385 global $recfolderpath,$recfolderpath;
386
387     exec ( "df -h  $recfolderpath | grep $recfolderpath", $hdfreearea);
388     $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]);
389
390     exec ( "ps ax | grep ffmpeg", $encoding);
391     exec ( "ps ax | grep faac", $processlock);
392
393 print "
394 <div style=\"width:100%;border:1px solid black;text-align:left;\"><span style=\"float:right;\">$freearea[3]</span>
395 <div style=\"width:$freearea[4];border:1px solid black;background:white;\">$freearea[2]/$freearea[1]($freearea[4])</div>
396 </div>
397 ";
398
399 //    print "$freearea[1]<br>$freearea[2]<br>$freearea[3]<br>$freearea[4]<br>$hdfreearea[0]<br>$encoding[0]<br>$processlock[0]</p>\n";
400     print "$encoding[0]<br>$processlock[0]</p>\n";
401
402 /*
403 <div style="width:100%;border:1px solid black;text-align:left;"><span style="float:right;">170GB</span>
404 <div style="width:86%;border:1px solid black;background:white;">1.1TB/1.3TB(87%)</div>
405 </div>
406 */
407
408 }//end sub
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451 ?>
452
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed