Results 1 to 5 of 5
-
November 4th, 2004, 03:50 PM #1Digitalosophyn/aGuest
posts[PHP] Banning users - help format code for html
I made a small system to where I can ban users from my webserver and print a reason for them getting banned.
My problem is now this:
The way my code is set up, php checks to see if the current IP address matches an IP address from the ban list. If true, print the reason and such. If false display the website.
Now of course, I want to add this to all my pages currently on my webserver including my blog.
To reformat the HTML to work with this system would definatly be a pain in the ***.
So my question is there any other way I can do this, so I don't have to reformat the HTML? Maybe I'm just not thinking properly at the moment.
PHP Code:<?php
//already connected to db of course
$s = $_SERVER["REMOTE_ADDR"];
$ipbancheck = "SELECT * from banip where IP='$s'";
$result = mysql_query($ipbancheck);
$row = mysql_fetch_array($result);
if($s = $row["IP"]){
echo "<p>Your IP Address has been banned from this webserver ";
echo htmlspecialchars( stripslashes($row["IP"])).'<br>';
echo "Reason: ";
echo htmlspecialchars( stripslashes($row["REASON"]));
echo "</p>";
}else{
echo "Display Website";
// here's the problem
// i don't want to have to reformat all my html
// for php, i have many pages i want to do this for.
}
?>
-
November 4th, 2004, 04:39 PM #24,863Registered User
postsjust save it to a file and include it in each of your pages
<?PHP include "banlist.php"; ?>
Don't have the else, just put die(); at the end of the if statement.
PHP Code:<?php
//already connected to db of course
$s = $_SERVER["REMOTE_ADDR"];
$ipbancheck = "SELECT * from banip where IP='$s'";
$result = mysql_query($ipbancheck);
$row = mysql_fetch_array($result);
if($s = $row["IP"]){
$error = "<p>Your IP Address has been banned from this webserver ";
$error .= htmlspecialchars( stripslashes($row["IP"])) . "<br />\n";
$error .= "<b>Reason:</b><br />\n";
$error .= htmlspecialchars( stripslashes($row["REASON"]));
$error .= "</p>";
die($error);
}
?>
-
November 4th, 2004, 04:53 PM #3Digitalosophyn/aGuest
postsha good looks man, I'll give that a go in a little while
-
November 4th, 2004, 04:56 PM #4Digitalosophyn/aGuest
postsWorks perfectly, thanks.
-
November 5th, 2004, 01:06 AM #54,863Registered User
postsAny time man.

Reply With Quote


Bookmarks