Results 1 to 7 of 7
-
2nd Oct 2011, 08:35 PM #1OPMember
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 ~*
-
2nd Oct 2011, 08:37 PM #2Banned
Wha tis the platform? is it VB?
-
2nd Oct 2011, 08:38 PM #3OPMember
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 ~*
-
2nd Oct 2011, 09:45 PM #4MemberWebsite's:
tehMoviez.com 0Senes.com GeekFaceGames.comyou may run a script on specific db tables to make the following:
- get data from database
- seeks for img tags (regex)
- downloads the image file
- replaces the original image url in the article
- saves the new article
JokerHacker Blog
JokerHacker PHP coding Service // back again!
CurlAxel PHP Download Accelerator
hardly remembering the milk :p
-
2nd Oct 2011, 09:58 PM #5OPMember
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 ~*
-
2nd Oct 2011, 10:00 PM #6MemberWebsite's:
tehMoviez.com 0Senes.com GeekFaceGames.comnot clear enough... explain
JokerHacker Blog
JokerHacker PHP coding Service // back again!
CurlAxel PHP Download Accelerator
hardly remembering the milk :p
-
2nd Oct 2011, 10:16 PM #7Respected 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($imagesPath, file_get_contents($otherSiteUrl))){
echo 'Failed to download file';
$imagesPath = null;
}
}
echo $imagesPath;
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.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
need imagehost support caching
By Proaudiozone.info in forum WordpressReplies: 3Last Post: 10th Oct 2012, 10:47 AM -
Optimizing APC Caching
By m1mi.dan0s in forum Webmaster DiscussionReplies: 3Last Post: 3rd Oct 2012, 08:37 AM -
Some help with browser caching
By beebee in forum Web Application/Script SupportReplies: 1Last Post: 18th Sep 2012, 02:38 PM -
[PHP] Twitter Feed Reader + Caching
By Whoo in forum Web Development AreaReplies: 0Last Post: 10th Feb 2012, 06:54 PM -
I need a good External facebook like/share script!
By Okenyon in forum Web Development AreaReplies: 1Last Post: 13th Feb 2011, 05:31 PM
themaCreator - create posts from...
Version 3.24 released. Open older version (or...