Exemplo n.º 1
0
function friend_user_ws_search($keyword = NULL)
{
    if (!isset($keyword)) {
        $keyword = func_arg(0);
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $search = new MongoRegex("/" . $keyword . "/i");
    $users = $lilo_mongo->find(array("username" => $search));
    while ($user = $users->getNext()) {
        if ($user['lilo_id'] != $_SESSION['user_id']) {
            $users_array[] = $user;
        }
    }
    for ($idx = 0; $idx < count($users_array); $idx++) {
        $lilo_mongo->selectDB('Social');
        $lilo_mongo->selectCollection('FriendInvitations');
        // cek apakah $user sudah ada di table Social.FriendInvitations, cek berdasar inviter_user_id, invitee_user_id
        $invitation_exists = $lilo_mongo->count(array('inviter_user_id' => $_SESSION['user_id'], 'invitee_user_id' => $users_array[$idx]['lilo_id']));
        $users_array[$idx]['invitation_exists'] = $invitation_exists;
        $lilo_mongo->selectDB('Users');
        $lilo_mongo->selectCollection('Properties');
        $property_array = $lilo_mongo->findOne(array('lilo_id' => $users_array[$idx]['lilo_id']));
        $users_array[$idx] = array_merge((array) $users_array[$idx], (array) $property_array);
    }
    //	return "<pre>" . print_r($users_array, true) . "</pre>";
    return json_encode($users_array);
}
Exemplo n.º 2
0
function mobile_banner_count()
{
    $output['count'] = 0;
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('Banner');
    $output['count'] = $lilo_mongo->count();
    return json_encode($output);
}
Exemplo n.º 3
0
function mobile_stream_count()
{
    $output['count'] = 0;
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Articles');
    $lilo_mongo->selectCollection('ContentNews');
    $output['count'] = $lilo_mongo->count(array("state_document" => "publish"));
    return json_encode($output);
}
Exemplo n.º 4
0
function mobile_avastream_count()
{
    $output['count'] = 0;
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('AvatarStream');
    $output['count'] = $lilo_mongo->count();
    return json_encode($output);
}
Exemplo n.º 5
0
function __features_part($email, $type, $start, $limit)
{
    $userData = __getUserDetails($email);
    $bodytype = $userData['bodytype'];
    $gender = $userData['gender'];
    $output = array();
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('Avatar');
    $query1 = $lilo_mongo->find_pagging(array('tipe' => $type, 'gender' => $gender, 'size' => $bodytype), $start, $limit, array('last_update' => -1));
    $count1 = $lilo_mongo->count();
    $newType = str_replace("face_part_", "", $type);
    //echo "........... ". $newType . ".......";
    foreach ($query1 as $item) {
        if ($newType != $type) {
            $element = array('tipe' => $newType, 'element' => str_replace(".unity3d", "", $item['material']));
        } else {
            $element = array('gender' => $gender, 'tipe' => $newType, 'element' => str_replace(".unity3d", "", $item['element']), 'material' => str_replace(".unity3d", "", $item['material']));
        }
        $json = str_replace("\"", "'", json_encode($element));
        $output['data'][] = array('tipe' => $type, 'title' => $item['name'], 'picture' => $item['preview_image'], 'action' => '/AvatarPreview?f=' . $type . "&id=" . (string) $item['_id'] . "&v=" . $json, 'value' => '');
    }
    $query2 = $lilo_mongo->find_pagging(array('tipe' => $type, 'gender' => 'unisex'), $start, $limit, array('last_update' => -1));
    $count2 = $lilo_mongo->count();
    foreach ($query2 as $item) {
        if ($newType != $type) {
            $element = array('tipe' => $newType, 'element' => str_replace(".unity3d", "", $item['material']));
        } else {
            $element = array('gender' => $gender, 'tipe' => $newType, 'element' => str_replace(".unity3d", "", $item['element']), 'material' => str_replace(".unity3d", "", $item['material']));
        }
        $json = str_replace("\"", "'", json_encode($element));
        $output['data'][] = array('tipe' => $type, 'title' => $item['name'], 'picture' => $item['preview_image'], 'action' => '/AvatarPreview?f=' . $type . "&id=" . (string) $item['_id'] . "&v=" . $json, 'value' => (string) $item['_id']);
    }
    $output['count'] = $count1 + $count2;
    return json_encode($output);
}
Exemplo n.º 6
0
function __style_mix($email)
{
    $mongo = new LiloMongo();
    $userDetails = __getUserDetails($email);
    $id = $userDetails["id"];
    $gender = $userDetails['gender'];
    $bodytype = $userDetails['bodytype'];
    //echo $gender. " " . $bodytype;
    $mongo->selectDB("Users");
    $mongo->selectCollection("AvatarMix");
    $query = $mongo->find_pagging(array('gender' => $gender, 'bodytype' => $bodytype));
    $count = $mongo->count(array('gender' => $gender, 'bodytype' => $bodytype));
    $output = array();
    $output['count'] = $count;
    if ($query) {
        foreach ($query as $item) {
            $json = $item['configuration'];
            $output['data'][] = array('tipe' => 'Mix', 'title' => $item['name'], 'picture' => $item['picture'], 'action' => '/AvatarPreview?f=character' . '&id=' . (string) $item['_id'] . "&v=" . $json, 'value' => '');
        }
    }
    return $output;
}
Exemplo n.º 7
0
function friend_user_getchat()
{
    // CHAT_ : start_time, time, text
    //
    extract($_REQUEST);
    // friend_id, text
    $friend_id = isset($friend_id) ? $friend_id : func_arg(0);
    if (!isset($friend_id)) {
        return '';
    }
    $curr_time = time();
    $user_id = $_SESSION['user_id'];
    if ($user_id < $friend_id) {
        $table_name = 'CHAT_' . $user_id . '_' . $friend_id;
    } else {
        $table_name = 'CHAT_' . $friend_id . '_' . $user_id;
    }
    // dapetin nama lengkap dari user_id dan friend_id
    $user_detail = friend_user_detailbyuserid($user_id);
    $user_detail = json_decode($user_detail);
    $friend_detail = friend_user_detailbyuserid($friend_id);
    $friend_detail = json_decode($friend_detail);
    $arr_fullname[$user_id] = $user_detail->fullname;
    $arr_fullname[$friend_id] = $friend_detail->fullname;
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Social');
    $lilo_mongo->selectCollection($table_name);
    $limit = 50;
    // dapatkan last 50 conversation
    // find($array_parameter = array(), $limit = 0, $sort = array())
    $count = $lilo_mongo->count();
    if ($count >= $limit) {
        $conversation = $lilo_mongo->find(array(), $limit, array('time' => -1));
        $retval = '';
        $retval_array = array();
        $idx = $limit - 1;
        while ($conv = $conversation->getNext()) {
            $speaker = $conv['speaker'];
            $text = $conv['text'];
            $speaker_fullname = $arr_fullname[$speaker];
            $retval_array[$idx] = "<br><strong>{$speaker_fullname}</strong><br>" . $text;
            $idx--;
        }
        for ($i = 0; $i < count($retval_array); $i++) {
            if (isset($retval_array[$i]) && trim($retval_array[$i]) != '') {
                $retval .= $retval_array[$i];
            }
        }
        return $retval;
    } else {
        $conversation = $lilo_mongo->find(array(), $limit, array('time' => 1));
        $retval = '';
        $retval_array = array();
        while ($conv = $conversation->getNext()) {
            $speaker = $conv['speaker'];
            $text = $conv['text'];
            $speaker_fullname = $arr_fullname[$speaker];
            $retval .= "<br><strong>{$speaker_fullname}</strong><br>" . $text;
        }
        return $retval;
    }
}
Exemplo n.º 8
0
/**
 * return property dari user ini
 */
function user_user_property($args = NULL, $rettype = NULL)
{
    if (!user_user_loggedin()) {
        return "0";
    }
    // write_log(array('log_text' => print_r($args, true)));
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $array_criteria = array('username' => $_SESSION['username']);
    if (isset($args)) {
        $array_criteria = $args;
    }
    $myproperty = $lilo_mongo->findOne($array_criteria);
    unset($myproperty['password']);
    unset($myproperty['_id']);
    // write_log(array('log_text' => print_r($myproperty, true)));
    $lilo_mongo->selectCollection('Properties');
    $array_criteria = array('lilo_id' => $myproperty['lilo_id']);
    $myproperty2 = $lilo_mongo->findOne($array_criteria);
    if (trim($myproperty2['profile_picture']) == '') {
        $myproperty2['profile_picture'] = 'default.png';
    }
    unset($myproperty2['_id']);
    unset($myproperty2['lilo_id']);
    //	count_unread_msg
    //	jumlah pesan dengan 'receiver' = $user_id dan 'read' != '1'
    $lilo_mongo->selectDB('Social');
    $lilo_mongo->selectCollection('Messages');
    $count_unread_msg = $lilo_mongo->count(array('receiver' => $_SESSION['user_id'], 'read' => array('$not' => '1')));
    $myproperty2['count_unread_msg'] = intval($count_unread_msg);
    //	power
    $lilo_mongo->selectDB('Game');
    $lilo_mongo->selectCollection('Achievement');
    $power_array = $lilo_mongo->findOne(array('userid' => $_SESSION['user_id'], 'tipe' => 'energy'));
    $myproperty2['power'] = $power_array['value'];
    $myproperty = array_merge((array) $myproperty, (array) $myproperty2);
    // write_log(array('log_text' => print_r($myproperty, true)));
    if ($rettype == 'array') {
        return $myproperty;
    }
    return json_encode($myproperty);
}
Exemplo n.º 9
0
function user_admin_wscountcurrentplayer()
{
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Game');
    $lilo_mongo->selectCollection('Concurrent');
    $cc_cursor = $lilo_mongo->count();
    return $cc_cursor;
}
Exemplo n.º 10
0
function mobile_social_listcommentnews()
{
    $news_id = func_arg(0);
    $start_from = func_arg(1);
    $limit = func_arg(2);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Social');
    $lilo_mongo->selectCollection('NewsComments');
    $temp_data = $lilo_mongo->find_pagging(array("news_id" => $news_id), $start_from, $limit, array("datetime" => -1));
    $output['count'] = $lilo_mongo->count(array("news_id" => $news_id));
    if ($temp_data) {
        foreach ($temp_data as $dt) {
            $datatemp_user = _detail_user($dt['user_id']);
            $tglcreate = "";
            if ($dt['datetime'] != "") {
                $tglcreate = date('Y-m-d H:i:s', $dt['datetime']->sec);
            }
            $output['data'][] = array('_id' => (string) $dt['_id'], 'userName' => $datatemp_user['userName'], 'picture' => $datatemp_user['picture'], 'sex' => $datatemp_user['sex'], 'userId' => $dt['user_id'], 'datetime' => $tglcreate, 'comment' => $dt['comment']);
        }
    }
    return json_encode($output);
}
Exemplo n.º 11
0
function mobile_avatar_delcollections()
{
    $user_id = func_arg(0);
    $_id = func_arg(1);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('AvatarCollection');
    $data = $lilo_mongo->delete(array('user_id' => $user_id, "_id" => $lilo_mongo->mongoid($_id)));
    $output['collectionsCount'] = $lilo_mongo->count(array("user_id" => $user_id));
    return json_encode($output);
}
Exemplo n.º 12
0
function report_admin_wsusercountquest()
{
    //Data Quest:
    //1a. Jumlah users yang mengaktifkan 1 Quest
    //1b. Jumlah users yang menyelesaikan 1 Quest
    //
    //2a. Jumlah users yang mengaktifkan 2 Quest
    //2b. Jumlah users yang menyelesaikan 2 Quest
    //
    //3a. Jumlah users yang mengaktifkan 3 Quest
    //3b. Jumlah users yang menyelesaikan 3 Quest
    //
    //4a. Jumlah users yang mengaktifkan 4 Quest
    //4b Jumlah users yang menyelesaikan 4 Quest
    // DB: Game.QuestJournal, Game.QuestActive
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Game');
    $lilo_mongo->selectCollection('QuestJournal');
    $all_users = $lilo_mongo->command_values(array('distinct' => "QuestJournal", 'key' => "userid"));
    $c_1 = array();
    $c_2 = array();
    $c_3 = array();
    $c_4 = array();
    foreach ($all_users as $u) {
        $criteria = array('userid' => $u);
        $count = $lilo_mongo->count($criteria);
        $user_acc_prop = report_admin_useraccountproperties($u);
        ${"c_" . $count}[] = $user_acc_prop;
    }
    $lilo_mongo->selectCollection('QuestActive');
    $all_users = $lilo_mongo->command_values(array('distinct' => "QuestActive", 'key' => "userid"));
    $cur_1 = array();
    $cur_2 = array();
    $cur_3 = array();
    $cur_4 = array();
    foreach ($all_users as $u) {
        $criteria = array('userid' => $u);
        $count = $lilo_mongo->count($criteria);
        $user_acc_prop = report_admin_useraccountproperties($u);
        ${"cur_" . $count}[] = $user_acc_prop;
    }
    $result = array('c_1' => $c_1, 'c_2' => $c_2, 'c_3' => $c_3, 'c_4' => $c_4, 'cur_1' => $cur_1, 'cur_2' => $cur_2, 'cur_3' => $cur_3, 'cur_4' => $cur_4);
    return json_encode($result);
}