Advertisement
Guest User

so header

a guest
May 20th, 2012
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. function _deep_replace( $search, $subject ) {
  2. $found = true;
  3. $subject = (string) $subject;
  4. while ( $found ) {
  5. $found = false;
  6. foreach ( (array) $search as $val ) {
  7. while ( strpos( $subject, $val ) !== false ) {
  8. $found = true;
  9. $subject = str_replace( $val, '', $subject );
  10. }
  11. }
  12. }
  13.  
  14. return $subject;
  15. }
  16.  
  17. function remove_null($string) {
  18. $string = preg_replace('/\0+/', '', $string);
  19. $string = preg_replace('/(\\\\0)+/', '', $string);
  20.  
  21. return $string;
  22. }
  23.  
  24. function hc_redirect($location, $status = 302) {
  25. $location = hc_sanitize_redirect($location);
  26.  
  27. header("Location: $location", true, $status);
  28. }
  29.  
  30. function hc_sanitize_redirect($location) {
  31. $location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location);
  32. $location = remove_null($location);
  33.  
  34. // remove %0d and %0a from location
  35. $strip = array('%0d', '%0a', '%0D', '%0A');
  36. $location = _deep_replace($strip, $location);
  37.  
  38. return $location;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement