Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. $route[rawurlencode("статьи")] = "article/index";
  2.  
  3. $config['permitted_uri_chars'] = '?A-Za-zА-Яа-я=s&0-9~%.:&_-|@';
  4.  
  5. class MY_Router extends CI_Router {
  6.  
  7. function _parse_routes() {
  8. $uri = implode('/', $this->uri->segments);
  9.  
  10. if (isset($this->routes[$uri])) {
  11. return $this->_set_request(explode('/', $this->routes[$uri]));
  12. }
  13.  
  14. foreach ($this->routes as $key => $val) {
  15. $key = rawurlencode(str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)));
  16.  
  17. if (preg_match('#^' . $key . '$#', $uri)) {
  18. // Do we have a back-reference?
  19. if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) {
  20. $val = preg_replace('#^' . $key . '$#', $val, $uri);
  21. }
  22.  
  23. return $this->_set_request(explode('/', $val));
  24. }
  25. }
  26. $this->_set_request($this->uri->segments);
  27. }
  28.  
  29. }
  30.  
  31. class MY_URI extends CI_URI
  32. {
  33. function _filter_uri($str)
  34. {
  35. if ($str != '' AND $this->config->item('permitted_uri_chars') != '')
  36. {
  37. if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", rawurlencode($str)))
  38. {
  39. exit('The URI you submitted has disallowed characters.');
  40. }
  41. }
  42.  
  43. return $str;
  44. }
  45. }
  46.  
  47. setlocale(LC_ALL, 'ru_RU.UTF8');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement