DebugDetector.php 779 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * Detect whether request should be debugged
  4. *
  5. * @package Minify
  6. * @author Stephen Clay <steve@mrclay.org>
  7. */
  8. class Minify_DebugDetector {
  9. public static function shouldDebugRequest($cookie, $get, $requestUri)
  10. {
  11. if (isset($get['debug'])) {
  12. return true;
  13. }
  14. if (! empty($cookie['minifyDebug'])) {
  15. foreach (preg_split('/\\s+/', $cookie['minifyDebug']) as $debugUri) {
  16. $pattern = '@' . preg_quote($debugUri, '@') . '@i';
  17. $pattern = str_replace(array('\\*', '\\?'), array('.*', '.'), $pattern);
  18. if (preg_match($pattern, $requestUri)) {
  19. return true;
  20. }
  21. }
  22. }
  23. return false;
  24. }
  25. }