andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


generate a page hash using cURL

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> WWW Checkup
View previous topic :: View next topic  
Author Message
already_dead
Newbie


Joined: 21 Dec 2005
Posts: 11

PostPosted: Sat Jan 21, 2006 8:52 pm    Post subject: generate a page hash using cURL Reply with quote

I came back after fixing my snag with fopen(). Here's the function that replaces the need for fopen(), a function some hosts disable.
Code:
<?php

function generate_page_hash($url, $get_amount, $get_header) {
   echo "Generating page hash from remote computer: ";
   echo $url . "<br />";         
   global $page_hash;   
   $channel = curl_init($url);
   curl_setopt($channel, CURLOPT_HEADER, $get_header);
   curl_setopt($channel, CURLOPT_RANGE, $get_amount);
   curl_setopt($channel, CURLOPT_RETURNTRANSFER, 1);
   $file_content = curl_exec($channel);
   curl_close($channel);
   $file_notags = strip_tags($file_content);
   $page_hash = md5($file_notags);
echo "COMPUTING... done:";
echo $page_hash;
}
generate_page_hash('http://www.yahoo.com',1000000,0);
?>
Back to top
View user's profile Send private message Visit poster's website
already_dead
Newbie


Joined: 21 Dec 2005
Posts: 11

PostPosted: Tue Jan 24, 2006 3:41 pm    Post subject: so andy Reply with quote

Code:
   function CheckAll()
   {
      $sql = "SELECT id,website,hash,UNIX_TIMESTAMP(lastchecked) AS lastchecked,UNIX_TIMESTAMP(lastupdated) AS lastupdated FROM {$this->tbl}";
      $result = @mysql_query($sql, $this->id) or die("Unable to perform query: $sql");
      while ($row = @mysql_fetch_array($result, MYSQL_ASSOC))
      {
         $site = array();
         set_time_limit(120);
         $site = @file($row['website']);


So, what I was thinking is if I could figure out how to replace the last line $site = @file($row['website']); with something that doesn't use @file, I would be able to get it working on my host, and probably a lot of other hosts. Site is an array, can you show me what would go into this array? ('one'->'xyz','two'->'xzy')
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Wed Jan 25, 2006 3:51 am    Post subject: Reply with quote

Imagine you connected to a web site that had this for the content:

Code:
<html>
<body>
<p>Hello world!</p>
</body>
</html>


then the $site array would be:

Code:
Array
(
    [0] => <html>
    [1] => <body>
    [2] => <p>Hello world!</p>
    [3] => </body>
    [4] => </html>
)


That array is then made in to a hash using the following:

Code:
$hash = md5(strip_tags(join('', $site)));


But instead of getting the site and then making the hash, you could use your cURL based method to get the hash.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> WWW Checkup All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group