<?php

function url($url) {
   return str_replace(array(' '), '_', $url); 
}





function iso2utf() {
   return Array(
      "\xb1" => "\xc4\x85",	"\xa1" => "\xc4\x84",	"\xe6" => "\xc4\x87",
      "\xc6" => "\xc4\x86",	"\xea" => "\xc4\x99",	"\xca" => "\xc4\x98",
      "\xb3" => "\xc5\x82",	"\xa3" => "\xc5\x81",	"\xf3" => "\xc3\xb3",
      "\xd3" => "\xc3\x93",	"\xb6" => "\xc5\x9b",	"\xa6" => "\xc5\x9a",
      "\xbc" => "\xc5\xbc",	"\xac" => "\xc5\xbb",	"\xbf" => "\xc5\xba",
      "\xaf" => "\xc5\xb9",	"\xf1" => "\xc5\x84",	"\xd1" => "\xc5\x83
   ");
}
function ISO88592_2_UTF8($tekst) {
   return strtr($tekst, iso2utf());
}
	
	
	
	
	



define('ENGINE_PATH', '');
require_once('run_engine.php');







include('buforowanie.php');

$zakladki = buforuj('http://video.belarte.pl/spis.php?kodowanie=iso-8859-2', 3600, 'buf.txt');
$zakladki = unserialize($zakladki);
$filmy = $zakladki['paznokcie'];

$zobacz_takze = $filmy[2];
if (!$zobacz_takze) $zobacz_takze = array(); 

$array = array();
foreach($zobacz_takze as $k => $s) {
   foreach($s[2] as $ss) {
      $rt = array();
      $rt = $ss;
      $rt[8] = $k;
      if ($rt[8] == 'main') $rt[8] = null; else $rt[8] .= '/';
      $rt[9] = $rt[8].url($rt[2]).'.html';
      $array[] = $rt;
   }
}








include('class.sitemap.php');
$sitemap = new sitemap;

//$sitemap->SciezkaCache('/');
//$sitemap->CzasCache(30);
//$sitemap->UruchomCache(true);





foreach($array as $a) {

   $t = $a[8];
   if (!$t) $t = 'main'; else $t = substr($t, 0, substr($t)-1);

   $mysql->PrzygotujZapytanie('SELECT ROUND(AVG(ocena)) AS ocena FROM [tabela] WHERE film = ? AND ocena <> \'\' AND ocena IS NOT NULL LIMIT 1;');
   $mysql->UzupelnijZapytanie($t.'_'.$a[0]);
   $mysql->WybierzTabele('paznokcie_tv_komentarze');
   $ret = $mysql->WykonajZapytanie();

   $a[10] = ISO88592_2_UTF8($a[10]);

   $a[10] = explode(',', $a[10]);
   while ($each = each($a[10])) {
      if ($each['value']{0} == ' ') $a[10][$each['key']] = substr($each['value'], 1, strlen($each['value']));
      if ($each['value']{strlen($each['value'])} == ' ') $a[10][$each['key']] = substr($each['value'], 0, strlen($each['value'])-1);
   }

   $sitemap->AddVideo(   
      ISO88592_2_UTF8($a[2]), // tytul
      ISO88592_2_UTF8($a[3]), // opis
      $a[4], // link dl flv
      $a[5], // fota
      'http://'.$_SERVER['HTTP_HOST'].'/'.$a[9], // link
      $a[10], // keywords/tags
      $ret['ocena']
   );



}





$sitemap->Add('http://'.$_SERVER['HTTP_HOST'].'/'.'o_nas.htm');
$sitemap->Add('http://'.$_SERVER['HTTP_HOST'].'/'.'wspolpraca.htm');
$sitemap->Add('http://'.$_SERVER['HTTP_HOST'].'/'.'reklama.htm');
$sitemap->Add('http://'.$_SERVER['HTTP_HOST'].'/'.'polityka_prywatnosci.htm');
$sitemap->Add('http://'.$_SERVER['HTTP_HOST'].'/'.'kontakt.htm');
$sitemap->Add('http://'.$_SERVER['HTTP_HOST'].'/'.'pobierz.htm');
$sitemap->Add('http://'.$_SERVER['HTTP_HOST'].'/'.'bannery.htm');
$sitemap->Add('http://'.$_SERVER['HTTP_HOST'].'/'.'rejestracja.htm');




$sitemap->Wyswietl();




?>

