Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

CGI script

  • 08-11-2002 12:56PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2, Paid Member Posts: 5,808 ✭✭✭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, Registered Users 2 Posts: 1,747 ✭✭✭Figment


    Worked a treat Kev.
    Thanks all.


  • Registered Users, Registered Users 2 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