View ¡m../sdba/bin/lib.pl¡n
# Common Subs in here package Common; use Data::Dumper; sub new_visitor { my ($name,$msg) = @_; my $r_visitor = { # Create a unique object "name" => $name, # using an anonymous hash "screenname" => "", "lastpage" => "", "currentpage" => "", "lastinput" => "", "currentinput" => "", "totalims" => "", "sessionims" => "", "sessionstart" => "", "sessionend" => "" }; return $r_visitor; # Return "object" } sub prepare { my $PREPPAGE = shift; my $curline = ""; #obscure shit local *FH; #print "CURRENT PREPARE PAGE = $PREPPAGE **********\n*****\n"; open (FH, "impages/$PREPPAGE"); #start the first line $Common::prepage .= "\$OUTMSG .=\""; while (
) { $curline = $_; #print "ORIGINAL CURLINE= $curline\n"; #get rid of leading spaces $curline =~ s/^ //; #skip comments if ($curline !~ /^#/){ #make a big ol string #need to only check for commands between <% %>, not everything.... ###TODO: htmlize real text (or escape $,",',%,@,etc.) only look for sessions, modules in real code $curline =~ s/<%/\";/g; $curline =~ s/%>/\$OUTMSG \.= \"/g; #look for imecho $curline =~ s/imecho/\$OUTMSG \.=/g; #look for modules and shit - wait just make them a sub mmmk #SKIP #look for session variables #is one getting intialized? if ($curline =~ /session\s*\(\s*(\S+)\s*\)\s*;/){ $thissess = $1; #print "oh joy a session variable initialized what to do - $&\n"; #print "*********\nthisess = $thissess\n******"; #grab it now before it is evaled #clear it out, it is in $thissess now anyway $curline =~ s/session\s*\(\s*\S+\s*\)\s*;//; #print "******\n\nhahaha it is $thissess \n*******\n\n"; #lose the quotes or $ if any $thissess =~ s/\"|\'|\$//g; #add to session array $visitors{$VISITOR}{"sessionvars"}{$thissess} = ""; } #replace them oh god if (exists $visitors{$VISITOR}{sessionvars}){ #references suck but I GOT YOU MOFO %hash = %{$visitors{$VISITOR}{sessionvars}}; while (($key, $value) = each %hash){ # find them - what a mess this is $curline =~ s/\$$key/\$visitors\{\$VISITOR\}\{sessionvars\}\{$key\}/g; #print "********\n rewriting...session $key = $value \n*****\n\n"; } #print Dumper($visitors{$VISITOR}); } #look for includes, just call this sub for it again if one is there #add in support for spaces and shit if ($curline =~ /include\s*\(\s*(\S+)\s*\)\s*;/){ $thisinclude = $1; #lose quotes $thisinclude =~ s/\"|\'//g; #clear the evidence $curline =~ s/include\s*\(\s*\S+\s*\)\s*;//; #what if some bozo puts it in the middle of a line among other commands? must be on its own line for now. #-- do this $Common::prepage .= $`; $curline = $'; #call prepare, its like magic! #print "* HEY LOOK -> $thisinclude \n\n"; #call it prepare($thisinclude); } $Common::prepage .= $curline; #print "NEW CURLINE= $curline\n"; } } close (FH); #finish up prepage #print "FINISHING PAGE = $PREPPAGE **********\n\n*****\n"; $Common::prepage .= "\";"; } sub SEND_IM { main::SEND_IM(@_); } sub SEND_PAGE { main::SEND_PAGE(@_); } 1;