#!/usr/bin/perl # You may need to change this path to /usr/local/bin/perl $mailprog = "/usr/sbin/sendmail"; #************************************************************** # # Script to monitor wwwacct script customizations: PWSwatchwwwacct V1.1 # # Written by: # Premier Website Solutions - http://www.premierwebsitesolutions.com # Created - in 2003 (V1.0) # Modified - September 12, 2004 (V1.1) # - minor modifications to make usable by others # # # Set a few variables below and upload this script to anywhere on your server, # then set a cron job to run the script every hour. I put mine in a subfolder # of the servers scripts folder. (/scripts/custom) # # To set the cronjob, in shell, type crontab -e, then enter what's between the quotes # on the following line as a new line in your cron listings: # "0 * * * * /scripts/custom/PWSwatchwwwacct.cgi" # # Ownership and permissions of the script should be root:root, and 0700. # # This script only needs to run after a cpanel upgrade, so you could set # the cron job to run it 1 hour after upcp runs, but then if you change # when upcp runs, you will need to change this also. This script is fast, # so it's easier to just run it every hour. # # **** Using this script **** # -------------------------------------------------------------------------------------- # |To use this script, you need to make a copy of the real wwwacct script and call it | # |wwwacctunedited, then after your customizations, make a copy of your custom one and | # |call it wwwacctedited. These copies need to be in the same directory as wwwacct. | # | | # |What this script does is compare your custom wwwacct script to a copy of it. | # |If a cpanel update changes the wwwacct script, this script will notice the change. | # | | # |Now the fun part. Many upgrades only change the wwwacct script back to what it was | # |originally. If it's changed, this script compares the new wwwacct to a copy of the | # |original one. If the update merely wrote the original one back, it would match the | # |copy. This script would then take the copy of your custom one and reuse it. Now, if | # |the update altered the script, you would be emailed and told that your customizations | # |are lost and that you will need to redo them. The script does tell you where changes | # |were made to help with reapplying your customizations. | # | | # |I customized my wwwacct script over a year ago and have only had to redo the changes | # |maybe half a dozen times. | # -------------------------------------------------------------------------------------- # # # Registered users of this script will be notified of any future updates. # If you registered this copy with me, put your email here for future reference. # This copy is registered to: # #************************************************************** # This is where the email will be sent when a change is detected. # If you use spamassassin, you should include a name, like this: # $sendto_email = 'me '; $sendto_email = ''; # This is the sender for the email message. # Change it if you wish. $sender_email = 'Mike '; # This is where your wwwacct file is located. # It shouldn't need to be changed. $path = "/scripts"; $diff1 = system("cmp $path/wwwacct $path/wwwacctedited"); if ($diff1 eq "0") { exit; } else { $diff2 = system("cmp $path/wwwacct $path/wwwacctunedited"); } if ($diff2 eq "0") { system("cp -f $path/wwwacctedited $path/wwwacct"); # Open The Mail Program open(MAIL,"|$mailprog -t"); print MAIL "Content-Type: text/html; charset=iso-8859-1\n"; print MAIL "To: $sendto_email\n"; print MAIL "From: $sender_email\n"; print MAIL "Subject: wwwacct file changed and restored\n"; print MAIL "The wwwacct file was changed back to the original and has been automatically replaced with the edited version.

\n\n"; close (MAIL); } if ($diff2 ne "0") { # Open The Mail Program open(MAIL,"|$mailprog -t"); print MAIL "Content-Type: text/html; charset=iso-8859-1\n"; print MAIL "To: $sendto_email\n"; print MAIL "From: $sender_email\n"; print MAIL "Subject: wwwacct file changed\n"; print MAIL "The wwwacct file has been changed and no longer matches the original file. You will need to redo your custom work.

\n\n"; close (MAIL); }