function addBet($uid, $g_id, $bi_id, $amount, $notify = 0) { global $config; $basedir = $config['basedir']; $now = time(); // insert to coin_deals $q = "INSERT INTO coin_deals (user_id, cd_amount, cd_inout, tx_id, cd_type, cd_tx_date) VALUES ('{$uid}', '{$amount}', 'out', '', 'bet', '{$now}')"; mysql_query($q); $id = mysql_insert_id(); if ($id) { // append all_coin_deals.txt cache $coindeal['cd_id'] = $id; $coindeal['user_id'] = $uid; $coindeal['g_id'] = 0; $coindeal['cd_amount'] = $amount; $coindeal['cd_inout'] = 'out'; $coindeal['tx_id'] = ''; $coindeal['cd_type'] = 'bet'; $coindeal['cd_tx_date'] = $now; $file = $basedir . '/temp/all_coin_deals.txt'; if (file_exists($file)) { $data = json_decode(file_get_contents($file), true); $data[] = $coindeal; unlink($file); file_put_contents($file, json_encode($data)); } //recompute user's coins $user_coins = getUserCoins($uid); updateUserCoins($uid, $user_coins); $activity = 'joinedgame'; $seen = 1; $fieldname = 'g_id'; $fieldvalue = $g_id; addActivity($uid, $activity, $seen, $fieldname, $fieldvalue); // insert to user_bets $q = "INSERT INTO user_bets (user_id, g_id, bi_id, ub_coins, ub_notify, cd_id) VALUES ('{$uid}', '{$g_id}', '{$bi_id}', '{$amount}', '{$notify}', '{$id}')"; mysql_query($q); $insert_id = mysql_insert_id(); // insert data to the cache file $newrec = array('ub_id' => $insert_id, 'user_id' => $uid, 'g_id' => $g_id, 'bi_id' => $bi_id, 'ub_coins' => $amount, 'ub_notify' => $notify, 'cd_id' => $id, 'ub_iswinner' => 0); $cachefile = $config['basedir'] . '/temp/user_bets_active.php'; if (file_exists($cachefile)) { // get the file $uba = json_decode(file_get_contents($cachefile), true); $uba[] = $newrec; file_put_contents($cachefile, json_encode($uba)); // write } } return true; }
$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); } } ?> <!DOCTYPE HTML> <html> <head> <title>Maverick Game - Play the Most Addicting Games Online!</title> <meta content="play games online, best online games, addicting games, arcade games, mmorpg, adventure games, action games, car racing gamees, arcade games, multiplayer games" name="keywords" /> <meta content="The most addicting games lie within Maverick Game! Play racing, stunt, cooking, strategy and all types of arcade games here!" name="description"/>