Check if file name is correct before creating db record. Log client ip address.

There has been some vandalism recently on infragram.org. Someone is using script to create many useless db records. This commit adds basic protection against such individuals. Filename is checked before db record is created. Also client ip address is logged so that it is easier to block such attacks in future.