############################################ ## ## ## WebAdverts (Rebuild) ## ## by Darryl Burgdorf ## ## (e-mail burgdorf@awsd.com) ## ## ## ## version: 3.20 ## ## last modified: 09/08/02 ## ## copyright (c) 2002 ## ## ## ## latest version is available from ## ## http://awsd.com/scripts/ ## ## ## ############################################ # NOTHING BELOW THIS LINE NEEDS TO BE ALTERED! sub RebuildDatabase { &ConfirmAdminPassword(1); unlink ("$ADVadverts_dir/adcount.txt"); foreach $key (a..z,0..9) { unless (-d "$ADVadverts_dir/$key") { mkdir ("$ADVadverts_dir/$key",0777); chmod 0777,"$ADVadverts_dir/$key"; } } opendir (FILES,$ADVadverts_dir); @files = readdir(FILES); closedir (FILES); &ADVLockOpen (GRPLIST, "groups.txt"); seek (GRPLIST,0,0); foreach $file (@files) { if ($file =~ /(.*)\.grp$/) { $AccountName = $1; &CheckName; rename ("$ADVadverts_dir/$1\.grp","$ADVadverts_dir/$AccountName\.grp"); print GRPLIST "$AccountName\n"; } } truncate (GRPLIST, tell(GRPLIST)); &ADVLockClose (GRPLIST, "groups.txt"); &ADVLockOpen (ADVLIST, "adlist.txt"); @adverts = ; chomp (@adverts); seek (ADVLIST,0,0); foreach $advert (@adverts) { next unless ($advert); $AccountName = $advert; &CheckName; next if ($OnList{$AccountName}); next unless ((-e "$ADVadverts_dir/$advert.txt") || (-e "$ADVadverts_dir/$subdir/$AccountName.txt")); unless (-d "$ADVadverts_dir/$subdir") { mkdir ("$ADVadverts_dir/$subdir",0777); chmod 0777,"$ADVadverts_dir/$subdir"; } foreach $file (@files) { if (($file =~ /^$advert\.(txt)/) || ($file =~ /^$advert\.(log)/) || ($file =~ /^$advert\.(\d\d\d\d\.log)/)) { rename ("$ADVadverts_dir/$file", "$ADVadverts_dir/$subdir/$AccountName.$1"); } } print ADVLIST "$AccountName\n"; $OnList{$AccountName} = 1; } truncate (ADVLIST, tell(ADVLIST)); &ADVLockClose (ADVLIST, "adlist.txt"); &ADVLockOpen (ADVLIST, "adnew.txt"); @adverts = ; chomp (@adverts); seek (ADVLIST,0,0); foreach $advert (@adverts) { next unless ($advert); $AccountName = $advert; &CheckName; next if ($OnList{$AccountName}); next unless ((-e "$ADVadverts_dir/$advert.txt") || (-e "$ADVadverts_dir/$subdir/$AccountName.txt")); unless (-d "$ADVadverts_dir/$subdir") { mkdir ("$ADVadverts_dir/$subdir",0777); chmod 0777,"$ADVadverts_dir/$subdir"; } foreach $file (@files) { if (($file =~ /^$advert\.(txt)/) || ($file =~ /^$advert\.(log)/) || ($file =~ /^$advert\.(\d\d\d\d\.log)/)) { rename ("$ADVadverts_dir/$file", "$ADVadverts_dir/$subdir/$AccountName.$1"); } } print ADVLIST "$AccountName\n"; $OnList{$AccountName} = 1; } foreach $advertcheck (@files) { if ($advertcheck =~ /^dbmlist/) { unlink ("$ADVadverts_dir/$advertcheck"); } next unless ($advertcheck =~ /(.*)\.txt$/); $advert = $1; next if (($advert eq "adcount") || ($advert eq "adlist") || ($advert eq "adminlog") || ($advert eq "adnew") || ($advert eq "adpassword") || ($advert eq "dupclicks") || ($advert eq "dupviews") || ($advert eq "groups") || ($advert eq "register") || ($advert eq "reject") || ($advert eq "welcome") || ($advert eq "update")); $AccountName = $advert; &CheckName; next if ($OnList{$AccountName}); open (DISPLAY, "$ADVadverts_dir/$advert.txt"); @lines = ; close (DISPLAY); chomp (@lines); ($max,$shown,$visits,$url,$image,$height,$width, $alt,$pass,$text,$start,$weight,$zone, $border,$target,$raw,$displayratio,$username,$email, $displayzone,$clicksfrom) = @lines; next unless ($max || $displayratio || $clicksfrom); ($max,$maxtype) = split(/\|/, $max); ($displayratio,$displaycount) = split(/\|/, $displayratio); ($clicksfrom,$clicksratio) = split(/\|/, $clicksfrom); next if (($max =~ /[^\d-]/) || ($shown =~ /[^\d-]/) || ($visits =~ /[^\d-]/) || ($start =~ /[^\d-]/) || ($weight =~ /[^\d-]/) || ($displayratio =~ /[^\d-]/) || ($displaycount =~ /[^\d-]/) || ($clicksfrom =~ /[^\d-]/) || ($clicksratio =~ /[^\d-]/)); unless (-d "$ADVadverts_dir/$subdir") { mkdir ("$ADVadverts_dir/$subdir",0777); chmod 0777,"$ADVadverts_dir/$subdir"; } foreach $file (@files) { if (($file =~ /^$advert\.(txt)/) || ($file =~ /^$advert\.(log)/) || ($file =~ /^$advert\.(\d\d\d\d\.log)/)) { rename ("$ADVadverts_dir/$file", "$ADVadverts_dir/$subdir/$AccountName.$1"); } } print ADVLIST "$AccountName\n"; $OnList{$AccountName} = 1; } foreach $key (a..z,0..9) { opendir (FILES,"$ADVadverts_dir/$key"); @files = readdir(FILES); closedir (FILES); foreach $file (@files) { unless (($file =~ /^\./) || $OnList{$file}) { print ADVLIST "$file\n"; $OnList{$AccountName} = 1; } } } truncate (ADVLIST, tell(ADVLIST)); &ADVLockClose (ADVLIST, "adnew.txt"); &ADVLockOpen (DBMLIST, "dbmlist.txt"); if ($ADVlockerror) { &Error_DBM; } else { &ADVDBMOpen; if ($ADVdbmerror) { &Error_DBM; } else { %DBMList = (); $DBMList{'adcount.txt'} = "1\n0\n$time"; foreach $account (keys %OnList) { $subdir = substr($account,0,1); $subdir .= "/$account"; open (DISPLAY, "$ADVadverts_dir/$subdir/$account.txt"); @lines = ; close (DISPLAY); chomp (@lines); ($max,$shown,$visits,$url,$image,$height,$width, $alt,$pass,$text,$start,$weight,$zone, $border,$target,$raw,$displayratio,$username,$email, $displayzone,$clicksfrom) = @lines; if ($image) { $image = "X"; } if ($raw =~ /