Esempio n. 1
0
function __getUserDetails($email)
{
    $mongo = new LiloMongo();
    $mongo->selectDB("Users");
    $mongo->selectCollection("Account");
    $id = "";
    $username = $email;
    $isValid = false;
    $gender = "male";
    $bodytype = "medium";
    $avatarname = "";
    $queryEmail = $mongo->findOne(array('email' => $email));
    if ($queryEmail) {
        $id = (string) $queryEmail['_id'];
        $username = $queryEmail['username'];
        $mongo->selectCollection("Properties");
        $queryProp = $mongo->findOne(array('lilo_id' => $id));
        if ($queryProp) {
            $gender = $queryProp['sex'];
            $bodytype = $queryProp['body_size'];
            $avatarname = $queryProp['avatarname'];
        } else {
            $datatinsert = array('lilo_id' => (string) $id, 'avatarname' => $username, 'fullname' => $username, 'sex' => $gender, 'body_size' => $bodytype, 'website' => '', 'link' => '', 'birthday' => '', 'birthday_dd' => '', 'birthday_mm' => '', 'birthday_yy' => '', 'state_mind' => '', 'about' => '', 'picture' => '', 'location' => '', 'handphone' => '', 'twitter' => '');
            $mongo->insert($datatinsert);
        }
        $isValid = true;
    }
    $output = array('id' => $id, 'username' => $username, 'avatarname' => $avatarname, 'gender' => $gender == "" || !isset($gender) ? "male" : $gender, 'bodytype' => $bodytype == "" || !isset($bodytype) ? "medium" : $bodytype);
    return $output;
}
Esempio n. 2
0
function message_guest_sessionvalidation($session_id = NULL)
{
    if (!isset($session_id) || trim($session_id) == '') {
        $session_id = func_arg(0);
    }
    if (!isset($session_id) || trim($session_id) == '') {
        return false;
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Session');
    $session_data = $lilo_mongo->findOne(array('session_id' => $session_id));
    // return "<pre>" . print_r($session_data, true) . "<pre>" . time();
    // cek apakah $session_id masih berlaku: Users.Session.time_end == '' || strtotime() - strtotime(Users.Session.time_end) < 3 * 60;
    if (!count($session_data)) {
        return false;
    }
    //	$valid_session = (trim($session_data['time_end']) == '') || (time() - strtotime($session_data['time_end']) < 3 * 60);
    $valid_session = time() - strtotime($session_data['time_end']) < 3 * 60;
    if (!$valid_session) {
        return false;
    }
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $account_data = $lilo_mongo->findOne(array('username' => $session_data['username']));
    // return "<pre>" . print_r($session_data, true) . "<pre>" . "<pre>" . print_r($account_data, true) . "<pre>" . time();
    if (!count($account_data)) {
        return false;
    }
    return $account_data['lilo_id'];
}
Esempio n. 3
0
function asset_guest_get_lobby()
{
    // harusnya ini masuk di server management!!! pindahkan kesana!
    // dapatkan daftar Lobby dari table Assets.Level
    //$lilo_mongo = new LiloMongo();
    //$lilo_mongo->selectDB('Assets');
    //$lilo_mongo->selectCollection('Level');
    //
    //$lobby_cursor = $lilo_mongo->find(array('tags' => 'Lobby'));
    //
    //$lobby_name_list = '';
    //while($curr = $lobby_cursor->getNext()){
    //	$lobby_name_list .= $curr['name'];
    //}
    // dapatkan last room dari table Game.RoomHistory [userid, room]
    $userid = $_SESSION['user_id'];
    if (trim($userid) == '') {
        $session_id = $_REQUEST['token'];
        $userid = user_user_session_to_user_id($session_id);
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Game');
    $lilo_mongo->selectCollection('RoomHistory');
    $room_data = $lilo_mongo->findOne(array('userid' => $userid));
    // dapatkan IP dan Port dari table Game.LobbySetting
    $lilo_mongo->selectCollection('LobbySetting');
    $lobby_setting = $lilo_mongo->findOne(array());
    $room_data_ = '';
    if (is_array($lobby_setting) && count($lobby_setting)) {
        $ip = $lobby_setting['ip'];
        $port = $lobby_setting['port'];
        $room_history = $lobby_setting['room_history'];
        if (intval($room_history) == 1) {
            $room_data_ = $room_data['room'];
        }
    }
    return "{$ip}:{$port}," . $room_data_;
    // Contooh...
    //	return "124.66.160.109:5055," . $room_data['room'];	// sementara di disable
    return "124.66.160.109:5055,";
    // Contooh...
    //	return "124.66.160.109:5055," . $lobby_name_list;
    //	return "192.168.1.4:5055," . $lobby_name_list;
    //	return "192.168.1.6:5055," . $lobby_name_list;
    //	return "192.168.1.3:5055," . $lobby_name_list;
    //	return "192.168.1.106:5055," . $lobby_name_list;
}
Esempio n. 4
0
function pm_sms_query()
{
    header("Content-Type: text/xml");
    echo "<?xml version='1.0' encoding='UTF-8' ?>";
    $msisdn = isset($_GET['msisdn']) ? $_GET['msisdn'] : "";
    $message = isset($_GET['message']) ? $_GET['message'] : "";
    $contentid = isset($_GET['contentid']) ? $_GET['contentid'] : "";
    $realmsisdn = isset($_GET['realmsisdn']) ? $_GET['realmsisdn'] : "";
    $parameter = explode(" ", $message);
    $jns = strtolower(isset($parameter[1]) ? $parameter[1] : "");
    $koderedeem = isset($parameter[1]) ? $parameter[1] : "";
    $kodeavatar = isset($parameter[3]) ? $parameter[3] : "";
    $notelepon = isset($parameter[4]) ? $parameter[4] : "";
    $dataxml = array('msisdn' => $msisdn, 'response' => "1", 'option' => "0", 'charge' => "0", 'appid' => "", 'partnerid' => "", 'mediaid' => "", 'trxid' => "", 'hptype' => "ALL", 'shortname' => "", 'contenttype' => "1", 'priority' => "1", 'contentid' => $contentid, 'desc' => "", 'mesage' => "Maaf, avatar item " . $koderedeem . " tidak valid, silakan coba lagi.");
    switch ($jns) {
        case "av":
            $lilo_mongo = new LiloMongo();
            $lilo_mongo->selectDB('Assets');
            $lilo_mongo->selectCollection('Avatar');
            $data = $lilo_mongo->find(array("code" => $koderedeem, "payment" => array('$in' => array('Unlock', 'Paid'))));
            if ($data) {
                $idavatar = $data['_id'];
                $count = 1;
                $kodegenerate = get_random(10);
                $lilo_mongo->selectCollection('Redeem');
                $datatinsert = array('code' => $kodegenerate, 'count' => $count, 'expire' => '', 'create' => $lilo_mongo->time(strtotime(date("Y-m-d H:i:s"))));
                $lilo_mongo->insert($datatinsert);
                $data2 = $lilo_mongo->findOne(array("code" => $kodegenerate));
                if ($data2) {
                    $idredeem = $data2['_id'];
                    $lilo_mongo->selectCollection('RedeemAvatar');
                    foreach ($data as $tampung) {
                        $datatinsert = array('avatar_id' => (string) $tampung['_id'], 'code_id' => (string) $idredeem);
                        $lilo_mongo->insert($datatinsert);
                    }
                    $dataxml['msisdn'] = $msisdn;
                    $dataxml['contentid'] = $contentid;
                    $dataxml['mesage'] = "Selamat, avatar item " . $koderedeem . " menjadi milik anda. Ini redeem codenya: " . $kodegenerate . ".";
                    echo return_xml($dataxml);
                } else {
                    $dataxml['msisdn'] = $msisdn;
                    $dataxml['contentid'] = $contentid;
                    $dataxml['mesage'] = "Maaf, avatar item " . $koderedeem . " Gagal tergenerate, silakan coba lagi.";
                    echo return_xml($dataxml);
                }
            } else {
                echo return_xml($dataxml);
            }
            break;
        default:
            echo return_xml($dataxml);
    }
}
Esempio n. 5
0
function server_admin_detail($server_to_show = NULL)
{
    $server_id = isset($server_to_show) ? $server_to_show : func_arg(0);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Servers');
    $lilo_mongo->selectCollection('GameServer');
    $server_detail = $lilo_mongo->findOne(array('lilo_id' => $server_id));
    $template = new Template();
    $template->basepath = $_SESSION['basepath'];
    $template->server_detail = $server_detail;
    return $template->render("modules/010_game_server_management/templates/server_admin_detail.php");
}
Esempio n. 6
0
function asset_user_session_to_user_id($session_id = NULL)
{
    if (!isset($session_id)) {
        $session_id = func_arg(0);
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Session');
    $array_criteria = array('session_id' => $session_id);
    $result_array = $lilo_mongo->findOne($array_criteria);
    return $result_array['user_id'];
}
Esempio n. 7
0
/**
 * examples:
 * -to get online time for user rully, use: http://localhost/popbloop/report/user/achievement/4df6e7192cbfd4e6c000fd9b/online_time/get
 * -to increase online time for user rully by 200ms, use: http://localhost/popbloop/report/user/achievement/4df6e7192cbfd4e6c000fd9b/online_time/dec/200
 */
function report_user_achievement($user_id = NULL, $achievement_type = NULL, $op = NULL, $value = NULL)
{
    $user_id = isset($user_id) ? $user_id : $_SESSION['user_id'];
    if (!isset($user_id)) {
        $user_id = func_arg(0);
    }
    if (!isset($achievement_type)) {
        $achievement_type = func_arg(1);
    }
    if (!isset($op)) {
        // inc, set, dec, * get
        // * = default
        $op = func_arg(2);
    }
    $op = strtolower(trim($op));
    if (!isset($value)) {
        $value = func_arg(3);
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Game');
    $lilo_mongo->selectCollection('Achievement');
    // jika ada, dapatkan dulu current value
    $criteria = array('tipe' => $achievement_type, 'userid' => $user_id);
    $curr_ach = $lilo_mongo->findOne($criteria);
    if (!($op == '' || $op == 'get') && count($curr_ach)) {
        $lilo_mongo->selectCollection('AchievementLog');
        // sebelum isi db diubah, backup dulu ke table AchievementLog
        $curr_ach_log = array_merge((array) $curr_ach, array('q' => $_REQUEST['q'], 'time' => time()));
        $lilo_mongo->insert($curr_ach_log);
    }
    $lilo_mongo->selectCollection('Achievement');
    switch ($op) {
        case '':
        case 'get':
            return $curr_ach['value'];
            break;
        case 'set':
            $lilo_mongo->update_set($criteria, array('value' => $value));
            break;
        case 'inc':
            $lilo_mongo->update_set($criteria, array('value' => (int) $curr_ach['value'] + (int) $value));
            break;
        case 'dec':
            $lilo_mongo->update_set($criteria, array('value' => (int) $curr_ach['value'] - (int) $value));
            break;
    }
    return "1";
}
Esempio n. 8
0
function check_session()
{
    //	return true;
    $session_id = $_SESSION['session_id'];
    $user_id = $_SESSION['user_id'];
    if (trim($user_id) != '' && trim($session_id) != '') {
        $lilo_mongo = new LiloMongo();
        $lilo_mongo->selectDB('Users');
        $lilo_mongo->selectCollection('Session');
        $exist = $lilo_mongo->findOne(array('session_id' => $session_id, 'user_id' => $user_id));
        if (!is_array($exist) || !count($exist)) {
            return false;
        }
        $cur_date = date("Y-m-d H:i:s");
        $lilo_mongo->update_set(array('session_id' => $session_id, 'user_id' => $user_id), array('time_end' => $cur_date));
    }
    return true;
}
Esempio n. 9
0
function log_guest_pageview($op, $var)
{
    // op: getall, var: ...
    // op: getbydate, var: 2012-03-28
    // op: inc, var: ...
    if (!isset($op)) {
        $op = func_arg(0);
    }
    if (!isset($var)) {
        $var = func_arg(1);
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Logs');
    $lilo_mongo->selectCollection('PageView');
    //
    // jika ada, dapatkan dulu current value
    $criteria = array('tipe' => $achievement_type, 'userid' => $user_id);
    $curr_ach = $lilo_mongo->findOne($criteria);
    if (!($op == '' || $op == 'get') && count($curr_ach)) {
        $lilo_mongo->selectCollection('AchievementLog');
        // sebelum isi db diubah, backup dulu ke table AchievementLog
        $curr_ach_log = array_merge((array) $curr_ach, array('q' => $_REQUEST['q'], 'time' => time()));
        $lilo_mongo->insert($curr_ach_log);
    }
    $lilo_mongo->selectCollection('Achievement');
    switch ($op) {
        case '':
        case 'get':
            return $curr_ach['value'];
            break;
        case 'set':
            $lilo_mongo->update_set($criteria, array('value' => $value));
            break;
        case 'inc':
            $lilo_mongo->update_set($criteria, array('value' => (int) $curr_ach['value'] + (int) $value));
            break;
        case 'dec':
            $lilo_mongo->update_set($criteria, array('value' => (int) $curr_ach['value'] - (int) $value));
            break;
    }
    return "1";
}
Esempio n. 10
0
function mobile_content_detail()
{
    $_id = func_arg(0) != "" ? func_arg(0) : "";
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Articles');
    $lilo_mongo->selectCollection('ContentPage');
    $dt = $lilo_mongo->findOne(array("_id" => $lilo_mongo->mongoid($_id)));
    $output = array('title' => "No Title", 'text' => "no Text", 'alias' => "no alias", 'document_update' => date("Y-m-d H:i:s"), 'state_document' => "");
    if ($dt) {
        $tgl = "";
        if ($dt['document_update'] != "") {
            $tgl = date('Y-m-d H:i:s', $dt['document_update']->sec);
        }
        $title = !isset($dt['title']) ? "" : $dt['title'];
        $text = !isset($dt['text']) ? "" : $dt['text'];
        $alias = !isset($dt['alias']) ? "" : $dt['alias'];
        $state_document = !isset($dt['state_document']) ? "" : $dt['state_document'];
        $output = array('title' => $title, 'alias' => $alias, 'text' => replace_text_content(filter_text($text)), 'document_update' => $tgl, 'state_document' => $state_document);
    }
    return json_encode($output);
}
Esempio n. 11
0
function mobile_stream_news()
{
    $_id = func_arg(0) != "" ? func_arg(0) : "";
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Articles');
    $lilo_mongo->selectCollection('ContentNews');
    $dt = $lilo_mongo->findOne(array("_id" => $lilo_mongo->mongoid($_id)));
    $output = array('title' => "No Title", 'text' => "no Text", 'update' => date("Y-m-d H:i:s"), 'state_document' => "");
    if ($dt) {
        $tgl = "";
        if ($dt['update'] != "") {
            $tgl = date('Y-m-d H:i:s', $dt['update']->sec);
        }
        $path_upload = URL_ASSET_IMAGE . "images/";
        $title = !isset($dt['title']) ? "" : $dt['title'];
        $text = !isset($dt['text']) ? "" : $dt['text'];
        $state_document = !isset($dt['state_document']) ? "" : $dt['state_document'];
        $picture = !isset($dt['picture']) ? "" : $dt['picture'];
        $output = array('title' => $title, 'text' => replace_text_content(filter_text($text)), 'update' => $tgl, 'imageName' => $picture, 'pathImage' => $path_upload, 'state_document' => $state_document);
    }
    return json_encode($output);
}
Esempio n. 12
0
function visitor_count()
{
    require_once 'libraries/LiloMongo.php';
    $today = date("Y-m-d");
    if (!isset($_SESSION['pop_visitor_logged']) || $_SESSION['pop_visitor_logged'] != $today) {
        $lilo_mongo = new LiloMongo();
        $lilo_mongo->selectDB('Logs');
        $lilo_mongo->selectCollection('Visitor');
        $visitor_data = array('date' => $today, 'time' => date("H:i:s"), 'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'], 'HTTP_USER_AGENT' => $_SERVER['HTTP_USER_AGENT'], '_SERVER' => $_SERVER);
        $lilo_mongo->insert($visitor_data);
        $lilo_mongo->selectCollection('VisitorCounter');
        // date, count
        $criteria = array('date' => $today);
        $today_visitor_data = $lilo_mongo->findOne($criteria);
        $count = 0;
        if ($today_visitor_data) {
            $count = intval($today_visitor_data['count']);
        }
        $count++;
        $lilo_mongo->update_set(array('date' => $today), array('count' => $count), array("multiple" => true, 'upsert' => true));
        $_SESSION['pop_visitor_logged'] = $today;
    }
}
Esempio n. 13
0
function mobile_avatar_getgender()
{
    $email = func_arg(0);
    $userDetails = __getUserDetails($email);
    $id = $userDetails['id'];
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection("Properties");
    $data = $lilo_mongo->findOne(array('lilo_id' => $id));
    $isValid = false;
    $status = "";
    if ($data) {
        $isValid = true;
        $status = $data['state_of_mind'];
    }
    $output = array('id' => $userDetails['id'], 'success' => $isValid, 'gender' => $userDetails['gender'], 'bodyType' => $userDetails['bodytype'], 'status' => $status == NULL ? "" : $status);
    return json_encode($output);
}
Esempio n. 14
0
function unity_user_status()
{
    $user_id = func_arg(0);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Properties');
    $properties = $lilo_mongo->findOne(array('lilo_id' => $user_id));
    if ($properties) {
        $status = $properties['state_of_mind'];
        if ($status == NULL) {
            $status = "";
        }
    }
    $retData = array('status' => $status);
    return json_encode($retData);
}
Esempio n. 15
0
function mobile_query_setconfavatar()
{
    $user_email = func_arg(0);
    $id_user = _get_id_user($user_email);
    $get_type = func_arg(1);
    $get_field = func_arg(2);
    $get_field = $get_field == "all" ? "" : $get_field;
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Avatar');
    $filter = array("user_id" => $id_user);
    $data = $lilo_mongo->findOne($filter);
    $datareturn['isSuccsesUpdate'] = FALSE;
    if ($data) {
        $datatinsert = array();
        $datareturn['isSuccsesUpdate'] = TRUE;
        if ($get_type == "configurations") {
            $conf = json_decode(str_replace("'", '"', $data['configuration']));
            if ($get_field != "") {
                if (strtolower($get_field) == "all") {
                    $datanew = "";
                    $temp = isset($_GET['massage']) ? $_GET['massage'] : "";
                    $datatemparray = explode("|", $temp);
                    if ($datatemparray) {
                        foreach ($datatemparray as $jml_json) {
                            $datanew .= "{";
                            $datatemp = explode(",", $jml_json);
                            if ($datatemp) {
                                foreach ($datatemp as $dttemp) {
                                    $dtinsert = explode(":", $dttemp);
                                    $key = $dtinsert[0];
                                    $value = isset($dtinsert[1]) ? $dtinsert[1] : "";
                                    $datanew .= "'" . $key . "':'" . $value . "',";
                                }
                                $datanew = substr($datanew, 0, strlen($datanew) - 1);
                            }
                            $datanew .= "},";
                        }
                        $datanew = substr($datanew, 0, strlen($datanew) - 1);
                    }
                    $datatinsert = array("configuration" => "[" . $datanew . "]");
                } else {
                    foreach ($conf as $dt => $listtemp) {
                        if ($listtemp->tipe == $get_field) {
                            continue;
                        }
                        $datanew .= "{";
                        foreach ($listtemp as $dt_json => $value_key) {
                            $datanew .= "'" . $dt_json . "':'" . $value_key . "',";
                        }
                        $datanew = substr($datanew, 0, strlen($datanew) - 1);
                        $datanew .= "},";
                    }
                    $datanew .= "{";
                    $datamessage = isset($_GET['massage']) ? $_GET['massage'] : "";
                    $datajson = explode(",", $datamessage);
                    if ($datajson) {
                        foreach ($datajson as $dttemp) {
                            $dtinsert = explode(":", $dttemp);
                            $key = $dtinsert[0];
                            $value = isset($dtinsert[1]) ? $dtinsert[1] : "";
                            $datanew .= "'" . $key . "':'" . $value . "',";
                        }
                        $datanew = substr($datanew, 0, strlen($datanew) - 1);
                    }
                    $datanew .= "}";
                    $datatinsert = array("configuration" => "[" . $datanew . "]");
                }
            }
        } else {
            if ($get_type == "size") {
                $datasize = isset($_GET['massage']) ? $_GET['massage'] : "medium";
                $datatinsert = array("size" => $datasize);
            }
        }
        $lilo_mongo->update_set($filter, $datatinsert);
    } else {
        $size = "medium";
        $gender = "female";
        $lilo_mongo->selectDB("Assets");
        $lilo_mongo->selectCollection("DefaultAvatar");
        $data3 = $lilo_mongo->findOne(array('gender' => $gender, 'size' => $size));
        if ($data3) {
            $lilo_mongo->selectDB('Users');
            $lilo_mongo->selectCollection('Avatar');
            $lilo_mongo->update(array("size" => $size, "user_id" => $id_user), array('$set' => array("configuration" => $data3['configuration'])), array('upsert' => TRUE));
        }
    }
    return json_encode($datareturn);
}
Esempio n. 16
0
function unity_query_quiz()
{
    $quiz_id = func_arg(0);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Game');
    $lilo_mongo->selectCollection('Quiz');
    $data = $lilo_mongo->findOne(array('ID' => $quiz_id));
    $output = array();
    $datebegintemp = "";
    $dateendtemp = "";
    if ($data) {
        $output['ID'] = $data['ID'];
        $output['Title'] = $data['Title'];
        $output['Description'] = $data['Description'];
        $output['BrandId'] = $data['BrandId'];
        $output['State'] = $data['State'];
        $output['StartTime'] = $data['StartTime'];
        $output['EndTime'] = $data['EndTime'];
        $output['IsRandom'] = (bool) $data['IsRandom'];
        $output['Number'] = (int) $data['Number'];
        $output['Count'] = (int) $data['Count'];
        $output['RequiredQuiz'] = (int) $data['RequiredQuiz'];
        $output['RequiredQuest'] = (int) $data['RequiredQuest'];
        $output['RequiredItem'] = $data['RequiredItem'];
        $output['Reward'] = $data['Reward'];
        $temp_dt_question = array();
        foreach ($data['Questions'] as $dtquestion) {
            $options = array();
            foreach ($dtquestion['Options'] as $dtpilihan) {
                $options[] = array('Answer' => $dtpilihan['Answer'], 'IsCorrect' => (bool) $dtpilihan['IsCorrect']);
            }
            $temp_dt_question[] = array('QuestionId' => $dtquestion['QuestionId'], 'Question' => $dtquestion['Question'], 'Difficulty' => $dtquestion['Difficulty'], 'QuestionTime' => $dtquestion['QuestionTime'], 'Tipe' => $dtquestion['Tipe'], 'Image' => $dtquestion['Image'] == "" ? "" : $dtquestion['Image'], 'Options' => $options);
        }
        $output['Questions'] = $temp_dt_question;
        if ($data['EndDate'] != '') {
            $dateendtemp = date('Y-m-d', $data['EndDate']->sec);
        }
        if ($data['StartDate'] != '') {
            $datebegintemp = date('Y-m-d', $data['StartDate']->sec);
        }
        $output['EndDate'] = $dateendtemp;
        $output['StartDate'] = $datebegintemp;
    }
    return json_encode($output);
}
Esempio n. 17
0
/**
 * return: array, detail user dari table Users.Account dan Users.Properties
 */
function friend_user_detailbyuserid($user_id = NULL)
{
    if (!isset($user_id)) {
        $user_id = func_arg(0);
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $account_data = $lilo_mongo->findOne(array('lilo_id' => $user_id));
    $lilo_mongo->selectCollection('Properties');
    $property_data = $lilo_mongo->findOne(array('lilo_id' => $user_id));
    if (trim($property_data['foto']) == '') {
        $property_data['foto'] = 'default.png';
    }
    $property_data['foto_url'] = $_SESSION['basepath'] . 'user_generated_data/profile_picture/' . $property_data['foto'];
    $result = array_merge((array) $account_data, (array) $property_data);
    unset($result['lilo_id']);
    unset($result['_id']);
    unset($result['password']);
    return json_encode($result);
}
Esempio n. 18
0
function article_guest_getoneslide($id = NULL)
{
    if (!isset($id)) {
        $id = $_POST['id'];
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Articles');
    $lilo_mongo->selectCollection('Slideshow');
    $article = $lilo_mongo->findOne(array('lilo_id' => $id));
    return json_encode($article);
}
Esempio n. 19
0
function friend_user_isonline($user_id = null)
{
    $user_id = isset($user_id) ? $user_id : func_arg(0);
    //	$user_id = func_arg(0);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Session');
    $session_data = $lilo_mongo->findOne(array('user_id' => $user_id));
    $online = 0;
    if (count($session_data)) {
        $idle_time = time() - strtotime($session_data['time_end']);
        $online = $idle_time < 5 * 60 ? 1 : 0;
    }
    return $online;
}
Esempio n. 20
0
function user_user_properties_by_uid($user_id = NULL)
{
    if (!isset($user_id) || trim($user_id) == '') {
        return array();
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Properties');
    $criteria = array('lilo_id' => $user_id);
    $user_prop = $lilo_mongo->findOne($criteria);
    if (!isset($user_prop['profile_picture']) || trim($user_prop['profile_picture']) == '') {
        $user_prop['profile_picture'] = "default.png";
    }
    return $user_prop;
}
Esempio n. 21
0
function asset_admin_category()
{
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('Category');
    $op = isset($op) ? $op : func_arg(0);
    $op = strtolower(trim($op));
    switch ($op) {
        case 'add':
            $data = array('name' => $_POST['name'], 'tipe' => $_POST['editor_div_type']);
            $anim_id = $lilo_mongo->insert($data);
            break;
        case 'delete':
            $lilo_mongo->remove(array('_id' => new MongoId($_POST['_id'])));
            break;
        case 'detail':
            $retval = $lilo_mongo->findOne(array('_id' => new MongoId($_POST['_id'])));
            $resultdetail = array('_id' => $_POST['_id'], 'name' => $retval['name'], 'tipe' => $retval['tipe']);
            echo json_encode($resultdetail);
            exit;
            break;
        case 'edit':
            $lilo_mongo->selectCollection('Category');
            $retval = $lilo_mongo->findOne(array('_id' => new MongoId($_POST['id'])));
            $lilo_mongo->selectCollection('Avatar');
            $lilo_mongo->update_set(array('category' => $retval['name']), array('category' => $_POST['name']));
            $lilo_mongo->selectCollection('Category');
            $lilo_mongo->update_set(array('_id' => new MongoId($_POST['id'])), array('name' => $_POST['name'], 'tipe' => $_POST['editor_div_type']));
            break;
    }
    $brand_data = $lilo_mongo->find(array(), 0, array("tipe" => 1));
    if ($_POST['showdt'] != '') {
        $brand_data = $lilo_mongo->find(array("tipe" => $_POST['showdt']), 0, array("tipe" => 1));
    }
    $returndt = array();
    foreach ($brand_data as $result) {
        $returndt[] = array('_id' => $result['_id'], 'name' => $result['name'], 'tipe' => $result['tipe']);
    }
    if (isset($_POST['json'])) {
        $listtabel = "";
        $listtabel .= "<table class='input_form' width='100%'>";
        $listtabel .= "<tr>";
        $listtabel .= "<th>Name</th>";
        $listtabel .= "<th>Avatar Body Part Type</th>";
        $listtabel .= "<th>Action</th>";
        $listtabel .= "</tr>";
        foreach ($brand_data as $dt) {
            $listtabel .= "<tr>";
            $listtabel .= "<td>" . $dt['name'] . "</td>";
            $listtabel .= "<td>" . $dt['tipe'] . "</td>";
            $listtabel .= "<td>";
            $listtabel .= "<button onclick='functionhapus(\"" . $dt['_id'] . "\");'>Delete</button>";
            $listtabel .= "<button onclick='functiongetdetail(\"" . $dt['_id'] . "\");'>Edit</button>";
            $listtabel .= "</td>";
            $listtabel .= "</tr>";
        }
        $listtabel .= "</table>";
        echo $listtabel;
        exit;
    }
    $html = '';
    $template = new Template();
    $template->basepath = $_SESSION['basepath'];
    $lilo_mongo->selectCollection('AvatarBodyPart');
    $listtipe = $lilo_mongo->find();
    $template->tipe_array = $listtipe;
    $template->category_array = $returndt;
    $html = $template->render("modules/002_asset_management/templates/asset_admin_category.php");
    $html = ui_admin_default(NULL, $html);
    return $html;
}
Esempio n. 22
0
function user_admin_wsplayerstat($date = NULL)
{
    // $date dalam format "n/j/Y", "7/9/2012"
    // dipanggil oleh user_admin_roomplayerstat
    // menampilkan data dari Game.PlayerStats berdasar tanggal yg dipilih user
    if (!isset($date)) {
        $date = func_arg(0);
    }
    if (trim($date) == '') {
        $date = date("n/j/Y");
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Game');
    $lilo_mongo->selectCollection('PlayerStats');
    // date, userid, room, visit
    $room_cursor = $lilo_mongo->find(array("date" => $date));
    $result = array();
    $no = 1;
    while ($room = $room_cursor->getNext()) {
        // dari $room['userid'] dapatkan data di Users.Account dan Users.Properties
        $lilo_mongo = new LiloMongo();
        $lilo_mongo->selectDB('Users');
        $lilo_mongo->selectCollection('Account');
        // email, username, join_date, lilo_id
        $criteria = array('lilo_id' => $room['userid']);
        $account = $lilo_mongo->findOne($criteria);
        $lilo_mongo->selectCollection('Properties');
        // lilo_id, fullname, avatarname, handphone, twitter, sex, birthday, location
        $criteria = array('lilo_id' => $room['userid']);
        $properties = $lilo_mongo->findOne($criteria);
        $result[] = array_merge(array('no' => $no), (array) $room, (array) $account, (array) $properties);
        $no++;
    }
    return json_encode($result);
}
Esempio n. 23
0
function message_user_loadusermessages($username = NULL)
{
    if (!isset($username)) {
        $username = func_arg(0);
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $account = $lilo_mongo->findOne(array('username' => $username));
    $user_id = $account['lilo_id'];
    $lilo_mongo->selectDB('Social');
    $lilo_mongo->selectCollection('Shout');
    $array_parameter = array('user_id' => $user_id);
    $limit = 100;
    $sort = array('time' => -1);
    $msg_me = array();
    $msg_me_cur = $lilo_mongo->find($array_parameter, $limit, $sort);
    while ($curr = $msg_me_cur->getNext()) {
        $user_properties = user_user_properties_by_uid($curr['user_id']);
        $msg_me[] = array("user_id" => $curr['user_id'], "shout_time" => $curr['shout_time'], "shout" => $curr['shout'], "circle" => $curr['circle'], "mentioned_friends" => $curr['mentioned_friends'], "mentioned_friends_notified" => $curr['mentioned_friends_notified'], "time" => $curr['time'], "lilo_id" => $curr['lilo_id'], "birthday" => $user_properties['birthday'], "fullname" => $user_properties['fullname'], "sender_id" => $user_properties['lilo_id'], "profile_picture" => $user_properties['profile_picture'], "sex" => $user_properties['sex'], "description" => $user_properties['description'], "time_word" => message_user_timetoword($curr['time']));
    }
    $all_messages = array('msg_me' => $msg_me);
    return json_encode($all_messages);
}
Esempio n. 24
0
function asset_admin_inventory()
{
    // CRUD for Assets.Inventory
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('Inventory');
    // delete
    $delete = trim($_REQUEST['delete']);
    if ($delete != '') {
        $lilo_mongo->delete(array('lilo_id' => $delete));
        return "1";
    }
    // detail
    $detail = trim($_REQUEST['detail']);
    if ($detail != '') {
        $data = $lilo_mongo->findOne(array('lilo_id' => $detail));
        return json_encode($data);
    }
    // new_inventory
    $new_inventory = trim($_REQUEST['new_inventory']);
    if ($new_inventory == "1") {
        extract($_POST);
        // tipe, description, icon
        if (trim($tipe) != '') {
            $inventory_data = array('tipe' => $tipe, 'description' => $description, 'icon' => $icon);
            $lilo_id_ = $lilo_mongo->insert($inventory_data);
            $lilo_mongo->update($inventory_data, array_merge($inventory_data, array('lilo_id' => (string) $lilo_id_)), array("multiple" => false));
        }
    }
    // dapatkan data Assets.Inventory
    $inventory_array = $lilo_mongo->find();
    $html = '';
    $template = new Template();
    $template->basepath = $_SESSION['basepath'];
    $template->inventory_array = $inventory_array;
    $html = $template->render("modules/002_asset_management/templates/asset_admin_inventory.php");
    $html = ui_admin_default(NULL, $html);
    return $html;
}
Esempio n. 25
0
function user_guest_accountproperties($username = NULL)
{
    // dari $username, dapatkan semua properti user ini di table: Users.Account, Users.Properties [Game.Achievement, Game.PlayerInventory]
    if (!isset($username)) {
        $username = func_arg(0);
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $criteria = array('username' => $username);
    $account = $lilo_mongo->findOne($criteria);
    if (!is_array($account) || !count($account)) {
        return "ERROR";
    }
    unset($account['_id']);
    unset($account['password']);
    $lilo_mongo->selectCollection('Properties');
    $criteria = array('lilo_id' => $account['lilo_id']);
    $properties = $lilo_mongo->findOne($criteria);
    unset($properties['_id']);
    $lilo_mongo->selectDB('Game');
    $lilo_mongo->selectCollection('Achievement');
    $criteria = array('userid' => $account['lilo_id']);
    $achievement_ = $lilo_mongo->find($criteria);
    $achievement = array();
    while ($curr = $achievement_->getNext()) {
        $achievement[] = $curr;
    }
    $user_data = array('account' => $account, 'properties' => $properties, 'achievement' => $achievement);
    // dapatkan property lain: gender, age, last-status,
    // gender: dari Users.Avatar, field configuration, di tipe: gender dapatkan element-nya
    return $user_data;
    //return print_r($achievement, true);
    //return print_r($properties, true);
    //return print_r($account, true);
}
Esempio n. 26
0
function mobile_social_likenewsbutton()
{
    $user_email = func_arg(0);
    $user_id = _get_id_user($user_email);
    $news_id = func_arg(1);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Social');
    $lilo_mongo->selectCollection('NewsLike');
    $parameter = array("user_id" => $user_id, "news_id" => $news_id);
    $data = $lilo_mongo->findOne($parameter);
    $output['message'] = "You Like This";
    $output['like'] = TRUE;
    $output['count'] = $lilo_mongo->count(array("news_id" => $news_id));
    if ($data) {
        $output['message'] = "You Unlike This";
        $output['like'] = FALSE;
        $lilo_mongo->remove($parameter);
        $output['count'] -= 1;
    } else {
        $lilo_mongo->insert($parameter);
        $output['count'] += 1;
    }
    return json_encode($output);
}
Esempio n. 27
0
function ui_user_avatar_editor_branditems()
{
    $ajax = func_arg(0);
    $template_file = "modules/000_user_interface/templates/ui_user_avatar_editor_branditems.php";
    $basepath = $_SESSION['basepath'];
    $template = new Template();
    $logged_in = user_user_loggedin();
    // Deteksi User Agent
    // cek apakah user ini admin
    $is_admin = ui_user_is_admin();
    $template->logged_in = $logged_in;
    $template->is_admin = $is_admin;
    $template->basepath = $basepath;
    // dapatkan semua bagian avatar berdasar tipe
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('Avatar');
    $avatar_array = array();
    // $tipe_array = array('face', 'face_part_eye_brows', 'face_part_eyes', 'face_part_lip', 'hair', 'pants', 'shoes', 'body', 'top', 'hand', 'hat');
    // face, hand tdk perlu diproses, karena tidak ditampilkan ke user
    $color_palette = array('face_part_eye_brows', 'face_part_eyes', 'face_part_lip', 'hair');
    $texture = array('pants', 'shoes', 'body', 'top', 'hat');
    $type_array = array_merge($color_palette, $texture);
    foreach ($type_array as $tipe_) {
        $var_name = $tipe_ . "_array";
        ${$var_name} = array();
        $lilo_mongo->selectCollection('Avatar');
        $avatar_ = $lilo_mongo->command_values(array("distinct" => "Avatar", "key" => "category", "query" => array('tipe' => $tipe_)));
        foreach ($avatar_ as $a_) {
            // dapatkan semua category + preview_picture + gender apa saja yg menggunakan category ini
            $gender_ = $lilo_mongo->command_values(array("distinct" => "Avatar", "key" => "gender", "query" => array('category' => $a_, 'tipe' => $tipe_)));
            foreach ($gender_ as $g_) {
                $size_ = $lilo_mongo->command_values(array("distinct" => "Avatar", "key" => "size", "query" => array('category' => $a_, 'tipe' => $tipe_, 'gender' => $g_)));
                foreach ($size_ as $s_) {
                    $prev_img_ = $lilo_mongo->findOne(array('preview_image' => array('$nin' => array('', false, 0)), 'gender' => $g_, 'category' => $a_, 'tipe' => $tipe_, 'gender' => $g_), array('preview_image'));
                    ${$var_name}[] = array('category' => $a_, 'preview_image' => $prev_img_['preview_image'], 'tipe' => $tipe_, 'gender' => $g_, 'size' => $s_, 'name' => $a_);
                }
            }
        }
        $avatar_array[$tipe_] = ${$var_name};
    }
    // dapatkan default avatar configuration utk [male x female] x [big x medium x small]
    require_once 'modules/003_avatar_editor/admin.php';
    $gender_array = array('male', 'female');
    $size_array = array('big', 'medium', 'small');
    foreach ($gender_array as $gender) {
        foreach ($size_array as $size) {
            ${'avatar_config_' . $gender . '_' . $size} = avatar_admin_get_default_configuration($gender, $size);
            $template->{'avatar_config_' . $gender . '_' . $size} = ${'avatar_config_' . $gender . '_' . $size};
        }
    }
    $template->session_id = $_SESSION['session_id'];
    $template->avatar_array = $avatar_array;
    $template->element_dir = $_SESSION['element_dir'];
    $template->material_dir = $_SESSION['material_dir'];
    $template->preview_dir = $_SESSION['preview_dir'];
    $user_property = user_user_property();
    $template->user_property = json_decode($user_property);
    $template->heartBeatInterval = 60000;
    $template->top = $template->render("modules/000_user_interface/templates/top.php");
    $template->left = $template->render("modules/000_user_interface/templates/left.php");
    $template->right = $template->render("modules/000_user_interface/templates/right.php");
    $template->bottom = $template->render("modules/000_user_interface/templates/bottom.php");
    $template->middle = $template->render($template_file);
    $return = $template->render("modules/000_user_interface/templates/ui_user_default.php");
    return $return;
}
Esempio n. 28
0
function quest_admin_dialogstorydetailbyid($lilo_id = NULL)
{
    if (!isset($lilo_id)) {
        $lilo_id = func_arg(0);
    }
    if (!isset($lilo_id)) {
        return false;
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Game');
    // Game: DialogStory, Dialog, DialogOption, Quest
    $lilo_mongo->selectCollection('DialogStory');
    $dialog_story = $lilo_mongo->findOne(array('lilo_id' => $lilo_id));
    $return = array();
    $data = $dialog_story['all_variable_2'];
    $return['Name'] = $data['dialog_story_name'];
    $return['Dialogs'] = array();
    // hitung jumlah dialog berdasar dialogid_x [x: 1, 2]
    $dialog_idx = 0;
    foreach ($data as $key => $val) {
        $pos = strpos($key, 'dialogid_');
        if ($pos !== false) {
            $key_expl = explode('_', $key);
            $return['Dialogs'][$dialog_idx]['ID'] = (int) $val;
            $return['Dialogs'][$dialog_idx]['Description'] = $data['description_' . $key_expl[1]];
            $return['Dialogs'][$dialog_idx]['Options'] = array();
            $option_idx = 0;
            foreach ($data as $key_ => $val_) {
                // dapatkan select_options_ $key_expl[1] _ xxx
                $pos_ = strpos($key_, 'select_options_' . $key_expl[1]);
                if ($pos_ !== false) {
                    $key_expl_ = explode('_', $key_);
                    $optidx = $key_expl_[3];
                    $return['Dialogs'][$dialog_idx]['Options'][$option_idx]['Tipe'] = (int) $val_;
                    $return['Dialogs'][$dialog_idx]['Options'][$option_idx]['Content'] = $data['option_content_choice_' . $key_expl[1] . '_' . $optidx];
                    $return['Dialogs'][$dialog_idx]['Options'][$option_idx]['Next'] = (int) $data['nextidoption_content_choice_' . $key_expl[1] . '_' . $optidx];
                    $option_idx++;
                }
            }
            $dialog_idx++;
        }
    }
    //	$return = json_encode($return);
    return $return;
    //	return str_replace('"', "'", $return);
}
Esempio n. 29
0
function quest_desc_by_id($ID = NULL)
{
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Game');
    // Game: DialogStory, Dialog, DialogOption, Quest
    $lilo_mongo->selectCollection('Quest');
    $ret = $lilo_mongo->findOne(array('ID' => "{$ID}"));
    return $ret['Description'];
}
Esempio n. 30
0
function avatar_admin_get_default_configuration($gender = NULL, $size = NULL, $name = NULL)
{
    // ambil data dari DefaultAvatar
    // pencarian dapat dilakukan berdasar [gender & size] maupun [name]
    if (!isset($gender)) {
        //		$gender = func_arg(0);
        $gender = $_REQUEST['gender'];
    }
    if (!isset($size)) {
        //		$size = func_arg(1);
        $size = $_REQUEST['size'];
    }
    if (!isset($name)) {
        //		$name = func_arg(2);
        $name = $_REQUEST['name'];
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('DefaultAvatar');
    if (!isset($name)) {
        if (isset($gender) && isset($size)) {
            $name = "default " . trim(strtolower($gender)) . " " . trim(strtolower($size));
        }
    }
    $criteria = array();
    if (isset($gender)) {
        $criteria = array_merge($criteria, array('gender' => $gender));
    }
    if (isset($name)) {
        $criteria = array_merge($criteria, array('name' => $name));
    }
    if (isset($size)) {
        $criteria = array_merge($criteria, array('size' => $size));
    }
    if (!count($criteria)) {
        return json_encode(array());
    }
    $defaultAvatar = $lilo_mongo->findOne($criteria);
    return $defaultAvatar['configuration'];
}