function RequestToRemove($Hash, $timestamp) { include "conf.php"; $doOnce = false; $conn = new mysqli($serverip, $username, $password, $dbname, $Port); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $hash = mysqli_escape_string($conn, $Hash); $UserQuerry = "SELECT * from User where hash = '{$hash}'"; $UserResult = $conn->query($UserQuerry); if (!$UserResult) { echo encrypt("hash not found: " . $hash); } if ($UserResult->num_rows > 0) { while ($UserRow = $UserResult->fetch_assoc()) { $PlayerQuerry = "SELECT * from Players where ID = '" . $UserRow['playerID'] . "'"; $PlayerResult = $conn->query($PlayerQuerry); while ($PlayerRow = $PlayerResult->fetch_assoc()) { $gameID = $PlayerRow['GameID']; if (!$doOnce) { $doOnce = true; $playerDeleteQuerry = "DELETE FROM Players where id = '" . $UserRow['playerID'] . "'"; $playerDeleteResult = $conn->query($playerDeleteQuerry); UpdateGame($gameID, $timestamp); } } } } else { echo encrypt("No Hash"); } $conn->close(); return; }
function ArcadeRate() { global $smcFunc, $txt, $arcSettings, $context, $user_info; $xml = isset($_REQUEST['xml']); $game = ArcadeGameInfo((int) $_REQUEST['game']); // Get game info if ($game === false) { fatal_lang_error('arcade_game_not_found'); } // Game was not found $rate = (int) $_REQUEST['rate']; if ($rate < 0 || $rate > 5) { fatal_lang_error('arcade_rate_error'); } // Don't allow invalid rates // To ensure there will be no doubles $smcFunc['db_query']('', ' DELETE FROM {db_prefix}arcade_rates WHERE id_member = {int:mem} AND id_game = {int:game}', array('mem' => $user_info['id'], 'game' => $game['id'])); if ($rate > 0) { $smcFunc['db_insert']('', '{db_prefix}arcade_rates', array('id_member' => 'int', 'id_game' => 'int', 'rating' => 'int', 'rate_time' => 'int'), array($user_info['id'], $game['id'], $rate, time()), array('id_rating')); } // Update rating $result = $smcFunc['db_query']('', ' SELECT SUM(rating) AS rating, COUNT(rating) AS rates FROM {db_prefix}arcade_rates WHERE id_game = {int:game} GROUP BY id_game', array('game' => $game['id'])); $row = $smcFunc['db_fetch_row']($result); $smcFunc['db_free_result']($result); $rate2 = $row[0] / $row[1]; UpdateGame($game['id'], array('game_rating' => $rate2)); if (!$xml) { // Go to reffering page (or highscore page) if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == '') { redirectexit('action=arcade;sa=highscore;game=' . $game['id']); } else { redirectexit($_SERVER['HTTP_REFERER']); } } else { $context['sub_template'] = 'xml'; $context['arcade']['message'] = 'arcade_rating_saved'; $context['arcade']['extra'] = '<rating>' . $rate2 . '</rating>'; } }
function GamesAdminEditor2() { global $scripturl, $txt, $context; if (!isset($_POST['data']['enabled'])) { $_POST['data']['enabled'] = 0; } if (!isset($_REQUEST['game'])) { fatal_error('arcade_no_game'); } $game = ArcadeGameInfo((int) $_REQUEST['game'], null, true); if ($game === false) { fatal_error('arcade_no_game'); } $errors = UpdateGame((int) $_REQUEST['game'], $_POST['data']); // There were no errors no need to display this again if (count($errors) === 0) { if (!isset($_SESSION['arcade_page'])) { redirectexit('action=admin;area=managearcade;sa=listgames'); } else { redirectexit('action=admin;area=managearcade;sa=listgames;start=' . $_SESSION['arcade_page']); } } $context['arcade']['config_errors'] =& $errors; prepareEditor($game); // Title for page $context['page_title'] = $txt['arcade_title_manage_games'] . ' - ' . $game['name']; // Template layers for editor //$context['template_layers'][] = 'editor'; $context['sub_template'] = 'arcadeadmin_editor'; // Game data $context['arcade']['game'] =& $game; }