<?php
error_reporting(-1);
ini_set("display_errors",true);
$
db = new mysqli("
mysql.webhosting68.1blu.de", "dbuser", "dbpass", "dbdatabase");
if ($mysqli->connect_errno) {
echo "Failed to connect to
MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$highscorestring=$_POST["Name"] . $_POST["Info"] . $_POST["Rank"] . $_POST["Score"] . $_POST["Skill"] . $_POST["Level"] . $_POST["Quest"] . $_POST["Vers"] . $_POST["Difficulty"] . "hi666";
if ( md5($highscorestring) == $_POST["Hash"]){
$
sql="Select Count(*) from mygame_highscores where ModeID=".$_POST["ModeID"]." and Name='".$_POST["Name"]."'";
$result = mysqli_query($
db, $
sql);
$row = mysqli_fetch_array($result,MYSQLI_BOTH);
if ($row[0] == 0)
{
$
sql = "INSERT INTO mygame_highscores (ModeID,Name,Rank,Info,Score,Skill,Level,Quest,Vers,Difficulty) VALUES (
'".$_POST["ModeID"]."',
'".$_POST["Name"]."',
'".$_POST["Rank"]."',
'".$_POST["Info"]."',
".$_POST["Score"].",
".$_POST["Skill"].",
".$_POST["Level"].",
".$_POST["Quest"].",
'".$_POST["Vers"]."',
".$_POST["Difficulty"].")";
}
else
{
$
sql = "Update mygame_highscores set
Score=".$_POST["Score"].",
Skill=".$_POST["Skill"].",
Rank='".$_POST["Rank"]."',
Level=".$_POST["Level"]."
where ModeID=".$_POST["ModeID"]."
AND Name='".$_POST["Name"]."'
AND Score<".$_POST["Score"];
}
$result = mysqli_query($
db, $
sql);
$sqlBack="Select Count(*) from mygame_highscores where
ModeID=".$_POST["ModeID"]."
AND Score>".$_POST["Score"];
$resultBack = mysqli_query($
db, $sqlBack);
$rowBack = mysqli_fetch_array($resultBack,MYSQLI_BOTH);
echo $rowBack[0];
}
else
{
echo "1000";
}
$
db->close();
?>