| 1 | package Lemonldap::Handlers::RewriteHTML; | ||
| 2 | use strict; | ||
| 3 | our ( @ISA, $VERSION, @EXPORTS ); | ||
| 4 | $VERSION = '3.1.0'; | ||
| 5 | our $VERSION_LEMONLDAP = "3.1.0"; | ||
| 6 | our $VERSION_INTERNAL = "3.1.0"; | ||
| 7 | sub get | ||
| 8 | { | ||
| 9 | my $class =shift; | ||
| 10 | my %_param= @_; | ||
| 11 | my $html =$_param{'html'}; | ||
| 12 | my $https =$_param{'https'} ; | ||
| 13 | my $host = $_param{'host'}; | ||
| 14 | my $target = $_param{'target'}; | ||
| 15 | |||
| 16 | $html =~ s/http:\/\//http:\/\/$host\//gi; | ||
| 17 | # href tag | ||
| 18 | $html=~ s/href="([^\/h])/href="\/$1/ig; | ||
| 19 | $html=~ s/(href="\/)/href="\/$target\//ig; | ||
| 20 | # src tag | ||
| 21 | $html=~ s/src="([^\/h])/src="\/$1/ig; | ||
| 22 | $html=~ s/(src="\/)/src="\/$target\//ig; | ||
| 23 | # action tag | ||
| 24 | $html=~ s/(action=\/)/action=\/$target\//ig; | ||
| 25 | # base tag | ||
| 26 | $html =~ s/(\<base\b(.+?))href[^\s]+/$1/i; | ||
| 27 | # feuille de style | ||
| 28 | $html =~ s/url\('/url\('\/$target\//gi; | ||
| 29 | $html =~ s/url\(/url\(\/$target\//gi; | ||
| 30 | $html=~ s/http:/https:/g if $https; | ||
| 31 | return $html; | ||
| 32 | } | ||
| 33 | 1; | ||
| 34 | =pod | ||
| 35 | |||
| 36 | =for html <center> <H1> Lemonldap::Handlers::RewriteHTML </H1></center> | ||
| 37 | |||
| 38 | |||
| 39 | =head1 NAME | ||
| 40 | |||
| 41 | Lemonldap::Handlers::RewriteHTML - Plugin for Lemonldap sso system | ||
| 42 | |||
| 43 | =head1 DESCRIPTION | ||
| 44 | |||
| 45 | RewriteHTML is the default rewriter manager of lemonldap websso framework . | ||
| 46 | This module rewrite on fly html response | ||
| 47 | |||
| 48 | see http://lemonldap.sf.net for more infos . | ||
| 49 | |||
| 50 | =head2 Overlay | ||
| 51 | |||
| 52 | If you wat use your own rewriter method you must use REWRITEHTMLPLUGIN parameter like this : | ||
| 53 | in httpd.conf : perlsetvar lemonldappluginhtml MyModule | ||
| 54 | |||
| 55 | Your module must accept 4 parameters : host :(the virtual host actived) ,target (the host target) | ||
| 56 | https (true if https request ) and html (the source page in html ) | ||
| 57 | Your module must provide the 'get' method and return a html string. | ||
| 58 | |||
| 59 | =head1 SEE ALSO | ||
| 60 | |||
| 61 | Lemonldap(3), Lemonldap::Portal::Standard | ||
| 62 | |||
| 63 | http://lemonldap.sourceforge.net/ | ||
| 64 | |||
| 65 | "Writing Apache Modules with Perl and C" by Lincoln Stein E<amp> Doug | ||
| 66 | MacEachern - O'REILLY | ||
| 67 | |||
| 68 | =over 1 | ||
| 69 | |||
| 70 | =item Eric German, E<lt>germanlinux@yahoo.frE<gt> | ||
| 71 | |||
| 72 | =item Isabelle Serre, E<lt>isabelle.serre@justice.gouv.frE<gt> | ||
| 73 | |||
| 74 | =back | ||
| 75 | |||
| 76 | =head1 COPYRIGHT AND LICENSE | ||
| 77 | |||
| 78 | Copyright (C) 2004 by Eric German E<amp> Isabelle Serre | ||
| 79 | |||
| 80 | Lemonldap originaly written by Eric german who decided to publish him in 2003 | ||
| 81 | under the terms of the GNU General Public License version 2. | ||
| 82 | |||
| 83 | =over 1 | ||
| 84 | |||
| 85 | =item This package is under the GNU General Public License, Version 2. | ||
| 86 | |||
| 87 | =item The primary copyright holder is Eric German. | ||
| 88 | |||
| 89 | =item Portions are copyrighted under the same license as Perl itself. | ||
| 90 | |||
| 91 | =item Portions are copyrighted by Doug MacEachern and Lincoln Stein. | ||
| 92 | This library is under the GNU General Public License, Version 2. | ||
| 93 | |||
| 94 | =item Portage under Apache2 is made with help of : Ali Pouya and | ||
| 95 | Shervin Ahmadi (MINEFI/DGI) | ||
| 96 | |||
| 97 | =back | ||
| 98 | |||
| 99 | This program is free software; you can redistribute it and/or modify | ||
| 100 | it under the terms of the GNU General Public License as published by | ||
| 101 | the Free Software Foundation; version 2 dated June, 1991. | ||
| 102 | |||
| 103 | This program is distributed in the hope that it will be useful, | ||
| 104 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 105 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 106 | GNU General Public License for more details. | ||
| 107 | |||
| 108 | A copy of the GNU General Public License is available in the source tree; | ||
| 109 | if not, write to the Free Software Foundation, Inc., | ||
| 110 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 111 | |||
| 112 | =cut | ||
| 113 |