Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

CGI script

Options
  • 08-11-2002 12:56pm
    #1
    Registered Users Posts: 1,747 ✭✭✭


    Hi,
    I have a .cgi mail script written in perl that at the moment just outputs 3 lines.

    Thank you
    Your mail has been sent
    <<back

    If i try editing it to do anything more complex i get a server error.

    I want the thank you page to look like the rest of the site. How can i do that in the script? or can i put code in that will pass the visitor onto a html page of my making?

    Any help would be greatly appreciated on this. Im not a programmer so the simplest solution the better.


    #!/usr/bin/perl
    #
    # mailsend.cgi
    # version 970605
    # copyright 1997 by bo larsson
    # all rights reserved
    #
    # bugs or feedback to bliss@seagull.net
    # for information on how to use, visit http://www.seagull.net/bliss/

    $mailer = "/usr/sbin/sendmail -t";
    $valist = "";

    # Get the input and strip off all unwanted characters
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    $temp = $buffer;
    $temp =~ s/\+/ /g;
    $temp =~ s/%([0-9|A-F]{2})/pack(C,hex($1))/eg;

    # Store the matching name and value pairs
    foreach (split(/&/,$temp))
    {
    ($NAM, $VAL) = split(/=/, $_);
    $DATA{$NAM} = $VAL;
    $valist .= "$NAM:$VAL\n";
    }

    # Grab necessary variables
    $sendto = $DATA{'sendto'};
    $subject = $DATA{'subject'};
    $response = $DATA{'response'};
    $redirect = $DATA{'redirect'};
    $user_email = $DATA{'user_email'};
    $user_name = $DATA{'user_name'};

    if ($sendto ne "")
    {
    # Send mail to $recipient
    open (MAIL, "|$mailer") || die "Can't open $mailprog!\n";
    print MAIL "Subject: $subject\n";
    print MAIL "From: $user_email ($user_name)\n";
    print MAIL "To: $sendto\n";
    print MAIL "\n";
    print MAIL "$valist";
    print MAIL "\n";
    print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
    close (MAIL);
    if ($redirect ne "")
    {
    # go to another page
    print("location:$redirect\n\n");
    }
    else
    {
    # Print the response
    print "Content-type:text/html\n\n";
    print "<HTML><HEAD><TITLE>Thank you</TITLE><META http-equiv="refresh" content="1;url=contact.html"></HEAD><BODY>\n";
    print "Thank You<br>\n";
    print "Your Details have been sent.<br>\n";
    print "<A HREF=../contact.html>Back</a>\n";
    print "</BODY></HTML>\n";
    }
    }
    else
    {
    print "Content-type:text/html\n\n";
    print "<HTML><BODY>Error - sendto variable not declared</BODY></HTML>\n";
    }


Comments

  • Registered Users Posts: 5,700 ✭✭✭jd


    Hi
    Are you sure you are not changing the file permissions on the server.?

    Post code of a script that
    doesn't work
    john


  • Closed Accounts Posts: 286 ✭✭Kev


    there is already code in the script to pass the client on to a page.

    it uses a variable called redirect. just define that in the form in the html page.

    there should be no reason why you cant change the script though.


  • Registered Users Posts: 1,747 ✭✭✭Figment


    Worked a treat Kev.
    Thanks all.


  • Registered Users Posts: 1,562 ✭✭✭Snaga


    That script looks really old and very easy to exploit. For example its easy to send a POST request to that cgi script and send a spam mail to whoever I want pretending to be whoever I want.

    Your best bet is a nice uptodate formail script, get a good one here....

    http://www.scriptarchive.com/formmail.html

    Theres also a faq section and a howto session to help you get it working.

    It basically allows you to restrict where you want the mails to be able to go and a few other nice things too.


Advertisement