
brosskgm
User
Mar 4, 2013, 6:34 AM
Post #74 of 76
(71932 views)
|
Re: [FishMonger] Perl MySQL help with code.
[In reply to]
|
Can't Post
|
|
I was trying to improve the code a bit the other day and ran into a slight snag. It is working as I was wanting, but it's creating two errors that I'm having a problem figuring out. I was trying to eliminate the need to tell it to send 1, 2 or 3. I added an extra table to the database to handle the cell sms address after their cell number and also to create a log file. It seems to be acting like it's processing all the if and elsif but still working as I was hoping. It still writes all the files and only sends the correct one. (Not a big deal, but it's an error.) 2nd) I'm now getting a mail error in the logs, but it's sending the mail just fine. Error:
[Mon Mar 04 04:51:52 2013] [error] [client 192.168.4.4] Send options without primary recipient specified., referer: http://192.168.4.4/ [Mon Mar 04 04:51:52 2013] [error] [client 192.168.4.4] Usage: mail -eiIUdEFntBDNHRV~ -T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE -f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users, referer: http://192.168.4.4/
if ( $username ) { #if we have a match open the file to write. open(FILEB, '>>'."$dirlog$subscr_id$extb"); # log file # lets put the time in the file. print FILEB strftime("%A %B %d, %Y - %I:%M %p %Z ", localtime(time) ); # put the IP address and web page visited. print FILEB " -- IP Address: $ENV{REMOTE_ADDR}\n"; #close the file. Finished with the first part close(FILEB); # Run the IP2Location script. # Lets send an email and or text with all the information. # Send email and text if($subscr_provider ne " " && $subscr_email ne " ") { # do something # open email & text files for write open(FILE, '>'."$dir$subscr_id$ext"); # email file open(FILEC, '>'."$dir$subscr_id$text"); # text message file # lets put the time in the file print FILE strftime("%A %B %d, %Y - %I:%M %p %Z\n", localtime(time) ); print FILEC strftime("%A %B %d, %Y - %I:%M %p %Z ", localtime(time) ); # Put the IP address and web page visited print FILE " -- IP Address: $ENV{REMOTE_ADDR}\n\t Accessed your page: $ENV{HTTP_REFERER}\n------\n"; print FILE " -- Here is the information we found:\n------\n"; print FILEC " -- IP Address: $ENV{REMOTE_ADDR} Accessed your page\n"; close(FILE); close(FILEC); # Run the IP2Location script. system("./iptrace.sh $ENV{REMOTE_ADDR} json city>> $dir$subscr_id$ext"); # were done send the notices system("mail -s 'Web Page visited' $subscr_email \< $dir$subscr_id$ext"); system("mail -s 'Web Page visited' $subscr_phone$subscr_provider \< $dir$subscr_id$text"); } elsif($subscr_provider eq " " && $subscr_email ne " ") # send email only { # open email file for write open(FILE, '>'."$dir$subscr_id$ext"); # email file # put the time in the file print FILE strftime("%A %B %d, %Y - %I:%M %p %Z\n", localtime(time) ); #put the ip address and web page visited print FILE " -- IP Address: $ENV{REMOTE_ADDR}\n\t Accessed your page: $ENV{HTTP_REFERER}\n------\n"; print FILE " -- Here is the information we found:\n------\n"; #close the file close(FILE); # Run the IP2Location script. system("./iptrace.sh $ENV{REMOTE_ADDR} json city>> $dir$subscr_id$ext"); system("mail -s 'Web Page visited' $subscr_email \< $dir$subscr_id$ext"); } elsif($subscr_provider ne " " && $subscr_email eq " ") # text message only { # open text file for write open(FILEC, '>'."$dir$subscr_id$text"); # text message file # lets put the time in the file print FILEC strftime("%A %B %d, %Y - %I:%M %p %Z\n", localtime(time) ); # put the ip address that accessed the web site print FILEC " -- IP Address: $ENV{REMOTE_ADDR} Accessed your page\n"; # We don't run IP2Location for text. Makes them 5 messages long. # were done lets send the notice. system("mail -s 'Web Page visited' $subscr_phone$subscr_provider \< $dir$subscr_id$text"); }
|