View Single Post
Old 06-27-2009, 05:08 PM   #9 (permalink)
benton
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

I tried
PHP Code:
echo ereg('php''elephpant'$match); 
with both php versions and they both returned 3. To give a better idea of this problem, I created two sub-directories, one with php4 and one with php5 (both have phpinfo.php files if you want to see the server info). I edited my code to just include the relevant information but still enough to see the failure. That code is below and the same file has been uploaded to both of the directories. So if you go to http://link-my-site.com/version/php4/position.php, you'll see "opened" displayed and then a bunch of text, finally ending with the searched for site and "closed." If you go to http://link-my-site.com/version/php5/position.php, all that is displayed are the words "opened" and "closed."

Here's the code used for both of the above:
PHP Code:
<?php
    $conditions 
"<cite>(.*)</cite>";
    
$hits_per_page 10;
    
$siteName 'Google'
    
$query "wholesale+candy";    
      
$position  0;       
      
$real_position 0;  
      
$found   NULL;
      
$lastURL NULL;
    
$searchurl 'mycandysupplier.com';
    
$siteresults = array();
    
$out = array();

      for(
$i=0;$i<10 && empty($found);$i+=$hits_per_page)
      {  
        
$filename "http://www.google.com/search?as_q=$query".
                         
"&num={$hits_per_page}&hl=en&ie=UTF-8&btnG=Google+Search".
                         
"&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=".
                         
"&as_qdr=all&as_nlo=&as_nhi=&as_occt=any&as_dt=i".
                         
"&as_sitesearch=&safe=images&start=$i";
 
          
$file = @fopen($filename"r");
          if (!
$file
          {
              echo 
"<p>Unable to open remote file $filename.\n";
          }
          else
          {          
      echo 
'opened<br>';
              while (!
feof($file))  // load the file into a variable line at a time
              
{
                  
$var fgets($file1024);

              if (
eregi($conditions,$var,$out)) // find the html code this SE uses to show the site URL
                 
{  
            echo 
'get '.$out[1].'<br>';
               
// highlight search terms within URLS 
                       
$out[1] = strtolower(strip_tags($out[1]));
               
// Get the domain name by looking for the first /
               
if (($x strpos($out[1],"/")) !== FALSE)
               {
                 if (
strstr($out[1], "https"))
                  {
                    
$x += 2;
                    
$x strpos($out[1],"/"$x);
                  }
               }
               else
                
$x strlen($out[1]);

               
// and get the URL
                      
$url substr($out[1],0,$x);
               
$url substr($url0strlen($searchurl));
               
$position++;

               
// If the last result process is the same as this one, it
               // is a nest or internal domain result, so don't count it
               // on $real_position
                      
if(strcmp($lastURL,$url)<>0)
                          
$real_position++;

                      
$lastURL $url;

               
// Else if the sites match we have found it!!!
                      
if(strcmp($searchurl,$url)==0)
                      {
                          
$found $position;
                          break; 
// quit - no need to go any further.
                      
}
                      else
               {

                  if (
strpos($searchurl"www") !== FALSE)
                    
$search_alt substr($searchurl4strlen($searchurl) - 4);
                  else
                    
$search_alt sprintf("www.%s",$searchurl);

                         
$url_alt substr($out[1],0,$x);
                  
$url_alt substr($url_alt0strlen($search_alt));

                    if(
strcmp($search_alt,$url_alt)==0)
                  {
                            
$found $position;
                             break; 
// quit - no need to go any further.
                  
}  
                      }                   
                  }
                 }
         
      echo 
'closed';   
          
fclose($file);    
          }         
      }
    
      
$result_google "The site $searchurl is at position $found ".
                
"( $real_position ) for the term <b>$query</b>" " on " "$siteName";
?>
This isn't relevant to the above but when I tried adding the url using the url option, my virus scanner popped up so I add to add them manually.
benton is offline  
Reply With Quote