package SharedVariable; use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Time::HiRes qw(gettimeofday); use Compress::Zlib; use CGI::Session qw/-ip-match/; use vars qw (%ENV $session_dir $cookie $page $dir $dirLang $dirError $imgdir $action $t0 $session_id $can_do_gzip $current_ip $lang $LANG %ARTICLE %SESSION %SERVER %USER $CGISESSID %LABEL %ERROR %VALUE $COMMANDID %COMMAND %DATE %PAYPALL $INDEX %LINK $query $session $host $t0 $client); #Set the values to the global variables $query = CGI->new ; $cookie = ""; $current_ip = $ENV{'REMOTE_ADDR'}; $client = $ENV{'HTTP_USER_AGENT'}; $t0 = gettimeofday(); $host = "http://avant-garde.no-ip.biz"; %ERROR = ();%LABEL = ();$LANG = "";%LINK = ();%ARTICLE = ();%SESSION = ();%SERVER = (); % $action = $query->param('action'); $page = $query->param("page"); $session_id = $query->param('session'); $can_do_gzip = ($ENV{'HTTP_ACCEPT_ENCODING'} =~ /gzip/i) ? 1 : 0; $dir = "/home/alexandre/apache/site/recordz1/"; $dirLang = "/home/alexandre/apache/site/recordz1/lang"; $dirError = "/home/alexandre/apache/site/recordz1/lang"; $imgdir= "/home/alexandre/apache/site/recordz1/upload"; $session_dir = "/home/alexandre/apache/site/recordz/sessions"; $action = $query->param('action'); $session_id = $query->param('session'); #load html label loadLanguage (); #load error label loadError(); sub new { my $class = shift; my ($opts)= @_; my $self = {}; return bless $self, $class; } sub loadLanguage { $lang = "FR"; $lang = $query->param("lang"); #$lang = substr ($ENV{'HTTP_ACCEPT_LANGUAGE'},0,2); #$lang =~ s/[^A-Za-z0-9 ]//; $lang = uc ($lang); open (FILE, "<$dirLang/$lang.conf") or die "cannot open file $dirLang/$lang.conf"; while () { (my $label, my $value) = split(/=/); $SERVER{$label} = $value; } close (FILE); } sub loadError { $lang = lc ($query->param('lang'));#=~ s/[^A-Za-z0-9 ]//; #$lang=~ s/[^A-Za-z0-9 ]//; open (FILE, "<$dirError/$lang.error.conf") or die "cannot open file $dirError/$lang.error.conf"; while () { (my $label, my $value) = split(/=/); $ERROR{$label} = $value; } close (FILE); } BEGIN { use Exporter (); @SharedVariable::ISA = qw(Exporter); @SharedVariable::EXPORT = qw(gettimeofday()); @SharedVariable::EXPORT_OK = qw ($session_dir $cookie $page $action $dir $dirLang $dirError $imgdir $session_id $can_do_gzip $current_ip $lang $LANG %ARTICLE %SESSION %SERVER %USER $CGISESSID %LABEL %ERROR %VALUE $COMMANDID %COMMAND %DATE %PAYPALL $INDEX %LINK $query $session $host $t0 $client); } 1;