Previous Thread
Next Thread
Print Thread
Rate Thread
#18089 10/31/04 07:33 PM
Joined: Jun 2003
Posts: 807
Likes: 2
G
Ghost Offline OP
UGN Super Poster
OP Offline
UGN Super Poster
G
Joined: Jun 2003
Posts: 807
Likes: 2
A little mail script i wrote that tells you when you didn't fill out a field, and allows you to ban ip addresses from viewing the page. Any suggestions for optimizations, additions, or removals? Comments?
Code
<?php
# Ghost's PHP Mail Script v1.3
# The source from this script may be freely distributed so long as credit is given
$ip = $_SERVER['REMOTE_ADDR'];
$banfile = fread(fopen("banip.txt", "r"), filesize("banip.txt"));
$file = fopen("maillog.txt", "a+");
$address = $_SERVER['REMOTE_ADDR'];
$mailaddress = $_POST['address'];
$subject = $_POST['subject'];
$from = $_POST['from'];
$message = $_POST['message'];
$submitted = $_POST['submitted'];
fwrite($file, "Page View: \n $address \n\n");
if(strstr($banfile, "$ip")) {
die("Banned.");
};
if(strpos($mailaddress, "@") && strpos($from, "@") && $subject !== NULL && $message !== NULL) {
fwrite($file, "Message: \n $address \n  $mailaddress \n $date \n $message \n\n");
mail($mailaddress, $subject, $message,
"Return-Path: $from\n" .
"From: $from\n" .
"X-Sent-With: Ghost's PHP Mail Sender v1.4");
echo "Your mail has been sent";
} elseif($submitted == "1") {
if(!strpos($mailaddress, "@")) {
echo "You need to input an address for the \"Address\" field.
";
};
if($subject == NULL) {
echo "You need to input a subject for the \"Subject\" field.
";
};
if(!strpos($from, "@")) {
echo "You need to input an address for the \"Return Address\" field.
";
};
if($message == NULL) {
echo "You need to input a message to send in the \"Message\" field.
";
};
echo "
<html>
 <head>
  <title>Mail Page</title>
 </head>
 <body>
  <form action=\"mail.php\" method=\"post\">
   Address: <input type=\"text\" name=\"address\">

   Subject: <input type=\"text\" name=\"subject\">

   Return Address: <input type=\"text\" name=\"from\">

   Message: <textarea name=\"message\"></textarea>

   <input type=\"hidden\" name=\"submitted\" value=\"1\">
   <input type=\"submit\">
  </form>
 </body>
</html>
";
} else {
echo "
<html>
 <head>
  <title>Mail Page</title>
 </head>
 <body>
  <form action=\"mail.php\" method=\"post\">
   Address: <input type=\"text\" name=\"address\">

   Subject: <input type=\"text\" name=\"subject\">

   Return Address: <input type=\"text\" name=\"from\">

   Message: <textarea name=\"message\"></textarea>

   <input type=\"hidden\" name=\"submitted\" value=\"1\">
   <input type=\"submit\">
  </form>
 </body>
</html>
"; };
?>

#18090 10/31/04 07:35 PM
Joined: Sep 2002
Posts: 390
UGN Member
Offline
UGN Member
Joined: Sep 2002
Posts: 390
Wow ghost, why don't you show off a little BIT!?!!???


"The secret to creativity is knowing how to hide your sources."
-Albert Einstein

Tech Ninja Security
#18091 10/31/04 08:11 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Ask me when I'm sober, I have a few pointers :hicup: should be tomorrow or somethig


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#18092 10/31/04 09:13 PM
Joined: Jun 2003
Posts: 807
Likes: 2
G
Ghost Offline OP
UGN Super Poster
OP Offline
UGN Super Poster
G
Joined: Jun 2003
Posts: 807
Likes: 2
Haha, all right gizmo, i'll bug you on irc.

#18093 11/01/04 07:28 AM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
How I'd handle listing my calls in a script:
Code
<?php
if($_SERVER["HTTPS"] == "on") {
  $type = "https";
}else{
  $type = "http";
}
$host = $_SERVER["HTTP_HOST"];
$url = "$type://$host/";
$me = $_SERVER["SCRIPT_URL"];
?>

<a href="<?php echo($ssl); ?>://<?php echo($host); ?><?php echo($me); ?>?function=call">link to script</a>
That way it'll auto update the script name and if it's being accessed through https or not; however as it's a mail script you don't really NEED ssl support so that'd knock us down to:
Code
<?php
$host = $_SERVER["HTTP_HOST"];
$me = $_SERVER["SCRIPT_URL"];
?>

<a href="http://<?php echo($host); ?><?php echo($me); ?>?function=call">link to script</a>
Or even:
Code
<?php
$script = $_SERVER["SCRIPT_URI"]
?>

<a href="<?php echo($script); ?>?function=call">link to script</a>
However I woudln't reccommend using the final one for subdomains; for some reason "script_uri" doesn't like subdomains in some enviroments (oen of the manyt hings i had to fix in the fserv)


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner

Link Copied to Clipboard
Member Spotlight
Phatal
Phatal
Houston, TX
Posts: 298
Joined: April 2004
Forum Statistics
Forums41
Topics33,840
Posts68,858
Average Daily Posts1
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Where and how do you torrent?
by danni75 - 03/01/24 05:58 AM
Animation,
by JohanKaariainen - 08/15/19 01:18 AM
Blackbeard.....
by Gremelin - 10/03/18 07:02 PM
my old account still exists!
by Crime - 08/10/18 02:47 PM
Okay WTF?
by HenryMiring - 09/27/17 01:45 AM
The History Thread...
by Gremelin - 08/11/17 12:11 PM
My friend NEEDS your HELP!
by Lena01 - 07/21/17 12:06 AM
I'm having fun with this guy.
by gabithompson730 - 07/20/17 01:50 AM
I want to upgrade my phone
by gabithompson730 - 07/20/17 01:49 AM
Doom 3
by Cyrez - 09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666 - 08/22/14 09:21 AM
AIM scene 99-03
by lavos - 09/02/13 08:06 AM
Planetside 2
by Crime - 03/04/13 07:10 AM
Beta Testers Wanted
by Crime - 03/04/13 06:55 AM
Hello Everyone
by Gremelin - 02/12/12 06:01 PM
Tracfone ESN Generator
by Zanvin Green - 01/18/12 01:31 PM
Python 3 issue
by Testing - 12/17/11 09:28 PM
tracfone airtime
by Drache86 - 07/30/11 03:37 AM
Backdoors and the Infinite
by ZeroCoolStar - 07/10/11 03:52 AM
HackThisZIne #12 Releaseed!
by Pipat2 - 04/28/11 09:20 PM
gang wars? l33t-wars?
by Gremelin - 04/28/11 05:56 AM
Consolidate Forums
by diggin2deep - 04/21/11 10:02 AM
LAN Hacking Noob
by Gremelin - 03/12/11 12:42 AM
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
Cyrez 1
Girlie 1
unreal 1
Crime 1
Powered by UBB.threads™ PHP Forum Software 7.7.5