UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store
 

Network Sites UGN Security, The GoNix Initiative, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
September
Su M Tu W Th F Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Sponsored Links
Latest Postings
Doom 3
by Cyrez
09/11/14 08:58 PM
The History Thread...
by Cyrez
09/11/14 08:56 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666
08/22/14 09:21 AM
Latest Reviews
Topic Options
Rate This Topic
#18089 - 10/31/04 06:33 PM PHP Mail Script
Ghost Offline


Registered: 06/16/03
Posts: 807
Loc: Wisconsin
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>
"; };
?>
_________________________
[[ GamerSupport ] [ UGN Security ] [ Evil Hosting ] [ Comic Relief ]
~[Ghost]

Top
Sponsored Links
      
#18090 - 10/31/04 06:35 PM Re: PHP Mail Script
Shinobi Offline
UGN Member

Registered: 09/25/02
Posts: 390
Loc: Asheville, NC
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

Top
#18091 - 10/31/04 07:11 PM Re: PHP Mail Script
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7192
Loc: Portland, OR; USA
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, Elite Web Gamers & VNC Web Design Owner

Top
#18092 - 10/31/04 08:13 PM Re: PHP Mail Script
Ghost Offline


Registered: 06/16/03
Posts: 807
Loc: Wisconsin
Haha, all right gizmo, i'll bug you on irc.
_________________________
[[ GamerSupport ] [ UGN Security ] [ Evil Hosting ] [ Comic Relief ]
~[Ghost]

Top
#18093 - 11/01/04 06:28 AM Re: PHP Mail Script
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7192
Loc: Portland, OR; USA
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, Elite Web Gamers & VNC Web Design Owner

Top

Moderator:  §intå×, Gremelin 
Featured Member
Registered: 08/22/14
Posts: 1
Forum Stats
2148 Members
46 Forums
34395 Topics
69564 Posts

Max Online: 1567 @ 04/25/10 02:20 AM
Top Posters
UGN Security 27557
Gremelin 7192
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
Gecko666, defghi795767, Devo60, ali, lavos
2147 Registered Users
Who's Online
0 registered (), 110 Guests and 159 Spiders online.
Key: Admin, Global Mod, Mod
Latest News


Donate
  Get Firefox!
Get FireFox!