\n";
}
function createAccount($login,$pw,$displayed_name,$email)
{
$query = "INSERT INTO `games` (`gameidlogin`,`displayed_name`,`password`,`email`,`hidden`) VALUES ('$login','$displayed_name','$pw','$email','clientid ')";
mysql_query($query) or
die ("error: account creation: ".mysql_error());
}
function highscoreTableExists($login)
{
$exists = mysql_query("SELECT 1 FROM $login LIMIT 0");
if ($exists) return true;
return false;
}
function accountExists($login)
{
$query="SELECT gameidlogin FROM games WHERE gameidlogin='$login'";
$result = mysql_query($query) or
die ("error: account excistence check: ".mysql_error());
if (mysql_num_rows($result) > 0)
return true;
else
return false;
}
function deleteAccount($login)
{
$query = "DELETE FROM `games` WHERE gameidlogin='$login'";
mysql_query($query) or
die ("error: deleting account: ".mysql_error());
if(highscoreTableExists($login))
{
$query = "DROP TABLE `$login`";
mysql_query($query) or
die ("error: dropping higscore table: ".mysql_error());
}
}
function isValidEmail($email)
{
return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}
function inputOk($login,$pw,$pw2,$gamename,$email)
{
$error="";
if($login=="")
$error.="Empty login/game-id not allowed!
";
else if($login!= ereg_replace("[^A-Za-z0-9_]","",$login))
$error.="'$login' is not allowed as a login/game-id because of invalid characters! (allowed: A-Za-z0-9_)
";
if($login=="games")
$error.="'games' is not allowed as a login/game-id!
";
if($login=="serverlist")
$error.="'serverlist' is not allowed as a login/game-id!
";
if($gamename=="")
$error.="Empty gamename not allowed!
";
if(!isValidEmail($email))
$error.="E-mail invalid: $email!
";
if($pw=="")
$error.="Empty password not allowed!
";
if($pw2!=$pw)
$error.="Password mismatch!
(Password should be equal to password2.)
";
if($error!="")
{
echo "