public static function getUserFacebookFriends(GameUsers $user)
 {
     if (!empty($user)) {
         $userId = $user->getUserId();
         $fbId = $user->getFacebookId();
         $oauthTOken = $user->getOauthToken();
         if (!empty($userId) && !empty($fbId) && !empty($oauthTOken)) {
             $facebook = new Facebook(array('appId' => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true));
             $facebook->setAccessToken($oauthTOken);
             try {
                 $fbFriends = array();
                 $apiUrl = "/me/friends";
                 while (!empty($apiUrl)) {
                     $result = $facebook->api($apiUrl);
                     $apiUrl = null;
                     if (!empty($result)) {
                         $data = null;
                         if (isset($result["data"])) {
                             $data = $result["data"];
                         }
                         if (!empty($data) && sizeof($data)) {
                             foreach ($data as $fbFriend) {
                                 if (!empty($fbFriend)) {
                                     array_push($fbFriends, $fbFriend);
                                 }
                             }
                         }
                         unset($data);
                         if (isset($result["paging"])) {
                             $paging = $result["paging"];
                             if (!empty($paging) && isset($paging["next"]) && !empty($paging["next"])) {
                                 $next = $paging["next"];
                                 if (strpos($next, "/friends")) {
                                     $apiUrl = "/me" . substr($next, strpos($next, "/friends"));
                                 }
                                 unset($next);
                             }
                             unset($paging);
                         }
                     }
                     unset($result);
                     unset($apiUrl);
                 }
                 return $fbFriends;
             } catch (Exception $exc) {
                 error_log("FriendUtils>getUserFacebookFriends> Error : " . $exc->getMessage() . " Trace : " . $exc->getTraceAsString());
             }
         }
     }
     return null;
 }
 public function log()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("userxplog > log > start userId : " . $this->userId . " xp : " . $this->xp . " type : " . $this->type . " time : " . $this->time . " gameId : " . $this->gameId . " result : " . $this->result . " opponentId : " . $this->opponentId);
     if (!empty($this->userId)) {
         $userXPLog = new GameUserXpLog();
         $userXPLog->setUserId($this->userId);
         $userXPLog->setXp($this->xp);
         $userXPLog->setTime($this->time);
         $userXPLog->setType($this->type);
         $userXPLog->setGameId($this->gameId);
         $userXPLog->setResult($this->result);
         $userXPLog->setOpponentId($this->opponentId);
         try {
             $user = GameUsers::getGameUserById($this->userId);
             if (!empty($user)) {
                 $userXPLog->setUserLevel($user->userLevelNumber);
                 $userXPLog->setUserCoin($user->coins);
                 //$userCoinLog->setUserSpentCoin($user->opponentId);
             }
         } catch (Exception $exc) {
             $log->logError("userxplog > log > User Error : " . $exc->getTraceAsString());
         }
         try {
             $userXPLog->insertIntoDatabase(DBUtils::getConnection());
             $log->logInfo("userxplog > log > Success");
         } catch (Exception $exc) {
             $log->logError("userxplog > log > Error : " . $exc->getTraceAsString());
         }
     } else {
         $log->logError("userxplog > log > user Id is empty ");
     }
 }
 public function lost()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("usergameaction > lost > start userId : " . $this->userId . " opponentId : " . $this->opponentId . " action : " . $this->action_ . " time : " . $this->time . " room groupId : " . $this->roomGroupId . " gameId : " . $this->gameId . " normal : " . $this->normal . " type : " . $this->type . " double : " . $this->double);
     if (!empty($this->userId)) {
         $user = GameUsers::getGameUserById($this->userId);
         if (!empty($user)) {
             $userId = $user->getUserId();
             if (!empty($userId)) {
                 $user->getUserLevel();
                 $opponent = GameUsers::getGameUserById($this->opponentId);
                 $opponentId = null;
                 if (!empty($opponent)) {
                     $opponentId = $opponent->getUserId();
                     $opponent->getUserLevel();
                 }
                 $result = GameUtils::gameResult($user, $opponent, $this->roomGroupId, $this->action_, $this->gameId, $this->double, $this->normal, $this->type, $this->time);
                 if (!empty($result) && $result->success) {
                     $log->logInfo("usergameaction > lost > success ");
                 } else {
                     $log->logError("usergameaction > lost > error :  " . $result->result);
                 }
                 unset($userId);
                 unset($user);
             } else {
                 $log->logError("usergameaction > lost > user Id is empty ");
             }
         } else {
             $log->logError("usergameaction > lost > user Id is empty ");
         }
     } else {
         $log->logError("usergameaction > lost > user Id is empty ");
     }
 }
Example #4
0
 public static function autoLogin($rememberme = true)
 {
     if (isset($_SESSION["userId"])) {
         $userId = $_SESSION["userId"];
         $user = GameUsers::getGameUserById($userId);
         if (!empty($user)) {
             UtilFunctions::storeSessionUser($user, $rememberme);
             return $user;
         }
     }
     if (isset($_COOKIE["auth"]) && false) {
         $cookie = $_COOKIE["auth"];
         $arr = explode('&', $cookie);
         $userName = substr($arr[0], 4);
         $hash = substr($arr[1], 5);
         $user = GameUsers::getGameUserByUserName($userName);
         if (!empty($user)) {
             if ($hash == md5($user->getPassword())) {
                 $user->setLastLoginDate(time());
                 $user->setLoginCount($user->getLoginCount() + 1);
                 $user->updateToDatabase(DBUtils::getConnection());
                 Queue::checkUserFriends($user->userId);
                 UtilFunctions::storeSessionUser($user, $rememberme);
                 return $user;
             } else {
                 UtilFunctions::forgetMe();
             }
         }
     }
     return false;
 }
 public static function createFromSQLWithUser($db_field)
 {
     if (!empty($db_field)) {
         $bot = GameBots::createFromSQL($db_field);
         $bot->user = GameUsers::createFromSQL($db_field);
         return $bot;
     }
     return null;
 }
Example #6
0
 public function checkFriends()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("user > checkFriends > start userId : " . $this->userId);
     $user = GameUsers::getGameUserById($this->userId);
     if (!empty($user)) {
         $userId = $user->userId;
         if (!empty($userId)) {
             $fbFriends = FriendUtils::getUserFacebookFriends($user);
             if (!empty($fbFriends) && sizeof($fbFriends) > 0) {
                 $fbFriendIds = null;
                 foreach ($fbFriends as $fbFriend) {
                     if (!empty($fbFriend) && isset($fbFriend["id"])) {
                         if (empty($fbFriendIds)) {
                             $fbFriendIds = $fbFriend["id"];
                         } else {
                             $fbFriendIds = $fbFriendIds . "," . $fbFriend["id"];
                         }
                     }
                 }
                 $fbFriendUserIds = FriendUtils::getUserIdsFromFacebookIds($fbFriendIds);
                 if (!empty($fbFriendUserIds)) {
                     $friendIds = FriendUtils::getUserFriendIds($userId);
                     foreach ($fbFriendUserIds as $fbFriendId) {
                         if (!empty($fbFriendId)) {
                             $add = false;
                             if (!empty($friendIds) && sizeof($friendIds) > 0) {
                                 if (!in_array($fbFriendId, $friendIds)) {
                                     $add = true;
                                 }
                             } else {
                                 $add = true;
                             }
                             if ($add) {
                                 $friend = new GameUserFriends();
                                 $friend->setUserId($this->userId);
                                 $friend->setType("facebook");
                                 $friend->setFriendId($fbFriendId);
                                 try {
                                     $friend->insertIntoDatabase(DBUtils::getConnection());
                                 } catch (Exception $exc) {
                                     error_log("userclass>checkFriends userId : " . $this->userId . " friend Id : " . $fbFriendId . " Error : " . $exc->getMessage() . " Trace :" . $exc->getTraceAsString());
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $log->logInfo("user > checkFriends > end userId : " . $this->userId);
 }
 public static function updateUserImage($userId)
 {
     $result = new FunctionResult();
     $result->success = false;
     if (!empty($userId)) {
         $user = GameUsers::getGameUserById($userId);
         if (!empty($user)) {
             $tmpImgPath = UserProfileImageUtils::downloadFBProfileImage($user->facebookId);
             $profileImageUrl = null;
             if (!empty($tmpImgPath)) {
                 try {
                     $s3 = new S3(AWS_API_KEY, AWS_SECRET_KEY);
                     $s3->setEndpoint(AWS_S3_ENDPOINT);
                     $imageName = "pi_" . $userId . ".png";
                     $s3Name = "profile.images/" . $userId . "/" . $imageName;
                     $res = $s3->putObjectFile($tmpImgPath, AWS_S3_BUCKET, $s3Name, S3::ACL_PUBLIC_READ);
                     if ($res) {
                         $profileImageUrl = 'http://' . AWS_S3_BUCKET . '.s3.amazonaws.com/' . $s3Name;
                         try {
                             unlink($tmpImgPath);
                         } catch (Exception $exc) {
                             error_log($exc->getTraceAsString());
                         }
                     } else {
                         $result->result = json_encode($res);
                     }
                 } catch (Exception $exc) {
                     $result->result = $exc->getTraceAsString();
                 }
             } else {
                 $profileImageUrl = USER_DEFAULT_IMAGE_URL;
             }
             if (!empty($profileImageUrl)) {
                 $user->setProfilePicture($profileImageUrl);
                 try {
                     $user->updateToDatabase(DBUtils::getConnection());
                     $result->success = true;
                     $result->result = null;
                 } catch (Exception $exc) {
                     $result->result = $exc->getTraceAsString();
                 }
             }
         } else {
             $result->result = "user not found";
         }
     } else {
         $result->result = "user id empty";
     }
     return $result;
 }
Example #8
0
    public function index()
    {
        if (defined("SERVER_PROD")) {
            if (!SERVER_PROD) {
                $this->user = GameUsers::getGameUserById(2);
                LanguageUtils::setLocale($this->user->language);
                if (!empty($this->user) && $this->user->active == 0) {
                    $this->redirect("banned");
                    exit(1);
                }
                return;
            }
        }
        $facebook = new Facebook(array('appId' => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true));
        $login_req = true;
        $this->user = UtilFunctions::autoLogin();
        if (!empty($this->user)) {
            $facebook->setAccessToken($this->user->getOauthToken());
            try {
                $fbUser = $facebook->api("/me");
                if (!empty($fbUser) && !empty($fbUser['id'])) {
                    $login_req = false;
                }
            } catch (Exception $exc) {
                $this->log->logError($exc->getTraceAsString());
            }
        } else {
            $login_req = true;
            if (isset($_GET['error']) || isset($_GET['error_reason']) || isset($_GET['error_description'])) {
                if ($_GET['error_description']) {
                    $this->addError($_GET['error_description']);
                }
                if (isset($_GET['error_reason'])) {
                    $this->addError(isset($_GET['error_reason']));
                }
                echo "<p> Error : " . $_GET['error_reason'] . "</p>";
                echo "<p> Please Refresh Page ! </p>";
                exit(1);
            } else {
                $facebook = new Facebook(array('appId' => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true));
                try {
                    $fbUser = $facebook->api("/me");
                } catch (Exception $exc) {
                    $this->log->logError($exc->getTraceAsString());
                }
                if (!empty($fbUser) && !empty($fbUser['id'])) {
                    $this->user = GameUsers::getGameUserByFBId($fbUser['id']);
                    if (!empty($this->user)) {
                        $this->user->setOauthToken($facebook->getAccessToken());
                        $this->user->setLastLoginDate(time());
                        $this->user->setLoginCount($this->user->getLoginCount() + 1);
                        $this->user->updateToDatabase(DBUtils::getConnection());
                        Queue::checkUserFriends($this->user->userId);
                        UtilFunctions::storeSessionUser($this->user);
                        $login_req = false;
                    } else {
                        $result = GameUsers::createGameUser($fbUser, $facebook->getAccessToken());
                        if ($result->success) {
                            $this->user = $result->result;
                            if (!empty($result)) {
                                $userId = $this->user->getUserId();
                                if (!empty($userId)) {
                                    Queue::checkUserFriends($this->user->userId);
                                    UtilFunctions::storeSessionUser($this->user);
                                    $login_req = false;
                                    $this->newUser = "******";
                                }
                            } else {
                                $this->addError(LANG_FACEBOOK_USER_CREATE_ERROR_UNKNOWN_ERROR);
                            }
                        } else {
                            if (!empty($result->result)) {
                                foreach ($result->result as $value) {
                                    $this->addError($value);
                                }
                            } else {
                                $this->addError(LANG_FACEBOOK_USER_CREATE_ERROR_UNKNOWN_ERROR);
                            }
                        }
                        unset($result);
                    }
                }
                if (!$login_req && !empty($this->user)) {
                    GameUserLoginLog::insertLog($this->user->userId);
                }
            }
        }
        if (!$login_req) {
            if (!empty($this->user) && $this->user->active == 0) {
                $this->redirect("banned");
                exit(1);
            }
        }
        if ($login_req) {
            UtilFunctions::forgetMe();
            $params = array('scope' => FB_SCOPE, 'redirect_uri' => FB_CALLBACK_URL);
            $login_url = $facebook->getLoginUrl($params);
            if (isset($_SERVER['QUERY_STRING'])) {
                if (strpos($login_url, "?")) {
                    $login_url . "&" . $_SERVER['QUERY_STRING'];
                } else {
                    $login_url . "?" . $_SERVER['QUERY_STRING'];
                }
            }
            ?>
            <!DOCTYPE html>
            <html xmlns="http://www.w3.org/1999/xhtml">
                <head></head>
                <body><script>top.location.href='<?php 
            echo $login_url;
            ?>
';</script></body>
            </html>
            <?php 
            exit(1);
        } else {
            $this->dailyBonus = BonusUtils::getDailyBonusPrice($this->user);
            if (isset($_GET['request_ids']) && !empty($_GET['request_ids'])) {
                $this->fbRequests = FacebookRequestUtils::getFacebookGiftRequest($this->user, $_GET['request_ids']);
            }
            LanguageUtils::setLocale($this->user->language);
        }
    }
 public static function updateXP(GameUsers $user, GameUsers $opponent, $roomGroupId, $action, $gameId = null, $double = 0, $normal = true, $type = null, $time = null)
 {
     $result = new FunctionResult();
     $result->success = false;
     if (!empty($user) && !empty($action)) {
         $gain = 0;
         $xp = $user->getUserXP();
         if ($action == GameUtils::$GAME_RESULT_ACTION_WIN) {
             $gain = (int) GameConstantUtil::getConstant(GameUtils::$CONSTANT_WIN_XP_GAIN);
             if (!$normal) {
                 $gain = $gain * 2;
             }
         } else {
             if ($action == GameUtils::$GAME_RESULT_ACTION_LOST) {
                 if ($type == GameUtils::$GAME_RESULT_ACTION_TYPE_QUIT) {
                     $gain = (int) GameConstantUtil::getConstant(GameUtils::$CONSTANT_QUIT_XP_GAIN);
                 } else {
                     if ($type == GameUtils::$GAME_RESULT_ACTION_TYPE_LEFT || $type == GameUtils::$GAME_RESULT_ACTION_TYPE_TIMESUP) {
                         $gain = (int) GameConstantUtil::getConstant(GameUtils::$CONSTANT_CONN_LOST_XP_GAIN);
                     } else {
                         $gain = (int) GameConstantUtil::getConstant(GameUtils::$CONSTANT_LOSE_XP_GAIN);
                     }
                 }
             } else {
                 $xp = -1;
             }
         }
         if ($xp >= 0) {
             $gameResult = $action . "_" . $normal . "_" . $double . "_" . $type;
             $oppId = null;
             if (!empty($opponent)) {
                 $oppId = $opponent->getUserId();
             }
             if (empty($time)) {
                 $time = time();
             }
             Queue::addUserXPLog($user->userId, $gain, $time, GameUserXpLog::$CONSTANT_LOG_TYPE_GAME, $gameId, $gameResult, $oppId);
             $xp = $xp + $gain;
             $user->setUserXP($xp);
             $userLevel = GameUserLevel::getUserLevel($xp);
             $user->userLevel = $userLevel;
             if (!empty($userLevel) && !empty($userLevel->levelNumber)) {
                 $user->setUserLevelNumber($userLevel->levelNumber);
             }
             $result->success = true;
         } else {
             $result->success = false;
             $result->result = "Action unknown";
         }
     }
     return $result;
 }
Example #10
0
require_once __ROOT__ . 'config/constants.php';
require_once __ROOT__ . 'utils/Functions.php';
require_once __ROOT__ . "models/GameUsers.class.php";
require_once __ROOT__ . "vendors/facebook/facebook.php";
$facebook = new Facebook(array('appId' => "696672047015429", 'secret' => "64d861272130d52b5e5a9dc4987e04ad", 'cookie' => true));
$count = 100;
$page = 0;
if (isset($_GET['page']) && !empty($_GET['page'])) {
    $page = intval($_GET['page']);
    if ($page < 0) {
        $page = 0;
    }
    $page = $page - 1;
}
$SQL = "SELECT * FROM " . TBL_GAME_USERS . " ORDER BY userId ASC LIMIT " . $page * $count . "," . ($page + 1) * $count;
$users = GameUsers::findBySql(DBUtils::getConnection(), $SQL);
$messages = array();
if (!empty($users) && sizeof($users) > 0) {
    foreach ($users as $user) {
        if (!empty($user)) {
            array_push($messages, "");
            array_push($messages, "");
            array_push($messages, "User(" . $user->userId . "-" . $user->userName . ") Start");
            $userFBId = $user->getFacebookId();
            if (!empty($userFBId)) {
                $QUERY = "SELECT page_id FROM page_fan WHERE uid = " . $userFBId . " and page_id =580982095281317";
                array_push($messages, "User(" . $user->userId . "-" . $user->userName . ") Facebook Like Status SQL :" . $QUERY);
                try {
                    $params = array('method' => 'fql.query', 'query' => $QUERY);
                    $result = $facebook->api($params);
                    if (!empty($result) && sizeof($result) > 0) {
 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;
 }
Example #12
0
    exit(1);
}
$log = KLogger::instance(KLOGGER_PATH . "apis/", KLogger::DEBUG);
if (empty($action) || !empty($action) && $action != GameUtils::$GAME_RESULT_ACTION_WIN && $action != GameUtils::$GAME_RESULT_ACTION_LOST) {
    $log->logError("Unknown Action");
    $result->result = "Unknown Action";
    echo json_encode($result);
    exit(1);
}
if (!empty($userId)) {
    $user = GameUsers::getGameUserById($userId);
    if (!empty($user)) {
        $userId = $user->getUserId();
        if (!empty($userId)) {
            $user->getUserLevel();
            $opponent = GameUsers::getGameUserById($opponentId);
            $opponentId = null;
            if (!empty($opponent)) {
                $opponentId = $opponent->getUserId();
                $opponent->getUserLevel();
            }
            $log->logInfo("gameResult : userId > " . $userId . " opponentId > " . $opponentId . " roomgroupId > " . $roomGroupId . " gameId > " . $gameId . " double > " . $double . " normal > " . $normal . " type > " . $type);
            $result = GameUtils::gameResult($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type);
            unset($userId);
            unset($user);
        } else {
            $log->logError("User not found");
            $result->result = "User not found";
        }
    } else {
        $log->logError("User not found");
    $user = GameUsers::getGameUserByFBId($fbUserId);
    if (!empty($user)) {
        //old user
        $user->setOauthToken($fbToken);
        $user->setLastLoginDate(time());
        $user->setLoginCount($user->getLoginCount() + 1);
        $user->updateToDatabase(DBUtils::getConnection());
        Queue::checkUserFriends($user->userId);
        UtilFunctions::storeSessionUser($user);
        $error = false;
    } else {
        //new user
        $facebook = new Facebook(array('appId' => FB_APP_ID, 'secret' => FB_APP_SECRET, 'cookie' => true));
        $facebook->setAccessToken($fbToken);
        $fbUser = $facebook->api("/me");
        $res = GameUsers::createGameUser($fbUser, $fbToken);
        if ($res->success) {
            $user = $res->result;
            $userId = $user->getUserId();
            if (!empty($userId)) {
                Queue::checkUserFriends($userId);
                UtilFunctions::storeSessionUser($user);
                $newUser = "******";
                $error = false;
            }
        } else {
            $result->result = LanguageUtils::getText("LANG_FACEBOOK_USER_CREATE_ERROR_UNKNOWN_ERROR");
        }
    }
} else {
    $result->result = "fbUserId or fbToken empty";
 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;
     }
 }
Example #15
0
                    <td style ="color: #7ba29a; font-weight: bold;">User Level(past)</td>
                    <td style ="color: #7ba29a; font-weight: bold;">Product Id</td>
                    <!--<td style ="color: #7ba29a; font-weight: bold;">Status</td>-->
                    <!--<td style ="color: #7ba29a; font-weight: bold;">Quantity</td>-->
                    <td style ="color: #7ba29a; font-weight: bold;">Coin</td>
                    <td style ="color: #7ba29a; font-weight: bold;">Amount</td>
                    <td style ="color: #7ba29a; font-weight: bold;">Currency</td>
                    <td style ="color: #7ba29a; font-weight: bold;">Time</td>
                </tr>
                <?php 
if (!empty($paymentList)) {
    $payment = new GameUserFbProductLog();
    $paymentTotal = 0;
    for ($i = 0; $i < sizeof($paymentList); $i++) {
        $payment = $paymentList[$i];
        $user = GameUsers::getGameUserById($payment->getUserId());
        $paymentTotal = $paymentTotal + $payment->getAmount();
        ?>
                        <tr>
                            <!--<td style ="color: #7ba29a; font-weight: bold;"><?php 
        echo $payment->getRequestId();
        ?>
</td> -->
                            <td style ="color: #7ba29a; font-weight: bold;"><?php 
        echo $payment->getUserId();
        ?>
</td> 
                            <td style ="color: #7ba29a; font-weight: bold;"><?php 
        echo $user->getUserFirstname() . " " . $user->getUserLastname();
        ?>
</td>
 /**
  * get single GameUsers instance from a DOMElement
  *
  * @param DOMElement $node
  * @return GameUsers
  */
 public static function fromDOMElement(DOMElement $node)
 {
     $o = new GameUsers();
     $o->assignByHash(self::domNodeToHash($node, self::$FIELD_NAMES, self::$DEFAULT_VALUES, self::$FIELD_TYPES));
     $o->notifyPristine();
     return $o;
 }
Example #17
0
    $startDate = date("d-m-Y", $sTimestamp);
    $start = strtotime($startDate . " 00:00:00");
    $eDate = $_POST["txtEndDate"];
    $eTimestamp = strtotime($eDate);
    $endDate = date("d-m-Y", $eTimestamp);
    $end = strtotime($endDate . " 23:59:59");
} else {
    $sdate = date('d-m-Y') . "";
    $eDate = date('d-m-Y') . "";
    $start = strtotime(date('d-m-Y') . " 00:00:00");
    $end = strtotime(date('d-m-Y') . " 23:59:59");
}
$dailyPayment = FBProductUtils::getDailyPayment($start, $end);
$totalPayment = FBProductUtils::getTotalPayment();
$dailylogin = GameUsers::getDailyLoginCount($start, $end);
$dailtReg = GameUsers::getDailyRegistrationCount($start, $end);
?>
<div class="container">
    <div class="row">
        <div class="span12" style="height: 40px"></div>
    </div>
    <div class="row">
        <div class="offset4 span8" style="height: 40px ;margin-left: 228px;margin-bottom: 10px;">
            <table>
                <tr>
                <form action="index.php" method="post">
                    <td> 
                <div id="startDate" class="input-append date" >
                    <label style="float: left; height: 30px; color: #7ba29a; font-weight: bold; margin-top: 3px;" >Start Date :</label>
                    <input type="text" name="txtStartDate" value="<?php 
echo $sdate;
Example #18
0
<?php

define("__ROOT__", __DIR__ . "/../");
require_once __ROOT__ . "models/GameUsers.class.php";
$page_var = "gamestats";
$page_js = array();
array_push($page_js, HOSTNAME . "scripts/gameStats.js");
//remane this
include_once __ROOT__ . 'admin/admin_header_layout.php';
$total_user = GameUsers::getTotalUserCount();
$total_coin = GameUsers::getTotalCoins();
$total_game = GameUsers::getTotalGame();
$start = strtotime(date("d-m-Y") . " 00:00:00");
$end = strtotime(date("d-m-Y") . " 23:59:59");
$total_game_today = GameUsers::getTotalGameDate($start, $end);
?>
<div class="container">
    <div class="row">
        <div class="span12" style="height: 40px;"></div>
    </div>
    <div class="row">
        <div class="span12" style="height: 40px; color: #7ba29a; font-weight: bold;">Economy</div>
        <div class="span12">
            <table class="table table-bordered">
                <tr>
                    <td style ="color: #7ba29a; font-weight: bold;">Total Coin</td>
                    <td style ="color: #7ba29a; font-weight: bold;">Total User</td>
                    <td style ="color: #7ba29a; font-weight: bold;">Total Coin / Total User</td>
                </tr>
                <tr>
                    <td><?php 
Example #19
0
        $useItem = $_GET['useItem'];
    }
}
if (!UtilFunctions::checkUserSession($userId)) {
    $result->result = "401 : auth error";
    header("HTTP/1.1 401 Unauthorized");
    echo json_encode($result);
    exit(1);
}
$log = KLogger::instance(KLOGGER_PATH . "apis/", KLogger::DEBUG);
$error = false;
if (!empty($userId)) {
    $user = GameUsers::getGameUserById($userId);
    if ($userId != $toUserId) {
        if (!empty($toUserId)) {
            $toUser = GameUsers::getGameUserById($toUserId);
            $error = true;
        } else {
            $log->logError(LanguageUtils::getText("LANG_API_TO_USER_ID_EMPTY"));
            $result->result = LanguageUtils::getText("LANG_API_TO_USER_ID_EMPTY");
        }
    } else {
        $toUser = $user;
        $error = true;
    }
} else {
    $log->logError(LanguageUtils::getText("LANG_API_USER_ID_EMPTY"));
    $result->result = LanguageUtils::getText("LANG_API_USER_ID_EMPTY");
}
if ($error) {
    $error = false;
Example #20
0
 }
 if ($bot->weightFaraway < 0) {
     $errorHTML .= "<p/>Select Weight Faraway";
 }
 if ($bot->weightSingle < 0) {
     $errorHTML .= "<p/>Select Weight Single";
 }
 if ($bot->roomGroupId == -1 || empty($bot->roomGroupId)) {
     $errorHTML .= "<p/>Select Room Group";
 }
 if (empty($user->userName)) {
     $errorHTML .= "<p/>Enter User Name";
 } else {
     $tmp_defu = getURLParam("defaultUserName");
     if ($tmp_defu != $user->userName) {
         $tmp = GameUsers::getGameUserByUserName($user->userName);
         if (!empty($tmp)) {
             $errorHTML .= "<p/>User Name already in use";
         }
     }
 }
 if (empty($user->userMail)) {
     $errorHTML .= "<p/>Enter User Mail";
 }
 if (empty($user->userFirstname)) {
     $errorHTML .= "<p/>Enter User First Name";
 }
 if (empty($user->userLastname)) {
     $errorHTML .= "<p/>Enter User Last Name";
 }
 if (empty($user->password)) {
 public function add()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("leaderboard > add > start userId : " . $this->userId . " diff Coin : " . $this->difCoin . " time : " . $this->time);
     if (!empty($this->userId)) {
         $user = GameUsers::getGameUserById($this->userId);
         if (!empty($user)) {
             $userId = $user->getUserId();
             if (!empty($userId)) {
                 $daily = GameLeaderboardDaily::getRecordByUserId($userId);
                 if (empty($daily)) {
                     $daily = new GameLeaderboardDaily();
                     $daily->setId(-1);
                     $daily->setUserId($userId);
                     $daily->setCoins(0);
                 }
                 $daily->setLastPlayed($this->time);
                 $weekly = GameLeaderboardWeekly::getRecordByUserId($userId);
                 if (empty($weekly)) {
                     $weekly = new GameLeaderboardWeekly();
                     $weekly->setId(-1);
                     $weekly->setUserId($userId);
                     $weekly->setCoins(0);
                 }
                 $weekly->setLastPlayed($this->time);
                 $dCoins = $daily->getCoins() + (int) $this->difCoin;
                 if ($dCoins < 0) {
                     $dCoins = 0;
                 }
                 $daily->setCoins($dCoins);
                 try {
                     $daily->updateInsertToDatabase(DBUtils::getConnection());
                     $log->logInfo("leaderboard > add >  daily success ");
                 } catch (Exception $exc) {
                     $log->logError("leaderboard > add > error daily : " . $exc->getMessage() . " detail : " . $exc->getTraceAsString());
                 }
                 $wCoins = $weekly->getCoins() + (int) $this->difCoin;
                 if ($wCoins < 0) {
                     $wCoins = 0;
                 }
                 $weekly->setCoins($wCoins);
                 try {
                     $weekly->updateInsertToDatabase(DBUtils::getConnection());
                     $log->logInfo("leaderboard > add >  weekly success ");
                 } catch (Exception $exc) {
                     $log->logError("leaderboard > add > error weekly : " . $exc->getMessage() . " detail : " . $exc->getTraceAsString());
                 }
                 $log->logInfo("leaderboard > add >  finished ");
                 unset($dCoins);
                 unset($wCoins);
                 unset($user);
                 unset($userId);
                 unset($weekly);
                 unset($daily);
             } else {
                 $log->logError("leaderboard > add > user found Id is empty");
             }
         } else {
             $log->logError("leaderboard > add > user Id not found");
         }
     } else {
         $log->logError("leaderboard > add > user Id is empty ");
     }
 }
 public static function getFacebookGiftRequest($user, $requestIds)
 {
     if (!empty($user) && !empty($requestIds)) {
         $day = intval(GameConstantUtil::getConstant(FacebookRequestUtils::$CONSTANT_REQUEST_GIFT_TIME));
         if ($day <= 0) {
             $day = 7;
         }
         $coin = intval(GameConstantUtil::getConstant(FacebookRequestUtils::$CONSTANT_REQUEST_GIFT_COIN));
         if ($day <= 0) {
             $day = FacebookRequestUtils::$CONSTANT_REQUEST_GIFT_COIN_DEFAULT;
         }
         $SQL = "SELECT * FROM " . TBL_GAME_FB_REQUEST . " WHERE  `to`='" . DBUtils::mysql_escape($user->facebookId) . "' AND used=0 AND type='" . FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT . "' AND requestId IN (" . $requestIds . ") ORDER BY `time` DESC";
         $fbRequests = GameFbRequest::findBySql(DBUtils::getConnection(), $SQL);
         $userArray = array();
         if (!empty($fbRequests) && sizeof($fbRequests) > 0) {
             for ($i = sizeof($fbRequests) - 1; $i >= 0; $i--) {
                 $req = $fbRequests[$i];
                 $req->coin = $coin;
                 if (!empty($req)) {
                     $usrArr = $userArray[$req->userId];
                     if (empty($usrArr)) {
                         $usrArr = array();
                         array_push($usrArr, $req);
                     } else {
                         $last = $usrArr[sizeof($usrArr) - 1];
                         if (intval(date("Ymd", $req->time)) - intval(date("Ymd", $last->time)) >= 7) {
                             array_push($usrArr, $req);
                         } else {
                             GameFbRequest::useRequest($req->getId(), 2);
                         }
                     }
                     $userArray[$req->userId] = $usrArr;
                 }
             }
         }
         unset($fbRequests);
         $result = array();
         foreach ($userArray as $userReq) {
             if (!empty($userReq) && sizeof($userReq) > 0) {
                 try {
                     $coin = 0;
                     $obj = new stdClass();
                     $tmp = GameUsers::findById(DBUtils::getConnection(), $userReq[0]->userId);
                     if (!empty($tmp)) {
                         $obj->user = new stdClass();
                         $obj->user->userId = $tmp->userId;
                         $obj->user->userName = $tmp->userName;
                         $obj->user->userFirstname = $tmp->userFirstname;
                         $obj->user->userLastname = $tmp->userLastname;
                         $obj->user->facebookId = $tmp->facebookId;
                         $obj->user->userXP = $tmp->userXP;
                         $obj->user->userLevelNumber = $tmp->userLevelNumber;
                         $obj->user->coins = $tmp->coins;
                         $ids = "";
                         foreach ($userReq as $req) {
                             if (!empty($req)) {
                                 GameFbRequest::useRequest($req->getId());
                                 $coin = $coin + intval($req->coin);
                                 if (!empty($ids)) {
                                     $ids = $ids . "," . $req->requestId;
                                 } else {
                                     $ids = $ids . "" . $req->requestId;
                                 }
                             }
                         }
                         $obj->coin = $coin;
                         $obj->ids = $ids;
                         $obj->type = FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT;
                         array_push($result, $obj);
                     }
                 } catch (Exception $exc) {
                     error_log($exc->getTraceAsString());
                 }
             }
         }
         unset($userArray);
         foreach ($result as $value) {
             if (!empty($value)) {
                 $time = time();
                 $user->setCoins($user->getCoins() + $value->coin);
                 $user->updateToDatabase(DBUtils::getConnection());
                 $userCoinLog = new GameUserCoinLog();
                 $userCoinLog->setUserId($user->userId);
                 $userCoinLog->setCoin($user->getCoins());
                 $userCoinLog->setDifCoin($value->coin);
                 $userCoinLog->setTime($time);
                 $userCoinLog->setType(FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT);
                 $userCoinLog->setAdd(1);
                 $userCoinLog->setResult(FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT . "->" . $value->user->userId . "->" . $value->ids);
                 $userCoinLog->setOpponentId($value->user->userId);
                 $userCoinLog->setUserLevel($user->userLevelNumber);
                 //$userCoinLog->setUserSpentCoin($user->opponentId);
                 try {
                     $userCoinLog->insertIntoDatabase(DBUtils::getConnection());
                 } catch (Exception $exc) {
                     error_log($exc->getTraceAsString());
                 }
                 Queue::addUserLeaderBoard($user->userId, $value->coin, $time);
             }
         }
     }
     return base64_encode(json_encode($requestIds));
 }
Example #23
0
                if (!empty($_user)) {
                    $_user->setActive($value);
                    $_user->updateToDatabase(DBUtils::getConnection());
                }
                $userList = GameUsers::getUserList(($pageNumber - 1) * 100, 100);
            }
        }
    }
} else {
    $userList = GameUsers::getUserList(($pageNumber - 1) * 100, 100);
    if (sizeof($userList) == 0) {
        $pageNumber = $pageNumber - 1;
        $userList = GameUsers::getUserList(($pageNumber - 1) * 100, 100);
    }
}
$total_user = GameUsers::getTotalUserCount();
$max_page = intval($total_user / 100);
if ($total_user % 100 > 0) {
    $max_page++;
}
?>

<div class="container">
    <div class="row">
        <div class="span12" style="height: 40px"></div>
    </div>

    <div class="row-fluid">
        <div class="span12 " >
            <div class="pagination">
                <ul>
Example #24
0
        $quantity = $_GET['quantity'];
    }
}
if ($quantity < 1) {
    $quantity = 1;
}
if (!UtilFunctions::checkUserSession($userId)) {
    $result->result = "401 : auth error";
    header("HTTP/1.1 401 Unauthorized");
    echo json_encode($result);
    exit(1);
}
$log = KLogger::instance(KLOGGER_PATH . "apis/", KLogger::DEBUG);
$error = false;
if (!empty($userId)) {
    $user = GameUsers::getGameUserById($userId);
    if (empty($user)) {
        $error = false;
        $log->logError(LanguageUtils::getText("LANG_API_USER_EMPTY"));
        $result->result = LanguageUtils::getText("LANG_API_USER_EMPTY");
    } else {
        $error = true;
    }
} else {
    $log->logError(LanguageUtils::getText("LANG_API_USER_ID_EMPTY"));
    $result->result = LanguageUtils::getText("LANG_API_USER_ID_EMPTY");
}
if ($error) {
    $error = false;
    if (!empty($itemCode)) {
        $itemCode = str_replace("/", "", $itemCode);
?>
</span>

        <p/>
        <table style="border: #000 solid">
            <tr>
                <td style="border: #000 solid">#</td>
                <td style="border: #000 solid">userId</td>
                <td style="border: #000 solid">userName</td>
                <td style="border: #000 solid">Fullname</td>
                <td style="border: #000 solid">FbId</td>
                <td style="border: #000 solid">Status</td>
                <td style="border: #000 solid">Time</td>
            </tr>
            <?php 
$userList = GameUsers::getUserListOrderBy(" userId ASC ", $page * $pageCount, $pageCount);
$listnotempty = false;
if (!empty($userList)) {
    $listnotempty = true;
    $user = new GameUsers();
    $i = 0;
    foreach ($userList as $user) {
        if (!empty($user)) {
            $i++;
            $st = date("Y.m.d H:i:s");
            $result = UserProfileImageUtils::updateUserImage($user->userId);
            ?>
                        <tr>
                            <td style="border: #000 solid">#<?php 
            echo $i;
            ?>