Activity Stream
48,167 MEMBERS
61058 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 7 of 7
  1.     
    #1
    Member

    Default Php: external caching script

    Hello, i'm looking for a script that caches data (mostly images) from an external site to my own server. Example: MYSITE/cache.php?=image.png: cache.php gets image.png from an external site and saves it to the server and sent the local copy the next time image.png is requested
    iMaarten Reviewed by iMaarten on . Php: external caching script Hello, i'm looking for a script that caches data (mostly images) from an external site to my own server. Example: MYSITE/cache.php?=image.png: cache.php gets image.png from an external site and saves it to the server and sent the local copy the next time image.png is requested Rating: 5
    *~ 24Khost.com ~*
    *~ Shared,Reseller, Master Reseller, and Cloud VPS Provider ~*
    *~ Check out our site at 24Khost.com ~*

  2.   Sponsored Links

  3.     
    #2
    Banned
    Wha tis the platform? is it VB?

  4.     
    #3
    Member
    My own platform, it doesn't need to be integraded in the site.
    *~ 24Khost.com ~*
    *~ Shared,Reseller, Master Reseller, and Cloud VPS Provider ~*
    *~ Check out our site at 24Khost.com ~*

  5.     
    #4
    Member
    Website's:
    tehMoviez.com 0Senes.com GeekFaceGames.com
    you may run a script on specific db tables to make the following:

    1. get data from database
    2. seeks for img tags (regex)
    3. downloads the image file
    4. replaces the original image url in the article
    5. saves the new article


  6.     
    #5
    Member
    The problem is they are dynamic images made by a script
    *~ 24Khost.com ~*
    *~ Shared,Reseller, Master Reseller, and Cloud VPS Provider ~*
    *~ Check out our site at 24Khost.com ~*

  7.     
    #6
    Member
    Website's:
    tehMoviez.com 0Senes.com GeekFaceGames.com
    not clear enough... explain

  8.     
    #7
    Respected Developer
    i assume you always have to download only from one site, see the code below
    PHP Code: 
        $url 'site.com/cache.php?=image.png';
        
    $url parse_url($url,PHP_URL_QUERY);
        
    $imgFile preg_replace("/^=/","",$url);
        
    // set your images folder path here
        
    $imagesPath =  " images/".$imgFile;

        if(!
    file_exists(($imagesPath))) {
            
            
    // i assume you always have to download from only one website
            // i.e http://thatsite.com/image.png
            
            
    $otherSiteUrl  'http://thatsite.com/' .  $imgFile;
            if(!
    file_put_contents($imagesPathfile_get_contents($otherSiteUrl))){
                echo 
    'Failed to download file';
                
    $imagesPath null;
            }
        }
        echo 
    $imagesPath
    edit: if you wants to display the image itself instead of echo location to it, replace echo $imagesPath with below code
    PHP Code: 
    if(!empty($imagesPath)) {
            
    $fileParts  pathinfo($imagesPath);
            
    $fileExtenstion $fileParts['extension'];
            switch( 
    $fileExtenstion ) {
            case 
    "gif":
                
    $type="image/gif";
            break;
            case 
    "png":
                
    $type="image/png";
            break;
            case 
    "jpg":
                
    $type="image/jpg";
            break;
            default:
                
    $type="image/jpg";
            }
            
    header("Content-Type: $type");
            
    readfile($imagesPath);
        } 
    Bots Development | Web Development | Wordpress Customization | PSD Conversion

    Life has many twists and turns in it, you have to take what you are given and use it for the best.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. need imagehost support caching
    By Proaudiozone.info in forum Wordpress
    Replies: 3
    Last Post: 10th Oct 2012, 10:47 AM
  2. Optimizing APC Caching
    By m1mi.dan0s in forum Webmaster Discussion
    Replies: 3
    Last Post: 3rd Oct 2012, 08:37 AM
  3. Some help with browser caching
    By beebee in forum Web Application/Script Support
    Replies: 1
    Last Post: 18th Sep 2012, 02:38 PM
  4. [PHP] Twitter Feed Reader + Caching
    By Whoo in forum Web Development Area
    Replies: 0
    Last Post: 10th Feb 2012, 06:54 PM
  5. I need a good External facebook like/share script!
    By Okenyon in forum Web Development Area
    Replies: 1
    Last Post: 13th Feb 2011, 05:31 PM

Tags for this Thread

BE SOCIAL