<?
include_once("slabefunkce.php");PRIPOJ(); 
echo "<";
echo "?xml version=\"1.0\" encoding=\"utf-8\"?";
echo ">
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">";
//echo ">
//<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";

$URL=konstanty("ADRESA")."/";
$DPH=21;
$xdate="2013-04-13";
$now=date("Y-m-d");

$co   = array("'","\"","<",">","&amp;","&","/");
$cim  = array("","","","","",""," ");   

$OUT="
<url>
<loc>".konstanty("ADRESA")."/akce</loc> 
<priority>0.9</priority>
<lastmod>$now</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>".konstanty("ADRESA")."/novinky</loc> 
<priority>0.9</priority>
<lastmod>$now</lastmod>
<changefreq>daily</changefreq>
</url>
";
$PREDEK=array();
$QUESTION="SELECT * from kategorie;";
$RESULT=MySQL_QUERY($QUESTION);
while ($ROW=MySQL_fetch_array($RESULT)){
$PREDEK[$ROW["idkategorie"]]=$ROW["predek"];}

$POCv=array();
$POCk=array();
$QUESTION="SELECT Vyrobce_idvyrobce as v,Kategorie_idkategorie as k from produkt where specialnivlastnost<=2;";
$RESULT=MySQL_QUERY($QUESTION);
while ($ROW=MySQL_fetch_array($RESULT))
  {$POCv[$ROW["v"]]++;
  $POCk[$ROW["k"]]++;
  $POCk[$PREDEK[$ROW["k"]]]++;
  $POCk[$PREDEK[$PREDEK[$ROW["k"]]]]++;
  }

$i=0;
$QUESTION="SELECT * from kategorie left join externcategory on idkategorie=id ORDER BY a2 desc;";
$RESULT=MySQL_QUERY($QUESTION);
while ($ROW=MySQL_fetch_array($RESULT)){
  if(!($POCk[$ROW["idkategorie"]]>0))continue;
  if($i==0)$A2=$ROW["a2"];$i++;
  $ROW["oznaceni"]  = str_replace($co,$cim,$ROW["oznaceni"]);
  $p=0.9;
  $p=min(0.9,round((0.4+0.60*($ROW["a2"]/$A2)),2));
  $d="weekly";
  if($p>0.60)$d="daily";
  $OUT.="
<url>
<loc>$URL".$ROW["url"]."</loc> 
<priority>$p</priority>
<lastmod>$now</lastmod>
<changefreq>$d</changefreq>
</url>";
  };





$QUESTION="SELECT * from vyrobce ORDER BY oznaceni;";
$RESULT=MySQL_QUERY($QUESTION);
while ($ROW=MySQL_fetch_array($RESULT)){
if(!($POCv[$ROW["idvyrobce"]]>2))continue;

  $ROW["oznaceni"]  = str_replace($co,$cim,$ROW["oznaceni"]);
  $OUT.="
<url>
<loc>$URL".$ROW["url"]."</loc> 
<priority>0.7</priority>
<lastmod>$now</lastmod>
<changefreq>weekly</changefreq>";
if(strlen($ROW["obrazek"])>0)
$OUT.="
  <image xmlns=\"http://www.google.com/schemas/sitemap-image/1.1\">
  <loc>{$URL}IMGMAKER/$ROW[obrazek]</loc> 
  <caption>$ROW[oznaceni]</caption> 
  <title>$ROW[oznaceni]</title>
  </image>";
$OUT.="
</url>";
  };



$QUESTION="SELECT * from produkt left join extern on idProdukt=id where specialnivlastnost<=2 ORDER BY a2 desc,a6 desc;";
$RESULT=MySQL_QUERY($QUESTION);
$i=0;
while ($ROW=MySQL_fetch_array($RESULT)){
if($i==0)$A2=$ROW["a2"];$i++;
if(strlen($ROW["oznkey"]))$ROW["oznaceni"]=$ROW["oznkey"];
  $ROW["oznaceni"]  = trim(str_replace($co,$cim,$ROW["oznaceni"]));
  
  $p=0.4;
  //if($ROW["a6"]>10)$p=round(min(0.9,0.4+$ROW["a6"]/10),2);
  //$p=round(min(0.9,0.4+$ROW["a2"]/12),2);
  $p=round((0.4+0.5*($ROW["a2"]/$A2)),2);
  
  $OUT.="
<url>
<loc>$URL".$ROW["url"]."</loc> 
<priority>$p</priority>
<lastmod>$xdate</lastmod>
<changefreq>weekly</changefreq>";
/*if(strlen($ROW["obrazek"])>0)
$OUT.="
  <image xmlns=\"http://www.google.com/schemas/sitemap-image/1.1\">
  <loc>{$URL}IMGPRODUCT/$ROW[obrazek]</loc> 
  <caption>$ROW[oznaceni]</caption> 
  <title>$ROW[oznaceni]</title>
  </image>";*/
$OUT.="
</url>";
  };



/*
$QUESTION="
SELECT categories_id,categories_name
FROM categories_description 
WHERE language_id=$language;";
$RESULT=@MySQL_QUERY($QUESTION);

while ($ROW=@MySQL_fetch_array($RESULT)){
  $I=$ROW["categories_id"];
  $ozn=$ROW["categories_name"];
  if(strlen($CAT2[$I])>0){$ozn=$CAT2[$I];}else{continue;}
echo"
   <url>
   <loc>$URL".getSeo($CAT2c[$I],"-c{$I}")."</loc> 
   <lastmod>$xdate</lastmod> 
   <changefreq>weekly</changefreq>
   <priority>0.5</priority> 
   </url>";
};




$QUESTION="
SELECT manufacturers_id,manufacturers_name,manufacturers_image
FROM manufacturers limit 0,10000;";
$RESULT=MySQL_QUERY($QUESTION);
while ($ROW=MySQL_fetch_array($RESULT)){
  $I=$ROW["manufacturers_id"];

echo"
   <url>
   <loc>$URL".getSeo($ROW["manufacturers_name"],"-m{$I}")."</loc> 
   <lastmod>$xdate</lastmod> 
   <changefreq>weekly</changefreq>
   <priority>0.5</priority> 
   </url>"; 
   };

*/
echo $OUT;
echo "\n</urlset>";
?>

