#!/usr/sbin/perl require '/usr/people/jevbratt/web/cookielib/cookie.lib'; #get file to link to and which link to edit $input=$ENV{'QUERY_STRING'}; ($link_nr,$pageurl)= split(/=/,$input); #redirect print "Location: $pageurl\n\n"; #if the right cookie is there if (&GetCookies('myType')) { #get file to edit (must be in same directory as cgi) link $ref_html=$ENV{'HTTP_REFERER'}; @path=split(/(\/)/,$ref_html); $change_html=@path[@path-1]; # Begin the editing of the file open (FILE,"$change_html") || die "Can't Open $change_html: $!\n"; @LINES=; close(FILE); $SIZE=@LINES; # Open Link File to Output open (GUEST,">$change_html") || die "Can't Open $change_html: $!\n"; for ($i=0;$i<=$SIZE;$i++) { $_=$LINES[$i]; if (//) { $COLORLINE=$_; @colorline=split(/#/,$COLORLINE); $COLORintR=hex(substr(@colorline[1],0,2)); $COLORintG=hex(substr(@colorline[1],2,2)); $COLORintB=hex(substr(@colorline[1],4,2)); #16777215 amout of colors (ffffff) #15658734 (eeeeee) $COLORintRc=(substr($Cookies{'myType'},0,1)); $COLORintGc=(substr($Cookies{'myType'},1,1)); $COLORintBc=(substr($Cookies{'myType'},2,1)); if ($COLORintRc==1){ $COLORintR=$COLORintR+20; $COLORintG=$COLORintG-10; $COLORintB=$COLORintB-10; } if ($COLORintGc==1){ $COLORintR=$COLORintR-10; $COLORintG=$COLORintG+20; $COLORintB=$COLORintB-10; } if ($COLORintBc==1){ $COLORintR=$COLORintR-10; $COLORintG=$COLORintG-10; $COLORintB=$COLORintB+20; } if($COLORintR < 0){ $COLORintR=0; } if($COLORintG < 0){ $COLORintG=0; } if($COLORintB < 0){ $COLORintB=0; } if($COLORintR > 255){ $COLORintR=255; } if($COLORintG > 255){ $COLORintG=255; } if($COLORintB > 255){ $COLORintB=255; } $COLORr = sprintf ("%lx", $COLORintR); $COLORg = sprintf ("%lx", $COLORintG); $COLORb = sprintf ("%lx", $COLORintB); if($COLORintR < 16){ $COLORr= join ('',"0",$COLORr); } if($COLORintG < 16){ $COLORg= join ('',"0",$COLORg); } if($COLORintB < 16){ $COLORb= join ('',"0",$COLORb); } substr(@colorline[1],0,2)=$COLORr; substr(@colorline[1],2,2)=$COLORg; substr(@colorline[1],4,2)=$COLORb; #$COLORLINE= join ('#',@colorline[0],@colorline[1]); print GUEST "@colorline[0]"; print GUEST "#"; print GUEST "@colorline[1]"; # print GUEST "$COLORLINE"; } else { print GUEST $_; } } close (GUEST); } #what happens if user has no cookie #else{ #print "Location: http://cadre.sjsu.edu/jevbratt/stillman/type/setCookie.html\n\n"; # print "Location: $pageurl\n\n"; #}