root/trunk/install/php/folcast.php

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

SQLite採用

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\" LIKE '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 = ?   
62 ";
63 //    $titlers = m_query($con, $query, "DBクエリに失敗しました");
64     $titlers = sql_query($con, $query, "DBクエリに失敗しました",array($tid));
65     $rowdata = $titlers->fetch();
66     $rsstitle = $rowdata[1];
67 }else{
68
69 $query = "
70 SELECT  foltia_program.tid,foltia_program.title,
71 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\" LIKE 'M%%'  AND foltia_program.tid = foltia_subtitle.tid ORDER BY \"enddatetime\" DESC
72 offset 0 limit  ?
73     ";
74     $rsstitle = "新規録画";
75 }//if
76
77 $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
78 <rss xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" version=\"2.0\">
79     <channel>
80         <title>$rsstitle:Folcast</title>
81         <itunes:author>DCC-JPL Japan/foltia project</itunes:author>
82         <link>http://www.dcc-jpl.com/soft/foltia/</link>
83         <description>フォルティアが未読処理をお助けしちゃいます</description>
84         <itunes:subtitle>foltia video podcast :$rsstitle:Folcast</itunes:subtitle>
85         <itunes:summary>フォルティアが未読処理をお助けしちゃいます</itunes:summary>
86         <language>ja</language>
87         <copyright>foltia</copyright>
88         <itunes:owner>
89             <itunes:name>$rsstitle:Folcast</itunes:name>
90             <itunes:email>foltia@dcc-jpl.com</itunes:email>
91         </itunes:owner>         
92         <category>Technology</category>
93         <itunes:category text=\"Technology\"></itunes:category>
94
95 ";
96 $header = mb_convert_encoding($header,"UTF-8", "EUC-JP");
97 print $header;
98
99 //    $rs = m_query($con, $query, "DBクエリに失敗しました");
100     $rs = sql_query($con, $query, "DBクエリに失敗しました",array($max));
101 $rowdata = $rs->fetch();
102
103 if (! $rowdata) {
104                 //die_exit("No items");   
105 }else{
106     do {
107 //$title = mb_convert_encoding($rowdata[1],"UTF-8", "EUC-JP");
108 $tid $rowdata[0];
109 $title = $rowdata[1];
110 $title = htmlspecialchars($title);
111 $countno = $rowdata[2];
112 if ($countno > 0 ){
113     $countprint = "第".$countno."回";
114 }else{
115     $countprint="";
116 }
117 $subtitle = $rowdata[3];
118 $subtitle = htmlspecialchars($subtitle);
119 $onairdate = $rowdata[4];
120 $day = substr($onairdate,0,4)."/".substr($onairdate,4,2)."/".substr($onairdate,6,2);
121 $time = substr($onairdate,8,2).":".substr($onairdate,10,2);
122 $onairdate = "$day $time";
123
124 $starttimerfc822 = foldate2rfc822($rowdata[4]);
125
126 $mp4filename = $rowdata[5];
127 $mp4uri = "http://". getserverfqdn()  .$httpmediamappath ."/$tid.localized/mp4/$mp4filename";
128 $mp4thmname = $rowdata[5];
129 $mp4thmname = ereg_replace(".MP4", ".THM", $mp4thmname);
130 $mp4thmnameuri = "http://". getserverfqdn() . $httpmediamappath ."/$tid.localized/mp4/$mp4thmname";
131
132 if (file_exists("$recfolderpath/$tid.localized/mp4/$mp4filename")) {
133     $mp4filestat = stat("$recfolderpath/$tid.localized/mp4/$mp4filename");
134     $mp4filesize = $mp4filestat[7];
135 } else {
136     $mp4filesize = 0;
137 }
138
139 if ($rowdata[0] == 0 ){//EPG録画
140     $showntitle = "$title $subtitle";
141 }else{
142     $showntitle = "$title $countprint";
143 }
144
145
146 $item ="    <item>
147           <title>$showntitle</title>
148           <itunes:author>foltia</itunes:author>
149           <description>$title $countprint $subtitle</description>
150           <itunes:subtitle>$title $countprint $subtitle</itunes:subtitle>
151           <itunes:summary>$title $countprint $subtitle</itunes:summary>
152           <enclosure url=\"$mp4uri\" length=\"$mp4filesize\" type=\"video/mov\" />
153           <guid isPermaLink=\"true\">$mp4thmnameuri</guid>
154           <pubDate>$starttimerfc822</pubDate>
155           <itunes:explicit>no</itunes:explicit>
156           <itunes:keywords>foltia,Folcast,DCC-JPL Japan,$title,$subtitle</itunes:keywords> 
157           <itunes:image href=\"$mp4thmnameuri\" />
158         </item>
159 ";
160
161 $item = mb_convert_encoding($item,"UTF-8", "EUC-JP");
162 print $item ;
163
164     } while ($rowdata = $rs->fetch()); //do
165
166 }//if
167         ?>
168    
169     </channel>
170 </rss>
171
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed