public function index() { $display = ''; $this->load->helper('corestatus'); if (!CoreStatus_initialFile()) { $this->load->helper('printerlog'); PrinterLog_logError('status files initialisation error when MY_Controller started', __FILE__, __LINE__); // let request failed $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; header($protocol . ' 500'); header('Content-type: text/plain; charset=UTF-8'); echo 'file initialisation error'; exit; } // $this->output->set_content_type('text/plain; charset=UTF-8'); $this->output->set_content_type('txt_u'); $display .= 'Log level: ' . $this->config->item('log_level') . "\n"; if (file_exists($this->config->item('log_file'))) { $array_log = @file($this->config->item('log_file')); foreach ($array_log as $line) { $display .= $line; } } else { $display .= "no log file\n"; } $this->load->library('parser'); $this->parser->parse('plaintxt', array('display' => $display)); // $this->output->set_header('Location: /test_log/debug'); return; }
public function __construct() { parent::__construct(); $this->load->helper('corestatus'); if (!CoreStatus_initialFile()) { $this->load->helper('printerlog'); PrinterLog_logError('status files initialisation error when MY_Controller started', __FILE__, __LINE__); // let request failed $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; header($protocol . ' 500'); header('Content-type: text/plain; charset=UTF-8'); echo 'file initialisation error'; exit; } return; }
public function __construct() { global $CFG; parent::__construct(); // $this->load->helper(array('corestatus', 'url')); $this->load->helper(array('corestatus', 'printerlog')); // set proper error handler set_error_handler(array($this, 'errorToSSO')); // add header to disable cache (IE need these headers) $this->output->set_header('Pragma: no-cache'); $this->output->set_header('Cache-Control: no-cache'); // initialisation status files if (!CoreStatus_initialFile()) { $this->load->helper('printerlog'); PrinterLog_logError('status files initialisation error when MY_Controller started', __FILE__, __LINE__); // let request failed $this->_exitWithError500('file initialisation error'); } // check tromboning autorisation if (CoreStatus_checkTromboning(FALSE)) { $this->load->helper(array('printerlog', 'errorcode')); PrinterLog_logMessage('detected and refused tromboning connection', __FILE__, __LINE__); // let request failed $this->_exitWithError500(ERROR_REMOTE_REFUSE . ' ' . MyERRMSG(ERROR_REMOTE_REFUSE), ERROR_REMOTE_REFUSE); } // Workflow management if (CoreStatus_checkCallREST()) { // we place the control for REST web service in his own class // because there are the special error codes for REST web service // and we do not need them in normal condition return; } else { $status_current = ''; $url_redirect = ''; $array_status = array(); // stats info (do not stats rest, app can initialize cookies in each request) $this->load->library('session'); if (FALSE === $this->input->cookie('stats_browserLog')) { $this->input->set_cookie('stats_browserLog', 'ok', 2592000); // 30 days for browser stats PrinterLog_statsWebAgent(); } // check initialization issue if (CoreStatus_checkInInitialization()) { if (CoreStatus_checkCallInitialization($url_redirect)) { return; // we are calling the right page } } else { if (CoreStatus_checkCallInitialization()) { $url_redirect = '/'; } else { if (CoreStatus_checkInUSB()) { if (CoreStatus_checkCallUSB($url_redirect)) { return; // we are calling the right page } } else { if (CoreStatus_checkCallUSB()) { $url_redirect = '/'; } else { if (CoreStatus_checkCallDebug()) { // we always let these interfaces go for debug return; } else { if (CoreStatus_checkInConnection()) { if (CoreStatus_checkCallNoBlockPageInConnection()) { return; // we are calling set hostname, activation or account page } if (CoreStatus_checkCallConnection($url_redirect)) { return; // we are calling the right page } } else { if (CoreStatus_checkCallConnection()) { $url_redirect = '/'; } else { if (!CoreStatus_checkInIdle($status_current, $array_status)) { switch ($status_current) { case CORESTATUS_VALUE_RECOVERY: //TODO finish and test me if (CoreStatus_checkCallRecovery($url_redirect)) { return; // we are calling the right page } break; case CORESTATUS_VALUE_PRINT: if (CoreStatus_checkCallPrinting($array_status, $url_redirect)) { return; // we are calling the right page } break; case CORESTATUS_VALUE_CANCEL: if (CoreStatus_checkCallCanceling($url_redirect)) { return; // we are calling the right page } break; case CORESTATUS_VALUE_LOAD_FILA_L: case CORESTATUS_VALUE_LOAD_FILA_R: if (CoreStatus_checkCallloading($url_redirect)) { return; // we are calling the right page } // return; // we do not block users when charging filament break; case CORESTATUS_VALUE_UNLOAD_FILA_L: case CORESTATUS_VALUE_UNLOAD_FILA_R: //FIXME finish here to block users if (CoreStatus_checkCallUnloading($url_redirect)) { return; // we are calling the right page } break; case CORESTATUS_VALUE_SLICE: if (CoreStatus_checkCallSlicing($url_redirect)) { return; } break; default: $url_redirect = '/'; // internal error, never reach here normally break; } } else { if (CoreStatus_checkCallPrintingAjax() || CoreStatus_checkCallCancelingAjax()) { // let ajax request failed when we finishing printing / canceling $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; header($protocol . ' 403'); header('Content-type: text/plain; charset=UTF-8'); echo 'Not in printing / canceling'; exit; } else { if (CoreStatus_checkCallPrinting() || CoreStatus_checkCallCanceling()) { $url_redirect = '/'; } else { if (CoreStatus_checkInPrinted()) { if (CoreStatus_checkCallEndPrinting($url_redirect) || CoreStatus_checkCallEndPrintingPlus()) { return; } } else { if (CoreStatus_checkCallEndPrinting()) { $url_redirect = '/'; // redirect to homepage when we have no timelapse } } } } if ($url_redirect) { header('Location: ' . $url_redirect); exit; } return; // continue to generate the current page } } } } } } } } // log error if we have no redirect url when reaching here if (is_null($url_redirect)) { $this->load->helper('printerlog'); PrinterLog_logError('no redirect place when MY_Controller finished', __FILE__, __LINE__); } header('Location: ' . $url_redirect); exit; } }