summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-01-27 11:15:09 +0100
committerYorhel <git@yorhel.nl>2011-01-27 11:15:09 +0100
commit2b1d425af0d2b27e383a0a4a18ec5d7c9b9b25ba (patch)
tree6a3db8ed20a4b9945ffa3671c18958a70a0e3e1a
parent64f3c44acebad3b64a7ea2a5462247c1a10f76ab (diff)
TUWF: Cleanup IE check code using pre_request_handler return value
No more ugly hacks in my code thanks to TUWF! (a browser check in itself is already ugly enough for my tastes...)
-rw-r--r--lib/VNDB/Handler/Misc.pm43
-rw-r--r--lib/VNDB/Util/Misc.pm51
-rwxr-xr-xutil/vndb.pl8
3 files changed, 51 insertions, 51 deletions
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index d3791c81..b0911f6b 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -15,7 +15,6 @@ TUWF::register(
qr{d([1-9]\d*)}, \&docpage,
qr{setlang}, \&setlang,
qr{nospam}, \&nospam,
- qr{we-dont-like-ie}, \&iemessage,
qr{xml/prefs\.xml}, \&prefs,
qr{opensearch\.xml}, \&opensearch,
@@ -375,48 +374,6 @@ sub nospam {
}
-sub iemessage {
- my $self = shift;
-
- if($self->reqParam('i-still-want-access')) {
- (my $ref = $self->reqHeader('Referer') || '/') =~ s/^\Q$self->{url}//;
- $ref = '/' if $ref eq '/we-dont-like-ie';
- $self->resRedirect($ref, 'temp');
- $self->resCookie('ie_sucks' => 1);
- return;
- }
-
- html;
- head;
- title 'Your browser sucks';
- style type => 'text/css',
- q|body { background: black }|
- .q|div { position: absolute; left: 50%; top: 50%; width: 500px; margin-left: -250px; height: 180px; margin-top: -90px; background-color: #012; border: 1px solid #258; text-align: center; }|
- .q|p { color: #ddd; margin: 10px; font: 9pt "Tahoma"; }|
- .q|h1 { color: #258; font-size: 14pt; font-family: "Futura", "Century New Gothic", "Arial", Serif; font-weight: normal; margin: 10px 0 0 0; } |
- .q|a { color: #fff }|;
- end;
- body;
- div;
- h1 'Oops, we were too lazy to support your browser!';
- p;
- lit qq|We decided to stop supporting Internet Explorer 6 and 7, as it's a royal pain in |
- .qq|the ass to make our site look good in a browser that doesn't want to cooperate with us.<br />|
- .qq|You can try one of the following free alternatives: |
- .qq|<a href="http://www.mozilla.com/firefox/">Firefox</a>, |
- .qq|<a href="http://www.opera.com/">Opera</a>, |
- .qq|<a href="http://www.apple.com/safari/">Safari</a>, or |
- .qq|<a href="http://www.google.com/chrome">Chrome</a>.<br /><br />|
- .qq|If you're really stubborn about using Internet Explorer, upgrading to version 8 will also work.<br /><br />|
- .qq|...and if you're mad, you can also choose to ignore this warning and |
- .qq|<a href="/we-dont-like-ie?i-still-want-access=1">open the site anyway</a>.|;
- end;
- end;
- end;
- end;
-}
-
-
sub prefs {
my $self = shift;
return if !$self->authCheckCode;
diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm
index f4f02b57..8917a4f8 100644
--- a/lib/VNDB/Util/Misc.pm
+++ b/lib/VNDB/Util/Misc.pm
@@ -4,9 +4,10 @@ package VNDB::Util::Misc;
use strict;
use warnings;
use Exporter 'import';
+use TUWF ':html';
use VNDB::Func;
-our @EXPORT = qw|filFetchDB|;
+our @EXPORT = qw|filFetchDB ieCheck|;
my %filfields = (
@@ -98,3 +99,51 @@ sub _fil_vn_compat {
return 0;
}
+
+sub ieCheck {
+ my $self = shift;
+
+ return 1 if !$self->reqHeader('User-Agent') ||
+ $self->reqHeader('User-Agent') !~ /MSIE [67]/ || $self->reqCookie('ie_sucks');
+
+ if($self->reqParam('i-still-want-access')) {
+ (my $ref = $self->reqHeader('Referer') || '/') =~ s/^\Q$self->{url}//;
+ $self->resRedirect($ref, 'temp');
+ $self->resCookie('ie_sucks' => 1);
+ return;
+ }
+
+ html;
+ head;
+ title 'Your browser sucks';
+ style type => 'text/css',
+ q|body { background: black }|
+ .q|div { position: absolute; left: 50%; top: 50%; width: 500px; margin-left: -250px; height: 180px; margin-top: -90px; background-color: #012; border: 1px solid #258; text-align: center; }|
+ .q|p { color: #ddd; margin: 10px; font: 9pt "Tahoma"; }|
+ .q|h1 { color: #258; font-size: 14pt; font-family: "Futura", "Century New Gothic", "Arial", Serif; font-weight: normal; margin: 10px 0 0 0; } |
+ .q|a { color: #fff }|;
+ end;
+ body;
+ div;
+ h1 'Oops, we were too lazy to support your browser!';
+ p;
+ lit qq|We decided to stop supporting Internet Explorer 6 and 7, as it's a royal pain in |
+ .qq|the ass to make our site look good in a browser that doesn't want to cooperate with us.<br />|
+ .qq|You can try one of the following free alternatives: |
+ .qq|<a href="http://www.mozilla.com/firefox/">Firefox</a>, |
+ .qq|<a href="http://www.opera.com/">Opera</a>, |
+ .qq|<a href="http://www.apple.com/safari/">Safari</a>, or |
+ .qq|<a href="http://www.google.com/chrome">Chrome</a>.<br /><br />|
+ .qq|If you're really stubborn about using Internet Explorer, upgrading to version 8 will also work.<br /><br />|
+ .qq|...and if you're mad, you can also choose to ignore this warning and |
+ .qq|<a href="/?i-still-want-access=1">open the site anyway</a>.|;
+ end;
+ end;
+ end;
+ end;
+ return 0;
+}
+
+
+1;
+
diff --git a/util/vndb.pl b/util/vndb.pl
index 0bdb49d1..b845cb26 100755
--- a/util/vndb.pl
+++ b/util/vndb.pl
@@ -97,13 +97,7 @@ sub reqinit {
$self->{l10n} = $handle;
# check for IE
- if($self->reqHeader('User-Agent') && $self->reqHeader('User-Agent') =~ /MSIE [67]/
- && !$self->reqCookie('ie-sucks') && $self->reqPath ne 'we-dont-like-ie') {
- # act as if we're opening /we-dont-like-ie6 (ugly hack, until YAWF supports preventing URL handlers from firing)
- # TODO: TUWF has support for this, use it
- $ENV{HTTP_REFERER} = $ENV{REQUEST_URI};
- $ENV{REQUEST_URI} = '/we-dont-like-ie';
- }
+ return 0 if !$self->ieCheck;
# load some stats (used for about all pageviews, anyway)
$self->{stats} = $self->dbStats;