Welcome to WebmasterWorld Guest from 54.196.224.166

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP games scoring system

     

Seedy

3:55 pm on Mar 9, 2012 (gmt 0)



My games scoring code is returning the games' .swf file URL as the User-Agent when a blank name is entered for the score (appending it to the beginning of the real U-A). How can I prevent this happening or maybe just block blank names from being submitted please? (a simple database ban of ' ' doesn't work)

Many thanks in advance.

 # Saving new score?
if (isset($player_score) && is_numeric($player_score) && isset($player_name) && strlen($player_name) > 0 && strlen($player_name) <= $name_max) {

# Is this IP banned?
$query = mysql_query('SELECT ip FROM ipban') or error_msg('Could not access database.');
while ($row = mysql_fetch_row($query))
{
$ip_check = strpos($player_ip, $row[0], 0);
if ($ip_check === 0) error_msg('Disallowed');
}
#Is this name banned?
$query = mysql_query('SELECT name FROM nameban') or error_msg('Could not access database.');
while ($row = mysql_fetch_row($query)) {
if (strstr(strtolower($player_name), $row[0])) error_msg('Disallowed');
}
# Has this name played already?
$query = mysql_query("SELECT name, score FROM $table_name") or error_msg('Could not access database.');
$num_rows = mysql_num_rows($query);
$name_found = false;
while ($row = mysql_fetch_row($query)) {
if ($player_name == $row[0]) {
$name_found = true;
break;
}
}