PHP failed attempts to log in record in a txt file -


Basically to keep it low I have an assignment for college where I have to make some scripts.

In any one of these, I have to create a scripts that record data when entering a logon form, it will take users' IP address and it will be time, date, error name (e.g. Incorrect username and password, wrong name, we will be placed in the text file after the error page and efforts).

I thought: How to get users to record how to get time and date to record

Now, what I want to do: I am a script user I want to search for IP address and if this IP address has already been filed for unsuccessful attempt, instead of creating a new record, I want to add the efforts made in that IP address by adding 1, S Update of date. Only in this case that this IP address has not been entered, a new record should be made.

  If the IP already exists (find out the attempts to dismiss ++;} Else {ADD IP; Add time; Add date; Add reason; Attempt = 1;}  

This is what I've done so far:

   

If you really want you to add the same text file above and above To add the number of attempts by each individual user, I have to rewrite the entire txt file as long as I have the information. If you want to make it easy for you, you can write your txt file in such a way that you can easily get it, like IP address.

You can type each line like:

  IPADDRESS, error code, ATTEMPTS / n  

Then when you use that line If you want to change, you will need to keep that record line is that a loop will be required to parse your TXT file. So the way I try it will be:

Store the text in a variable from the file.

Use the Exploding () function to create an array of records. (Like a line in a database). I will use it as the $ rows = explosion ("/ n", $ txt);

Loop through rows, I'll use the foreach ($ lines as line $) for it.

Keep track of the row number, create a variable for it and iterate it.

to rebuild () function to make a list ($ IP, $ mistake, $ effort) again list ($ ip, $ err, $ attempt) = explosion (",", $ line);

Now use normal php if () check to see if two ips match, if the error code is the same

if they do, then you $ Attempt ++ can now make it difficult / essential part

You will need to create a string, but do not include that line and put it in a variable call As $ firstpart .

You must also do this for the rows after the affected row such as $ lastpart

Now create a new string for your affected row easily Goes: $ str = $ ip ",". $ Mistake ",". $ Effort;

Finally, write your TCT file using the variable, in order: $ firstpart, $ str, $ lastpart.

It will not be sure that this will work, it is not sure how it is practical, but at the very least I hope that with some kind of problem Brainwatch.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -