/    Sign up×
Community /Pin to ProfileBookmark

php ip logging question

how can i make a php code that will disallow anything to show up if their ip is logged in a text file?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@DanUKJan 30.2005 — Hi there.

Quickly came up with this, it's untested so if you have problems let me know.

From what you've said - it being a text file, you could use something like this in the header of all your files:

[code=php]
<?php
$banned = file_get_contents("/path/to/the/ipfile.txt");
if ($banned == "the.bad.ip") {
echo "<h1>Banned.</h1>";
} else {
?>

your html

<?php
}
?>
[/code]


Then you'll need to take a look at the strpos

[b]edit[/b]: this probably won't work without the strpos function, sorry. Take a look at php.net/strpos to integrate it.

Hope this helps.
Copy linkTweet thisAlerts:
@ScriptNoobie86authorJan 30.2005 — what i want to do is once they goto a webpage, it logs their ip and they cant access the site anymore.
Copy linkTweet thisAlerts:
@DanUKJan 30.2005 — Oh I see. So have you already got a script that will log their IP to the textfile? If not, you didn't say that on your first post ?

Also see the edit in my post.
Copy linkTweet thisAlerts:
@ScriptNoobie86authorJan 30.2005 — i have a logger because its easy to make... i know about this much php: |--|

to be more specific, the code takes 2 input fields, goes to the php address that writes them to a separate text file which i already have the code for. I would like to add the ability to ban them from viewing the input area and the writing php file again.
×

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 6.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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...