Вход Регистрация
Файл: rss.php
Строк: 84
<?php
// mod Gemorroj


header('Content-Type: application/rss+xml; charset=UTF-8');

require 
'moduls/config.php';
define('DIRECTORY', str_replace(array('\', '//'), '/', dirname($_SERVER['PHP_SELF']) . '/'));

$link = 'http://' . $_SERVER['HTTP_HOST'] . DIRECTORY . 'news.php';

class 
rss2 extends DOMDocument
{
    private 
$channel;

    public function 
__construct($title, $link, $description)
    {
        
parent::__construct();
        
$this->formatOutput = true;

        
$this->encoding = 'UTF-8';
        
$root = $this->appendChild($this->createElement('rss'));
        
$root->setAttribute('version', '0.92');

        
$channel = $root->appendChild($this->createElement('channel'));

        
$channel->appendChild($this->createElement('title', $title));
        
$channel->appendChild($this->createElement('link', $link));
        
$channel->appendChild($this->createElement('description', $description));

        
$this->channel = $channel;
    }

    public function 
addItem($title, $link, $description)
    {
        
$item = $this->createElement('item');
        
$item->appendChild($this->createElement('title', $title));
        
$item->appendChild($this->createElement('link', $link));
        
$item->appendChild($this->createElement('description', $description));
        
$this->channel->appendChild($item);
    }
}


$rss = new rss2($_SESSION['language']['news'], $link, $_SESSION['language']['news']);

if (
$_SESSION['langpack'] == 'russian') {
    
$q = mysql_query('SELECT `rus_news` as `news`, `time` FROM `news` ORDER BY `id` DESC LIMIT 0, 10', $mysql);
} else {
    
$q = mysql_query('SELECT `news`, `time` FROM `news` ORDER BY `id` DESC LIMIT 0, 10', $mysql);
}

while (
$arr = mysql_fetch_assoc($q)) {
    
$rss->addItem('Новость - ' . date('Y.m.d H:i', $arr['time']), $link, '<div>' . $arr['news'] . '</div>');
}

echo 
trim($rss->saveXML());

?>
Онлайн: 2
Реклама