  ,   dle_cache ,       integrator.php

if ( !function_exists( "dle_cache" ) ){
	function dle_cache($prefix, $cache_id = false, $member_prefix = false) {
		global $config, $is_logged, $member_id;
		if( $config['allow_cache'] != "yes" ) return false;
		if( $is_logged ) $end_file = $member_id['user_group'];
		else $end_file = "0";
		if( ! $cache_id ) {
			$filename = ENGINE_DIR . '/cache/' . $prefix . '.tmp';
		} else {
			$cache_id = md5( $cache_id );
			if( $member_prefix ) $filename = ENGINE_DIR . "/cache/" . $prefix . "_" . $cache_id . "_" . $end_file . ".tmp";
			else $filename = ENGINE_DIR . "/cache/" . $prefix . "_" . $cache_id . ".tmp";
		}
		return @file_get_contents( $filename );
	}
}
if ( !function_exists( "create_cache" ) ){
	function create_cache($prefix, $cache_text, $cache_id = false, $member_prefix = false) {
		global $config, $is_logged, $member_id;
		if( $config['allow_cache'] != "yes" ) return false;
		if( $is_logged ) $end_file = $member_id['user_group'];
		else $end_file = "0";
		if( ! $cache_id ) {
			$filename = ENGINE_DIR . '/cache/' . $prefix . '.tmp';
		} else {
			$cache_id = md5( $cache_id );
			if( $member_prefix ) $filename = ENGINE_DIR . "/cache/" . $prefix . "_" . $cache_id . "_" . $end_file . ".tmp";
			else $filename = ENGINE_DIR . "/cache/" . $prefix . "_" . $cache_id . ".tmp";
		}
		$fp = fopen( $filename, 'wb+' );
		fwrite( $fp, $cache_text );
		fclose( $fp );
		@chmod( $filename, 0666 );
	}
}
if ( !function_exists( "clear_cache" ) ){
	function clear_cache($cache_area = false) {
		$fdir = opendir( ENGINE_DIR . '/cache' );
		while ( $file = readdir( $fdir ) ) {
			if( $file != '.' and $file != '..' and $file != '.htaccess' and $file != 'system' ) {
				if( $cache_area ) {
					if( strpos( $file, $cache_area ) !== false ) @unlink( ENGINE_DIR . '/cache/' . $file );
				} else {
					@unlink( ENGINE_DIR . '/cache/' . $file );
				}
			}
		}
	}
}