-
Notifications
You must be signed in to change notification settings - Fork 8
/
rss.class.php
74 lines (69 loc) · 2.82 KB
/
rss.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/* CRss âåðñèÿ 1.0 îò 02.01.2007
* êëàññ äëÿ ñîçäàíèÿ êàíàëîâ íîâîñòåé RSS
* http://www.caseclub.ru
* èñïîëüçóéòå áåç îãðàíè÷åíèé
*/
class CRss
{
var $Title; // çàãîëîâîê êàíàëà
var $Link; // ññûëêà íà ãëàâíóþ ñòðàíèöó
var $Copyright; // êîïèðàéò
var $Description; // îïèñàíèå êàíàëà
var $LastBuildDate; // äàòà ïîñëåäíåãî äîêóìåíòà (ïî óìîë÷àíèþ òåêóùàÿ)
var $Language; // ÿçûê
var $PubDate; // äàòà ïóáëèêàöèè
var $ManagingEditor; // E-mail ðåäàêòîðà
var $WebMaster; // E-mail webmaster
var $Category; // êàòåãîðèÿ
var $Query; // ñîäåðæèìîå çàïðîñà
var $Connect; // äëÿ ñîåäèíåíèÿ ñ áàçîé äàííûõ
var $Result; // äëÿ õðàíåíèÿ ðåçóëüòàòà
function Translate($text) // êîäèðóåì äëÿ âûâîäà
{
$trans = array("<" => "<", ">" => ">",'"' => ""","&" => "&");
$text=strtr($text,$trans);
$array=explode("<br>",$text);
$count=count($array);
return $text;
}
function PrintHeader() // ïå÷àòü çàãîëîâêà
{
header("Content-Type: application/xml "); // ñðàçó ãîâîðèì, ÷òî ýòî ôîðìàò XML
$End="?";
$Date=date("r"); // äàòà â ôîðìàòå Mon, 25 Dec 2006 10:23:37 +0400
print "<$End";
print "xml version=\"1.0\" encoding=\"windows-1251\" $End> \r\n";
print "<rss version=\"2.0\">\r\n";
print " <channel>\r\n";
print " <title>$this->Title</title>\r\n";
print " <category>$this->Category</category>\r\n";
print " <link>$this->Link</link>\r\n";
print " <copyright>$this->Copyright</copyright>\r\n";
print " <description>$this->Description</description>\r\n";
print " <lastBuildDate>$this->LastBuildDate</lastBuildDate>\r\n";
print " <language>$this->Language</language>\r\n";
print " <pubDate>$this->PubDate</pubDate>\r\n";
print " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\r\n";
print " <managingEditor>$this->ManagingEditor</managingEditor>\r\n";
print " <webMaster>$this->WebMaster</webMaster>\r\n";
}
function PrintBody($Title,$Link,$Description,$Category,$PubDate) // ïå÷àòü òåëà
{
$Description = $this->Translate($Description);
print " <item>\r\n";
print " <title>".$Title."</title>\r\n";
print " <link>".$Link."</link>\r\n";
print " <description><![CDATA[".$Description."]]></description>\r\n";
print " <category>".$Category."</category>\r\n";
print " <pubDate>".$PubDate."</pubDate>\r\n";
print " <guid>".$Link."#".$PubDate."</guid>\r\n";
print " </item>\r\n";
}
function PrintFooter() // ïå÷àòü çàãîëîâêà
{
print " </channel>\r\n";
print "</rss>\r\n";
}
}
?>