Guest User

Untitled

a guest
Jan 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. class MY_URI extends CI_URI{
  2. function __construct(){
  3. parent::__construct();
  4. }
  5. function _filter_uri($str){
  6. if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
  7. {
  8. // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
  9. // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
  10. if ( ! preg_match("|^[".str_replace(array('\-', '-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str))
  11. {
  12. redirect('main/cate/page');
  13. }
  14. }
  15.  
  16. // Convert programatic characters to entities
  17. $bad = array('$', '(', ')', '%28', '%29');
  18. $good = array('$', '(', ')', '(', ')');
  19.  
  20. return str_replace($bad, $good, $str);
  21. }
  22. }
  23.  
  24. <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  25. class OOR_Exceptions extends CI_Exceptions
  26. {
  27. public function show_error($heading, $message, $template = '', $status_code = 500)
  28. {
  29. $ci =& get_instance();
  30. if (!$page = $ci->uri->uri_string()) {
  31. $page = 'home';
  32. }
  33. switch($status_code) {
  34. case 403: $heading = 'Access Forbidden'; break;
  35. case 404: $heading = 'Page Not Found'; break;
  36. case 503: $heading = 'Undergoing Maintenance'; break;
  37. }
  38. log_message('error', $status_code . ' ' . $heading . ' --> '. $page);
  39. if ($status_code == 404)
  40. {
  41. redirect('/mypage');
  42. }
  43. return parent::show_error($heading, $message, 'error_general', $status_code);
  44. }
  45. }
Add Comment
Please, Sign In to add comment