diff options
author | Yorhel <git@yorhel.nl> | 2011-01-27 11:15:09 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2011-01-27 11:15:09 +0100 |
commit | 2b1d425af0d2b27e383a0a4a18ec5d7c9b9b25ba (patch) | |
tree | 6a3db8ed20a4b9945ffa3671c18958a70a0e3e1a /lib/VNDB/Util/Misc.pm | |
parent | 64f3c44acebad3b64a7ea2a5462247c1a10f76ab (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...)
Diffstat (limited to 'lib/VNDB/Util/Misc.pm')
-rw-r--r-- | lib/VNDB/Util/Misc.pm | 51 |
1 files changed, 50 insertions, 1 deletions
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; + |