What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » General » General Chit Chat » Website Help :)

Website Help :)
Author: Message:
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
32 / Male / Flag
Joined: Oct 2005
Status: Away
O.P. Website Help :)
Hello all, remember my website? :P 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
Profile PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
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
Profile E-Mail PM Web Find Quote Report
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
32 / Male / Flag
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? :S

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
Profile PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
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
Profile E-Mail PM Web Find Quote Report
NiteMare
Veteran Member
*****

Avatar
Giga-Byte me

Posts: 2497
Reputation: 37
37 / Male / Flag
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
[Image: sig/]
I'll never forget what she said 6865 days, 18 hours, 59 minutes, 31 seconds ago
Need hosting? Check
out my website. we can help you out :)
03-09-2007 06:54 AM
Profile PM Web Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
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. :p
03-09-2007 07:02 AM
Profile PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
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. :p
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
Profile E-Mail PM Web Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
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. :P
03-09-2007 07:14 AM
Profile PM Web Find Quote Report
Eddie
Veteran Member
*****


Posts: 2078
Reputation: 30
32 / Male / Flag
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
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On