+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Jan 2003
    Posts
    1

    I have created an anonymous email script...

     
    I have created an anonymous email script...

    I have a problem... I am currently logging the emails, but I would like to view them via another perl script that I have failed at doing. You can see the script in action at negativepulse.com.

    Here is how it prints to the log from the initial email script.
    Code:
     
    
    $logmail = "1";
    #
    #----------
    if ($logmail == 1) {
    open(LOG, ">>BLAHsecretBLAH.txt") ||
    flock(LOG, 2);
    print LOG "---------------------------------- \n";
    print LOG "Date: $date \n";
    print LOG "IP: $ip \n";
    print LOG "Referrer: $ref \n";
    print LOG "Browser: $browser \n";
    print LOG "User: $user \n";
    print LOG "To: $FORM{'email'}\n";
    print LOG "From: $FORM{'from'}\n";
    print LOG "Subject: $FORM{'subject'}\n";
    print LOG "Message: $FORM{'message'}\n";
    flock(LOG, 8);
    close(LOG);
    
    }
    
    #######
    An example of the output is...

    Code:
     ---------------------------------- 
    Date: Wednesday, November 27, 2002 at 23:56:34 
    IP: ***************
    Referrer: ************
    Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) 
    User:  
    To: ***********
    From: ************
    Subject: ***********
    Message: ******
    Please help me code a script that reads this....

  2. #2
    Not Really a Member
    Join Date
    Oct 2001
    Posts
    27,879
    have you tried using regular expressions?

    I'm not entirely familiar with perl, but I've done other similar work. If you have a set format its much easier than a loose format where you dont' know exactly what to expect. Here you could look for specific text, find the position of it and find all the text after that text appears and stop at the end of the line.
    For instance in vb you could do...

    iDatePos = InStr(1, strLineToRead, "Date:")
    iDateString = Mid(strLineToRead, iDatePos + 5, Len(strLineToRead))
    I use iDatePos + 5 because you want to start at the end of Date: which is 5 chars... if you want to include that text just get rid of the +5...
    Now to do that in perl I'm unsure but that may be at least the pseudocode to help ya out.

    Welcome to TechIMO
    Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.

  3. #3
    Junior Member
    Join Date
    Feb 2003
    Posts
    4
    Try this:
    code:

    open (FILE, 'BLAHsecretBLAH.txt');
    @lines = (<FILE>);
    foreach $lines (@lines) {
    print;
    }

    That will put the lines in an array that to Perl will have the string representation of what you printed to the file. So the array itself would look like kind of this very shortened version, if you defined it manually:
    @lines = qw ("-------" , "Date: 12/2/02\n", "IP: $ip \n", "Referrer: $ref \n", "Browser: $browser \n", "User: $user \n", "To: $FORM{'email'}\n", "From: $FORM{'from'}\n", "Subject: $FORM'subject'}\n", "Message: $FORM{'message'}\n");

    Of course all the variables above would be the actual data that the person entered when mailing you.

    I hope that helps....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews