Responsible for sending final output to browser
Exemplo n.º 1
0
 private function processResponseData(array $response)
 {
     if (!$this->input->is_ajax_request()) {
         redirect('/');
     }
     $this->output->set_content_type('application/json');
     if ($response['code'] == 200) {
         if ($response['data']['success']) {
             $this->output->set_output(json_encode($response['data']['data']));
         }
     }
 }
 public function __construct()
 {
     parent::__construct();
     // Added by Ivan Tcholakov, 24-JAN-2016.
     $this->parse_exec_vars = ENVIRONMENT !== 'production';
     //
 }
Exemplo n.º 3
0
 function _display($output = '')
 {
     if (ENVIRONMENT !== 'development') {
         $this->final_output = str_replace('> <', '><', preg_replace("/\\s+|\n+|\r/", ' ', $this->final_output));
     }
     parent::_display($output);
 }
Exemplo n.º 4
0
 public function __construct()
 {
     parent::__construct();
     // Set the super object to a local variable for use later
     //$this->CI =& get_instance();
     //$this->CI->load->model('tool/report');
 }
Exemplo n.º 5
0
 function __construct()
 {
     parent::__construct();
     $this->final_output = '';
     //would be just set to 'null' in CI_Output
     $this->_ci_ob_level = ob_get_level();
     $this->cookies = array();
 }
 function _display($output = '')
 {
     parent::_display($output);
     if (class_exists('CI_Controller') && class_exists('Smarty_Internal_Debug') && (config_item('smarty_debug') || $this->enable_profiler)) {
         $CI =& get_instance();
         $smarty_debug = new Smarty_Internal_Debug();
         $smarty_debug->display_debug($CI->ci_smarty);
     }
 }
Exemplo n.º 7
0
 public function _display($output = '')
 {
     parent::_display($output);
     // If Smarty is active - NOTE: $this->output->enable_profiler(TRUE) active Smarty debug to simplify
     if (class_exists('CI_Controller') && class_exists('Smarty_Internal_Debug') && (config_item('smarty_debug') || $this->enable_profiler)) {
         $CI =& get_instance();
         Smarty_Internal_Debug::display_debug($CI->smarty);
     }
 }
Exemplo n.º 8
0
 function _write_cache($output)
 {
     if ($this->is_logged_in) {
         // don't write cache if user is logged in
         return false;
     } else {
         // user isn't logged in, proceed as normal
         parent::_write_cache($output);
     }
 }
Exemplo n.º 9
0
 public function cache($minute)
 {
     if (ENVIRONMENT == 'development') {
         return;
     }
     require_once APPPATH . 'hooks/cache_override.php';
     parent::cache($minute);
     $offset = $minute * 60;
     // calc the string in GMT not localtime and add the offset
     $this->set_header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + $offset));
     $this->set_header('Cache-Control: max-age=' . $offset);
     header_remove('Pragma');
     $this->cacheable();
     $this->cache_instance = new Cache_Override();
     $this->cache_instance->lock();
 }
Exemplo n.º 10
0
 /**
  * An override to the CI cache reading mechanism 
  * @param object $CFG CI config object
  * @param object $URI CI uri object
  * @return 
  */
 function _display_cache(&$CFG, &$URI)
 {
     if (!function_exists('apc_add')) {
         return parent::_display_cache($CFG, $URI);
     }
     log_message('debug', 'APC Cache Check');
     $uri = $CFG->item('base_url') . $CFG->item('index_page') . $URI->uri_string;
     $cache_key = md5($uri);
     $output = apc_fetch($cache_key);
     if ($output === FALSE) {
         log_message('debug', 'APC Cache Miss..');
         return FALSE;
     } else {
         log_message('debug', 'APC Cache Hit. Sending to browser.');
     }
     # Display the cached output
     $this->_display($output);
     return TRUE;
 }
Exemplo n.º 11
0
 /**
  * Display the final output
  *
  * @access	public
  * @return	void
  */
 function _display($output = '')
 {
     $EE =& get_instance();
     if ($output == '') {
         $output = $this->final_output;
     }
     // Generate No-Cache Headers
     if ($EE->config->item('send_headers') == 'y' && $this->out_type != 'feed' && $this->out_type != '404' && $this->out_type != 'cp_asset') {
         $this->set_status_header(200);
         $this->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
         $this->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         $this->set_header("Pragma: no-cache");
     }
     // Content Type Headers
     // Also need to do some extra work for feeds
     switch ($this->out_type) {
         case 'webpage':
             $this->set_header("Content-Type: text/html; charset=" . $EE->config->item('charset'));
             break;
         case 'css':
             $this->set_header("Content-type: text/css");
             break;
         case 'js':
             $this->set_header("Content-type: text/javascript");
             $this->enable_profiler = FALSE;
             break;
         case '404':
             $this->set_status_header(404);
             $this->set_header("Date: " . gmdate("D, d M Y H:i:s") . " GMT");
             break;
         case 'xml':
             $this->set_header("Content-Type: text/xml");
             $output = trim($output);
             break;
         case 'feed':
             $this->_send_feed($output);
             break;
         default:
             // Likely a custom template type
             // -------------------------------------------
             // 'template_types' hook.
             //  - Provide information for custom template types.
             //
             $template_types = $EE->extensions->call('template_types', array());
             //
             // -------------------------------------------
             if (isset($template_types[$this->out_type])) {
                 // Set custom headers as defined by the template_headers key,
                 // and replace any headers as necessary
                 if (isset($template_types[$this->out_type]['template_headers'])) {
                     foreach ($template_types[$this->out_type]['template_headers'] as $header) {
                         $this->set_header($header, TRUE);
                     }
                 }
             }
             break;
     }
     // Compress the output
     // We simply set the ci config value to true
     if ($EE->config->item('gzip_output') == 'y' and REQ == 'PAGE') {
         $EE->config->set_item('compress_output', TRUE);
     }
     // Parse query count
     if (REQ != 'CP') {
         $output = str_replace(LD . 'total_queries' . RD, $EE->db->query_count, $output);
     }
     // Send it to the CI method for final processing
     parent::_display($output);
 }
 */
require APPPATH . 'config/config' . EXT;
if (!isset($config) or !is_array($config)) {
    show_error('Your config file does not appear to be formatted correctly.');
}
/*
 * ------------------------------------------------------
 *  Load and instantiate the base classes
 * ------------------------------------------------------
 */
require BASEPATH . 'libraries/Config' . EXT;
require BASEPATH . 'libraries/Router' . EXT;
require BASEPATH . 'libraries/Output' . EXT;
$CFG = new CI_Config($config);
$RTR = new CI_Router($CFG);
$OUT = new CI_Output();
/*
 * ------------------------------------------------------
 *	Is there a valid cache file?  If so, we're done...
 * ------------------------------------------------------
 */
if ($OUT->_display_cache($CFG, $RTR) == TRUE) {
    exit;
}
/*
 * ------------------------------------------------------
 *  Does the requested controller exist?
 * ------------------------------------------------------
 */
if (!file_exists(APPPATH . 'controllers/' . $RTR->fetch_class() . EXT)) {
    show_404();
Exemplo n.º 13
0
 protected function htmlResponse($html)
 {
     return $this->output->set_content_type('text/html')->set_output($html);
 }
Exemplo n.º 14
0
 function set_status_header($code = 200, $text = '')
 {
     $this->set_header('Status-Text: ' . json_encode($text));
     parent::set_status_header($code, $text);
 }
Exemplo n.º 15
0
 /**
  * Constructor
  *
  * @access	public
  * @return	null
  */
 function MY_Output()
 {
     parent::CI_Output();
 }
Exemplo n.º 16
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
 }
Exemplo n.º 17
0
 /**
  * Set output content
  * 
  * @param string $type data type
  * @param array $value data value
  * @return void
  */
 public function setOutputContent($type = 'data', $value = array())
 {
     switch (strtolower($type)) {
         case 'data':
             $this->data = $value;
             break;
         case 'errors':
             $this->errors = $value;
             break;
         case 'success':
             $this->success = $value;
             break;
         case 'template':
             $this->template = $value;
             break;
         case 'code':
             parent::set_status_header($value);
             $this->code = $value;
             break;
         case 'header':
             $this->header = $value;
             break;
         case 'help':
             $this->help = $value;
             break;
         case 'back_link':
             $this->back_link = $value;
             break;
         case 'redirect':
             $this->redirect = $value;
             break;
     }
 }
Exemplo n.º 18
0
 function send_png_header(CI_Output $output)
 {
     //header('Content-type: text/css');
     $header = 'Content-type: image/png';
     $output->set_header($header, TRUE);
 }
Exemplo n.º 19
0
 /**
  * Display the final output
  *
  * @access	public
  * @return	void
  */
 function _display($output = '')
 {
     $EE =& get_instance();
     if ($output == '') {
         $output = $this->final_output;
     }
     // Generate No-Cache Headers
     if ($EE->config->item('send_headers') == 'y' && $this->out_type != 'feed' && $this->out_type != '404' && $this->out_type != 'cp_asset') {
         $this->set_status_header(200);
         $this->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
         $this->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         $this->set_header("Pragma: no-cache");
     }
     // Content Type Headers
     // Also need to do some extra work for feeds
     switch ($this->out_type) {
         case 'webpage':
             $this->set_header("Content-Type: text/html; charset=" . $EE->config->item('charset'));
             break;
         case 'css':
             $this->set_header("Content-type: text/css");
             break;
         case 'js':
             $this->set_header("Content-type: text/javascript");
             $this->enable_profiler = FALSE;
             break;
         case '404':
             $this->set_status_header(404);
             $this->set_header("Date: " . gmdate("D, d M Y H:i:s") . " GMT");
             break;
         case 'xml':
             $this->set_header("Content-Type: text/xml");
             $output = trim($output);
             break;
         case 'feed':
             $this->_send_feed($output);
             break;
     }
     // Parse elapsed time and query count
     if (REQ != 'CP') {
         $output = str_replace(LD . 'total_queries' . RD, $EE->db->query_count, $output);
         // If 'debug' is turned off, we will remove any variables that didn't get parsed due to syntax errors.
         if ($EE->config->item('debug') == 0 and $this->remove_unparsed_variables == TRUE) {
             $output = preg_replace("/" . LD . "[^;\n]+?" . RD . "/", '', $output);
         }
     }
     // Compress the output
     // We simply set the ci config value to true
     if ($EE->config->item('gzip_output') == 'y' and REQ == 'PAGE') {
         $EE->config->set_item('compress_output', TRUE);
     }
     // Send it to the CI method for final processing
     parent::_display($output);
 }
Exemplo n.º 20
0
 /**
  * (non-PHPdoc)
  * @see system/libraries/CI_Output#_display($output)
  */
 function _display($output = '')
 {
     if ($output == '') {
         $output = $this->get_output();
     }
     switch ($this->_mode) {
         case self::OUTPUT_MODE_TEMPLATE:
             $output = $this->get_template_output($output);
             break;
         case self::OUTPUT_MODE_NORMAL:
         default:
             $output = $output;
             break;
     }
     parent::_display($output);
 }
Exemplo n.º 21
0
 function __construct()
 {
     parent::__construct();
     $this->_ci_ob_level = ob_get_level();
     $this->cookies = array();
 }
Exemplo n.º 22
0
 /**
  * Class constructor
  *
  * Determines whether zLib output compression will be used.
  *
  * @return	void
  */
 public function __construct()
 {
     $this->_zlib_oc = (bool) ini_get('zlib.output_compression');
     $this->_compress_output = $this->_zlib_oc === FALSE && config_item('compress_output') === TRUE && extension_loaded('zlib');
     isset(self::$func_override) or self::$func_override = extension_loaded('mbstring') && ini_get('mbstring.func_override');
     // Get mime types for later
     $this->mimes =& get_mimes();
     log_message('info', 'Output Class Initialized');
 }
Exemplo n.º 23
0
 function __construct()
 {
     parent::__construct();
     //Se fuerza que el contenido sea UTF-8
     $this->set_content_type('text/html; charset=utf-8');
 }