summaryrefslogtreecommitdiff
path: root/src/web/lib/ie.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/lib/ie.php')
-rw-r--r--src/web/lib/ie.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/web/lib/ie.php b/src/web/lib/ie.php
new file mode 100644
index 0000000..ead6c1a
--- /dev/null
+++ b/src/web/lib/ie.php
@@ -0,0 +1,32 @@
+<?php /* Copyright (c) 2024 Freya Murphy */
+
+/// IE 5 though 8 support IE conditional comments
+/// IE 4 does not (need to fall back to user agent)
+
+{
+ if (preg_match('/MSIE\s(?P<v>\d+)/i', @$_SERVER['HTTP_USER_AGENT'], $B)) {
+ define('IE_VERSION', $B['v']);
+ } else {
+ define('IE_VERSION', FALSE);
+ }
+
+ if (IE_VERSION == FALSE || IE_VERSION > 4) {
+ // ADD COND COMMENTS
+ define('IE_START', "<!--[if lt IE 8 ]>");
+ define('IE_END', "<![endif]-->");
+ } else {
+ // IE4 DETECTED, DO NOT ADD COMMENTS
+ define('IE_START', '');
+ define('IE_END', '');
+ }
+}
+
+function ie(string $inner) {
+ return IE_START . $inner . IE_END;
+}
+
+function ie_ua(string $inner, int $ver) {
+ if (IE_VERSION == $ver)
+ return $inner;
+ return '';
+}