If you insist on doing this in this way, I would use directory trees to store the login count, meaning for the ip 127.0.0.1 use
/var/run/iptracker/127/0/0/1/count this will make the application run much faster than storing a huge number of files in one directory. when you get above a certain number of files in a directory (it differs on platform/version) you will see a _HUGE_ slowdown when stating files and opening files in said directory. I would recommend using some type of database or tie hash to store this instead. You get one file with quick lookups and no messy filesystem cleanups to worry about. Also 127.0.0.1 is a proper IP address.
Edited to add:
I agree with ovid that IP/failed login pairing not a very good metric for taking action. Many ISP's are claiming "Speed enhancers" nowadays which is really just a transparent proxy farm set up to grab a page, reduce image size/quality and push on to the requester. So more often than ever your site will be hit by proxy servers -- taking action based on IP is not worthwhile. One of the only things I can see being useful in that arena is to maybe take a rolling average of badauths/ip/time to throttle an attack from a source ip. But even that is hard to do without penalizing good users.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.