function __style_bodypart($email, $tipe, $start, $limit) { $userDetails = __getUserDetails($email); $output = array(); if ($userDetails) { $bodytype = !isset($userDetails['bodytype']) || $userDetails['bodytype'] == "" ? "medium" : $userDetails['bodytype']; $gender = $userDetails['gender']; //echo $tipe ." " . $bodytype . " " . $gender . "<br/>"; $mongo = new LiloMongo(); $mongo->selectDB("Assets"); $mongo->selectCollection("Avatar"); $avatar = null; $count = 0; if ($tipe == "hat") { $avatar = $mongo->find(array('tipe' => $tipe)); $count = $mongo->count(array('tipe' => $tipe)); } else { if ($tipe == "shoes") { $avatar = $mongo->find(array('tipe' => $tipe)); $count = $mongo->count(array('tipe' => $tipe)); } else { $avatar = $mongo->find(array('tipe' => $tipe, 'size' => $bodytype, 'gender' => $gender)); $count = $mongo->count(array('tipe' => $tipe, 'size' => $bodytype, 'gender' => $gender)); } } if ($avatar) { $output = __explode_avatar_items($avatar, $gender, $count); } } return $output; }
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); } }
function server_admin_default() { // CRUD of registered server: name, port, ip, max CCU, current CCU* (*: updated realtime by game server on user connect/disconnect) // add server $ajax = func_arg(0); // dapatkan semua level dari Assets.Level $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Servers'); $lilo_mongo->selectCollection('GameServer'); $server_array = $lilo_mongo->find(); $html = ''; $template = new Template(); $template->basepath = $_SESSION['basepath']; $template->server_array = $server_array; $html = $template->render("modules/010_game_server_management/templates/server_admin_default.php"); if (trim($ajax) == 'ajax') { } else { $html = ui_admin_default(NULL, $html); } return $html; }
function user_user_add_lilo_id_to_users() { // loop semua row di table users // tambahkan field lilo_id di tiap row tersebut $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('Account'); $users_cursor = $lilo_mongo->find(array()); while ($curr = $users_cursor->getNext()) { if (trim($curr['lilo_id']) == '') { $ret .= "<br />" . print_r($curr, true) . "<br />"; $lilo_id = (string) $curr['_id']; $lilo_mongo->update($curr, array_merge($curr, array('lilo_id' => (string) $lilo_id)), array("multiple" => false)); } } return "beres..." . $ret; }
function article_guest_getslides() { $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Articles'); $lilo_mongo->selectCollection('Slideshow'); $array_parameter = array(); $limit = 0; $sort = array('no' => 1); $article_cursor = $lilo_mongo->find($array_parameter, $limit, $sort); $article_array = array(); while ($curr = $article_cursor->getNext()) { $article_array[] = array('lilo_id' => $curr['lilo_id'], 'no' => $curr['no'], 'title' => $curr['title'], 'image' => $curr['image'], 'description' => $curr['description'], 'link' => $curr['link']); } return json_encode($article_array); }
function avatar_admin_preset($op = NULL) { // CRUD // data selain op dikirim via post if (!isset($op)) { $op = func_arg(0); } $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Assets'); $lilo_mongo->selectCollection('DefaultAvatar'); switch (strtolower(trim($op))) { case 'getall': $preset_cursor = $lilo_mongo->find(); $result = array(); while ($preset = $preset_cursor->getNext()) { $key = $preset['name']; $result[$key] = $preset; } $result_['default male thin'] = $result['default male thin']; $result_['default male medium'] = $result['default male medium']; $result_['default male fat'] = $result['default male fat']; $result_['default female thin'] = $result['default female thin']; $result_['default female medium'] = $result['default female medium']; $result_['default female fat'] = $result['default female fat']; return "<pre>" . print_r($result_, true) . "</pre>"; return json_encode($result_); break; } }
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; }
function avatar_user_avatar_category() { // die("<pre>" . print_r($_POST, true) . "</pre>"); /* Array ( [tipe] => body [gender] => male [category] => T-Shirt [size] => fat ) */ extract($_POST); if (trim($tipe) == '') { die("Error - Incomplete argument"); } $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Assets'); $lilo_mongo->selectCollection('Avatar'); $var_name = $tipe . "_array"; $avatar_array = array(); // $avatar_cursor = $lilo_mongo->find(array('tipe' => $tipe_)); $avatar_cursor = $lilo_mongo->find(array('tipe' => $tipe, 'gender' => $gender, 'category' => $category, 'size' => $size), 0, array('gender' => 1, 'name' => 1, 'category' => 1)); while ($curr = $avatar_cursor->getNext()) { $avatar_array[] = array('id' => $curr['lilo_id'], 'gender' => $curr['gender'], 'size' => $curr['size'], 'color' => $curr['color'], 'tipe' => $curr['tipe'], 'name' => $curr['name'], 'element' => $curr['element'], 'material' => $curr['material'], 'preview_image' => $curr['preview_image']); } $basepath = $_SESSION['basepath']; $template = new Template(); $logged_in = user_user_loggedin(); $template->logged_in = $logged_in; $template->basepath = $basepath; $template->avatar_array = $avatar_array; $template->tipe = $tipe; $template->background_image = str_replace('"', "'", $background_image); $template->element_dir = $_SESSION['element_dir']; $template->material_dir = $_SESSION['material_dir']; $template->preview_dir = $_SESSION['preview_dir']; $return = $template->render("modules/003_avatar_editor/templates/avatar_user_avatar_category.php"); return $return; }
function ui_user_avatar_editor() { $ajax = func_arg(0); // $template_file = "modules/000_user_interface/templates/ui_user_avatar_editor.php"; $template_file = "modules/000_user_interface/templates/ui_user_avatar_editor_new.php"; // $template_file = "modules/000_user_interface/templates/ui_user_avatar_editor_categorized.php"; // if($ajax == 'ajax'){ $basepath = $_SESSION['basepath']; $template = new Template(); $logged_in = user_user_loggedin(); // Deteksi User Agent $template->logged_in = $logged_in; $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'); foreach ($tipe_array as $tipe_) { $var_name = $tipe_ . "_array"; ${$var_name} = array(); // $avatar_cursor = $lilo_mongo->find(array('tipe' => $tipe_)); $avatar_cursor = $lilo_mongo->find(array('tipe' => $tipe_), 0, array('gender' => 1, 'name' => 1, 'category' => 1)); while ($curr = $avatar_cursor->getNext()) { ${$var_name}[] = array('id' => $curr['lilo_id'], 'gender' => $curr['gender'], 'size' => $curr['size'], 'tipe' => $curr['tipe'], 'name' => $curr['name'], 'element' => $curr['element'], 'material' => $curr['material'], 'element2' => $curr['element_2'], 'material2' => $curr['material_2'], 'preview_image' => $curr['preview_image']); } $avatar_array[$tipe_] = ${$var_name}; } $template->avatar_array = $avatar_array; $template->element_dir = $_SESSION['element_dir']; $template->material_dir = $_SESSION['material_dir']; $template->preview_dir = $_SESSION['preview_dir']; // $return = $template->render($template_file); // return $return; $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; // } else { // return ui_user_default($template_file); // } }
function friend_user_ws_friendlist($keyword = NULL) { if (!isset($keyword)) { $keyword = func_arg(0); } // dapatkan circle array // ... $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Social'); $lilo_mongo->selectCollection('Circles'); $circle_data_ = $lilo_mongo->findOne(array('user_id' => $_SESSION['user_id'])); $circle_data = $circle_data_['circle_array']; // dapatkan semua data di table Friends dengan user_id = $_SESSION['user_id'] $lilo_mongo->selectDB('Social'); $lilo_mongo->selectCollection('Friends'); $friend_cursor = $lilo_mongo->find(array('user_id' => $_SESSION['user_id'])); $friend_data = array(); while ($friend = $friend_cursor->getNext()) { unset($friend['_id']); // tambahkan detail $friend dari table Users.Account dan Users.Properties // dari $friend['user_id'] $friend_account_detail = friend_user_detailbyuserid($friend['friend_id']); $friend_account_detail = json_decode($friend_account_detail); $friend = array_merge((array) $friend, (array) $friend_account_detail); $friend_data[] = $friend; } $outer_circle_friend_data = $friend_data; for ($idx = 0; $idx < count($circle_data); $idx++) { $friend_list = array(); foreach ($friend_data as $friend) { $circle_array = $friend['circle_array']; if (in_array($circle_data[$idx], $circle_array)) { // // tambahkan detail $friend dari table Users.Account dan Users.Properties // // dari $friend['user_id'] // // $friend_account_detail = friend_user_detailbyuserid($friend['friend_id']); // $friend_account_detail = json_decode($friend_account_detail); // $friend = array_merge((array)$friend, (array)$friend_account_detail); $friend_list[] = $friend; } } $circle_data[$idx] = array_merge((array) $circle_data[$idx], (array) $friend_list); } // dapatkan semua friend yg tdk masuk circle manapun... // $outer_circle_friend_data = array_diff($outer_circle_friend_data, $friend_list); for ($idx = 0; $idx < count($outer_circle_friend_data); $idx++) { if (count($outer_circle_friend_data[$idx]['circle_array'])) { unset($outer_circle_friend_data[$idx]); } } // write_log(array('filename' => NULL, 'somecontent' => print_r($outer_circle_friend_data, true) . "\n\n" . print_r($friend_list, true))); $circle_data[] = array_merge(array('Outer Circle'), (array) $outer_circle_friend_data); unset($friend_list); unset($friend_data); unset($circle_data_); $lilo_mongo->close(); // dapatkan property setiap friend ! // return print_r($circle_data, true); // return print_r($circle_data, true) . '-------------' . print_r($friend_data, true); return json_encode($circle_data); }
function update_admin($username, $old_password, $new_password, $email) { // username tidak bisa diganti, hanya password dan email if (trim($username) == '' || trim($old_password) == '' || trim($new_password) == '' || trim($email) == '') { return FALSE; } $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('Admin'); $admin_data = $lilo_mongo->find(array('username' => $username, 'password' => md5($old_password))); $exist = FALSE; while ($curr = $admin_data->getNext()) { $exist = TRUE; } if (!exist) { return "Data (Username / Password) yang Anda masukkan salah!"; } $array_criteria = array('username' => $username, 'password' => md5($old_password)); $array_newobj = array('password' => $new_password, 'email' => $email); $lilo_mongo->update_set($array_criteria, $array_newobj, NULL); return TRUE; }
function quest_admin_wsplayertoquest($type = NULL, $userid = NULL, $sort_by = NULL, $asc_desc = NULL) { // input: type (completed, current), player userid / username // return: semua quest yg diselesaikan player ini // Game.QuestJournal if (!isset($type)) { $type = func_arg(0); } if (!isset($userid)) { $userid = func_arg(1); } $userid = trim($userid); $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Game'); // Game: DialogStory, Dialog, DialogOption, Quest if (trim(strtolower($type)) == 'completed') { $lilo_mongo->selectCollection('QuestJournal'); $criteria = array('userid' => $userid); $journal_cursor = $lilo_mongo->find($criteria); $result = array(); while ($journal = $journal_cursor->getNext()) { // dari $journal['questid'], dapatkan properti quest $quest_property = quest_admin_ws_quest('detail', $journal['questid']); // dari $journal['start_date'] & $journal['end_date'] dapatkan durasi if (trim($journal['start_date']) != '' && trim($journal['end_date']) != '') { $duration = unitytounixtime(trim($journal['end_date'])) - unitytounixtime(trim($journal['start_date'])); // $duration = date("Y-m-d H:i:s", $duration); $journal['duration'] = sec2hms($duration); } $result[] = array_merge((array) json_decode($quest_property), $journal); } // die('<pre>' . print_r($result, true) . '</pre>'); return json_encode($result); } else { $lilo_mongo->selectCollection('QuestActive'); $criteria = array('userid' => $userid); $journal_cursor = $lilo_mongo->find($criteria); $result = array(); while ($journal = $journal_cursor->getNext()) { // dari $journal['questid'], dapatkan properti quest // SAMPE SENEEE... $quest_property = quest_admin_ws_quest('detail', $journal['questid']); $result[] = array_merge((array) json_decode($quest_property), $journal); } // die('<pre>' . print_r($result, true) . '</pre>'); return json_encode($result); } }
function mobile_avatar_default() { $start_from = func_arg(0); $limit = func_arg(1); $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Assets'); $lilo_mongo->selectCollection('DefaultAvatar'); $data = $lilo_mongo->find(array()); $output = array(); if ($data) { foreach ($data as $tampung) { $defconfigurasi = !isset($tampung['configuration']) ? "" : $tampung['configuration']; $conf_array = json_decode(str_replace("'", '"', $defconfigurasi)); $output[] = array('_id' => !isset($tampung['_id']) ? "" : (string) $tampung['_id'], 'name' => !isset($tampung['name']) ? "" : $tampung['name'], 'gender' => !isset($tampung['gender']) ? "" : $tampung['gender'], 'size' => !isset($tampung['size']) ? "" : $tampung['size'], 'configuration' => $conf_array); } } return json_encode($output); }
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); }
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; } }
function generate_redeem_avatar($avatar_item_code, $count) { $code = get_random(10); $lilo_mongo = new LiloMongo(); $id = $lilo_mongo->mongoid($code . date('YmdHis')); $lilo_mongo->selectDB('Assets'); // Create Redeem $lilo_mongo->selectCollection('Redeem'); $generatetime = date("Y-m-d H:i:s"); $time_start = strtotime($generatetime); $datatinsert = array('code' => $code, 'count' => $count, 'expire' => '', 'create' => $lilo_mongo->time($time_start), '_id' => $id); $result = $lilo_mongo->insert($datatinsert); $redeemId = (string) $id; // Create Mapping Avatar $lilo_mongo->selectCollection('Avatar'); $data = $lilo_mongo->find(array("code" => $avatar_item_code)); $datareturn = array(); if ($data) { $lilo_mongo->selectCollection('RedeemAvatar'); foreach ($data as $tampung) { $dataaddnew = array('avatar_id' => (string) $tampung['_id'], 'code_id' => $redeemId); $lilo_mongo->insert($dataaddnew); $datareturn[] = $dataaddnew; } } $ret = array('id' => $datareturn, 'code' => $code); return $ret; }
function quest_admin_ws_dialogstory($op = NULL, $id = NULL, $data = NULL) { // quest/admin/ws_dialogstory => list all dialog_story // quest/admin/ws_dialogstory/read => -- idem -- // quest/admin/ws_dialogstory/create => menerima $_POST untuk dimasukkan ke db // quest/admin/ws_dialogstory/update/$id => menerima $_POST untuk update dialog_story dgn id = $id // quest/admin/ws_dialogstory/delete/$id => menghapus dialog_story dgn id = $id if (!isset($op)) { $op = func_arg(0) != '' ? func_arg(0) : 'read'; } $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Game'); // Game: DialogStory, Dialog, DialogOption, Quest $lilo_mongo->selectCollection('DialogStory'); switch ($op) { case 'create': // sementara baru data di Game.DialogStory dulu belum sampe ke anak2nya... if (!isset($data)) { // data = array(name, description); $data = $_POST; } // return $data['all_variable']; if (!isset($data['name'])) { return false; } // $data['all_variable'] = parse_str($data['all_variable']); $a = explode('&', $data['all_variable']); $i = 0; while ($i < count($a)) { $b = split('=', $a[$i]); // echo 'Value for parameter ', htmlspecialchars(urldecode($b[0])), // ' is ', htmlspecialchars(urldecode($b[1])), "<br />\n"; $i++; $key = urldecode($b[0]); $val = urldecode($b[1]); // option_content_quest_ if (substr($key, 0, 21) == 'option_content_quest_') { $val_expl = explode('-', $val); $val = trim($val_expl[0]); } $data['all_variable_2'][$key] = $val; } $dialog_story_id = $lilo_mongo->insert($data); $lilo_mongo->update($data, array_merge($data, array('lilo_id' => (string) $dialog_story_id)), array("multiple" => false)); return "1"; //$dialog_story_id; break; case 'update': // sementara baru data di Game.DialogStory dulu belum sampe ke anak2nya... if (!isset($id)) { $id = func_arg(1); } if (!isset($data)) { // data = array(name, description); $data = $_POST; } $lilo_mongo->update(array('lilo_id' => $id), $data, array("multiple" => false)); return "1"; break; case 'delete': if (!isset($id)) { $id = func_arg(1); } $lilo_mongo->delete(array('lilo_id' => $id)); return "1"; break; } // op == 'read' $dialog_stories = array(); $dialog_stories_cursor = $lilo_mongo->find(); while ($dialog_story = $dialog_stories_cursor->getNext()) { $dialog_stories[] = $dialog_story; } // return json_encode($dialog_stories); $dialog_stories = json_encode($dialog_stories); return $dialog_stories; // return str_replace('"', "'", $dialog_stories); }
function unity_user_profile() { $email = func_arg(0); $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('Account'); $cekada = $lilo_mongo->findOne(array("email" => $email)); if (!$cekada) { $cekada = $lilo_mongo->findOne(array("username" => $email)); } $retData = array('valid' => false, 'email' => "", 'username' => "", 'avatarname' => "", 'fullname' => "", 'sex' => "", 'website' => "", 'link' => "", 'birthday' => "", 'birthday_dd' => "", 'birthday_mm' => "", 'birthday_yy' => "", 'state_of_mind' => "", 'about' => "", 'picture' => "", 'location' => "", 'handphone' => "", 'twitter' => "", 'status' => ""); if ($cekada) { $lilo_mongo->selectCollection('UserProfile'); $datastatus = $lilo_mongo->find(array('lilo_id' => (string) $cekada['_id']), 1000, array('date' => -1)); $lilo_id = $cekada["_id"]; $tempstatus = array(); if ($datastatus) { foreach ($datastatus as $dt) { $tempstatus[] = $dt['StateMind']; } } $lilo_mongo->selectCollection('Properties'); $datadetail = $lilo_mongo->findOne(array("lilo_id" => (string) $cekada['_id'])); $retData = array('valid' => TRUE, 'lilo_id' => isset($lilo_id) ? (string) $lilo_id : "", 'email' => isset($cekada['email']) ? $cekada['email'] : "", 'username' => isset($cekada['username']) ? $cekada['username'] : "", 'avatarname' => isset($datadetail['avatarname']) ? $datadetail['avatarname'] : '', 'fullname' => isset($datadetail['fullname']) ? $datadetail['fullname'] : '', 'sex' => isset($datadetail['sex']) ? $datadetail['sex'] : '', 'website' => isset($datadetail['website']) ? $datadetail['website'] : '', 'link' => isset($datadetail['link']) ? $datadetail['link'] : '', 'birthday' => isset($datadetail['birthday']) ? $datadetail['birthday'] : '', 'birthday_dd' => isset($datadetail['birthday_dd']) ? $datadetail['birthday_dd'] : '', 'birthday_mm' => isset($datadetail['birthday_mm']) ? $datadetail['birthday_mm'] : '', 'birthday_yy' => isset($datadetail['birthday_yy']) ? $datadetail['birthday_yy'] : '', 'state_of_mind' => isset($datadetail['state_of_mind']) ? $datadetail['state_of_mind'] : '', 'about' => isset($datadetail['about']) ? $datadetail['about'] : '', 'picture' => isset($datadetail['picture']) ? $datadetail['picture'] : '', 'location' => isset($datadetail['location']) ? $datadetail['location'] : '', 'handphone' => isset($datadetail['handphone']) ? $datadetail['handphone'] : '', 'twitter' => isset($datadetail['twitter']) ? $datadetail['twitter'] : '', 'status' => $tempstatus); } return json_encode($retData); }
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; }
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); }
/** kapan fungsi ini dipanggil? saat user login? */ function report_admin_countuseronlinetime($user_id = NULL) { // hitung total time utk user $user_id di table SessionLog // tambahkan waktu yg diperoleh ke field online_time di table Game.Achievement (userid, tipe, value) untuk tipe: online_time // table SessionLog utk user $user_id diberi flag (counted = 1) $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('SessionLog'); $user_id = isset($user_id) ? $user_id : func_arg(0); $criteria = array('user_id' => $user_id, 'counted' => array('$ne' => '1')); $sess_cursor = $lilo_mongo->find($criteria); $total_time = 0; while ($curr = $sess_cursor->getNext()) { $time_start = strtotime($curr['time_start']); $time_end = strtotime($curr['time_end']); $total_time += $time_end - $time_start; // $total_time dalam satuan second } $lilo_mongo->selectDB('Game'); $lilo_mongo->selectCollection('Achievement'); $curr_ach = $lilo_mongo->findOne(array('userid' => $user_id, 'tipe' => 'online_time')); $curr_online_time = intval($curr_ach['value']); $total_time += $curr_online_time; $lilo_mongo->update_set(array('userid' => $user_id, 'tipe' => 'online_time'), array('value' => $total_time), array('upsert' => true)); $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('SessionLog'); $lilo_mongo->update_set($criteria, array('counted' => '1'), array('multiple' => true, 'safe' => true)); // return sec2hms($total_time, true); return 1; }