Results 1 to 5 of 5

Thread: thumbshots cached on own server

  1. #1
    Join Date
    Feb 2005
    Location
    Antwerp, Belgium
    Posts
    118

    Default thumbshots cached on own server

    Hi,

    i have thumbs provided from thumshots.org on my directory.

    want i want is that these images can be cached on my server. why?

    google images !! (i have another site with a lot o pics and there is coming a huge amaont of visitors tru google images.(50% of visitors))
    there is a free php script on their site but i can 't manage it to work.

    can someone have a look at this script?

    PHP Code:
    /*
    PHP Function to Locally store website images from http://www.thumshots.org
    Code is free. No guarantees or warranties.

    usage:
    <img src="<? echo get_thumb("[LINK]"); ?>">

    requires:
    PHP 4 >= 4.3.0
    */

    function get_thumb($url) {
        //EDITABLE PARAMETERS
        $local_thumb_dir="img/thumbs"; //Where Thumbnail images are stored locally
                                       //Web Server needs to be able to write here
        $days_to_keep=60;              //How many days till check if new thumbnail
        $return_img="/img/p.gif";      //To use if no thumbnail exists
        //END EDITABLE

        if(substr($url,0,4)!='http') $url='http://' . $url; //Make sure URL proper
        $url=urlencode($url);
        $fname=str_replace(array('%3A','%2F'),'_',$url);
        $full_img_path=$_SERVER['DOCUMENT_ROOT'] . "/$local_thumb_dir/$fname.jpg";

        if(file_exists($full_img_path)) {
            //check age
            $diff=(time() - filemtime($full_img_path))/60/60/24;
            if ($diff > $days_to_keep) {
                unlink($full_img_path);
            } else {
                $return_img="/$local_thumb_dir/$fname.jpg";
            }   
        }

        if(!file_exists($full_img_path)) {
            //get from thumbshots.org
            $buff=file_get_contents("http://open.thumbshots.org/image.pxf?url=$url");
            if($buff!="") {
                $fp=fopen($full_img_path, "wb");
                fwrite($fp,$buff);
                 fclose($fp);
                $return_img="/$local_thumb_dir/$fname.jpg";
            }
        }

        return $return_img;
    }
    i think that $url must be replaced somehow with <%url%> isn't it?

    greetings peter

  2. #2
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    in php the url is correct, its only the tempaltes you need to use <%url%>
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  3. #3
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    I can se eno reaosn why the above wouldnt work if the directory is writeable... nothing obvious.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  4. #4
    Join Date
    Feb 2005
    Location
    Antwerp, Belgium
    Posts
    118

    Default

    i look for an answer in another threat....about the html to image.

    http://www.nicecoder.com/community/s...ead.php?t=3055

    i 'm going to try to make them myself ( the thumbs ) and serve them from my own server.
    Last edited by landuyt; 10-11-2005 at 11:45 AM.

  5. #5
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    thats the best way... thumbshots isnt great.

    Pity home made solutions are always a bit "cludgy" to do this, i have yet to find something server side that just Works.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

Similar Threads

  1. Replies: 1
    Last Post: 08-14-2005, 04:30 PM
  2. Replies: 2
    Last Post: 06-20-2005, 12:56 AM
  3. Fatal error - moved to new server !
    By 12noon in forum v5.x
    Replies: 23
    Last Post: 01-23-2005, 08:08 AM
  4. Changed my server - script error
    By 12noon in forum v5.x
    Replies: 2
    Last Post: 10-09-2004, 07:09 AM
  5. Mail Server question
    By craven in forum v5.x
    Replies: 2
    Last Post: 08-22-2002, 08:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •