function ci_redirect($uri = '', $method = 'location', $http_response_code = 302) { if (!(!is_array($uri) && preg_match('#^https?://#i', $uri))) { $uri = ci_site_url($uri); } /* 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; }
* -------------------------------------------------------------------- * * And away we go... * */ require_once BASEPATH . 'core/CodeIgniter_.php'; /* if ajax display it and exit */ $CI =& ci_get_instance(); if ($CI->input->wants_json()) { $CI->output->set_content_type('application/json'); $already_out = $CI->output->get_output(); echo $already_out; hc_ci_before_exit(); exit; } if ($CI->input->is_ajax_request()) { if ($CI->input->post()) { $return = array(); $already_out = $CI->output->get_output(); if (strlen($already_out)) { $return = array('html' => $already_out); $CI->output->set_content_type('application/json'); $CI->output->set_output(json_encode($return)); } } $CI->output->_display(); hc_ci_before_exit(); exit; } /* End of file index.php */ /* Location: ./index.php */
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; }
function redirect($to) { if ($this->input->is_ajax_request()) { // if( $this->input->post() ) // { // clear flash $this->session->set_flashdata('message', NULL); $this->session->set_flashdata('error', NULL); // } $to = ci_site_url($to); $out = array('redirect' => $to); $this->output->set_content_type('application/json'); $this->output->enable_profiler(FALSE); echo json_encode($out); hc_ci_before_exit(); exit; // return; } else { ci_redirect($to); return; } return; }