root/trunk/install/php/folcast.php

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

環境ポリシー機能搭載

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 header('Content-Disposition: attachment; filename="folcast.xml"');
23
24 include("./foltialib.php");
25 $con = m_connect();
26 /*
27 if ($useenvironmentpolicy == 1){
28     if (!isset($_SERVER['PHP_AUTH_USER'])) {
29         header("WWW-Authenticate: Basic realm=\"foltia\"");
30         header("HTTP/1.0 401 Unauthorized");
31         redirectlogin();
32         exit;
33     } else {
34     login($con,$_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']);
35     }
36 }//end if login
37 */
38 $now = date("YmdHi");   
39 $nowrfc822 date("r");
40
41 $max = getgetnumform(max);
42
43 if ($max > 0 ){
44     //件数指定があればなにもしない
45 }else{
46     $max = 45;
47 }
48 $tid = getgetnumform(tid);
49 if (($tid >= 0 ) && ($tid != "")){
50
51 $query = "
52 SELECT  foltia_program.tid,foltia_program.title,
53 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   
54 ORDER BY \"enddatetime\" DESC
55 offset 0 limit  $max
56     ";
57
58 $titlequery = "
59 SELECT  foltia_program.tid,foltia_program.title
60 FROM  foltia_program   
61 WHERE foltia_program.tid = $tid   
62 ";
63     $titlers = m_query($con, $query, "DBクエリに失敗しました");
64     $rowdata = pg_fetch_row($titlers, 0);
65     $rsstitle = $rowdata[1];
66 }else{
67
68 $query = "
69 SELECT  foltia_program.tid,foltia_program.title,
70 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
71 offset 0 limit  $max
72     ";
73     $rsstitle = "新規録画";
74 }//if
75
76 $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
77 <rss xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" version=\"2.0\">
78     <channel>
79         <title>$rsstitle:Folcast</title>
80         <itunes:author>DCC-JPL Japan/foltia project</itunes:author>
81         <link>http://www.dcc-jpl.com/soft/foltia/</link>
82         <description>フォルティアが未読処理をお助けしちゃいます</description>
83         <itunes:subtitle>foltia video podcast :$rsstitle:Folcast</itunes:subtitle>
84         <itunes:summary>フォルティアが未読処理をお助けしちゃいます</itunes:summary>
85         <language>ja</language>
86         <copyright>foltia</copyright>
87         <itunes:owner>
88             <itunes:name>$rsstitle:Folcast</itunes:name>
89             <itunes:email>foltia@dcc-jpl.com</itunes:email>
90         </itunes:owner>         
91         <category>Technology</category>
92         <itunes:category text=\"Technology\"></itunes:category>
93
94 ";
95 $header = mb_convert_encoding($header,"UTF-8", "EUC-JP");
96 print $header;
97
98     $rs = m_query($con, $query, "DBクエリに失敗しました");
99     $maxrows = pg_num_rows($rs);
100
101 if ($maxrows == 0) {
102                 //die_exit("No items");   
103 }else{
104
105 for ($row = 0; $row < $maxrows; $row++) {
106         $rowdata = pg_fetch_row($rs, $row);
107         
108 //$title = mb_convert_encoding($rowdata[1],"UTF-8", "EUC-JP");
109 $tid $rowdata[0];
110 $title = $rowdata[1];
111 $title = htmlspecialchars($title);
112 $countno = $rowdata[2];
113 if ($countno > 0 ){
114     $countprint = "第".$countno."回";
115 }else{
116     $countprint="";
117 }
118 $subtitle = $rowdata[3];
119 $subtitle = htmlspecialchars($subtitle);
120 $onairdate = $rowdata[4];
121 $day = substr($onairdate,0,4)."/".substr($onairdate,4,2)."/".substr($onairdate,6,2);
122 $time = substr($onairdate,8,2).":".substr($onairdate,10,2);
123 $onairdate = "$day $time";
124
125 $starttimerfc822 = foldate2rfc822($rowdata[4]);
126
127 $mp4filename = $rowdata[5];
128 $mp4uri = "http://". getserverfqdn()  .$httpmediamappath ."/$tid.localized/mp4/$mp4filename";
129 $mp4thmname = $rowdata[5];
130 $mp4thmname = ereg_replace(".MP4", ".THM", $mp4thmname);
131 $mp4thmnameuri = "http://". getserverfqdn() . $httpmediamappath ."/$tid.localized/mp4/$mp4thmname";
132
133 if (file_exists("$recfolderpath/$tid.localized/mp4/$mp4filename")) {
134     $mp4filestat = stat("$recfolderpath/$tid.localized/mp4/$mp4filename");
135     $mp4filesize = $mp4filestat[7];
136 } else {
137     $mp4filesize = 0;
138 }
139
140 if ($rowdata[0] == 0 ){//EPG録画
141     $showntitle = "$title $subtitle";
142 }else{
143     $showntitle = "$title $countprint";
144 }
145
146
147 $item ="    <item>
148           <title>$showntitle</title>
149           <itunes:author>foltia</itunes:author>
150           <description>$title $countprint $subtitle</description>
151           <itunes:subtitle>$title $countprint $subtitle</itunes:subtitle>
152           <itunes:summary>$title $countprint $subtitle</itunes:summary>
153           <enclosure url=\"$mp4uri\" length=\"$mp4filesize\" type=\"video/mov\" />
154           <guid isPermaLink=\"true\">$mp4thmnameuri</guid>
155           <pubDate>$starttimerfc822</pubDate>
156           <itunes:explicit>no</itunes:explicit>
157           <itunes:keywords>foltia,Folcast,DCC-JPL Japan,$title,$subtitle</itunes:keywords> 
158           <itunes:image href=\"$mp4thmnameuri\" />
159         </item>
160 ";
161
162 $item = mb_convert_encoding($item,"UTF-8", "EUC-JP");
163 print $item ;
164
165 }//for
166
167 }//if
168         ?>
169    
170     </channel>
171 </rss>
172
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed