<?
//error_reporting(0);

/*
$attack_host=gethostbyaddr($_SERVER['REMOTE_ADDR']);
$classc=substr($_SERVER['REMOTE_ADDR'],0,strrpos($_SERVER['REMOTE_ADDR'],"."));
if (strstr($attack_host,"googlebot.com") && strstr($_SERVER['HTTP_USER_AGENT'], "Googlebot")) {
  ini_set("url_rewriter.tags", "");
  ini_set('session.use_only_cookies', "1");
  ini_set('session.use_trans_sid', false);
  $bot = true;
} else {
  //$starttime=time(); 
  $attack_array=file("/www/ecms24/attacks.txt");
  foreach ($attack_array as $k => $v) {
   list($attack_typ,$attack_content,$attack_date)=explode(";",$v);
   if ($attack_typ=="ip" && $_SERVER['REMOTE_ADDR']==$attack_content) { die;
   } elseif ($attack_typ=="classc" && $classc==$attack_content) { die; 
   } elseif ($attack_typ=="agent" && strstr($_SERVER['HTTP_USER_AGENT'],$attack_content)) { die;
   //} elseif ($attack_typ=="referer" && strstr($_SERVER['HTTP_REFERER'],$attack_content)) { die;
   }
  }
}
*/

$messpunkt["sitemap_anfang"]=microtime(true);
include "include.html";

if (!$set_internal && $status==0) {
 header("Status: 404 Not Found");
 header("HTTP/1.0 404 Not Found");
 die;
}
header('Content-Type: text/xml');

//$makenew=FALSE;
//if (strtoupper($_GET["makenew"])=="TRUE") $makenew=true;

//$sitemapdomain=$sdom;
$sitemapdomain=idn_to_ascii(($sdom));
//if (!($sdom<>$almdom[$lang] && $sslhost=="letsencrypt")) {
// $sitemapdomain=idn_to_ascii(($almdom[$lang]));
//}

/*
if (!$set_internal && !$makenew && file_exists("/www/ecmstemp/$projectid/sitemap_".$sitemapdomain."_$lang.xml")) {
 $utime=filectime("/www/ecmstemp/$projectid/sitemap_".$sitemapdomain."_$lang.xml");
 if ((time()-$utime)>(60*60*24)) {
  $makenew=TRUE;
 } else {
  echo file_get_contents("/www/ecmstemp/$projectid/sitemap_".$sitemapdomain."_$lang.xml");
 }
} else {
 $makenew=TRUE;
} 
*/

$sitemap="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

$avalidmodules["articles"]="articles";
$avalidmodules["shop"]="articles";
$avalidmodules["news"]="news";
$avalidmodules["event"]="event";
$avalidmodules["jobs"]="jobs";
$avalidmodules["blog"]="blog";
$avalidmodules["gallery"]="gallery";
$avalidmodules["booth"]="booth";
$avalidmodules["estate"]="estate";
$avalidmodules["food"]="food";

if (!isset($action)) $action="index";
if ($action=="index") {
    
$sitemap.='
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=pages</loc></sitemap>
  ';

//if ($set_internal) $sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=catalogs</loc></sitemap>';
//if ($set_internal) var_dump($afunction); 

if (isset($afunction)) { // nicht bei allen Projekten sind Module gesetzt
 foreach ($afunction as $gmodul => $navid) {
  $gmodul=strtok($gmodul,":");  
  if (isset($avalidmodules[$gmodul]) && $avalidmodules[$gmodul]<>"articles") {
   $sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action='.$avalidmodules[$gmodul].'</loc></sitemap>
  ';
  $sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=catalogs&amp;catalog='.$gmodul.'</loc></sitemap>';
  }
 }
}

if ($mdomain == "verbandsforum.de" || $mdomain == "paxperpetua.de" || $mdomain == "vayumaya.de") {
 //if ($set_internal) $sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=catalogs&amp;catalog=addresses</loc></sitemap>';
 $sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=0</loc></sitemap>
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=1</loc></sitemap>
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=2</loc></sitemap>
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=3</loc></sitemap>
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=4</loc></sitemap>
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=5</loc></sitemap>
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=6</loc></sitemap>
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=7</loc></sitemap>
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=8</loc></sitemap>
  <sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=addresses&amp;loc=9</loc></sitemap>';

}

// Articles aufteilen!!!
if ($mdomain == "7sellers.shop") { 
 if ($set_internal) $sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=catalogs&amp;catalog=articles</loc></sitemap>';
 //$sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=7sellers</loc></sitemap>';
 $sq="select katid,kat1 from kat where projectid='".$projectid."' and lang='".$lang."' and katname='articles' and kat1<>'' and kat2='' and count>0 and status=1";
 $sr=$db->query($sq);
 while ($sz=$sr->fetch_assoc()) {
  //$akat1[$sz["katid"]]=$sz["kat1"];
  $sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=7sellers&amp;catrel='.$sz["katid"].'</loc></sitemap>
  ';
 }
} else {
 //if (isset($afunction["articles"])) {
  $sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=catalogs&amp;catalog=articles</loc></sitemap>';
  $sq="select katid,kat1 from kat where projectid='".$projectid."' and lang='".$lang."' and katname='articles' and kat1<>'' and kat2='' and status=1";
  $sr=$db->query($sq);
  while ($sz=$sr->fetch_assoc()) {
   //$akat1[$sz["kat1"]]=$sz["katid"];
   $sitemap.='<sitemap><loc>https://www.'.$sitemapdomain.'/sitemap.xml?action=articles&amp;catrel='.$sz["katid"].'</loc></sitemap>
   ';
  }
 //}
}

$sitemap.='
</sitemapindex>
';
    
} else {
    
$sitemap.='<?xml-stylesheet type="text/xsl" href="https://www.'.$sitemapdomain.'/sitemap.xsl"?>'."\n";
$sitemap.="<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\" xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\" xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\">";

$lastmod = date("Y-m-d") . "T" . date("H:i:s+02:00");
$sitemap.="
<!-- Created by eCMSvario Version 2.5 -->
<url>
<loc>https://www.".$sitemapdomain."/</loc>
<lastmod>".$lastmod."</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
";

if ($action=="pages") {
    
// Menü-Struktur
$query = "select *, CHAR_LENGTH(xdata) AS textlen from menu x, content y where x.projectid='$projectid' and x.lang='$lang' and x.navid=y.navid and y.lang='$lang' ";
$query .= " and x.sitemap='J'";
$query .= " and (x.status='1' OR x.status='2')";
$query .= " and x.zone='0'";
$query .= " and x.projectid=y.projectid and y.bakid='0' and y.navid<>''";
$query .= " having (textlen>15 OR function<>'')";
$result = $db->query($query);
//if ($set_internal) echo $query."<br />";
while ($zeile = $result->fetch_array()) {
 $sitemap.="<url>\n";
    $sitemap.="<loc>".("https://www.".$sitemapdomain.url(array("array" => $zeile)))."</loc>\n";
    $lastmod_date = date("Y-m-d", $zeile["timestamp"]) . "T" . date("H:i:s+02:00", $zeile["timestamp"]);
    $sitemap.="<lastmod>" . $lastmod_date . "</lastmod>\n";
    $sitemap.="<changefreq>".$zeile['changefreq']."</changefreq>\n";
    $sitemap.="<priority>".$zeile['priority']."</priority>\n";
 $sitemap.="</url>\n";
 $anzahl_urls++;
};

} elseif ($action=="catalogs") {
    
 //var_dump($akid);    
 //var_dump($afunction);
 $boolcount=($mdomain=="7sellers.shop")?true:false;
 $catalogname=(($catalog=="articles")?"shop":$catalog);
 $catalognavid=$afunction[$catalogname];
 $cache_name="qcache_".$lang."_".$catalog."_".$catalog;
 if (isset(${$cache_name})) { 
   //if ($set_internal) { echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$projectid."<br />"; }
   $cache_data=${$cache_name};
   $az=unserialize(gzuncompress(base64_decode($cache_data)));
   //echo count($az);
   foreach ($az as $z) {
    $doit=true; if ($mdomain=="7sellers.shop" && $z["count"]==0) $doit=false;
    if ($doit) {
        
    //var_dump($z);    
     $sdescr=(($z["descr"]<>"")?clean_str($z["descr"]).",":"");
     if ($z["kat2"]<>'' && $z["kat3"]<>'' && $z["kat4"]=='') {
      $pstr=clean_str("**".$catalogname."**".$z["kat1"]."**".$z["kat2"]."**".$z["kat3"]."**").$sdescr; $url=$pstr.$catalognavid.",".$lang.",".$z["katid"];  
     } elseif ($z["kat2"]<>'' && $z["kat3"]=='') {
      $pstr=clean_str("**".$catalogname."**".$z["kat1"]."**".$z["kat2"]."**").$sdescr; $url=$pstr.$catalognavid.",".$lang.",".$z["katid"]; 
     } elseif ($z["kat2"]=='') {
      $pstr=clean_str("**".$catalogname."**".$z["kat1"]."**").$sdescr; $url=$pstr.$catalognavid.",".$lang.",".$z["katid"]; 
     }
    
    $sitemap.="<url>\n";
     //$sitemap.="<loc>".("https://www.".$sitemapdomain.url(array("array" => $zeile)))."</loc>\n";
     //$sitemap.="<loc>https://www.".$sitemapdomain."/".$catalogname."/".$z["kat1"].",".$catalognavid.",".$lang.",".$z["katid"]."</loc>\n";
     $sitemap.="<loc>https://www.".$sitemapdomain.$url."</loc>\n";
     $lastmod_date = date("Y-m-d", $zeile["timestamp"]) . "T" . date("H:i:s+02:00", $zeile["timestamp"]);
     $sitemap.="<lastmod>" . $lastmod_date . "</lastmod>\n";
     $sitemap.="<changefreq>always</changefreq>\n";
     $sitemap.="<priority>"."0.5"."</priority>\n";
    $sitemap.="</url>\n";
    }

   } 
 }

} elseif ($action=="addresses" && isset($loc)) {
    
   if (!isset($loc)) {

    
   } else {
    
    if ($mdomain == "verbandsforum.de") {
     $navid = 854; $appname="Verbaende"; $zusatz=" and v.x_mod='verband'";
    //} elseif ($mdomain == "angewandtekunst.de") {
    // $navid = 8475; $appname=""; $zusatz='';
    } elseif ($mdomain == "paxperpetua.de") {
     $navid = 10189; $appname=""; $zusatz='';
    } elseif ($mdomain == "vayumaya.de") {
     $navid = 585119; $appname=""; $zusatz=''; $onlykat='11';
    }
    $q = 'select x.kat1,x.kat2,x.kat3,x.katid,v.uid,v.abk,v.firma 
          FROM kat x, katrel y, addresses v 
          WHERE x.projectid=\''.$projectid.'\' '.((isset($onlykat)?" and x.katid=".$onlykat:"")).' and x.status=\'1\' and x.lang=\''.$lang.'\' and x.projectid=y.projectid and x.katid=y.katid and y.relapp=\'addresses\' and y.relid=v.uid and plz like \''.$loc.'%\' and v.status=\'1\''.$zusatz;
    $rx = $db->query($q);
    while ($zx = $rx->fetch_array()) {

        $sitemap.="<url>\n";
        $sitemap.="<loc>" . ("https://www.".$sitemapdomain.url_app(array("array" => $zx,
            "navid" => $navid, "lang" => $lang, "app" => "$appname", "page" => strtok($zx['firma'],"\n"),
            "detail" => $zx['uid']))) . "</loc>\n";

        $lastmod = date("Y-m-d") . "T" . date("H:i:s+02:00");
        $sitemap.="<lastmod>" . $lastmod . "</lastmod>\n";
        $sitemap.="<changefreq>"."always"."</changefreq>\n";
        $sitemap.="<priority>"."0.5"."</priority>\n";
        $sitemap.="</url>\n";
        $anzahl_urls++;
    };

   } 

} elseif ($action=="7sellers") {
    
   $anzahl_urls=0;
   $anzahl_images=0;
    
   $sq="select * from kat where projectid='".$projectid."' and lang='".$lang."' and katname='articles' and status=1";
   $sr=$db->query($sq);
   while ($sz=$sr->fetch_array()) {
    $akatpath[$sz["katid"]]=clean_str($sz["kat1"]).(($sz["kat2"]<>"")?"/".clean_str($sz["kat2"]):"").(($sz["kat3"]<>"")?"/".clean_str($sz["kat3"]):"");
   }
   
   $filter=(($mdomain<>$sdom && $dkeywords<>"")?$dkeywords:"");

   $asearch=array(
   "size"=>"5000",
   "searchword"=>"%",
   "index_type"=>$ecms_searchoptions_array["type"],
   "catalog"=>$ecms_searchoptions_array["catalog"],
   "relation"=>$catrel,
   "filter"=>$filter,
   "lang"=>$lang,
   "projectid"=>""
   );
   //"projectid"=>((isset($ecms_searchoptions_array["pid"]) && $ecms_searchoptions_array["pid"]=="all")?"":$projectid)
  
  //if ($set_internal) print_r($asearch);
  
  $response=eCMSisearch($asearch);
  foreach ($response["uids"] as $_uid => $_score) {
    
   $_print=$response["source"][$_uid]["print"];
   $blankpos=strrpos($response["source"][$_uid]["relation"]," ");
   if ($blankpos==0) {
    $_relation=$response["source"][$_uid]["relation"];
   } else {
    $_relation=substr($response["source"][$_uid]["relation"],strrpos($response["source"][$_uid]["relation"]," ")+1); 
   }
   $lastmod = $response["source"][$_uid]["lastmod"]; // date("Y-m-d") . "T" . date("H:i:s+02:00");

   $sitemap.="<url>\n";
   $sitemap.="<loc>" . "https://www.".$sitemapdomain."/shop/".$akatpath[$_relation]."/".clean_str($_print).",583892".",".$lang.",".$_relation.",".$_uid."</loc>\n";
   
   // Bilder
   //if ($set_internal) {
   $ci=0;

   $additional_images=$response["source"][$_uid]["additional_images"];
   $additional_images[]=$response["source"][$_uid]["image"]; 
   foreach ($additional_images as $image) {
    $sitemap.="<image:image>\n";
    $sitemap.="<image:loc>https://www.".$sitemapdomain."/module/".$image."</image:loc>\n";
    $sitemap.="<image:title>Bild ".++$ci.": ".str_replace('&','&amp;',str_replace('<','&gt;',$_print))."</image:title>\n";
    $sitemap.="</image:image>\n";
    $anzahl_images++;
   }
   //}
   
   $sitemap.="<lastmod>" . $lastmod . "</lastmod>\n";
   $sitemap.="<changefreq>"."always"."</changefreq>\n";
   $sitemap.="<priority>"."0.5"."</priority>\n";
   $sitemap.="</url>\n";
   $anzahl_urls++;
  
   //if ($anzahl_urls==25) break;  
  }

/*
} elseif ($set_internal && $action=="articles") {
    
   $sq="select * from kat where projectid='".$projectid."' and lang='".$lang."' and katname='articles' and status=1";
   $sr=$db->query($sq);
   while ($sz=$sr->fetch_array()) {
    $akatpath[$sz["katid"]]=clean_str($sz["kat1"]).(($sz["kat2"]<>"")?"/".clean_str($sz["kat2"]):"").(($sz["kat3"]<>"")?"/".clean_str($sz["kat3"]):"");
   }

   $asearch=array(
   "size"=>"5000",
   "searchword"=>"%",
   "index_type"=>$ecms_searchoptions_array["type"],
   "catalog"=>$ecms_searchoptions_array["catalog"],
   "relation"=>$catrel,
   "lang"=>$lang,
   "projectid"=>$projectid
   );
   //"projectid"=>((isset($ecms_searchoptions_array["pid"]) && $ecms_searchoptions_array["pid"]=="all")?"":$projectid)
  
  //if ($set_internal) print_r($asearch);
  
  $response=eCMSisearch($asearch);
  foreach ($response["uids"] as $_uid => $_score) {
    
   $_print=$response["source"][$_uid]["print"];
   $blankpos=strrpos($response["source"][$_uid]["relation"]," ");
   if ($blankpos==0) {
    $_relation=$response["source"][$_uid]["relation"];
   } else {
    $_relation=substr($response["source"][$_uid]["relation"],strrpos($response["source"][$_uid]["relation"]," ")+1); 
   }
   echo $_image=$response["source"][$_uid]["image"]; 
   $_additional_images=$response["source"][$_uid]["additional_images"]; 
   
   $lastmod = date("Y-m-d") . "T" . date("H:i:s+02:00");

   $sitemap.="<url>\n";
   $sitemap.="<loc>" . "https://www.".$sitemapdomain."/shop/".$akatpath[$_relation]."/".clean_str($_print).",583892".",".$lang.",".$_relation.",".$_uid."</loc>\n";
   
   // Bilder
   if ($_image) {
    $sitemap.="<image:image>\n";
    $sitemap.="<image:loc>https://www.".$sitemapdomain.$v["file"]."</image:loc>\n";
    $sitemap.="<image:title>".str_replace('&','&amp;',str_replace('<','&gt;',$v["shortdes"]))."</image:title>\n";
    $sitemap.="</image:image>\n";
    $anzahl_images++;
   }
   
   $sitemap.="<lastmod>" . $lastmod . "</lastmod>\n";
   $sitemap.="<changefreq>"."always"."</changefreq>\n";
   $sitemap.="<priority>"."0.5"."</priority>\n";
   $sitemap.="</url>\n";
   $anzahl_urls++;
  
   //if ($anzahl_urls==25) break;  
  }
*/
} else {

// Module inkl. Bilder
// indivs abgeloesst: 90046|vision-gmbh.de; |audyn.de; 20116|a-p-werbung.de; 101026|intertechnik.de
// things to do: 
// 1. lastmod von jump2detail mitliedern lassen?!?
// 2. changefreq / priority von getModule mitliefern lassen oder bei Moduldef festlegen?
// 3. https / http
// 4. mdomain in jump2detail zu sdom in sitemap

//$m=getModule_array(); 
//if ($_SERVER["REMOTE_ADDR"]=="10.10.11.171") echo var_dump($afunction);
$anzahl_news=0;
$anzahl_images=0;
$anzahl_videos=0;

if (isset($afunction)) { // nicht bei allen Projekten sind Module gesetzt
reset($afunction);
$gmodul=$action;
$navid=$afunction[$gmodul];

//foreach ($afunction as $gmodul => $navid) {
 if ($gmodul=="jobs" || $gmodul=="event" || $gmodul=="blog" || 
     $gmodul=="news" || $gmodul=="articles" || $gmodul=="gallery" ||
     $gmodul=="booth" || $gmodul=="estate" || $gmodul=="food") {
        
  if ($moddef[$gmodul]) {
    // Ergaenzung der Shortdes, wenn das Bild keine Beschreibung hat! nur fuer articles und als Test eingebaut
    if ($gmodul=="articles") { 
        
     //if ($set_internal) {
      if (isset($catrel)) {
        
      $sq="select kat1 from kat where projectid='".$projectid."' and lang='".$lang."' and katname='articles' and katid=$catrel and status=1";
      $sr=$db->query($sq);
      $sz=$sr->fetch_assoc();
      $kat1=$sz["kat1"];
            
      $sq="select x.katid,y.relid from kat x, katrel y, articles z where x.projectid='".$projectid."' and x.lang='".$lang."' and x.katname='articles' and x.kat1='".$kat1."' and x.status=1 and x.projectid=y.projectid and x.lang=y.lang and x.katname=y.katname and x.katid=y.katid and y.relapp='articles' and y.relid=z.uid and z.status=1"; 
      $sr=$db->query($sq);
      while ($sz=$sr->fetch_assoc()) {
       $auids[$sz["relid"]]=$sz["relid"];
      }
      //if ($set_internal) { echo $sq."<br />"; };
      }  

     //} else {
        /*
      $asearch=array(
       "size"=>"5000",
       "searchword"=>"%",
       "index_type"=>$ecms_searchoptions_array["type"],
       "catalog"=>$ecms_searchoptions_array["catalog"],
       "relation"=>$catrel,
       "lang"=>$lang,
       "projectid"=>$projectid
      );
      //if ($set_internal) print_r($asearch);
      $response=eCMSisearch($asearch);
      //print_r($response);

      $suids="";
      foreach ($response["uids"] as $_uid => $_score) {
       $auids[]=$_uid;
       $suids.=$_uid.",";
      }
      $suids="'".substr($suids,0,-1)."'";
      //print_r($auids);
      */  
     //}
        
     $sq="select uid, shortdes, cdate, mdate from articles where projectid='".$projectid."' and status=1";
     $sr=$db->query($sq);
     while ($sz=$sr->fetch_assoc()) {
      $ashortdes[$sz["uid"]]=$sz["shortdes"];
      //$lastmod_date = date("Y-m-d", $zeile["timestamp"]) . "T" . date("H:i:s+02:00", $zeile["timestamp"]);
      if ($sz["mdate"]<>0) {
        $sdate=$sz["mdate"];
      } else {
        $sdate=$sz["cdate"];
      }
      $alastmod[$sz["uid"]]=date("Y-m-d",$sdate) . "T" . date("H:i:s+02:00",$sdate);
     }
     
     //if ($set_internal) { echo "Anz: ".count($auids); };
     
    } elseif ($gmodul=="news") { 
     $sq="select uid,cdate,lang,headline,teaser,descr,mdate from news where projectid='".$projectid."' and status=1 order by mdate desc";
     $sr=$db->query($sq);
     while ($sz=$sr->fetch_array()) {
      $anews[$sz["uid"]]=$sz;
      $sdate=($sz["mdate"]<>0)?$sz["mdate"]:$sdate=$sz["cdate"];
      $alastmod[$sz["uid"]]=date("Y-m-d",$sdate) . "T" . date("H:i:s+02:00",$sdate);
     }
    } elseif ($gmodul=="blog") { 
     $sq="select uid,cdate,lang,headline,teaser,descr,mdate from blog where projectid='".$projectid."' and status=1 order by mdate desc";
     $sr=$db->query($sq);
     while ($sz=$sr->fetch_array()) {
      //$anews[$sz["uid"]]=$sz;
      $sdate=($sz["mdate"]<>0)?$sz["mdate"]:$sdate=$sz["cdate"];
      $alastmod[$sz["uid"]]=date("Y-m-d",$sdate) . "T" . date("H:i:s+02:00",$sdate);
     }
    }

    if (isset($auids)) {
     $all=jump2detail($auids,$gmodul,$lang,$projectid,"long",FALSE,TRUE);
    } else {
     $all=jump2detail("",$gmodul,$lang,$projectid,"long",TRUE,TRUE);
     
    }
    foreach ($all as $uid => $link) {
     $summary_data[$uid]=str_replace($mdomain,$sitemapdomain,$link);
     $uid_array[$uid]=$uid;
    }
    $medien=media_files($uid_array,$gmodul,'0,imp-');
    foreach ($summary_data as $uid => $link) {
    //if ($set_internal) echo $uid; var_dump($medien[$uid]);
     $sitemap.="<url>\n";
     $sitemap.="<loc>".$link."</loc>\n";
        if ($mdomain=="vision-gmbh.de" && $gmodul=="news") {
           $sitemap.="<news:news>\n";
            $sitemap.="<news:publication>\n";
             $sitemap.="<news:name>"."Vision Consulting Deutschland GmbH"."</news:name>";
             $sitemap.="<news:language>".$anews[$uid]["lang"]."</news:language>";
            $sitemap.="</news:publication>";
           //$sitemap.="<news:genres>."".</news:genres>";
           $sitemap.="<news:publication_date>".date("c",$anews[$uid]["cdate"])."</news:publication_date>";
           $sitemap.="<news:title>".$anews[$uid]["headline"]."</news:title>";
           //$sitemap.="<news:keywords>unternehmen, fusion, Ã¼bernahme, A, B</news:keywords>";
           //$sitemap.="<news:stock_tickers>NASDAQ:A, NASDAQ:B</news:stock_tickers>";
           $sitemap.="</news:news>\n";
           $anzahl_news++;
           
        }
        if (isset($medien[$uid])) {
         foreach ($medien[$uid] as $k => $v) {
          if ($v["filetype"]=="image") {
           if ($v["shortdes"]=="") {
            $v["shortdes"]=$ashortdes[$uid];
           } 
           $sitemap.="<image:image>\n";
           $sitemap.="<image:loc>https://www.".$sitemapdomain.$v["file"]."</image:loc>\n";
           $sitemap.="<image:title>".str_replace('&','&amp;',str_replace('<','&gt;',$v["shortdes"]))."</image:title>\n";
           $sitemap.="</image:image>\n";
           $anzahl_images++;
          } elseif (($v["filetype"]=="video/mp4" || $v["filetype"]=="video/webm")) {
           if ($v["shortdes"]=="") {
            $v["shortdes"]=$ashortdes[$uid];
           } 
           $sitemap.="<video:video>\n";
           $sitemap.="<video:content_loc>https://www.".$sitemapdomain.$v["file"]."</video:content_loc>\n";
           $sitemap.="<video:title>".str_replace('&','&amp;',str_replace('<','&gt;',$v["shortdes"]))."</video:title>\n";
           $sitemap.="</video:video>\n";
           $anzahl_videos++;
          }
         }
        }
      $sitemap.="<lastmod>".((isset($alastmod[$uid]))?$alastmod[$uid]:$lastmod)."</lastmod>\n";
      $sitemap.="<changefreq>"."always"."</changefreq>\n";
      $sitemap.="<priority>"."0.5"."</priority>\n";
     $sitemap.="</url>\n";
     $anzahl_urls++;
    };
   };
   unset($summary_data);
 };
//};

}

    
}
$sitemap.="</urlset>";

}

echo $sitemap;
//$fd=fopen("/www/ecmstemp/$projectid/sitemap_".$sitemapdomain."_$lang.xml","w"); fputs($fd,$sitemap); fclose ($fd);
$messpunkt["sitemap_ende"]=microtime(true);

/*
if ($mdomain=="7sellers.shop" || $mdomain=="videokonferenz.shop") { 
// Statistik per Email senden
$sitemap_time=number_format($messpunkt["sitemap_ende"]-$messpunkt["sitemap_anfang"],6);
$anzahl_querys=count($ecms_query_array);
$show_domain=(($sdom==$mdomain)?$sdom:$sdom." => ".$mdomain);

$sitemap_statistics="Querys: ".$anzahl_querys."\n"."Urls..: ".$anzahl_urls."\n"."Images: ".$anzahl_images."\n"."Images: ".$anzahl_videos."";
reset($_SERVER); foreach ($_SERVER as $k => $v) { $pserver.=$k."=>".$v."\n"; }
//reset($ecms_query_array); foreach ($ecms_query_array as $k => $v) { $pserver.=$k."=>".$v."\n"; }
mail("protokoll@vision-gmbh.de","** Sitemap: (".$sitemap_time." => ".$anzahl_querys.") ".$show_domain,"\n\n".$sitemap_statistics."\n\n=======================\n\n".$pserver."\n\n=======================\n\n".$sitemap,"From: cron@vision-gmbh.de"); 
//if ($set_internal) { echo $sitemap_time."<br />"; }
}
*/
?>
