function redirect($to = '', $parent_refresh = array()) { $parent = 0; if ($this->input->is_ajax_request()) { // if( $this->input->post() ) // { // clear flash $this->session->set_flashdata('message', NULL); $this->session->set_flashdata('error', NULL); // } if (!is_array($to) && $to == '-referrer-') { } else { // already starts with http:// ? if (!HC_Lib::is_full_url($to)) { $to = HC_Lib::link($to); $to = $to->url(); } } $out = array('redirect' => $to, 'parent' => $parent, 'parent_refresh' => $parent_refresh); $this->output->set_content_type('application/json'); $this->output->enable_profiler(FALSE); echo json_encode($out); hc_ci_before_exit(); exit; // return; } else { if (!is_array($to) && $to == '-referrer-') { $to = (!isset($_SERVER['HTTP_REFERER']) or $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']); } HC_Lib::redirect($to); return; } return; }
static function redirect($uri = '', $method = 'location', $http_response_code = 302) { // if( ! ( (! is_array($uri)) && preg_match('#^https?://#i', $uri) ) ){ if (!(!is_array($uri) && HC_Lib::is_full_url($uri))) { $uri = HC_Lib::link($uri)->url(); } /* this is a hack to ensure that post controller and post system hooks are triggered */ hc_ci_before_exit(); switch ($method) { case 'refresh': header("Refresh:0;url=" . $uri); break; default: header("Location: " . $uri, TRUE, $http_response_code); break; } return; }