示例#1
0
    //invalid feedback data form
    echo "invalid game progress data form 2";
    return;
}
unset($exp[$arraySize - 1]);
$arraySize--;
//insert into mysql databse ===================================================
require 'config.php';
$con = mysqli_connect($config_var['mySQLHost'], $config_var['mySQLLogUsername'], $config_var['mySQLLogPassword'], $config_var['mySQLLogDatabase']);
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL. (prog1)";
    return;
}
//get user_id
require_once 'scripts/LogHelperFunctions.php';
$userId = getUserId($con, $_POST['deviceID']);
if (!$userId) {
    return;
}
$now = time();
$statsString = getStringId($con, $exp[0]);
$localGamesStarted = (int) $exp[1];
$multiplayerStated = (int) $exp[2];
$multiplayerWin = (int) $exp[3];
$multiplayerLose = (int) $exp[4];
$localMultiplayerStarted = (int) $exp[5];
$localMultiplayerFinished = (int) $exp[6];
$secondsPlayed = (int) $exp[7];
$achievementPoints = (int) $exp[8];
$achievementString = getStringId($con, $exp[9]);
mysqli_query($con, "INSERT INTO game_progress (`user`, `datetime`, `multiplayer_started`, `multiplayer_win`, `multiplayer_lose`, `local_multiplayer_started`, `local_multiplayer_finished`, `seconds_played`, `achievement_points`, `achievement_string`, `computer_games_stats`, `computer_games_started`)\r\n\t\tVALUES ({$userId}, {$now}, {$multiplayerStated}, {$multiplayerWin}, {$multiplayerLose}, {$localMultiplayerStarted}, {$localMultiplayerFinished}, {$secondsPlayed}, {$achievementPoints}, {$achievementString}, {$statsString}, {$localGamesStarted})");
示例#2
0
    return;
}
//last entry should be ""
if ($exp[$arraySize - 1] !== "") {
    //invalid feedback data form
    echo "invalid feedback data form 2";
    return;
}
unset($exp[$arraySize - 1]);
$arraySize--;
//insert into mysql databse ===================================================
require 'config.php';
$con = mysqli_connect($config_var['mySQLHost'], $config_var['mySQLLogUsername'], $config_var['mySQLLogPassword'], $config_var['mySQLLogDatabase']);
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL. (feed1)";
    return;
}
//get user_id
require_once 'scripts/LogHelperFunctions.php';
$userId = getUserId($con, $_POST['deviceID']);
if (!$userId) {
    return;
}
$now = time();
$versionId = getStringId($con, $_GET['VERSION']);
//add feedbacks
for ($i = 0; $i < $arraySize; $i += 2) {
    $questionId = getStringId($con, $exp[$i]);
    $answerId = getStringId($con, $exp[$i + 1]);
    mysqli_query($con, "INSERT INTO feedback (user, datetime, version, question, answer)\r\n\t\t\tVALUES ({$userId}, {$now}, {$versionId}, {$questionId}, {$answerId})");
}
示例#3
0
function getUserId($con, $device_id)
{
    if (2 !== substr_count($device_id, ':')) {
        echo "ERROR: Invalid format of device id: {$device_id}";
        return null;
    }
    $device_id = substr($device_id, 0, strpos($device_id, ':', strpos($device_id, ':') + 1));
    $deviceID = mysqli_real_escape_string($con, $device_id);
    $resultTmp = mysqli_query($con, "SELECT `user`.`id` FROM `user`, `string` WHERE `string`.`id` = `user`.`device_id` AND `string`.`value` = '{$deviceID}'");
    $row = $resultTmp->fetch_assoc();
    if (!$row) {
        $devStringId = getStringId($con, $deviceID);
        if ($devStringId === null) {
            return null;
        }
        mysqli_query($con, "INSERT INTO user (device_id) VALUES ({$devStringId})");
        $resultTmp = mysqli_query($con, "SELECT `user`.`id` FROM `user`, `string` WHERE `string`.`id` = `user`.`device_id` AND `string`.`value` = '{$deviceID}'");
        $row = $resultTmp->fetch_assoc();
        if (!$row) {
            echo "Failed to add new user with device id: {$deviceID}";
            return null;
        }
    }
    return $row['id'];
}