Website Help :) |
Author: |
Message: |
Eddie
Veteran Member
Posts: 2078 Reputation: 30
32 / /
Joined: Oct 2005
Status: Away
|
O.P. Website Help :)
Hello all, remember my website? well i need some more help some people have been abusing the contact us form on the site unfortunately so i need a way (in php) to be able to obtain the IP Address of someone sending in a contact us, and the possibility to disallow that IP to "Contact Us" via the form Any ideas?
EDIT: Here is the PHP Code:
code: <?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "admin@haboz.net";
$Subject = "Contact Us";
$Name = Trim(stripslashes($_POST['HabboName']));
$Query = Trim(stripslashes($_POST['Query']));
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.haboz.net/v6/contact_us_error.php>";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Habbo Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Query: ";
$Body .= $Query;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.haboz.net/v6/contact_us_ok.php>";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.haboz.net/v6/contact_us_error.php>";
}
?>
This post was edited on 03-09-2007 at 06:35 AM by Eddie.
...there used to be a signature here
|
|
03-09-2007 06:32 AM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: Website Help :)
code: $ip = $_SERVER[REMOTE_ADDR];//Add this in your message
And then if its the spammers ip
code: $spammers = array(
'IP 1',
'IP 2',
'IP 2'
);
for($i=0;$i<sizeof($spammers);$i++) {
if(strpos($ip, $spammers[$i])!==false) {
//Display you are a spammer and are not allowed to view this page
}
}
|
|
03-09-2007 06:40 AM |
|
|
Eddie
Veteran Member
Posts: 2078 Reputation: 30
32 / /
Joined: Oct 2005
Status: Away
|
O.P. RE: Website Help :)
So like this
code: <?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "admin@haboz.net";
$Subject = "Contact Us";
$Name = Trim(stripslashes($_POST['HabboName']));
$Query = Trim(stripslashes($_POST['Query']));
$ip = $_SERVER[REMOTE_ADDR];
// validation
$validationOK=true;$ip =
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.haboz.net/v6/contact_us_error.php>";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Habbo Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Query: ";
$Body .= $Query;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.haboz.net/v6/contact_us_ok.php>";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.haboz.net/v6/contact_us_error.php>";
}
$spammers = array(
'IP 1',
'IP 2',
'IP 2'
);
for($i=0;$i<sizeof($spammers);$i++) {
if(strpos($ip, $spammers[$i])!==false) {
//Display you are a spammer and are not allowed to view this page
}
}
?>
?????
But if thats the way where do i place the url to "not allowed" page?
This post was edited on 03-09-2007 at 06:48 AM by Eddie.
...there used to be a signature here
|
|
03-09-2007 06:43 AM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: Website Help :)
You didn't get me right
For the php
code: <?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "admin@haboz.net";
$Subject = "Contact Us";
$Name = Trim(stripslashes($_POST['HabboName']));
$Query = Trim(stripslashes($_POST['Query']));
$Ip = $_SERVER[REMOTE_ADDR];
$spammers = array(
'IP 1',
'IP 2',
'IP 2'
);
for($i=0;$i<sizeof($spammers);$i++) {
if(strpos($ip, $spammers[$i])!==false) {
header('Location: contact_us_spammer.php');
}
}
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
header('Location: contact_us_error.php');
}
// prepare email body text
$Body = "";
$Body .= "Habbo Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "IP: ";
$Body .= $Ip;
$Body .= "\n";
$Body .= "Query: ";
$Body .= $Query;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
header('Location: contact_us_ok.php');
}
else{
header('Location: contact_us_error.php');
}
?>
This post was edited on 03-09-2007 at 07:23 AM by Felu.
|
|
03-09-2007 06:52 AM |
|
|
NiteMare
Veteran Member
Giga-Byte me
Posts: 2497 Reputation: 37
37 / /
Joined: Aug 2003
|
RE: Website Help :)
underneath code: //Display you are a spammer and are not allowed to view this page
you could try puting code: header('Location: http://yoursite.com/bannage.html');
you could give that a try, then test it on your self
|
|
03-09-2007 06:54 AM |
|
|
WDZ
Former Admin
Posts: 7106 Reputation: 107
– / /
Joined: Mar 2002
|
RE: Website Help :)
Felu: Bad idea relying on the form like that. It would be extremely easy for a spammer to fake his IP address.
|
|
03-09-2007 07:02 AM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: Website Help :)
quote: Originally posted by WDZ
Felu: Bad idea relying on the form like that. It would be extremely easy for a spammer to fake his IP address.
quote: Originally posted by Eddie
to be able to obtain the IP Address of someone sending in a contact us, and the possibility to disallow that IP to "Contact Us" via the form
If not blocking the IP, which other method would you like to use?
|
|
03-09-2007 07:08 AM |
|
|
WDZ
Former Admin
Posts: 7106 Reputation: 107
– / /
Joined: Mar 2002
|
RE: Website Help :)
By "relying on the form," I mean passing the IP address via the form using that hidden field. It would be much easier and safer to use $_SERVER['REMOTE_ADDR'] in the script, and don't change the form at all.
|
|
03-09-2007 07:14 AM |
|
|
Eddie
Veteran Member
Posts: 2078 Reputation: 30
32 / /
Joined: Oct 2005
Status: Away
|
O.P. RE: Website Help :)
ok me and felu sorted out the form and deleted stuff we changed, heres the php code now:
code: <?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "admin@haboz.net";
$Subject = "Contact Us";
$Name = Trim(stripslashes($_POST['HabboName']));
$Query = Trim(stripslashes($_POST['Query']));
$Ip = $_SERVER[REMOTE_ADDR];
$spammers = array('banned ip here (felus was here)');
for($i=0;$i<sizeof($spammers);$i++) {
if(strpos($ip, $spammers[$i])!==false) {
header('Location: contact_us_ban.php');
}
}
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
header('Location: contact_us_error.php');
}
// prepare email body text
$Body = "";
$Body .= "Habbo Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "IP: ";
$Body .= $Ip;
$Body .= "\n";
$Body .= "Query: ";
$Body .= $Query;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
header('Location: contact_us_ok.php');
}
else{
header('Location: contact_us_error.php');
}
?>
But it doesnt seem to be working
EDIT: Yay it seems to be working now Thanks Felu, WDZ and Nitemare appreciated
This post was edited on 03-09-2007 at 07:46 AM by Eddie.
...there used to be a signature here
|
|
03-09-2007 07:43 AM |
|
|
|