HTML Help Forum HTML Help
Please Search for the answer to your question before asking it! Thanks.
 

Spider.php
Post a Reply to this Topic Ask a New Question
Click here to go to the original topic
       HTML Help Forum -> PHP
View previous topic :: View next topic  
Author Message
jarodco



Joined: 09 Jun 2009
Posts: 21

Posted: Tue Aug 25, 2009 10:30 am     Spider.php  

what's wrong here:

Database is right:
Code:
<?
      if (isset($_GET['url']))

      {
      $accountname='jarodco_sec123';
      $password='sec';
      $dbhost='localhost';
      $database='jarodco_ip';

      mysql_connect($dbhost,$accountname,$password)
      or die("Could not connect to MySQL server");
      mysql_select_db($database) or die(mysql_error()."Could not select database");

      $file=file_get_contents($_GET['url']);

      $links=preg_split('/(href\=\'|href\=\"|href\=)/is',$file);

      //$file=preg_replace('/(.*)(\ href\=\"|\ href\=\'|\ href=)(.*\ |.*\"|.*\'|.*>)/is','$2|^=^|',$file,1);

      //echo $file."<br>";

      mysql_query("INSERT INTO `indextemp` SET `url`='".$_GET['url']."', `stage`='1'");

      $id=1;
 
      while (isset($links[$id]))
 
      {
 
      $links[$id]=preg_replace("/([^\'])\'(.*)/is",'$1',$links[$id]);
 
      $links[$id]=preg_replace("/([^\"])\"(.*)/is",'$1',$links[$id]);
 
      $links[$id]=preg_replace("/([^\>])\>(.*)/is",'$1',$links[$id]);
 
      $links[$id]=preg_replace("/([^ ])\ (.*)/is",'$1',$links[$id]);
 
      $links[$id]=preg_replace("/([^\'])\'(.*)/i",'$1',$links[$id]);
 
      $links[$id]=preg_replace("/([^\"])\"(.*)/i",'$1',$links[$id]);
 
      $links[$id]=preg_replace("/([^\>])\>(.*)/i",'$1',$links[$id]);

      $links[$id]=@preg_replace("/([^ ])\ (.*)/i",'$1',$links[$id]);

      $ifexists=mysql_query("SELECT * FROM `indextemp` WHERE `url`='".$links[$id]."'");

      if (mysql_num_rows($ifexists)==0 && strlen($links[$id])>16)

      {

      mysql_query("INSERT INTO `indextemp` SET `url`='".$links[$id]."', `stage`='0'");
 
      echo $links[$id]."<br>";

      }

      $id+=1;

      }

      unset ($links);

      $continue=1;

      while ($continue=1)

      {

      $sqllinksa=mysql_query("SELECT * FROM `indextemp` WHERE `stage`='0'");

      while ($sqllinksa =mysql_fetch_array($sqllinksa))

      {

      $file=file_get_contents($sqllinks['url']);

      $links=preg_split('/(href\=\'|href\=\"|href\=)/is',$file);

      mysql_query("UPDATE `indextemp` SET `stage`='1' WHERE `url`='".$sqllinks['url']."'");

      $id=1;

      while (isset($links[$id]))

      {

      $links[$id]=preg_replace("/([^\'])\'(.*)/is",'$1',$links[$id]);

      $links[$id]=preg_replace("/([^\"])\"(.*)/is",'$1',$links[$id]);
 
      $links[$id]=preg_replace("/([^\>])\>(.*)/is",'$1',$links[$id]);

      $links[$id]=preg_replace("/([^ ])\ (.*)/is",'$1',$links[$id]);

      $links[$id]=preg_replace("/([^\'])\'(.*)/i",'$1',$links[$id]);

      $links[$id]=preg_replace("/([^\"])\"(.*)/i",'$1',$links[$id]);

      $links[$id]=preg_replace("/([^\>])\>(.*)/i",'$1',$links[$id]);

      $links[$id]=preg_replace("/([^ ])\ (.*)/i",'$1',$links[$id]);


      $ifexist=mysql_query("SELECT * FROM `indextemp` WHERE `url`='".$links[$id]."'");

      if (strlen($links[$id])>5 && mysql_num_rows($ifexist)==0)

      {
 
      mysql_query("INSERT INTO `indextemp` SET `url`='".$links[$id]."', `stage`='0'");
 
      echo $links[$id]."<br>";
 
      } else { unset($ifexists['url']); }
 
      $id+=1;
 
      }
 
       
 
       
 
      $ifexists=mysql_query("SELECT * FROM `indextemp` WHERE `url`='".$links[$id]."'");
 
      $ifexists=mysql_fetch_array($ifexists);
 
      if (!isset($ifexists['url']) && strlen($links[$id])>5)
 
      {
 
      mysql_query("INSERT INTO `indextemp` SET `url`='".$links[$id]."', `stage`='0'");
 
      echo $links[$id]."<br>";
 
      }
 
      }
 
      $checkcontinue=mysql_query("SELECT * FROM `indextemp` WHERE `stage`='0'");
 
      if (mysql_num_rows($checkcontinue)==0)

      {

      $continue=0;
 
      break;
 
      }
 
      }

      //

      }

      echo "<form><input type='text' name='url' size=50><input type='submit' value='index'></form>";

      ?>
 
 
DARFUR
HOSTING / DESIGN
MAKE MONEY

       HTML Help Forum -> PHP
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group