<?php
header('Content-Type: text/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8" ?>'."\n";

$lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
if(is_file ("../lang/".$lang.".php")) include "../lang/".$lang.".php";
  else include "../lang/ru.php";

require_once "../config.php";

if(!@mysql_select_db($dbname,$dbcnx))
  {
    echo("<p>At this moment database is not available, therefore correct display of page is impossible.<br />If you do not install project previously, run script <a href=install.php>http://".$_SERVER['SERVER_ADDR']."/personal/install.php</a></p>");
    exit();
  }

$address = "http://".$_SERVER['SERVER_ADDR']."/personal/support/";
$iconka = "http://".$_SERVER['SERVER_ADDR']."/personal/img/know_rss.png";
$opentg=Array("<");
$closetg=Array(">");
?>
<rss version="2.0">
<channel>
<title><?php echo $TEXT['know-izm']; ?></title>
<description><?php echo $TEXT['know-izm-title']; ?></description>
<language><?php echo $lang; ?></language>
<link><?php echo $address; ?></link>
<copyright><?php echo $TEXT['maker7']; ?></copyright>
<managingEditor><?php echo $TEXT['admin-mail-rss']; ?></managingEditor>
<webMaster><?php echo $TEXT['admin-mail-rss']; ?></webMaster>
<generator><?php echo $TEXT['global-title']; ?> <?php echo $TEXT['maker8']; ?></generator>
<ttl>60</ttl>
<skipDays>7,1</skipDays>
<image>
    <url><?php echo $iconka; ?></url>
    <width>32</width>
    <height>32</height>
    <title><?php echo $TEXT['global-title']; ?></title>
    <description><?php echo $TEXT['top-news-mail']; ?></description>
    <link><?php echo $address; ?></link>
</image>
<?php
$query = "SELECT zhurn_id, zh_str_id, zh_tema, UNIX_TIMESTAMP(data) AS data, SUBSTRING_INDEX(zh_soobschenie, ' ', 20) AS soobschenie FROM `tbl_bd_zhnaniy` WHERE `visible` = 'show' ORDER BY data DESC LIMIT 10";
$result = mysql_query($query);
if(!$result) puterror($TEXT['error-tbl46']);
while($news = mysql_fetch_array($result,MYSQL_ASSOC))
{
  $dat=date('D, d M Y H:i:s',$news['data']);
  $address_new = "http://".$_SERVER['SERVER_ADDR']."/personal/support/know_view.php?zhurn_id=".$news['zhurn_id']."&amp;zh_str_id=".$news['zh_str_id']."&amp;otkr=2&amp;s=1";
  $news['soobschenie'] = str_replace($opentg,"&lt;",$news['soobschenie']);
  $news['soobschenie'] = str_replace($closetg,"&gt;",$news['soobschenie']);

  echo "<item>";
  echo "<title>".$news['zh_tema']."</title>";
  echo "<link>".$address_new."</link>";
  echo "<description>".$news['soobschenie']." &#8811;</description>";
  echo "<pubDate>".$dat."</pubDate>";
  echo "<guid isPermaLink='true'>".$address_new."</guid>";
  echo "</item>";
}
echo "</channel>";
echo "</rss>";