[eluser]Unknown[/eluser]
I am trying to store each user cache in their specific folder. Each user has a uniqe id stored in their session. This id will be the folder name inside system/cache/ directory.
But the session is not accessable in side this function and always returns and error: Fatal error: Call to undefined function get_instance()
Below is the complete code
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Cache file naming routine factored out to allow for manual deletion.
*
* Responsible for sending final output to browser
*
* @package CodeIgniter
* @subpackage Libraries
* @hacked-by Bradford Mar
*/
class MY_Output extends CI_Output {
/**
* Get the uri of a given cached page
*
* @access public
* @return
*/
function get_cache_URI($set_uri = null,$user_box = null){
$CFG =& load_class('Config');
$URI =& load_class('URI');
$CI =& get_instance();
$set_uri = (isset($set_uri)) ? $set_uri : $URI->uri_string;
$user_box = $CI->session->userdata('box_id');
$cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/'.$user_box.'/' : $CFG->item('cache_path');
if ( ! is_dir($cache_path))
{
mkdir($cache_path, 0777);
if(! is_really_writable($cache_path)){
return FALSE;
}
}
/*
* Build the file path. The file name is an MD5 hash of the full URI
*
* NOTE: if you use .htaccess to remove your "index.php" file in the url
* you might have to prepend a slash to the submitted$set_uri in order to
* get it working.
*/
$uri = $CFG->item('base_url').
$CFG->item('index_page').
$set_uri;
return array('path'=>$cache_path, 'uri'=>$uri);
}
}
// END MY_Output Class
/* End of file MY_Output.php */
/* Location: ./system/application/libraries/MY_Output.php */
Any idea how i can do this in a better way?