Ændring til script.
Jeg har dette script som læser indholdet af variablen$totalratio.
Set. path er usr/local/psa/home/vhosts/cool/cgi-bin/settings.pl
Jeg har en kopi af dette script der gør det samme her hedder variablen $totalcount1 og path hedder usr/local/psa/home/vhosts/cool/cgi-bin/settings1.pl
Hver især tæller de tilmeldinger på min side, kan jeg på en eller anden snu måde koble de to scripts sammen så tallen bliver lagt sammen ?
Feks. hvis $totalcount = 119 og $totalcount1 = 56
så skal feks $totalsum = 119 + 56
Håber jeg har gjort mig forståelig.
Scriptet kan ses herunder.
#!/usr/bin/perl
$settings_path = \"/usr/local/psa/home/vhosts/cool/cgi-bin/settings.pl\";
require $settings_path;
require $display_path;
open (LIST, \"<$adverts_dir/adlist.txt\");
@advertisements = <LIST>;
close (LIST);
chomp (@advertisements);
@sortedadverts = sort (@advertisements);
&ADVLockOpen (DBMLIST, \"dbmlist.txt\");
if ($ADVlockerror) { &Error_DBM; }
else {
&ADVDBMOpen;
if ($ADVdbmerror) { &Error_DBM; }
else {
foreach $advertiser (@sortedadverts) {
$expired = 0;
$name = $advertiser;
next if (length($advertiser) < 1);
($max,$shown,$visits,$image,$start,$weight,
$zone,$raw,$displayratio,$clicksfrom) = split(/\\t/,$DBMList{$name});
next unless ($max || $displayratio || $clicksfrom);
($max,$maxtype) = split(/\\|/, $max);
unless ($maxtype) { $maxtype = \"E\"; }
($displayratio,$displaycount) = split(/\\|/, $displayratio);
($clicksfrom,$clicksratio) = split(/\\|/, $clicksfrom);
if ($maxtype eq \"N\") { $max = 0; }
if ((($maxtype eq \"E\") || ($maxtype eq \"N\"))
&& ($displayratio > 0)) {
$max = $max+int($displaycount/$displayratio);
}
if ((($maxtype eq \"E\") || ($maxtype eq \"N\"))
&& ($clicksratio > 0)) {
$max = $max+($clicksfrom*$clicksratio);
}
if ($max == 0) { $max = \"0\"; }
if ($maxtype eq \"D\") {
($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime($max);
$year += 1900;
unless ($max > $time) { $expired = 1 ; }
}
else {
if ($maxtype eq \"C\") {
unless ($max > $visits) { $expired = 1; }
}
else {
unless ((($maxtype eq \"N\") && ($displayratio == 0) && ($clicksratio == 0))
|| ($displayratio > 0) || ($clicksratio > 0)) {
unless ($max > $shown) { $expired = 1; }
}
}
}
next if ($expired == 1);
if (($shown == 0) || ($visits == 0)) {
$ratio{$name} = 1000000000;
$realratio{$name} = \"N/A\";
}
else {
$ratio{$name} = (($shown/$visits)+.5001);
$realratio{$name} = $ratio{$name};
$realratio{$name} =~ s/(\\d+)\\.\\d.*/$1/;
$realratio{$name} = $realratio{$name}.\":1\";
$totalshown += $shown;
$totalvisits += $visits;
}
$totalcount++;
}
}
}
&ADVLockClose (DBMLIST, \"dbmlist.txt\");
print \"Cache-Control: no-cache\\n\";
print \"Pragma: no-cache\\n\";
print \"Content-type: application/x-javascript\\n\\n\";
$printline = \"\";
if ($ENV{\'QUERY_STRING\'} =~ /ratio/) {
if (($totalshown == 0) || ($totalvisits == 0)) {
$totalratio = \"N/A\";
}
else {
$totalratio = (($totalshown/$totalvisits)+.5001);
$totalratio =~ s/(\\d+)\\.\\d.*/$1/;
$totalratio = $totalratio.\":1\";
}
$printline = $totalratio;
}
elsif ($ENV{\'QUERY_STRING\'} =~ /list/) {
$printline = \"<TABLE>\";
foreach $key (sort ByRatio keys(%ratio)) {
$printline .= \"<TR><TD><STRONG><FONT SIZE=2><FONT FACE=TAHOMA><FONT COLOR=FFFFCC>$key</TD><TD> </TD>\";
$printline .= \"<TD ALIGN=RIGHT><FONT SIZE=2><STRONG><FONT FACE=TAHOMA><FONT COLOR=FFFFCC>$realratio{$key}</TD></TR>\";
$counter++;
last if ($counter == 1);
}
$printline .= \"</TABLE>\";
}
else {
$printline = &commas($totalcount);
}
$printline = &JSoutput($printline);
print $printline;
exit;
sub JSoutput {
$_[0] =~ s/\\\"/\\\\\"/g;
$_[0] =~ s/\\r//g;
$_[0] =~ s/\\n/\\\")\\;\\ndocument.write(\\\" /g;
$_[0] = \"document.write(\\\" $_[0] \\\");document.close();\";
return $_[0];
}
sub ByRatio { $ratio{$a}<=>$ratio{$b}; }
sub commas { local($_)=@_; 1 while s/(.*\\d)(\\d\\d\\d)/$1,$2/; $_; }
sub Error_DBM { print \"Error!\\n\"; exit; }