<?php session_start(); header("Content-Type: application/json"); include "../dbconnection.php"; $_SESSION['user_loged_id'] = 34; $total_coins = 0; if (isset($_SESSION['user_loged_id'])) { $user_id = $_SESSION['user_loged_id']; $result = getUserGameCoins($user_id); $game_coins = mysql_fetch_array($result); if ($game_coins['total_coins'] > 0) { $user_data = array('user_id' => $user_id, 'total_coins' => $game_coins['total_coins'], 'status' => '1'); echo json_encode($user_data); } else { $user_data = array('user_id' => $user_id, 'total_coins' => "{$total_coins}", 'status' => '1'); echo json_encode($user_data); } } else { $user_data = array('status' => '0', 'err' => 'user not login'); echo json_encode($user_data); }
<?php session_start(); include "dbconnection.php"; $sender = $_GET['sender']; //phone num. $amount = $_GET['amount']; //credit $_SESSION['amount'] = $amount; $cuid = $_GET['cuid']; //resource i.e. user if (preg_match("/completed/i", $_GET['status'])) { $result = getUserGameCoins($cuid); $user_coins = mysql_fetch_array($result); if ($user_coins['total_coins'] > 0) { $total_coins = $user_coins['total_coins'] + $amount; $updatedAt = date("Y-m-d"); $query = "update user_game_coins set total_coins={$total_coins},fortomo_coins={$amount} where user_id={$cuid}"; mysql_query($query) or die(mysql_error()); } else { $createdAt = date("Y-m-d"); $updatedAt = date("Y-m-d"); $query = "insert into user_game_coins (user_id,createdAt,total_coins,fortomo_coins) vaues({$cuid},'{$createdAt}',{$amount},{$amount})"; mysql_query($query) or die(mysql_error()); } }
session_start(); include "dbconnection.php"; $max_scores = getGameHightestScore(); $max_score = mysql_fetch_array($max_scores); $game_users = getUserByMaxScore($max_score['game_score']); $game_user = mysql_fetch_array($game_users); $user_id = $game_user['user_id']; $current_date = date("Y-m-d"); $updateAt = strtotime($game_user['updateAt']); $updatedAt = date("Y-m-d", $updateAt); $d1 = new DateTime($current_date); $d2 = new DateTime($updatedAt); $interval = $d2->diff($d1); $difference = $interval->format('%d'); if ($interval->format('%d') > 1) { $game_point = getUserGameCoins($user_id); $user_points = mysql_fetch_array($game_point); if ($user_points['total_coins'] > 0) { if ($user_points['heightest_score_coins'] < 1) { $heightest_score_point = 10; $total_points = $user_points['total_coins'] + $heightest_score_point; updateUserCoins($user_id, $heightest_score_point, $total_points); } else { $heightest_score_point = 10; $total_points = $heightest_score_point; updateUserCoins($user_id, $heightest_score_point, $total_points); } } else { $heightest_score_point = 10; $total_points = $heightest_score_point; createUserHightScoreCoins($user_id, $heightest_score_point, $total_points);
<?php session_start(); include "dbconnection.php"; if (isset($_SESSION['user_loged_id'])) { $scratch_card_number = mysql_real_escape_string($_REQUEST['scratch_card_number']); $scratch_cards = getScratchCardByNumber($scratch_card_number); $scratch_card = mysql_fetch_array($scratch_cards); if ($scratch_card['card_id'] > 0) { $card_id = $scratch_card['card_id']; $scratch_card_coins = $scratch_card['number_of_coins']; $session_id = $_SESSION['user_loged_id']; $result = getUserGameCoins($session_id); $user_coins = mysql_fetch_array($result); $total_coins = $user_coins['total_coins'] + $scratch_card['number_of_coins']; $query = "update user_game_coins set total_coins={$total_coins} where user_id={$session_id}"; mysql_query($query) or die(mysql_error()); $queryq = "update maverick_game_card set isused='yes' where card_id={$card_id}"; mysql_query($queryq) or die(mysql_error()); $_SESSION['coins'] = $scratch_card_coins; header("location:thanks-scratchcard-payment"); } else { header("location:scratch-card-payment?err"); } } else { header("location:maverick-game-user-login"); }