summaryrefslogtreecommitdiffstats
path: root/admin/survey/minify/lib/Minify/DebugDetector.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/survey/minify/lib/Minify/DebugDetector.php')
-rw-r--r--admin/survey/minify/lib/Minify/DebugDetector.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/admin/survey/minify/lib/Minify/DebugDetector.php b/admin/survey/minify/lib/Minify/DebugDetector.php
new file mode 100644
index 0000000..2a3c7a7
--- /dev/null
+++ b/admin/survey/minify/lib/Minify/DebugDetector.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * Detect whether request should be debugged
+ *
+ * @package Minify
+ * @author Stephen Clay <steve@mrclay.org>
+ */
+class Minify_DebugDetector
+{
+ public static function shouldDebugRequest(Minify_Env $env)
+ {
+ if ($env->get('debug') !== null) {
+ return true;
+ }
+
+ $cookieValue = $env->cookie('minifyDebug');
+ if ($cookieValue) {
+ foreach (preg_split('/\\s+/', $cookieValue) as $debugUri) {
+ $pattern = '@' . preg_quote($debugUri, '@') . '@i';
+ $pattern = str_replace(array('\\*', '\\?'), array('.*', '.'), $pattern);
+ if (preg_match($pattern, $env->getRequestUri())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+}