svenvogel
Goto Top

Auto php xml sitemap script robots.txt Fehler

Ich habe folgende Datei: sidemap.php


<?php

header("Content-type: text/xml");  

echo "<?xml version='1.0' encoding='UTF-8'?>\n";  
echo "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd'>\n";  
echo "# automatic generator for Google Site\n";  
echo "# By http://web-script-tube.de\n";  

echo "User-agent: *\n";  

//text pick out of robots
if (is_file("robots.txt"))  
{
$site = file("robots.txt");  //robot text datein wird durch sucht  
   for ($i=0;$i<count($site);$i++)
   {
   $pos = stristr($site[$i], "Disallow:" );  
     if ($pos)
     {
     $pos = substr($pos, 9);
     $pos2 = strpos($pos, "/" );  
     $pos3 = substr($pos, $pos2 +1);
     $all = trim($pos3) ;         
     }   
   }
}//is_file end  
else
{
echo "#ATTENTION!!! NO ROBOTSTEXT!!!!!\n";  
} 
//text pick out of robots "END"  


//all files select
 $number =2;
  for ($e=0;$e<=$number;++$e) 
  {
    if (glob("$var_folder*",GLOB_ONLYDIR|GLOB_MARK)==true)  
    {
    $folder_url = '';  
       foreach (glob("$var_folder*",GLOB_ONLYDIR|GLOB_MARK) as $folder_url)    
       {
       $folder_url =preg_replace('/.$/', '/', $folder_url);                     
          for ($r =0; $r <= count($all);$r++)
          {
            if ($folder_url == $all[$r])
            {
            $var_folder = $folder_url;       
            }
          }//for end
       
         if ($var_folder != $folder_url) 
         {
         
                
 //file exclusion by hand  
 $out_fold ="";  
 //end
                 	
           if($folder_url != $out_fold) //
       	   {
           $array_folder = $folder_url;
           $array_folder  =array_unique($array_folder);          
           $number =count($array_folder)+1;
          }
         }
       }
   }
 $var_folder = $array_folder[$e];         
 }
    $var = '';  
    $array_php='';  
    $array_html='';        
    for ($i=0;$i<$number;$i++)
    {      
      if (glob("$var*.php")==true)  
      {
      $file_php ='';  
        foreach (glob("$var*.php") as $file_php)   
        {
        
          for ($p =0; $p <= count($all);$p++)
          {
          if ($file_php == $all[$p])
          {
          $var_php = $file_php;       
          }
        }//for
       
           if ($var_php != $file_php) 
           {   

             if ($file_php != "sitemap.php")  
             {               
             $array_php = $file_php;
             }
           }//if
         }
      }
     
       if (glob("$var*.html")==true)  
       {
       $file_html ='';  
         foreach (glob("$var*.html") as $file_html)  
         {
          for ($j =0; $j <= count($all);$j++)
          {
             if ($file_html == $all[$j])
             {
             $var_html = $file_html;       
             }
          }//for
       
             if ($var_html != $file_html) 
             {       
             $array_html = $file_html;
             }
         }
}
$array_all ='';  

if ( (!empty($array_html)) && (!empty($array_php)) )
{
@$array_all = array_merge($array_html, $array_php);
}
  elseif (!empty($array_html))
  {
  $array_all = $array_html;
  }
    elseif (!empty($array_php))
    {
    $array_all = $array_html;
    }
$var = $array_folder[$i];
 }              

// end of search adress


// search noindex of website
$head="";  
$site_="";  

       for($t=0;$t<=count($array_all);$t++)
       {
       
           if (is_file($array_all[$t]))
           {

           $site_ = file_get_contents($array_all[$t]); 
                          
           preg_match('/<meta name="robots(.*)<\/head>/is',$site_, $head);    
            if ($head)
            {
            $head2[$t] = $head[1];
       
                 if (stristr($head2[$t], "noindex"))  
                 {
                 $nourl = $array_all[$t];      
                 }    
             }
         }
         
         else
         {
         $nourl ="";  
         }
       }
       
// search noindex of website END! 
$robot_text ="";       
$robot_text = (array_diff($array_all,$nourl)); //join array_all and nourl

   $e = 0;
       foreach($robot_text as $_text)   
       {  
       $e++;       
       $_text = $_SERVER['HTTP_HOST']."/". $_text;  
         if ($_text != $_SERVER['HTTP_HOST']."/") //change for localhost  
         {        
         $_text  = str_replace("//", "/", $_text );  
         $_text ="http://".$_text;  
         $robot = $_text ; 
         $robot_text = $robot_text[$e]; 
         }
       }

$g =0;
//time
foreach($robot as $site_robots)
{

$g++;

if (!empty($site_robots))
{
echo "<url><loc>".$site_robots."</loc><lastmod>";  
$filename =$robot_text[$g]; // variable von oben
if (file_exists($filename)) {
    echo date ("Y-m-d\TH:i:s", filemtime($filename));  
    echo "+00:00";  
}
else 
{
echo "2007-08-10T10:00:47+00:00" ;  
}
 
echo "</lastmod><changefreq>daily</changefreq><priority>";  
if ( (stristr($site_robots, "index.html")) or (stristr($site_robots, "index.php")) or (stristr($site_robots, "index.xhtml")) )  
{
echo "1.00";  
}
else
{
echo "0.50";  
}


echo "</priority></url>\n";  

}//if von oben
}//schleifen ende

echo "</urlset>";  
?>



In der robots.txt habe ich mehre unterverzeichnisse, welche nicht erlaubt sind.... war alles kein Problem! in der Sitemap wurden sie ausgeschlossen! Aber als ich den unterordner /infusions hinzugefügt habe, gibt sitemap.php nur noch fehler aus!

hier meine robots.txt
User-agent: *
Disallow: /cgi-bin/
Disallow: /bin/
Disallow: /includes/
Disallow: /infusions/

Wo liegt denn in der php der Fehler?

Content-ID: 97534

Url: https://administrator.de/contentid/97534

Ausgedruckt am: 19.11.2024 um 13:11 Uhr

svenvogel
svenvogel 26.09.2008 um 22:23:27 Uhr
Goto Top
Ok, da mir hier keiner helfen wollte oder konnte, habe ic hweitergesucht, und eine ausgleichslösung gefunden!

<?php
header("Content-type: text/xml");  

echo "<?xml version='1.0' encoding='UTF-8'?>\n";  
echo "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd'>\n";  

echo "User-agent: *\n";  

$datum=date("Y-m-d");  

//text pick out of robots
if (is_file("robots.txt"))  
{
$site = file("robots.txt");  //robot text datein wird durch sucht  
   for ($i=0;$i<count($site);$i++)
   {
   $pos = stristr($site[$i], "Disallow:" );  
     if ($pos)
     {
     $pos = substr($pos, 9);
     $pos2 = strpos($pos, "/" );  
     $pos3 = substr($pos, $pos2 +1);
     $all = trim($pos3) ;         
     }   
   }
}//is_file end  
else
{
echo "#ATTENTION!!! NO ROBOTSTEXT!!!!!\n";  
} 
//text pick out of robots "END"  


//all files select
 $number =2;
  for ($e=0;$e<=$number;++$e) 
  {
    if (glob("$var_folder*",GLOB_ONLYDIR|GLOB_MARK)==true)  
    {
    $folder_url = '';  
       foreach (glob("$var_folder*",GLOB_ONLYDIR|GLOB_MARK) as $folder_url)    
       {
       $folder_url =preg_replace('/.$/', '/', $folder_url);                     
          for ($r =0; $r <= count($all);$r++)
          {
            if ($folder_url == $all[$r])
            {
            $var_folder = $folder_url;       
            }
          }//for end
       
         if ($var_folder != $folder_url) 
         {
         
                
 //file exclusion by hand  
 $out_fold ="infusions";  
 //end
                 	
           if($folder_url != $out_fold) //
       	   {
           $array_folder = $folder_url;
           $array_folder  =array_unique($array_folder);          
           $number =count($array_folder)+1;
          }
         }
       }
   }
 $var_folder = $array_folder[$e];         
 }
    $var = '';  
    $array_php='';  
    $array_html='';        
    for ($i=0;$i<$number;$i++)
    {      
      if (glob("$var*.php")==true)  
      {
      $file_php ='';  
        foreach (glob("$var*.php") as $file_php)   
        {
        
          for ($p =0; $p <= count($all);$p++)
          {
          if ($file_php == $all[$p])
          {
          $var_php = $file_php;       
          }
        }//for
       
           if ($var_php != $file_php) 
           {   

             if ($file_php != "sitemap.php")  
             {               
             $array_php = $file_php;
             }
           }//if
         }
      }
     
       if (glob("$var*.html")==true)  
       {
       $file_html ='';  
         foreach (glob("$var*.html") as $file_html)  
         {
          for ($j =0; $j <= count($all);$j++)
          {
             if ($file_html == $all[$j])
             {
             $var_html = $file_html;       
             }
          }//for
       
             if ($var_html != $file_html) 
             {       
             $array_html = $file_html;
             }
         }
}
$array_all ='';  

if ( (!empty($array_html)) && (!empty($array_php)) )
{
@$array_all = array_merge($array_html, $array_php);
}
  elseif (!empty($array_html))
  {
  $array_all = $array_html;
  }
    elseif (!empty($array_php))
    {
    $array_all = $array_html;
    }
$var = $array_folder[$i];
 }              

// end of search adress


// search noindex of website
$head="";  
$site_="";  

       for($t=0;$t<=count($array_all);$t++)
       {
       
           if (is_file($array_all[$t]))
           {

           $site_ = file_get_contents($array_all[$t]); 
                          
           preg_match('/<meta name="robots(.*)<\/head>/is',$site_, $head);    
            if ($head)
            {
            $head2[$t] = $head[1];
       
                 if (stristr($head2[$t], "noindex"))  
                 {
                 $nourl = $array_all[$t];      
                 }    
             }
         }
         
         else
         {
         $nourl ="";  
         }
       }
       
// search noindex of website END! 
$robot_text ="";       
$robot_text = (array_diff($array_all,$nourl)); //join array_all and nourl

   $e = 0;
       foreach($robot_text as $_text)   
       {  
       $e++;       
       $_text = $_SERVER['HTTP_HOST']."/". $_text;  
         if ($_text != $_SERVER['HTTP_HOST']."/") //change for localhost  
         {        
         $_text  = str_replace("//", "/", $_text );  
         $_text ="http://".$_text;  
         $robot = $_text ; 
         $robot_text = $robot_text[$e]; 
         }
       }

$g =0;
//time
foreach($robot as $site_robots)
{
$g++;
if((strpos($site_robots , 'infusions')) === false)  
{
if (!empty($site_robots))
{
echo "<url><loc>".$site_robots."</loc><lastmod>";  
$filename =$robot_text[$g]; // variable von oben
if (file_exists($filename)) {
    echo date ("Y-m-d");  
}
else 
{
echo "$datum" ;  
}
 
echo "</lastmod><changefreq>daily</changefreq><priority>";  
if ( (stristr($site_robots, "index.html")) or (stristr($site_robots, "index.php")) or (stristr($site_robots, "contact.php")) or (stristr($site_robots, "downloads.php")) or (stristr($site_robots, "news.php")) or (stristr($site_robots, "photogallery.php")) or (stristr($site_robots, "articles.php")) or (stristr($site_robots, "register.php")) or (stristr($site_robots, "viewforum.php")) or (stristr($site_robots, "index.xhtml")) or (stristr($site_robots, "index.xhtml")) or (stristr($site_robots, "index.xhtml")) or (stristr($site_robots, "index.xhtml")))  
{
echo "1.00";  
}
else
{
echo "0.50";  
}


echo "</priority></url>\n";  

}//if von oben
}//mein eigenes if
}//schleifen ende

echo "</urlset>";  
?>


habe es mit dieser Funktion gemacht!
if((strpos($site_robots , 'infusions')) === false)  
und natürlich an den geeigneten stellen die klammern gesetzt!

MFG kann geclosed werden!