- <?Php
-
- class Cache
- {
- function Cache( $Dir , $Exp )
- {
- $this->DirCache = './' . $Dir . '/';
- $this->FilCache = $this->DirCache . md5( $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ] ) . '.cache';
-
- if( !$this->verif( $this->DirCache ) )
- {
- die( "The Directory Cache doesn't exist" );
- }
-
- if( ( ( @file_exists( $this->FilCache ) ) ? @filemtime( $this->FilCache ) : 0 ) > time() - $Exp )
- {
- echo "<!-- Start Cache File //-->\r\n\r\n";
- readfile( $this->FilCache );
- echo "\r\n\r\n<!-- End Cache File //-->\r\n";
- exit;
- }
-
- ob_start();
- }
-
- function verif( $dir )
- {
- if( !is_dir( $dir ) )
- {
- if( !@mkdir( $dir , 0777 ) && function_exists( 'system' ) )
- {
- @system( 'mkdir ' . $dir );
- return $this->verif( $dir );
- }
- elseif( !is_dir( $dir ) )
- {
- return false;
- }
- }
-
- return true;
- }
-
- function EndCache()
- {
- $this->t = @fopen( $this->FilCache , 'w+' );
- @fputs( $this->t , ob_get_contents() );
- @fclose( $this->t );
- ob_end_flush();
- }
- }
-
-
- ?>
<?Php
class Cache
{
function Cache( $Dir , $Exp )
{
$this->DirCache = './' . $Dir . '/';
$this->FilCache = $this->DirCache . md5( $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ] ) . '.cache';
if( !$this->verif( $this->DirCache ) )
{
die( "The Directory Cache doesn't exist" );
}
if( ( ( @file_exists( $this->FilCache ) ) ? @filemtime( $this->FilCache ) : 0 ) > time() - $Exp )
{
echo "<!-- Start Cache File //-->\r\n\r\n";
readfile( $this->FilCache );
echo "\r\n\r\n<!-- End Cache File //-->\r\n";
exit;
}
ob_start();
}
function verif( $dir )
{
if( !is_dir( $dir ) )
{
if( !@mkdir( $dir , 0777 ) && function_exists( 'system' ) )
{
@system( 'mkdir ' . $dir );
return $this->verif( $dir );
}
elseif( !is_dir( $dir ) )
{
return false;
}
}
return true;
}
function EndCache()
{
$this->t = @fopen( $this->FilCache , 'w+' );
@fputs( $this->t , ob_get_contents() );
@fclose( $this->t );
ob_end_flush();
}
}
?>