... And here comes the last and final method I tried...use CGI qw(param); require "config.txt"; $refresh="60"; $ip=$ENV{'REMOTE_ADDR'}; $time=time; open(FILE,$log); flock (FILE,3); @users=<FILE>; close(FILE); foreach $lines (@users){ chop($lines); ($ips,$times,$locationold,$titles)=split('×',$lines); $timeoff=$time-$times; push @titlez,$titles if (!$exists{$titles}); push @locations,$locationold if (!$exists{$locationold}); $exists{$locationold}=1; $exists{$titles}=1; ${$locationold}{online}++; } $line="$ip×$time×$place×$title"; ${$location}{online}++; foreach $loc (@locations){ if(${$loc}{online} < "2") { ${$loc}{users} = "user"; } else { ${$loc}{users} = "users"; } }
...The part above I know I don't need, because it doesn't work..foreach $ttl (@titlez){ #chop($ttl); ($titlea)=split('þ',$ttl); push @titleb,$titlea if (!$exists{$titlea}); $exists{$titlea}=1; } foreach $loctitle (@titleb){ $online++; }
if($online < "2") { $users = "user"; $userz = "User"; } else { $users = "users"; $userz = "Users"; } $nocache = "<meta http-equiv='PRAGMA' content='nocache'>\n"; $nocache .= "</head>"; print "Content-type: text/html\n\n"; open (FILE,"<$header"); while( $tmplh = <FILE> ) { $tmplh =~ s/<<UO\:\:Number>>/$online/g; $tmplh =~ s/<<UO\:\:Users>>/$userz/g; $tmplh =~ s/<\/head>/$nocache/g; print $tmplh; } close(FILE); foreach my $loc (sort {${$b}{online} <=> ${$a}{online}} @locations) { if ($loc eq "" || $loc eq "Unknown" ) { $area = "Unknown"; } else { if ($loc =~ /http:/i && $loc ne "") { $area = "<a href=\"javascript:opener.location.href='$loc';location.hre +f='$where';\"><acronym title=\"$loctitle\">$loc</acronym></a><\!-- Ti +tlez: @titlez --><!-- TitleB: @titleb --><!-- Locations: @locations - +->"; } else { $area = "$loc"; } } open (FILE,"<$middle"); while( $tmplm = <FILE> ) { $tmplm =~ s/<<UO\:\:Number>>/${$loc}{online}/g; $tmplm =~ s/<<UO\:\:Users>>/${$loc}{users}/g; $tmplm =~ s/<<UO\:\:Page>>/$area/g; print $tmplm; print "\n"; } close(FILE); } $showon = "$online $users"; # If you even dare try to edit ANYTHING between here... $cr = "<font face='Arial' size='1' color='#CCCCCC'><i>Powered By <a hr +ef=\"javascript:alert('Don\\'t laugh, but currently, Kage is siteless +.');\"><acronym title=\"Powered By UzerzOnlyne v$version\">UzerzOnlyn +e v$version</acronym></a></i></font></center>\n"; # and here, that will make this script against the Copyright that was +placed upon it. Don't even # try it. That is your only warning. $cr .= "</body>"; open (FILE,"<$footer"); while( $tmplf = <FILE> ) { $tmplf =~ s/<<UO\:\:ShowOnline>>/$showon/g; $tmplf =~ s/<\/body>/$cr/g; print $tmplf; } close(FILE);
In reply to ForEach Command struggle.. by Kage
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |