dats cached result which is saving the resource & CPU usage, the cache is stored for 10000 secs by default & then again updated
Ultimate fourshared leecher!
Collapse
X
-
Originally posted by smart View PostBro can teach me how to add cache option in any simple grabber script ?
let's say you're trying to grab a webpage, w/ the below code
PHP Code:$url = "http://example.com";
$file = file_get_content($url);
echo $file; //simple enough to understand
But you can make use of a cool php function ob_start(); which will start output buffering
PHP Code:/*
create a variable for the file dat will be used to show cached content
*/
$cache_filename = 'cache/'.md5($_SERVER['REQUEST_URI']);
/*
$_SERVER['REQUEST_URI'] will make an unique identity for each url w/ query strings
i.e http://some.com/file.php?foo=bar&bar=foo
*/
/*
Let's make a function,to overcome repeating codes in every page
*/
function load_cache($cache_time, $cache_filename)
{
/*check if,the cache file already exists, & the filesize is more than the given value
why filesize?
Incase the function you're using to fetch the page(may be file_get_contents/cURL or something else) returns false(i.e the requested server is unresponsive),the cache file will remain blank,
& if you dont use the filesize param, the blank page will be shown to the visitors...
*/
if (file_exists($cache_filename) && filesize($cache_filename) > 10) //
{
// the time the file was created
$cache_created = filemtime($cache_filename);
}
else
{
// if the file was not found
$cache_created = 0;
}
if ((time() - $cache_created) < $cache_time)
{
return TRUE;
}
else
{
return FALSE;
}
//now use the function
if(load_cache(1000, $cache_filename))
{
//the first param,i.e cache time,1000 here,cuz i wana update the cache every 1000 secs
//if it returns true,it'll mean the file exist, & we can show it to the visitor
require_once $cache_filename;
}
else
{
$url = "http://example.com";
$file = file_get_content($url);
//start output_buffering, which will prevent outputting directly to the browser
ob_start();
echo $file;
/*
//you can put anything here which you want to cache
echo "blah blah";
*/
$cached_content = ob_get_contents(); // this will save the buffer in a variable,
//if you don't understand,it's same like collecting rainwater in a tub :D
//Now put the cached contents in a file which will be served to the next user,requesting the same URL
file_put_contents($cache_filename, $cached_content);
//flush the current buffer output , you may also use the buffer dat you save i.e $cached_content
ob_end_flush();
}
PHP Code:
$cache_filename = 'cache/'.md5($_SERVER['REQUEST_URI']);
if(load_cache(1000, $cache_filename))
{
require_once $cache_filename;
}
else
{
$url = "http://example.com";
$file = file_get_content($url);
ob_start();
echo $file;
$cached_content = ob_get_contents();
file_put_contents($cache_filename, $cached_content);
ob_end_flush();
list of the functions used which will help you to understand better
PHP: ob_start - Manual
PHP: ob_end_flush - Manual
PHP: ob_get_contents - Manual
PS: i learnt it from someone's script when I used to be dead noob but modifed it later to make it work better...Last edited by softwarefreak; 07.03.12, 07:29.I need some facebook likes, can you please help me
http://facebook.com/softwarefreakin
I noticed social media is really powerful
Well DONE is better than well SAID
Comment
-
-
Originally posted by demzx View Post
403 Permission Denied
i think they got file inclusion protection or something that don't allow http:// in url path mod the file and replace http:// from grabbed links and open it internal ...Last edited by just_m3.; 07.03.12, 21:56.This is ten percent luck, twenty percent skill
Fifteen percent concentrated power of will
Five percent pleasure, fifty percent pain
And a hundred percent reason to remember the name!
Comment
-
How do i need to fix the problem?? do i need to change anything in files?? yeah think it wus the http://
when this :
it showed.
when this :
403 Permission Denied
it not showed.
Comment
-
Originally posted by demzx View PostHow do i need to fix the problem?? do i need to change anything in files?? yeah think it wus the http://
when this :
it showed.
when this :
403 Permission Denied
it not showed.
Search results for - enrique
I need some facebook likes, can you please help me
http://facebook.com/softwarefreakin
I noticed social media is really powerful
Well DONE is better than well SAID
Comment
-
Originally posted by softwarefreak View PostHi bro, follow this,it's an easy thing...
let's say you're trying to grab a webpage, w/ the below code
PHP Code:$url = "http://example.com";
$file = file_get_content($url);
echo $file; //simple enough to understand
But you can make use of a cool php function ob_start(); which will start output buffering
PHP Code:/*
create a variable for the file dat will be used to show cached content
*/
$cache_filename = 'cache/'.md5($_SERVER['REQUEST_URI']);
/*
$_SERVER['REQUEST_URI'] will make an unique identity for each url w/ query strings
i.e http://some.com/file.php?foo=bar&bar=foo
*/
/*
Let's make a function,to overcome repeating codes in every page
*/
function load_cache($cache_time, $cache_filename)
{
/*check if,the cache file already exists, & the filesize is more than the given value
why filesize?
Incase the function you're using to fetch the page(may be file_get_contents/cURL or something else) returns false(i.e the requested server is unresponsive),the cache file will remain blank,
& if you dont use the filesize param, the blank page will be shown to the visitors...
*/
if (file_exists($cache_filename) && filesize($cache_filename) > 10) //
{
// the time the file was created
$cache_created = filemtime($cache_filename);
}
else
{
// if the file was not found
$cache_created = 0;
}
if ((time() - $cache_created) < $cache_time)
{
return TRUE;
}
else
{
return FALSE;
}
//now use the function
if(load_cache(1000, $cache_filename))
{
//the first param,i.e cache time,1000 here,cuz i wana update the cache every 1000 secs
//if it returns true,it'll mean the file exist, & we can show it to the visitor
require_once $cache_filename;
}
else
{
$url = "http://example.com";
$file = file_get_content($url);
//start output_buffering, which will prevent outputting directly to the browser
ob_start();
echo $file;
/*
//you can put anything here which you want to cache
echo "blah blah";
*/
$cached_content = ob_get_contents(); // this will save the buffer in a variable,
//if you don't understand,it's same like collecting rainwater in a tub :D
//Now put the cached contents in a file which will be served to the next user,requesting the same URL
file_put_contents($cache_filename, $cached_content);
//flush the current buffer output , you may also use the buffer dat you save i.e $cached_content
ob_end_flush();
}
PHP Code:
$cache_filename = 'cache/'.md5($_SERVER['REQUEST_URI']);
if(load_cache(1000, $cache_filename))
{
require_once $cache_filename;
}
else
{
$url = "http://example.com";
$file = file_get_content($url);
ob_start();
echo $file;
$cached_content = ob_get_contents();
file_put_contents($cache_filename, $cached_content);
ob_end_flush();
Comment
-
Originally posted by demzx View Post@sofwarefreak,
Bro its via_google.php // not working on xml_api.php
Any idea anyone ??
Originally posted by smart View Postbro should i create cache folder in same grabber folder ?I need some facebook likes, can you please help me
http://facebook.com/softwarefreakin
I noticed social media is really powerful
Well DONE is better than well SAID
Comment
-
Originally posted by Macneth View Posti wonder if the preview.pm3 will be replace of its original file name..
rihana - live your life.mp3 - free download!Last edited by softwarefreak; 09.03.12, 11:32.I need some facebook likes, can you please help me
http://facebook.com/softwarefreakin
I noticed social media is really powerful
Well DONE is better than well SAID
Comment
-
Originally posted by softwarefreak View PostYou're joking? mp3 files are saved as original file names not preview.mp3, yeah there's an alternative download link which saves files as preview.mp3,you can remove it from flash.php
rihana - live your life.mp3 - free download!
Last edited by Macneth; 10.03.12, 10:24.
Comment
-
Originally posted by Macneth View Post
Added after 5 minutes:
Originally posted by JishnutpHey bro in the picture and vid sections when we usemsearch it doesnt give thumnails but when using it from search it gives thumbs can you fix this my site Mr.Downloader - Free search and download!
Added after 6 minutes:
Here check an mp4 search Search results for - Rihanna
Forgot to say
My demo
Mr.Downloader - Free search and download!
& sorry no personal help for dem,who doesn't likes giving any credits to the script, use it if you want or else DONT! thank youLast edited by softwarefreak; 10.03.12, 11:14.I need some facebook likes, can you please help me
http://facebook.com/softwarefreakin
I noticed social media is really powerful
Well DONE is better than well SAID
Comment
-
Originally posted by Macneth View Post
just replace your old flash.php code with this and its done....
PHP Code:<?php
echo '<div style="display:inline;float:right;"><object type="application/x-shockwave-flash" data="/dewplayer.swf?mp3=preview.php?url='.$preview.'" width="200" height="18" id="dewplayer"><param name="wmode" value="transparent" /><param name="movie" value="/dewplayer-vol.swf?mp3=preview.php?url='.$preview.'" /></object>
<a href="/initiate.php?url='.$link.'" title="Download Now"><img src="hide.png" /></a></div>';
?>Sandeep DiL (INDIAN)
Comment
Comment