Приглашаем посетить
WebAdverts (Admin)
#!/usr/bin/perl
############################################
## ##
## WebAdverts (Admin) ##
## by Darryl Burgdorf ##
## (e-mail burgdorf@awsd.com) ##
## ##
## last modified: 5/27/97 ##
## copyright (c) 1997 ##
## ##
## latest version is available from ##
## http://awsd.com/scripts/ ##
## ##
############################################
# COPYRIGHT NOTICE:
#
# Copyright 1997 Darryl C. Burgdorf. All Rights Reserved.
#
# This program may be used and modified free of charge by anyone, so
# long as this copyright notice and the header above remain intact. By
# using this program you agree to indemnify Darryl C. Burgdorf from any
# liability.
#
# Selling the code for this program without prior written consent is
# expressly forbidden. Obtain permission before redistributing this
# program over the Internet or in any other medium. In all cases
# copyright and header must remain intact.
# VERSION HISTORY:
#
# 1.04 05/27/97 Added new script to display all active banners
# Put variable assignments in configuration script
# Added option to define max click-thrus
# Added ability to "weight" banners
# Added start date to log info for each advert
# Added "exposures per day" to advert info display
# Improved error handling
# Added basic URL format validation
# Numerous "tweaks" and format adjustments
# 1.03 05/22/97 Added configurable link text
# Added new script to put banners in CGI pages
# Fixed bugs introduced by previous file locking "fix"
# Corrected style of main password input box
# Minor bug fixes in display code
# 1.02 04/20/97 Fixed file locking!
# Added actual click-thru ratios to display
# Revised display of percentages
# 1.01 04/03/97 Allowed for automatic creation of necessary text files
# Closed hole that allowed spaces in file names
# 1.00 04/01/97 Initial "public" release
require "/usr/www/users/dburgdor/scripts/ads/ads_configure.pl";
&ConfigureAdverts;
$UseLocking = 1;
@months = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
$version = "1.04";
print "Content-type: text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$INPUT{$name} = $value;
}
if ($INPUT{'edit'}) { &edit; }
elsif ($INPUT{'del'}) { &del; }
elsif ($INPUT{'newpass'}) { &newpass; }
elsif ($INPUT{'resetcount'}) { &resetcount; }
elsif ($INPUT{'editfinal'}) { &editfinal; }
elsif ($INPUT{'delfinal'}) { &delfinal; }
elsif ($INPUT{'reviewall'}) { &reviewall; }
elsif ($INPUT{'reviewone'}) {&reviewone; }
else { &printoptions; }
sub printoptions {
print "<HTML><HEAD><TITLE>WebAdverts Access Page";
print "</TITLE></HEAD><BODY>\n";
print "<H1 ALIGN=CENTER>Administrative Access</H1>\n";
print "<P>To view the status of all adverts and access ";
print "WebAdvert's main administrative functions, ";
print "input the administrative password and click on the ";
print ""Review All Adverts" button. ";
print "To view the status of any single advert, input ";
print "the password and name of the advert you wish to view, ";
print "and click on the "Review a Single Advert" ";
print "button.</P>\n";
print "<CENTER><FORM METHOD=POST ACTION=$advertcgi>\n";
print "<P><STRONG>Password:</STRONG> ";
print "<INPUT TYPE=PASSWORD NAME=password SIZE=10> ";
print "<STRONG>Advert Name:</STRONG> ";
print "<INPUT TYPE=TEXT NAME=review SIZE=10>\n";
print "<P><INPUT TYPE=SUBMIT NAME=reviewone ";
print "VALUE=\"Review a Single Advert\"> ";
print "<INPUT TYPE=SUBMIT NAME=reviewall ";
print "VALUE=\"Review All Adverts\">\n";
print "</P></FORM></CENTER>\n";
&Footer;
exit;
}
sub reviewall {
unless ($actionresult == 1) {
unless ($INPUT{'password'}) {
print "<HTML><HEAD><TITLE>No Password!";
print "</TITLE></HEAD><BODY>\n";
print "<P ALIGN=CENTER>You must enter a password!</P>\n";
&Footer;
exit;
}
open (PASSWORD, "$advertspasswordfile") ||
&Error_File("$advertspasswordfile");
$password = <PASSWORD>;
close (PASSWORD);
chop ($password) if ($password =~ /\n$/);
if (!$password) {
$INPUT{'passad'} = $INPUT{'password'};
&newpass;
}
$newpassword = crypt($INPUT{'password'}, aa);
unless ($newpassword eq $password) {
print "<HTML><HEAD><TITLE>Invalid Password!";
print "</TITLE></HEAD><BODY>\n";
print "<P ALIGN=CENTER>";
print "The password you entered is incorrect!</P>\n";
&Footer;
exit;
}
}
print "<HTML><HEAD><TITLE>WebAdverts Main Admin Page";
print "</TITLE></HEAD><BODY>\n";
print "<FORM METHOD=POST ACTION=$advertcgi>\n";
print "<P><STRONG>The following adverts are running:</STRONG>\n";
print "<P><TABLE CELLPADDING=6>\n";
print "<TR ALIGN=CENTER><TD><EM>Advert</EM></TD>";
print "<TD><EM>Start Date</EM></TD>";
if ($AdvertTracking == 2) {
print "<TD><EM>Click-Thrus Purchased</EM></TD>";
}
else {
print "<TD><EM>Exposures Purchased</EM></TD>";
}
print "<TD><EM>"Weight"</EM></TD>";
print "<TD><EM>Exposures To Date</EM></TD>";
print "<TD><EM>Exposures Per Day</EM></TD>";
print "<TD><EM>Click-Thrus</EM></TD>";
print "<TD><EM>Percentage</EM></TD>";
print "<TD><EM>Ratio</EM></TD></TR>\n";
open (COUNT, "+<$advertcount") || &Error_Line("$advertcount");
$lockerror = &LockFile(COUNT);
if ($lockerror) {
print "[ File Lock Error: $advertcount ]";
exit;
}
@lines = <COUNT>;
if (@lines < 2) {
$lines[0] = 1;
$lines[1] = 0;
$lines[2] = time;
truncate (COUNT,0);
seek(COUNT, 0, 0);
foreach $line (@lines) { print COUNT "$line\n"; }
}
&UnlockFile(COUNT);
close (COUNT);
foreach $line (@lines) { chop ($line) if ($line =~ /\n$/); }
$max = @lines - 1;
$exposures = $lines[1];
$starttime = $lines[2];
@advertisements = @lines[3..$max];
foreach $advertiser (@advertisements) {
open (DISPLAY, "$adverts_dir/$advertiser.txt") ||
&Error_Line("$adverts_dir/$advertiser.txt");
@lines = <DISPLAY>;
close (DISPLAY);
foreach $line (@lines) { chop ($line) if ($line =~ /\n$/); }
($max,$shown,$visits,$url,$image,$height,$width,$alt,$pass,$text,$start,$weight) = @lines;
if ($shown == 0) {
$perc = "N/A";
$ratio = "N/A";
}
elsif ($visits == 0) {
$perc = "N/A";
$ratio = "N/A";
}
else {
$perc = ((100*($visits/$shown))+.05001);
$ratio = (($shown/$visits)+.5001);
}
unless ($perc eq "N/A") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
unless ($ratio eq "N/A") {
$ratio =~ s/(\d+)\.\d.*/$1/;
$ratio = $ratio.":1";
}
print "<TR ALIGN=CENTER><TD>$advertiser</TD>";
$time = 0;
if ($start) {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($start);
print "<TD>$mday @months[$mon]</TD>";
$time = time;
$time = $time - $start + 1;
}
else { print "<TD></TD>"; }
print "<TD>",&commas($max),"</TD>";
print "<TD>$weight</TD>";
print "<TD>",&commas($shown),"</TD>";
if ($time > 86400) {
$average = int(($shown/($time/86400))+.5);
print "<TD>",&commas($average),"</TD>";
}
else {
print "<TD>N/A</TD>";
}
print "<TD>",&commas($visits),"</TD>";
print "<TD>$perc</TD><TD>$ratio</TD></TR>\n";
}
print "</TABLE></P>\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($starttime);
if ($hour < 10) { $hour = "0".$hour; }
if ($min < 10) { $min = "0".$min; }
print "<P>(Since $hour:$min on $mday @months[$mon] 19$year, ";
print "there have been a total of <STRONG>",&commas($exposures);
print "</STRONG> advert exposures";
$time = time;
$time = $time - $starttime + 1;
if ($time > 86400) {
$average = int(($exposures/($time/86400))+.5);
print ", for an average of <STRONG>",&commas($average);
print "</STRONG> exposures per day";
}
print ".)\n";
print "<P><STRONG>The following options ";
print "are available:</STRONG>\n";
print "<P><INPUT TYPE=SUBMIT NAME=edit ";
print "VALUE=\"Add/Edit Advert:\"> ";
print "<INPUT TYPE=TEXT NAME=editad SIZE=25 ";
print "VALUE=\"(advert name)\">\n";
print "<P><INPUT TYPE=SUBMIT NAME=del VALUE=\"Delete Advert:\"> ";
print "<INPUT TYPE=TEXT NAME=delad SIZE=25 ";
print "VALUE=\"(advert name)\">\n";
print "<P><INPUT TYPE=SUBMIT NAME=newpass ";
print "VALUE=\"Change Admin Password:\"> ";
print "<INPUT TYPE=TEXT NAME=passad SIZE=25 ";
print "VALUE=\"(new password)\">\n";
print "<P><INPUT TYPE=SUBMIT NAME=resetcount ";
print "VALUE=\"Reset Overall Total Exposures Count\">\n";
print "</P></FORM>\n";
&Footer;
exit;
}
sub reviewone {
unless ($INPUT{'password'}) {
print "<HTML><HEAD><TITLE>No Password!";
print "</TITLE></HEAD><BODY>\n";
print "<P ALIGN=CENTER>You must enter a password!</P>\n";
&Footer;
exit;
}
unless (-e "$adverts_dir/$INPUT{'review'}.txt") {
print "<HTML><HEAD><TITLE>Invalid Advert Name";
print "</TITLE></HEAD><BODY>\n";
print "<P ALIGN=CENTER>There is no advert with the name ";
print "<STRONG>"$INPUT{'review'}"</STRONG> on the list!\n";
print "<P ALIGN=CENTER>(Note that advert names <EM>are</EM> ";
print "case sensitive!)</P>\n";
&Footer;
exit;
}
open (DISPLAY, "$adverts_dir/$INPUT{'review'}.txt") ||
&Error_File("$adverts_dir/$INPUT{'review'}.txt");
@lines = <DISPLAY>;
close (DISPLAY);
foreach $line (@lines) { chop ($line) if ($line =~ /\n$/); }
($max,$shown,$visits,$url,$image,$height,$width,$alt,$pass,$text,$start,$weight) = @lines;
unless ($text) { $text = "Please Visit Our Sponsor!"; }
$newpassword = crypt($INPUT{'password'}, aa);
unless ($newpassword eq $pass) {
open (PASSWORD, "$advertspasswordfile") ||
&Error_File("$advertspasswordfile");
$password = <PASSWORD>;
close (PASSWORD);
chop ($password) if ($password =~ /\n$/);
unless ($password && ($newpassword eq $password)) {
print "<HTML><HEAD><TITLE>Invalid Password!";
print "</TITLE></HEAD><BODY>\n";
print "<P ALIGN=CENTER>";
print "The password you entered is incorrect!</P>\n";
&Footer;
exit;
}
}
print "<HTML><HEAD><TITLE>WebAdverts Review Page";
print "</TITLE></HEAD><BODY>\n";
print "<P><STRONG>Current status of the ";
print "$INPUT{'review'} advert:</STRONG></P>\n";
print "<P><TABLE CELLPADDING=6>\n";
print "<TR ALIGN=CENTER><TD><EM>Advert</EM></TD>";
print "<TD><EM>Start Date</EM></TD>";
if ($AdvertTracking == 2) {
print "<TD><EM>Click-Thrus Purchased</EM></TD>";
}
else {
print "<TD><EM>Exposures Purchased</EM></TD>";
}
print "<TD><EM>Exposures To Date</EM></TD>";
print "<TD><EM>Exposures Per Day</EM></TD>";
print "<TD><EM>Click-Thrus</EM></TD>";
print "<TD><EM>Percentage</EM></TD>";
print "<TD><EM>Ratio</EM></TD></TR>\n";
if ($shown == 0) {
$perc = "N/A";
$ratio = "N/A";
}
elsif ($visits == 0) {
$perc = "N/A";
$ratio = "N/A";
}
else {
$perc = ((100*($visits/$shown))+.05001);
$ratio = (($shown/$visits)+.5001);
}
unless ($perc eq "N/A") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
unless ($ratio eq "N/A") {
$ratio =~ s/(\d+)\.\d.*/$1/;
$ratio = $ratio.":1";
}
print "<TR ALIGN=CENTER><TD>$INPUT{'review'}</TD>";
$time = 0;
if ($start) {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($start);
print "<TD>$mday @months[$mon]</TD>";
$time = time;
$time = $time - $start + 1;
}
else { print "<TD></TD>"; }
print "<TD>",&commas($max),"</TD>";
print "<TD>",&commas($shown),"</TD>";
if ($time > 86400) {
$average = int(($shown/($time/86400))+.5);
print "<TD>",&commas($average),"</TD>";
}
else {
print "<TD>N/A</TD>";
}
print "<TD>",&commas($visits),"</TD>";
print "<TD>$perc</TD><TD>$ratio</TD></TR>\n";
print "</TABLE></P>\n";
print "<P><EM>Site URL:</EM> $url\n";
print "<BR><EM>Banner URL:</EM> $image\n";
print "<BR><EM>ALT Text:</EM> $alt\n";
print "<BR><EM>Link Text:</EM> $text\n";
print "<P>The advert appears as shown below:\n";
print "<P ALIGN=CENTER><A HREF=\"$gotoadvert?$INPUT{'review'}\">";
print "<IMG SRC=\"$image\" HEIGHT=$height WIDTH=$width ";
print "ALT=\"$alt\">";
print "</A><BR><SMALL><A HREF=\"$gotoadvert?$INPUT{'review'}\">";
print "$text</SMALL></A></P>\n";
&Footer;
exit;
}
sub edit {
$INPUT{'editad'} =~ s/[ \/\\]//g;
if (-e "$adverts_dir/$INPUT{'editad'}.txt") {
open (DISPLAY, "$adverts_dir/$INPUT{'editad'}.txt") ||
&Error_File("$adverts_dir/$INPUT{'editad'}.txt");
@lines = <DISPLAY>;
close (DISPLAY);
foreach $line (@lines) { chop ($line) if ($line =~ /\n$/); }
($max,$shown,$visits,$url,$image,$height,$width,$alt,$pass,$text,$start,$weight) = @lines;
}
unless ($text) { $text = "Please Visit Our Sponsor!"; }
unless ($url) { $url = "http://"; }
unless ($image) { $image = "http://"; }
unless ($weight) { $weight = 1; }
print "<HTML><HEAD><TITLE>WebAdverts Add/Edit Page";
print "</TITLE></HEAD><BODY>\n";
print "<FORM METHOD=POST ACTION=$advertcgi>\n";
print "<P><STRONG>Info for ";
print "$INPUT{'editad'} advert:</STRONG></P>\n";
print "<P><TABLE CELLPADDING=6>\n";
if ($AdvertTracking == 2) {
print "<TR><TD>Click-Thrus Purchased:";
}
else {
print "<TR><TD>Exposures Purchased:";
}
print "</TD><TD><INPUT TYPE=TEXT ";
print "NAME=purch VALUE=\"$max\" SIZE=10></TD></TR>\n";
print "<TR><TD>"Weight":</TD><TD><INPUT TYPE=TEXT ";
print "NAME=weight VALUE=\"$weight\" SIZE=5></TD></TR>\n";
print "<TR><TD>Site URL:</TD><TD><INPUT TYPE=TEXT ";
print "NAME=url VALUE=\"$url\" SIZE=40></TD></TR>\n";
print "<TR><TD>Banner URL:</TD><TD><INPUT TYPE=TEXT ";
print "NAME=image VALUE=\"$image\" SIZE=40></TD></TR>\n";
print "<TR><TD>Banner Height:</TD><TD><INPUT TYPE=TEXT ";
print "NAME=height VALUE=\"$height\" SIZE=5> pixels</TD></TR>\n";
print "<TR><TD>Banner Width:</TD><TD><INPUT TYPE=TEXT ";
print "NAME=width VALUE=\"$width\" SIZE=5> pixels</TD></TR>\n";
print "<TR><TD>ALT Text:</TD><TD><INPUT TYPE=TEXT ";
print "NAME=alt VALUE=\"$alt\" SIZE=40></TD></TR>\n";
print "<TR><TD>Link Text:</TD><TD><INPUT TYPE=TEXT ";
print "NAME=text VALUE=\"$text\" SIZE=40></TD></TR>\n";
print "<TR><TD>Password:</TD><TD><INPUT TYPE=TEXT ";
print "NAME=pass SIZE=40></TD></TR>\n";
print "</TABLE></P>\n";
print "<P><INPUT TYPE=HIDDEN NAME=editad ";
print "VALUE=\"$INPUT{'editad'}\">\n";
print "<INPUT TYPE=HIDDEN NAME=start VALUE=\"$start\">\n";
print "Check here to reset advert start date, ";
print "exposures & click-thrus: ";
print "<INPUT TYPE=CHECKBOX NAME=\"resetadvert\">";
print "<P><INPUT TYPE=SUBMIT NAME=editfinal ";
print "VALUE=\"Add/Edit\">\n";
print "</P></FORM>\n";
&Footer;
exit;
}
sub del {
unless (-e "$adverts_dir/$INPUT{'delad'}.txt") {
print "<HTML><HEAD><TITLE>Invalid Advert Name";
print "</TITLE></HEAD><BODY>\n";
print "<P ALIGN=CENTER>There is no advert with the name ";
print "<STRONG>"$INPUT{'delad'}"</STRONG> on the list!\n";
print "<P ALIGN=CENTER>(Note that advert names <EM>are</EM> ";
print "case sensitive!)</P>\n";
&Footer;
exit;
}
print "<HTML><HEAD><TITLE>WebAdverts Delete Page";
print "</TITLE></HEAD><BODY>\n";
print "<FORM METHOD=POST ACTION=$advertcgi>\n";
print "<P>Are you sure you want to delete the ";
print "<STRONG>$INPUT{'delad'}</STRONG> advert?\n";
print "<INPUT TYPE=HIDDEN NAME=delad VALUE=$INPUT{'delad'}>\n";
print "<INPUT TYPE=SUBMIT NAME=delfinal VALUE=\"Yes\">\n";
print "</P></FORM>\n";
&Footer;
exit;
}
sub newpass {
$newpassword = crypt($INPUT{'passad'}, aa);
open (PASSWORD, ">$advertspasswordfile") ||
&Error_File("$advertspasswordfile");
$lockerror = &LockFile(PASSWORD);
if ($lockerror) {
print "[ File Lock Error: $advertspasswordfile ]";
exit;
}
print PASSWORD "$newpassword";
&UnlockFile(PASSWORD);
close (PASSWORD);
print "<HTML><HEAD><TITLE>Password Changed";
print "</TITLE></HEAD><BODY>\n";
print "<P ALIGN=CENTER>The new administrative password is ";
print "<STRONG>$INPUT{'passad'}</STRONG>.</P>\n";
&Footer;
exit;
}
sub resetcount {
open (COUNT, "+<$advertcount") || &Error_File("$advertcount");
$lockerror = &LockFile(COUNT);
if ($lockerror) {
print "[ File Lock Error: $advertcount ]";
exit;
}
@lines = <COUNT>;
foreach $line (@lines) { chop ($line) if ($line =~ /\n$/); }
$max = @lines - 1;
$count = $lines[0];
$time = time;
truncate (COUNT,0);
seek(COUNT, 0, 0);
print COUNT "$count\n";
print COUNT "0\n";
print COUNT "$time\n";
@advertisements = @lines[3..$max];
foreach $advertiser (@advertisements) {
print COUNT "$advertiser\n";
}
&UnlockFile(COUNT);
close (COUNT);
$actionresult = 1;
&reviewall;
}
sub editfinal {
$editad = $INPUT{'editad'};
if (-e "$adverts_dir/$editad.txt") {
open (DISPLAY, "$adverts_dir/$editad.txt") ||
&Error_File("$adverts_dir/$editad.txt");
@lines = <DISPLAY>;
close (DISPLAY);
foreach $line (@lines) { chop ($line) if ($line =~ /\n$/); }
($max,$shown,$visits,$url,$image,$height,$width,$alt,$pass,$text,$start,$weight) = @lines;
}
else {
open (COUNT, ">>$advertcount") ||
&Error_File("$advertcount");
$lockerror = &LockFile(COUNT);
if ($lockerror) {
print "[ File Lock Error: $advertcount ]";
exit;
}
print COUNT "$editad\n";
&UnlockFile(COUNT);
close (COUNT);
$shown = 0;
$visits = 0;
$start = time;
}
$INPUT{'url'} =~ s/ |;|,|\*//g;
if ($INPUT{'url'} =~ /.*\:\/\/.*\..*/) {
$url = $INPUT{'url'};
}
$INPUT{'image'} =~ s/ |;|,|\*//g;
if ($INPUT{'image'} =~ /.*\:\/\/.*\..*/) {
$image = $INPUT{'image'};
}
$max = $INPUT{'purch'};
$height = $INPUT{'height'};
$width = $INPUT{'width'};
$alt = $INPUT{'alt'};
$text = $INPUT{'text'};
$weight = $INPUT{'weight'};
if ($weight < .01) { $weight = 0; }
if ($weight > 1) { $weight = 1; }
if ($INPUT{'resetadvert'}) {
$shown = 0;
$visits = 0;
$start = time;
}
if ($INPUT{'pass'}) { $pass = crypt($INPUT{'pass'}, aa); }
unless ($max && $url && $image && $height && $width && $alt && $text && $pass) {
print "<HTML><HEAD><TITLE>Incomplete Advert";
print "</TITLE></HEAD><BODY>\n";
print "<P>You didn't provide all of the necessary ";
print "information to allow ";
print "addition of the <STRONG>$editad</STRONG> ";
print "advert!</P>\n";
&Footer;
exit;
}
open (DISPLAY, ">$adverts_dir/$editad.txt") ||
&Error_File("$adverts_dir/$editad.txt");
$lockerror = &LockFile(DISPLAY);
if ($lockerror) {
print "[ File Lock Error: $editad.txt ]";
exit;
}
print DISPLAY "$max\n";
print DISPLAY "$shown\n";
print DISPLAY "$visits\n";
print DISPLAY "$url\n";
print DISPLAY "$image\n";
print DISPLAY "$height\n";
print DISPLAY "$width\n";
print DISPLAY "$alt\n";
print DISPLAY "$pass\n";
print DISPLAY "$text\n";
print DISPLAY "$start\n";
print DISPLAY "$weight\n";
&UnlockFile(DISPLAY);
close (DISPLAY);
print "<HTML><HEAD><TITLE>Advert Updated";
print "</TITLE></HEAD><BODY>\n";
print "<P>The <STRONG>$editad</STRONG> advert will appear ";
print "as shown below:\n";
print "<P ALIGN=CENTER><A HREF=\"$gotoadvert?$editad\">";
print "<IMG SRC=\"$image\" HEIGHT=$height WIDTH=$width ";
print "ALT=\"$alt\">";
print "</A><BR><SMALL><A HREF=\"$gotoadvert?$editad\">";
print "$text</SMALL></A></P>\n";
&Footer;
exit;
}
sub delfinal {
$delad = $INPUT{'delad'};
unlink ("$adverts_dir/$delad.txt");
open (COUNT, "+<$advertcount") || &Error_File("$advertcount");
$lockerror = &LockFile(COUNT);
if ($lockerror) {
print "[ File Lock Error: $advertcount ]";
exit;
}
@lines = <COUNT>;
foreach $line (@lines) { chop ($line) if ($line =~ /\n$/); }
truncate (COUNT,0);
seek(COUNT, 0, 0);
foreach $line (@lines) {
unless ($line eq $delad) {
print COUNT "$line\n";
}
}
&UnlockFile(COUNT);
close (COUNT);
$actionresult = 1;
&reviewall;
}
sub Footer {
print "<HR WIDTH=25%><P ALIGN=CENTER><SMALL>";
print "<STRONG><A HREF=\"http://awsd.com/scripts/webadverts/\">";
print "WebAdverts $version</A></STRONG></SMALL></P>\n";
print "</BODY></HTML>\n";
}
sub LockFile {
local(*FILE) = @_;
local($TrysLeft) = 10;
if ($UseLocking) {
while ($TrysLeft--) {
$lockresult = eval("flock(FILE,6)");
if ($@) {
$UseLocking = 0;
last;
}
if (!$lockresult) {
select(undef,undef,undef,0.1);
}
else {
last;
}
}
}
if ($TrysLeft >= 0) {
return 0;
}
else {
return -1;
}
}
sub UnlockFile {
local(*FILE) = @_;
if ($UseLocking) {
flock(FILE,8);
}
}
sub commas {
local($_)=@_;
1 while s/(.*\d)(\d\d\d)/$1,$2/;
$_;
}
sub Error_File {
print "<HTML><HEAD><TITLE>Oops!</TITLE></HEAD><BODY>\n";
print "<H1 ALIGN=CENTER>File Permission Error!</H1>\n";
print "<P>The server encountered an error while trying ";
print "to access <STRONG>$_[0]</STRONG>! Either the directory ";
print "or file doesn't exist, or its permissions are set ";
print "incorrectly.</P>\n";
&Footer;
exit;
}
sub Error_Line {
print "[ File Permission Error: $_[0] ]";
}