1A2B.log
- After implementing the game 1A2B,
try to enhance it by adding records to a log file "1a2b.log" (under the
same directory as 1a2b.php).
- Each line in the file consists of the following fields, separated
by TABs:
- Current date and time
- How many guesses did it take to guess those 4 digits
- How many seconds it took to guess
- The remote IP address of the player
- The HTTP agent (including OS and the browser) used by the
player
- You may find it useful to define a function add_record($iteration, $duration).
- Current date and time can be obtained by date() in PHP.
- The remote IP address may be found from $_SERVER['REMOTE_ADDR'].
- The HTTP agent can be identified by $_SERVER['HTTP_USER_AGENT'].
- If you encounter a permission issue, and you don't want to open the
write permission for the whole directory to anybody, you can try to open
only the write permission of a file:
- touch 1a2b.log
- chmod o+w 1a2b.log
- After the record of current play is written to the log file, all the
records are shown on the webpage in a table. You may wish to show the
last record with a different color to make it distinguishable.