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 unity_user_newuser() { $email = func_arg(0); $password = urldecode(func_arg(1)); $username = urldecode(func_arg(2)); $gender = func_arg(3) != "" ? func_arg(3) : "male"; $statemind = urldecode(func_arg(4)); $tgl_lahir = func_arg(5) != "" ? urldecode(func_arg(5)) : date('Y-m-d'); $fb_id = func_arg(6) != "" ? func_arg(6) : ""; $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('Account'); $cekada = $lilo_mongo->findOne(array("email" => $email)); $retValid = FALSE; $retMessage = "Duplicate email"; if (!$cekada) { $key = get_random(25); $id = $key; $activkey = date('Y-m-d H:i:s'); $datatinsert = array('email' => $email, 'password' => md5($password), 'username' => $email, 'join_date' => $lilo_mongo->time(strtotime(date("Y-m-d H:i:s"))), 'activation_key' => md5($activkey), 'token_key' => md5($key), 'fb_id' => $fb_id, 'access' => ''); $lilo_mongo->insert($datatinsert); // Sync between _id and lilo_id, this is a pain in the ass, why do need lilo_id in the first f*****g place????????????????// $findQuery = $lilo_mongo->findOne(array("email" => $email)); if ($findQuery) { $lilo_id = $findQuery["_id"]; $lilo_mongo->update_set(array("email" => $email), array("lilo_id" => (string) $lilo_id)); $lilo_mongo->selectCollection('Properties'); $pecahtgllahir = explode("-", $tgl_lahir); $datatinsert = array('lilo_id' => (string) $lilo_id, 'avatarname' => $username, 'fullname' => $username, 'sex' => $gender, 'website' => '', 'link' => '', 'birthday' => $tgl_lahir, 'birthday_dd' => $pecahtgllahir[2], 'birthday_mm' => $pecahtgllahir[1], 'birthday_yy' => $pecahtgllahir[0], 'state_mind' => $statemind, 'about' => '', 'picture' => '', 'location' => '', 'handphone' => '', 'twitter' => ''); $lilo_mongo->insert($datatinsert); $lilo_mongo->selectCollection('UserProfile'); $generatetime = date("Y-m-d H:i:s"); $time_start = strtotime($generatetime); $datatinsert = array('lilo_id' => (string) $lilo_id, 'StateMind' => $statemind, 'date' => $lilo_mongo->time($time_start)); $lilo_mongo->insert($datatinsert); $retValid = TRUE; $retMessage = "Succesfully created user: " . $email; write_session($id, md5($activkey), md5($key)); } } else { write_session($cekada['_id'], $cekada['activation_key'], $cekada['token_key']); } $ret = array('valid' => $retValid, 'message' => $retMessage); return json_encode($ret); }
function log_user_default() { $log_type = $_REQUEST['log_type']; $log = $_REQUEST['log']; $stacktrace = $_REQUEST['stacktrace']; $ip_address = $_SERVER['REMOTE_ADDR']; $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Logs'); $lilo_mongo->selectCollection('Error'); $log_array = array('log_type' => $log_type, 'log' => $log, 'stacktrace' => $stacktrace, 'ip_address' => $ip_address); $lilo_mongo->insert($log_array); return "1"; }
function server_admin_add() { extract($_REQUEST); $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Servers'); $lilo_mongo->selectCollection('GameServer'); if ($submitted == 1) { $game_server = array('name' => $server_admin_add_name, 'ip' => $server_admin_add_ip, 'port' => $server_admin_add_port, 'max_ccu' => $server_admin_add_max_ccu); $game_server_id = $lilo_mongo->insert($game_server); $lilo_mongo->update($game_server, array_merge($game_server, array('lilo_id' => (string) $game_server_id)), array("multiple" => false)); } $_SESSION['pop_status_msg'][] = "New server added."; header("Location: " . $_SESSION['basepath'] . 'server/admin'); exit; }
/** * 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"; }
function message_guest_shout($session_id = NULL, $shout = NULL, $circle = '') { // hanya menerima $_POST // variable yg diterima: // - session_id: diproses hanya jika session_id masih valid & aktif, meskipun nanti yg disimpan di db adalah user_id // - circle: '', 'public', [circle_name_1], [circle_name_2] // - shout = text status if (!isset($session_id) || trim($session_id) == '') { // dapatkan $session_id dari $_POST $session_id = $_POST['session_id']; } if (!isset($session_id) || trim($session_id) == '') { $session_id = $_SESSION['session_id']; } if (!isset($shout) || trim($shout) == '') { $shout = $_POST['shout']; } if (!isset($circle) || trim($circle) == '') { $circle = $_POST['circle']; } // cek apakah $session_id masih berlaku: Users.Session.time_end == '' || strtotime() - strtotime(Users.Session.time_end) < 3 * 60; $user_id = message_guest_sessionvalidation($session_id); if (!$user_id || trim($user_id) == '') { write_log(array('log_text' => "Invalid session_id: {$session_id}")); return "ERROR - Validation failed."; } $shout = trim($shout); if ($shout == '') { return "ERROR - Shout should not be empty."; } $mentioned_friends = message_guest_mentionedfriends($shout); if (strlen($shout) > 500) { $shout = substr($shout, 0, 500); } $shout = htmlspecialchars($shout); $shout = message_guest_shoutlinktomentioneduser($shout); $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Social'); $lilo_mongo->selectCollection('Shout'); $shout_data = array('user_id' => $user_id, 'shout_time' => date("Y-m-d - H:i:s"), 'shout' => $shout, 'circle' => $circle, 'mentioned_friends' => $mentioned_friends, 'mentioned_friends_notified' => 0); // notify mentioned friends dengan CRON $lilo_id = $lilo_mongo->insert($shout_data); $lilo_mongo->update($shout_data, array_merge($shout_data, array('lilo_id' => (string) $lilo_id)), array("multiple" => false)); return "OK"; }
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"; }
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; } }
function user_user_deactivate_account() { // data apa saja yang 'dipindahkan'? // Users.Account, Users.Properties, Users.GroupMember // Social.Friends (user_id dan friend_id) $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); $user_id = $_SESSION['user_id']; // 1. Users.Account $lilo_mongo->selectCollection('Account'); $criteria = array('lilo_id' => $user_id); $backup_account = $lilo_mongo->findOne($criteria); $lilo_mongo->remove($criteria); // 2. Users.Properties $lilo_mongo->selectCollection('Properties'); $criteria = array('lilo_id' => $user_id); $backup_properties = $lilo_mongo->findOne($criteria); $lilo_mongo->remove($criteria); // 3. Users.GroupMember $lilo_mongo->selectCollection('GroupMember'); $criteria = array('user_id' => $user_id); $backup_groupmember = $lilo_mongo->findOne($criteria); $lilo_mongo->remove($criteria); $lilo_mongo->selectDB('Social'); // 4. Social.Friends $lilo_mongo->selectCollection('Friends'); $criteria = array('user_id' => $user_id); $backup_friends = $lilo_mongo->findOne($criteria); $lilo_mongo->remove($criteria); // masukkan ke table Users.DeletedUsers $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('DeletedUsers'); $deletedusers = array('account' => $backup_account, 'properties' => $backup_properties, 'groupmember' => $backup_groupmember, 'friends' => $backup_friends); $lilo_mongo->insert($deletedusers); // Logout current user user_user_logout(); header("Location: " . $_SESSION['basepath']); exit; }
function mobile_avatar_addcollections() { $user_id = func_arg(0); $subject = isset($_GET['subject']) ? $_GET['subject'] : ""; $descriptions = isset($_GET['description']) ? $_GET['description'] : ""; $skin = isset($_GET['skin']) ? $_GET['skin'] : "1"; $gender = isset($_GET['gender']) ? $_GET['gender'] : "male"; $eyebrows = isset($_GET['eyebrows']) ? $_GET['eyebrows'] : ""; $eyes = isset($_GET['eyes']) ? $_GET['eyes'] : ""; $lip = isset($_GET['lip']) ? $_GET['lip'] : ""; $element_hair = isset($_GET['element_hair']) ? $_GET['element_hair'] : ""; $hair = isset($_GET['hair']) ? $_GET['hair'] : ""; $element_body = isset($_GET['element_body']) ? $_GET['element_body'] : ""; $body = isset($_GET['body']) ? $_GET['body'] : ""; $element_pants = isset($_GET['element_pants']) ? $_GET['element_pants'] : ""; $pants = isset($_GET['pants']) ? $_GET['pants'] : ""; $element_shoes = isset($_GET['element_shoes']) ? $_GET['element_shoes'] : ""; $shoes = isset($_GET['shoes']) ? $_GET['shoes'] : ""; $element_hat = isset($_GET['element_hat']) ? $_GET['element_hat'] : ""; $hat = isset($_GET['hat']) ? $_GET['hat'] : ""; $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('AvatarCollection'); $configurations = "[{'tipe':'Skin','color':'" . $skin . "'},{'tipe':'Hand','element':'" . $gender . "_body_hand','material':'" . $gender . "_body'},{'tipe':'gender','element':'" . $gender . "_base'},{'tipe':'Face','element':'" . $gender . "_head','material':'' ,'eye_brows':'" . $eyebrows . "','eyes':'" . $eyes . "','lip':'" . $lip . "'},{'tipe':'Hair','element':'" . $element_hair . "','material':'" . $hair . "'},{'tipe':'Body','element':'" . $element_body . "','material':'" . $body . "'},{'tipe':'Pants','element':'" . $element_pants . "','material':'" . $pants . "'},{'tipe':'Shoes','element':'" . $element_shoes . "','material':'" . $shoes . "'},{'tipe':'Hat','element':'" . $element_hat . "','material':'" . $hat . "'}]"; $datainsert = array("user_id" => $user_id, "configuration" => $configurations, "subject" => $subject, "descriptions" => $descriptions, "gender" => $gender, "date_add" => $lilo_mongo->time(strtotime(date("Y-m-d H:i:s")))); $lilo_mongo->insert($datainsert); $output['collectionsCount'] = $lilo_mongo->count(array("user_id" => $user_id)); return json_encode($output); }
function friend_user_add($args = NULL) { // args: user_id, friend_user_id, circle_array, approving_time if (!isset($args)) { $args = $_REQUEST; } extract($args); if (!isset($user_id)) { $user_id = $_SESSION['user_id']; } if (!isset($friend_user_id)) { return "0"; } $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Social'); // Social: Circles, Friends, FriendInvitations, PersonalMessages, Shout $lilo_mongo->selectCollection('Friends'); $approving_time = time(); $friend_data_1 = array('user_id' => $user_id, 'friend_user_id' => $friend_user_id, 'circle_array' => $circle_array, 'approving_time' => $approving_time); $lilo_mongo->insert($friend_data_1); }
function message_user_shout_reply() { /* die(print_r($_REQUEST, true)); Array ( [q] => message/user/shout_reply [comment] => Reply to testsdfsdfsdfsdf [circle] => [shout_id] => 4fa0897cc1b4ba341b000000 [__utma] => 111872281.1470462402.1327380803.1336389708.1336418449.37 [__utmz] => 111872281.1327380803.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) [MANTIS_STRING_COOKIE] => d51124df32701606e74f6e86a7da46f7bfb7835038e6ea4748643db7e4c2f0c0 [POSTNUKESID] => d365816dbaef684d8522d130c239fc29 [PHPSESSID] => ibi020pgc7hiesda9dmih8gip1 [__utmc] => 111872281 [__utmb] => 111872281.0.10.1336418449 ) */ extract($_REQUEST); if (!isset($shout_id)) { die("Error"); } if (trim($comment) == '') { die('Error: empty comment'); } $user_id = $_SESSION['user_id']; $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Social'); $lilo_mongo->selectCollection('ShoutComment'); $reply_data = array('shout_id' => $shout_id, 'datetime' => date("Y-m-d - H:i:s"), 'comment' => $comment, 'time' => time()); $lilo_id = $lilo_mongo->insert($reply_data); $lilo_mongo->update($reply_data, array_merge($reply_data, array('lilo_id' => (string) $lilo_id)), array("multiple" => false)); // delete all related comments print "OK"; exit; }
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 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 create_new_admin($username = NULL, $password = NULL, $email = NULL) { if (trim($username) == '' || trim($password) == '' || trim($email) == '') { return FALSE; } $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('Admin'); // cek apakah username / email sudah digunakan $admin_data = $lilo_mongo->find(array('username' => $username)); while ($curr = $admin_data->getNext()) { return "Username {$username} sudah digunakan!"; } $admin_data = $lilo_mongo->find(array('email' => $email)); while ($curr = $admin_data->getNext()) { return "Email {$email} sudah digunakan!"; } $new_admin = array('username' => $username, 'password' => $password, 'email' => $email); $lilo_mongo->insert($new_admin); return TRUE; }
function mobile_social_addcommentnews() { $user_email = func_arg(0); $user_id = _get_id_user($user_email); $news_id = func_arg(1); $comment = isset($_GET['comment']) ? $_GET['comment'] : ""; $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Social'); $lilo_mongo->selectCollection('NewsComments'); $data = $lilo_mongo->insert(array("user_id" => $user_id, "news_id" => $news_id, "comment" => $comment, "datetime" => $lilo_mongo->time(strtotime(date("Y-m-d H:i:s"))))); $output['count'] = $lilo_mongo->count(array("news_id" => $news_id)); return json_encode($output); }
function friend_user_submitchat() { 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; } $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Social'); $lilo_mongo->selectCollection($table_name); $text = htmlspecialchars(trim($text)); if ($text != '') { // masukkan ke DB $data = array('time' => $curr_time, 'speaker' => $user_id, 'text' => $text); $lilo_mongo->insert($data); } // CATATAN TAMBAHAN //saat rully kirim chat ke mukhtar, sekalian masukin data ke table ChatAlert (sender: rully, receiver: mukhtar, time: time() ) // //mukhtar: saat loadFriendList, cek jika ada row di ChatAlert dengan (receiver:mukhtar), dapatkan semua sender-nya, // //jika window chat utk sender blm ada: // show circlenya jika masih hidden, ubah warna sender jadi merah // atau // sekalian show windownya? [v] // //jika window chat utk sender sudah ada: do nothing $lilo_mongo->selectCollection("ChatAlert"); $data = array('sender' => $user_id, 'receiver' => $friend_id, 'time' => $curr_time); $lilo_mongo->insert($data); return "1"; }
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 article_admin_addslide($no = NULL, $title = NULL, $image = NULL, $description = NULL, $link = NULL) { if (!isset($no) || !isset($title) || !isset($image) || !isset($description) || !isset($link)) { $no = $_POST['no']; $title = $_POST['title']; $image = $_POST['image']; $description = $_POST['description']; $link = $_POST['link']; } $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Articles'); $lilo_mongo->selectCollection('Slideshow'); $slide = array('no' => $no, 'title' => $title, 'image' => $image, 'description' => $description, 'link' => $link); $lilo_id = $lilo_mongo->insert($slide); $lilo_mongo->update($slide, array_merge($slide, array('lilo_id' => (string) $lilo_id)), array('multiple' => false)); return (string) $lilo_id; }
function mobile_mix_create() { $email = func_arg(0); $mixName = func_arg(1); $configuration = $_POST["configuration"]; $pathimages = PATH_IMAGE_UPLOAD; $allowedExts = array("jpg", "jpeg", "gif", "png"); $success = FALSE; $message = ""; $filename = $_FILES['file']['name']; if (isset($_FILES['file']["name"])) { if ($_FILES['file']['name'] != "") { $extension = end(explode(".", strtolower($_FILES['file']["name"]))); //$filetype=$_FILES["file"]["type"]; //$filesize=$_FILES["file"]["size"]; if (in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { $message = "Invalid mix preview."; } else { $path = $pathimages; if (file_exists($path . $_FILES["file"]["name"])) { $message = "Filename exists.."; } else { //echo "File : " . $_FILES['file']['tmp_name'] . " => " .$path.$_FILES["file"]["name"]; if (@move_uploaded_file($_FILES["file"]["tmp_name"], $path . $_FILES["file"]["name"])) { $message = "File berhasil terupload"; $success = TRUE; $filename = $_FILES["file"]["name"]; } else { $message = "File gagal terupload"; } } } } else { $message = "Image type does not supported"; } } else { $message = "Image data empty"; } } else { $message = "Failed upload mix preview"; } $userDetails = __getUserDetails($email); $mongo = new LiloMongo(); $mongo->selectDB("Users"); $mongo->selectCollection("AvatarMix"); /* * 1. userid. 2. authorname. 3. Nama. 4. Deskripsi 5. tanggal dan jam pembuatan. 6. konfigurasi 7. gender. 8. body type (medium, thin, fat) 9. picture.(screenshot) */ $data = array("userid" => $userDetails["id"], "author" => isset($userDetails["avatarname"]) ? $userDetails['avatarname'] : $userDetails['username'], "name" => $mixName, "description" => "", "date" => date('Y-m-d H:i:s'), "gender" => $userDetails["gender"], "bodytype" => $userDetails["bodytype"], "picture" => "mix/" . $filename, "configuration" => $configuration); $mongo->insert($data); $output = array('success' => $success, 'filename' => $filename, 'message' => $message); return json_encode($output); }
function user_guest_login($uname = NULL, $passwd = NULL) { // bisa diakses lewat web dgn path: /user/user/login/[username/password] // atau dipanggil langsung dgn fungsi user_guest_login('username','password') $username = isset($uname) ? (string) $uname : (string) func_arg(0); $password = isset($passwd) ? (string) $passwd : (string) func_arg(1); if (!isset($username) || trim($username) == '') { $username = $_POST['username']; } if (!isset($password) || trim($password) == '') { $password = $_POST['password']; } // die("$username, $password"); if (strlen(trim($username)) == 0 || strlen(trim($password)) == 0) { unset($_SESSION['session_id']); unset($_SESSION['username']); unset($_SESSION['user_id']); return "0"; } unset($_SESSION['pop_error_msg']); unset($_SESSION['pop_status_msg']); // connect to mongodb using default setting $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); $lilo_mongo->selectCollection('Account'); $user_exists = $lilo_mongo->findOne(array('username' => $username, 'password' => md5($password))); // revisi 04072012: jika username tidak ditemukan, gunakan email if (!is_array($user_exists) || count($user_exists) == 0) { $user_exists = $lilo_mongo->findOne(array('email' => $username, 'password' => md5($password))); $username = $user_exists['username']; } $session_id = $_SESSION['session_id']; $session_username = $_SESSION['username']; // bagaimana jika $session_username berbeda dengan $username? $cur_date = date("Y-m-d H:i:s"); if (is_array($user_exists) && count($user_exists)) { // die("<pre>".print_r($user_exists, true)."</pre>"); if (trim($session_id) == '' || trim($session_username) == '') { $user_id = (string) $user_exists['_id'] . ''; // generate session_id $session_id = md5($cur_date . " - " . $username); $_SESSION['session_id'] = $session_id; $_SESSION['username'] = $username; $_SESSION['user_id'] = $user_id; // simpan di table session // array(session_id, username, time_start, time_end) // untuk mencegah user login di lebih dari satu browser, jika data session utk user_id sudah ada, maka lakukan hanya update // lakukan insert hanya bila data session utk user_id belum ada $lilo_mongo->selectCollection('Session'); $exist_user_id = $lilo_mongo->findOne(array('user_id' => $user_id)); if (is_array($exist_user_id) && count($exist_user_id)) { // $lilo_mongo->update_set( // array( // 'user_id' => $user_id, // ), // array( // 'session_id' => $session_id, //// 'user_id' => $user_id, //// 'username' => $username, //// 'time_start' => $cur_date, //// 'time_end' => '' // ) // ); $lilo_mongo->selectCollection('SessionLog'); $lilo_mongo->insert($exist_user_id); } // else { $lilo_mongo->selectCollection('Session'); $lilo_mongo->remove(array('user_id' => $user_id)); $lilo_mongo->insert(array('session_id' => $session_id, 'user_id' => $user_id, 'username' => $username, 'time_start' => $cur_date, 'time_end' => '', 'HTTP_USER_AGENT' => $_SERVER['HTTP_USER_AGENT'], 'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'], 'REMOTE_HOST' => $_SERVER['REMOTE_HOST'])); // } report_admin_countuseronlinetime($user_id); return $session_id; } else { // sepertinya kondisi ini tidak akan terpenuhi... :P if ($session_username == $username) { // mencoba login, padahal sudah terdaftar... // biarkan saja, sepertinya orang ini ga ada kerjaan return $session_id; } else { // sudah terdaftar, kemudian mencoba login dengan username dan password yg lain // logout dulu, baru login dengan username yg baru // update($array_criteria, $array_newobj, $array_options) $array_criteria = array('session_id' => $session_id); $array_newobj = array('$set' => array('time_end' => $cur_date)); $array_options = array('upsert' => true); $lilo_mongo->selectCollection('Session'); $lilo_mongo->update($array_criteria, $array_newobj, $array_options); $session_id = md5($cur_date . " - " . $username); $_SESSION['session_id'] = $session_id; $_SESSION['username'] = $username; // simpan di table session // array(session_id, username, time_start, time_end) $lilo_mongo->selectCollection('Session'); $lilo_mongo->insert(array('session_id' => $session_id, 'username' => $username, 'time_start' => $cur_date, 'time_end' => '', 'HTTP_USER_AGENT' => $_SERVER['HTTP_USER_AGENT'], 'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'], 'REMOTE_HOST' => $_SERVER['REMOTE_HOST'])); return $session_id; } } } else { unset($_SESSION['session_id']); unset($_SESSION['username']); unset($_SESSION['user_id']); return "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; }
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; }