public static function getCategoryGameItemWithLanguage($categoryCode) { $SQL = "SELECT items.*,lang.language AS langCode,lang.text AS langText FROM game_items AS items,game_item_language AS lang WHERE items.category='" . DBUtils::mysql_escape($categoryCode) . "' AND items.active=1 AND items.itemCode=lang.itemCode"; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { $list = array(); $ids = array(); $i = 0; while ($db_field = mysql_fetch_assoc($query)) { $item = GameItems::createFromSQLWithLanguage($db_field); if (!empty($item)) { $itemId = $item->getId(); if (!empty($itemId)) { if (isset($ids[$itemId]) && isset($list[$ids[$itemId]])) { $oldItem = $list[$ids[$itemId]]; $oldItem->languages = array_merge($oldItem->languages, $item->languages); } else { array_push($list, $item); $ids[$itemId] = $i; $i++; } } } } unset($ids); return $list; } return array(); }
public static function getGameCategoryItemWithLanguage() { $SQL = "SELECT categories.*,lang.language AS langCode,lang.text AS langText FROM " . TBL_GAME_ITEM_CATEGORY . " AS categories," . TBL_GAME_ITEM_CATEGORY_LANGUAGE . " AS lang WHERE categories.active=1 AND categories.categoryCode=lang.categoryCode ORDER BY id ASC"; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { $list = array(); $ids = array(); $i = 0; while ($db_field = mysql_fetch_assoc($query)) { $cat = GameItemCategory::createFromSQLWithLanguage($db_field); if (!empty($cat)) { $catId = $cat->getId(); if (!empty($catId)) { if (isset($ids[$catId]) && isset($list[$ids[$catId]])) { $oldItem = $list[$ids[$catId]]; $oldItem->languages = array_merge($oldItem->languages, $cat->languages); } else { array_push($list, $cat); $ids[$catId] = $i; $i++; } } } } unset($ids); return $list; } return array(); }
public static function getDAU($sDate, $eDate) { $SQL = "SELECT count(distinct " . TBL_GAME_USER_LOGIN_LOG . ".userId) as count_ FROM " . TBL_GAME_USER_LOGIN_LOG . "," . TBL_GAME_USERS . " WHERE " . TBL_GAME_USER_LOGIN_LOG . ".userId NOT IN(" . ADMIN_EXCEPT_USERS . ") AND " . TBL_GAME_USER_LOGIN_LOG . ".time BETWEEN " . $sDate . " AND " . $eDate . " AND " . TBL_GAME_USER_LOGIN_LOG . ".userId=" . TBL_GAME_USERS . ".userId AND " . TBL_GAME_USERS . ".registerDate<" . $sDate; $query = mysql_query($SQL, DBUtils::getManualConnection()); $count = 0; if (!empty($query)) { $db_field = mysql_fetch_assoc($query); if (isset($db_field["count_"])) { $count = $db_field["count_"]; } } return $count; }
public static function getTotalCount() { $SQL = "SELECT COUNT(*) as total FROM " . TBL_GAME_USER_FEEDBACK; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { while ($db_field = mysql_fetch_assoc($query)) { if (!empty($db_field["total"])) { return $db_field["total"]; } } } return 0; }
public static function getRetention($resgister_date, $start_Date, $end_date, $text = true) { $resgiter_max = strtotime(date("Y-m-d", $resgister_date) . " +1 day"); $SQL = "SELECT count(distinct game_users.userId) as signed_up_users,count(distinct game_user_login_log.userId) as logged_in_users FROM game_users " . " LEFT JOIN game_user_login_log ON game_users.userId = game_user_login_log.userId AND game_users.userId NOT IN(" . ADMIN_EXCEPT_USERS . ") AND game_users.registerDate <> game_user_login_log.time AND game_user_login_log.time >= " . $start_Date . " AND game_user_login_log.time < " . $end_date . " WHERE game_users.userId NOT IN(" . ADMIN_EXCEPT_USERS . ") AND game_users.registerDate >= " . $resgister_date . " AND game_users.registerDate < " . $resgiter_max; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { $db_field = mysql_fetch_assoc($query); $result_obj = new stdClass(); $result_obj->text = $db_field["logged_in_users"] . " - " . $db_field["signed_up_users"]; $s = intval($db_field["signed_up_users"]); $l = intval($db_field["logged_in_users"]); $result = $l / $s * 100; $result = rtrim(number_format($result, 2), '0.'); $result_obj->value = $result; return $result_obj; } return ""; }
public static function authenticate($username, $password) { if (empty($username) || empty($password)) { return NULL; } //TODO sql escape $SQL = "SELECT * FROM " . TBL_ADMIN_USERS . " WHERE userName='******' AND userPassword='******'"; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (empty($query)) { return NULL; } while ($db_field = mysql_fetch_assoc($query)) { $admin_user = AdminUsersModel::createAdminUserWithSQL($db_field); if (!empty($admin_user)) { return $admin_user; } } return null; }
public static function getUsersProfileByLostLeftGame($minMatch, $minRatio) { $SQL = "SELECT users.*,(( users.lostCountConnectionLostGame / users.lostGameCount ) *100 ) AS ratio FROM " . TBL_GAME_USERS . " AS users WHERE users.lostGameCount>" . $minMatch . " AND (( users.lostCountConnectionLostGame / users.lostGameCount ) *100 )>" . $minRatio . " ORDER BY ratio DESC"; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { $users = array(); while ($db_field = mysql_fetch_assoc($query)) { $user = GameUsers::createFromSQL($db_field); if (!empty($user)) { $obj = new stdClass(); $obj->user = $user; $obj->ratio = 0; if (isset($db_field["ratio"])) { $obj->ratio = $db_field["ratio"]; } array_push($users, $obj); } } if (!empty($users) && sizeof($users) > 0) { return $users; } return null; } }
<?php ini_set('max_execution_time', 600); define("__ROOT__", __DIR__ . "/../"); require_once __ROOT__ . 'config/constants.php'; require_once __ROOT__ . 'utils/Functions.php'; $SQL = "UPDATE " . TBL_GAME_LEADERBOARD_WEEKLY . " SET coins =0"; mysql_query($SQL, DBUtils::getManualConnection());
public static function getUserIdsFromFacebookIds($fbFriendIds) { if (!empty($fbFriendIds)) { $SQL = "SELECT users.userId FROM " . TBL_GAME_USERS . " users WHERE users.facebookId IN (" . $fbFriendIds . ")"; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { $friends = array(); while ($db_field = mysql_fetch_assoc($query)) { if (isset($db_field["userId"]) && !empty($db_field["userId"])) { array_push($friends, $db_field["userId"]); } } if (!empty($friends) && sizeof($friends) > 0) { return $friends; } } } return null; }
public static function getSoldItemList($start, $end, $str) { $SQL = "SELECT log.itemId,lang.text,COUNT(log.id) AS total_count, sum(log.coin) AS total_coin FROM " . TBL_GAME_USER_ITEM_LOG . " as log," . TBL_GAME_ITEMS . " as item," . TBL_GAME_ITEMS_LANG . " as lang " . " WHERE log.userId NOT IN(" . ADMIN_EXCEPT_USERS . ") AND log.type='buy' AND " . " log.itemId=item.id AND lang.itemCode=item.itemCode AND lang.language='tr' AND " . " log.time BETWEEN " . $start . " AND " . $end . " GROUP BY log.itemId" . " ORDER BY " . $str; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { $array = array(); while ($db_field = mysql_fetch_assoc($query)) { $obj = new stdClass(); if (!empty($db_field["itemId"])) { $obj->itemId = $db_field["itemId"]; } if (!empty($db_field["text"])) { $obj->text = $db_field["text"]; } if (!empty($db_field["total_count"])) { $obj->totalCount = $db_field["total_count"]; } if (!empty($db_field["total_coin"])) { $obj->totalCoin = $db_field["total_coin"]; } array_push($array, $obj); } return $array; } return null; }
public static function getBotsList($index, $limit, $orderBy = null) { if (empty($orderBy)) { $orderBy = "userId DESC"; } $SQL = "SELECT bots.id as bot_id, bots.weight_bar as weight_bar, bots.weight_blocked as weight_blocked, bots.weight_faraway as weight_faraway," . " bots.weight_single as weight_single, bots.roomGroupId as roomGroupId, bots.active as bot_active, users.* FROM " . TBL_GAME_BOTS . " bots," . TBL_GAME_USERS . " as users " . " WHERE bots.userId=users.userId ORDER BY " . $orderBy . " LIMIT " . $index . " , " . $limit; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { $bots = array(); while ($db_field = mysql_fetch_assoc($query)) { $bot = GameBots::createFromSQLWithUser($db_field); if (!empty($bot)) { array_push($bots, $bot); } } if (!empty($bots) && sizeof($bots) > 0) { return $bots; } } return null; }
public static function getTotalPayment() { $SQL = "SELECT SUM(amount) AS totalAmount FROM " . TBL_GAME_USER_FB_PRODUCT_LOG . " WHERE userId NOT IN(" . ADMIN_EXCEPT_USERS . ") AND type='buy_product' " . " ORDER BY time"; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { while ($db_field = mysql_fetch_assoc($query)) { if (!empty($db_field["totalAmount"])) { return $db_field["totalAmount"]; } } } }
public static function getTotalGameDate($start, $end) { $SQL = "SELECT count(id) as toplam FROM " . TBL_GAME_USER_COIN_LOG . " WHERE userId NOT IN(" . ADMIN_EXCEPT_USERS . ") AND type=\"game\" AND time BETWEEN " . $start . " AND " . $end; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { while ($db_field = mysql_fetch_assoc($query)) { if (!empty($db_field["toplam"])) { return $db_field["toplam"]; } } } }
public static function getAllProducts() { $SQL = "SELECT products.*," . "lang.language AS langCode,lang.text AS langText," . "price.currency AS priceCurrency,price.amount AS priceAmount " . "FROM game_fb_products AS products,game_fb_product_language AS lang,game_fb_product_prices AS price " . "WHERE products.active=1 AND products.Id=lang.fbProductId AND products.Id=price.fbProductId"; $query = mysql_query($SQL, DBUtils::getManualConnection()); if (!empty($query)) { $list = array(); $ids = array(); $i = 0; while ($db_field = mysql_fetch_assoc($query)) { $item = GameFbProducts::createFromSQLWithLanguagePrice($db_field); if (!empty($item)) { $itemId = $item->getId(); if (!empty($itemId)) { if (isset($ids[$itemId]) && isset($list[$ids[$itemId]])) { $oldItem = $list[$ids[$itemId]]; $oldItem->languages = UtilFunctions::array_unique_merge(array($oldItem->languages, $item->languages)); $oldItem->prices = UtilFunctions::array_unique_merge(array($oldItem->prices, $item->prices)); } else { array_push($list, $item); $ids[$itemId] = $i; $i++; } } } } unset($ids); return $list; } return array(); }
public static function getAllLeaderBoard($userId = null, $action = null, $page = 0, $pageCount = 10) { $result = new FunctionResult(); $result->success = false; if ($action == LeaderBoardUtils::$LEADERBOARD_ACTION_ALL) { $SQL = "SELECT users.coins as leaderboard_coins,users.lastLoginDate as leaderboard_lastplayed,level.levelName as level_levelname,level.levelNumber as level_levelnumber,level.maxXP as level_maxXP,level.minXP as level_minXP,users.* FROM " . TBL_GAME_USERS . " users," . TBL_GAME_USER_LEVEL . " as level WHERE users.userLevelNumber=level.levelNumber ORDER BY users.coins DESC LIMIT " . DBUtils::mysql_escape($page) . "," . DBUtils::mysql_escape($pageCount); $query = mysql_query($SQL, DBUtils::getManualConnection()); if (empty($query)) { $result->success = true; $result->result = new stdClass(); $result->result->list = array(); $result->result->page = $page; $result->result->pageCount = $pageCount; } else { $list = array(); $userAdded = false; while ($db_field = mysql_fetch_assoc($query)) { $user = GameUsers::createFromSQLWithLeaderboard($db_field); if (!empty($user)) { $userId_ = $user->getUserId(); if (!empty($userId_)) { array_push($list, $user); } if ($userId_ == $userId) { $userAdded = true; } } } if (!$userAdded) { $user = LeaderBoardUtils::getUserAllBoard($userId); if (!empty($user)) { array_push($list, $user); } } $result->success = true; $result->result = new stdClass(); $result->result->list = $list; $result->result->page = $page; $result->result->pageCount = $pageCount; } } else { $result->result = "Action is unknown"; } return $result; }