PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|Proxy|HoTTProxy|HoTTProxy.pl =

page 9 of 12



   
   
   # // ***************  Rule validation for the path restriction  *************** \\
   
   # Path restriction rules:
   
   # 1. Path defaults to '/' if it is blank
   # 2. Path must start with a slash
   # 3. Path must end with a slash
   # 3. Path must head match the called path
   
   # Rule #1
   if (not $cookie{'path'}) {
    $cookie{'path'} = '/';
   }
   
   # Rule #2
   if (not $cookie{'path'} =~ m/^\//) {  # if the first character of the path restriction isn't a 
slash
    $cookie{'path'} = '/' . $cookie{'path'}; # make it so
   }

   # Rule #3
   if (not $cookie{'path'} =~ m/\/$/) {  # if the last character of the path restriction isn't a 
slash
    $cookie{'path'} .= '/'; # make it so
   }

 # Rule #4
 if (not $path =~ m/^$cookie{'path'}/) {
  $cookie{'path'} = '/';
 }

   # \\ ***************  Rule validation for the path restriction  *************** //



   # // ***************  Rule validation for the domain restriction  *************** \\
   
   # Domain restriction rules:
   
   # 1. Domian *is* the host if it is blank
   # 2. Domain must start with a period
   # 3. Domain must have two periods
   # 4. Domain must tail match the host

 # Rule #1
   if (not $cookie{'domain'}) {
    $cookie{'domain'} = $host;  # default domain if none specified
   }

 # Rule #2   
   if (not $cookie{'domain'} =~ m/^\./) {  # if the first character of the domain restriction isn't 
a period
    $cookie{'domain'} = '.' . $cookie{'domain'}; # make it so
   }

 # Rule #3
 if (periodCount($cookie{'domain'}) < 2) {
  $cookie{'domain'} = $host;
 }
   
 # Rule #4
 if (not $host =~ m/$cookie{'domain'}$/) {
  $cookie{'domain'} = $host;
 }

   # \\ ***************  Rule validation for the domain restriction  *************** //

   
   return %cookie;
}

sub assembleCookie {
 # Legal hash items: name, value, domain, path, expires, secure
 my $cookieObject = shift;
 my ($i, $cookieText);

 $cookieText = "$$cookieObject{'name'}=$$cookieObject{'value'}; domain=$$cookieObject{'domain'}; 
path=$$cookieObject{'path'}";

 foreach $i ('expires', 'secure') {
    if ($$cookieObject{$i}) {
     $cookieText .= "; $i=$$cookieObject{$i}";
    }
   }

 return $cookieText; 
}

sub parseStoredCookie {

 # returns hash of: $hash{'name'}
 #        $hash{'value'}
 #        $hash{'expires'}
 #        $hash{'expiresEpoch'}
 #        $hash{'domain'}
 #        $hash{'path'}
 #        $hash{'secure'}
   
=9=

1|2|3|4|5|6|7|8| < PREV = PAGE 9 = NEXT > |10|11|12

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.00676298 wallclock secs ( 0.01 usr + 0.01 sys = 0.02 CPU)