Exemple #1
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";
}
Exemple #2
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";
}
Exemple #3
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;
}
Exemple #4
0
function avatar_admin_set_default_configuration($avatar_conf = NULL, $gender = NULL, $size = NULL, $name = NULL)
{
    if (!isset($avatar_conf)) {
        $avatar_conf = $_REQUEST['avatar_conf'];
    }
    if (!isset($size)) {
        $size = $_REQUEST['size'];
    }
    if (!isset($gender)) {
        $gender = $_REQUEST['gender'];
    }
    if (!isset($name)) {
        $name = $_REQUEST['name'];
    }
    $name = trim($name);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('DefaultAvatar');
    $insert_id = $lilo_mongo->update_set(array('gender' => $gender, 'size' => $size, 'name' => $name), array('gender' => $gender, 'size' => $size, 'name' => $name, 'configuration' => $avatar_conf), array('upsert' => true));
    return "1";
}
Exemple #5
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;
    }
}
Exemple #6
0
function user_user_properties_update()
{
    //	return "<pre>" . print_r($_REQUEST, true) . "\n\n" . print_r($_FILES) . "</pre>";
    /*
    Array ( [properties_x_profile_picture] => Array ( [name] => 05df4031edecf51406421e912bda5bc5.png [type] => image/png [tmp_name] => C:\Development\Web\xampp\tmp\php13B9.tmp [error] => 0 [size] => 8192 ) )
    Array
    (
        [q] => user/user/properties_update
        [account_x_fullname] => Rully Wijoyo
        [__utma] => 111872281.217400160.1312219046.1313694564.1314331379.15
        [__utmz] => 111872281.1312219046.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
        [PHPSESSID] => r54l10rb1hl9bttocatt7hke53
    )
    1
    Array
    (
        [q] => user/user/properties_update
        [properties_x_fullname] => Rully Wijoyo
        [account_x_email] => rully@m-stars.net
        [properties_x_birthday] => 23-02-2012
        [properties_x_sex] => male
        [__utma] => 111872281.1470462402.1327380803.1327380803.1327380803.1
        [__utmz] => 111872281.1327380803.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
        [PHPSESSID] => omsh3r2onegu6ommo5t3ch21p3
    )
    */
    //	die("<pre>" . print_r($_REQUEST, true) . "</pre>");
    extract($_REQUEST);
    if ($account_x_password != $confirm_password || $account_x_password == '') {
        unset($account_x_password);
        unset($_REQUEST['account_x_password']);
    }
    $user_id = $_SESSION['user_id'];
    $account = array();
    $properties = array();
    foreach ($_REQUEST as $key => $val) {
        $processed_variable = strpos($key, '_x_');
        if ($processed_variable !== false) {
            $key_explode = explode('_x_', $key);
            ${$key_explode[0]}[$key_explode[1]] = $val;
        }
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    // function update_set($array_criteria, $array_newobj, $array_options = array("multiple" => true)){
    // update table Users.Account dengan variable $account
    $lilo_mongo->selectCollection('Account');
    if (count($account)) {
        if (isset($account['email'])) {
            if (!eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})\$", $account['email'])) {
                $_SESSION['pop_error_msg'][] = "Email yang Anda masukkan tidak valid";
                header("Location: " . $_SESSION['basepath'] . 'profile');
                exit;
            }
        }
        $lilo_mongo->update_set(array('lilo_id' => $user_id), $account, array('multiple' => false, 'upsert' => true, 'safe' => true));
    }
    // update table Users.Properties dengan variable $properties
    $lilo_mongo->selectCollection('Properties');
    if (count($properties)) {
        if (isset($properties['fullname']) && strlen($properties['fullname']) > 40) {
            $properties['fullname'] = substr($properties['fullname'], 0, 40);
        }
        $lilo_mongo->update_set(array('lilo_id' => $user_id), $properties, array('multiple' => false, 'upsert' => true, 'safe' => true));
    }
    // tangani file upload
    // TODO: buat thumbnail ukuran kecil, sedang, besar & orig file
    if (isset($_FILES['properties_x_profile_picture'])) {
        $uploaddir = 'user_generated_data/profile_picture/';
        if (!is_dir($uploaddir)) {
            mkdir($uploaddir);
        }
        $uploadfile = $uploaddir . basename($_FILES['properties_x_profile_picture']['name']);
        if (move_uploaded_file($_FILES['properties_x_profile_picture']['tmp_name'], $uploadfile)) {
            $profile_picture = $_FILES['properties_x_profile_picture']['name'];
            $lilo_mongo->update_set(array('lilo_id' => $user_id), array('profile_picture' => $profile_picture), array('multiple' => false, 'upsert' => true, 'safe' => true));
        }
    }
    $_SESSION['pop_status_msg'][] = "Your profile updated successfully.";
    //	return print_r($account, true);
    //	header("Location: " . $_SESSION['basepath'] . 'user/user/properties');
    header("Location: " . $_SESSION['basepath'] . 'myprofile');
    exit;
}
Exemple #7
0
function avatar_user_set_configuration($avatar_conf = NULL, $size = NULL)
{
    if (!isset($avatar_conf)) {
        $avatar_conf = $_REQUEST['avatar_conf'];
    }
    if (!isset($size)) {
        $size = $_REQUEST['size'];
    }
    // bagaimana format avatar_conf?
    /*
    	$avatar_conf = array(
    		array('tipe' => "gender", 'element' => "male_base"),
    		array('tipe' => 'Face','element' => 'male_face-1','material' => 'male_face-1'),
    		array('tipe' => 'Hair','element' => 'male_hair-2','material' => 'male_hair-2_blond'),
    		array('tipe' => 'Body','element' => 'male_top-2','material' => 'male_top-2_green'),
    		array('tipe' => 'Pants','element' => 'male_pants-1','material' => 'male_pants-1_green'),
    		array('tipe' => 'Shoes','element' => 'male_shoes-2','material' => 'male_shoes-2_red'),
    	);
    	
    	var message = 
    "[
    	{'tipe':'gender','element':'male_base'},
    	{'tipe':'Face','element':'male_face-1','material':'male_face-1'},
    	{'tipe':'Hair','element':'male_hair-2','material':'male_hair-2_blond'},
    	{'tipe':'Body','element':'male_top-2','material':'male_top-2_green'},
    	{'tipe':'Pants','element':'male_pants-1','material':'male_pants-1_green'},
    	{'tipe':'Shoes','element':'male_shoes-2','material':'male_shoes-2_red'}]";
    */
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Avatar');
    $insert_id = $lilo_mongo->update_set(array('user_id' => $_SESSION[user_id]), array('user_id' => $_SESSION[user_id], 'configuration' => $avatar_conf, 'size' => $size), array('upsert' => true));
    return "1";
}
Exemple #8
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);
}
Exemple #9
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;
}
Exemple #10
0
function quest_admin_ws_quest($op = NULL, $id = NULL, $data = NULL)
{
    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('Quest');
    switch ($op) {
        case 'create':
            $data = $_POST;
            // return "<pre>" . print_r($data, true) . "<pre>";
            // cek dulu apakah ID yg dimasukkan sudah ada di db
            $exists = $lilo_mongo->findOne(array('ID' => $data['ID']));
            if (count($exists)) {
                return "Data Quest dengan ID = " . $data['ID'] . " sudah ada di database!";
            }
            $lilo_id = $lilo_mongo->insert($data);
            $lilo_mongo->update($data, array_merge($data, array('lilo_id' => (string) $lilo_id)), array("multiple" => false));
            return "1";
            break;
        case 'update':
            $data = $_POST;
            $exists_ = $lilo_mongo->findOne(array('ID' => $data['ID']));
            $exist = $exists_['lilo_id'] != $data['lilo_id'];
            if ($exists) {
                return "Data Quest dengan ID = " . $data['ID'] . " sudah ada di database! Gunakan ID lain";
            }
            $lilo_mongo->update_set(array('lilo_id' => $data['lilo_id']), $data);
            return "1";
            break;
        case 'delete':
            $lilo_id = func_arg(1);
            $lilo_mongo->remove(array('lilo_id' => $lilo_id));
            return "1";
            break;
            // detail == getone == findONe
            // digunakan unity web player
        // detail == getone == findONe
        // digunakan unity web player
        case 'detail':
            $ID = func_arg(1);
            //			$result = $lilo_mongo->findOne(array('lilo_id' => $lilo_id));
            $result = $lilo_mongo->findOne(array('ID' => $ID));
            $result['IsActive'] = strtolower($result['IsActive']) == 'true' ? true : false;
            $result['IsDone'] = strtolower($result['IsDone']) == 'true' ? true : false;
            $result['IsReturn'] = strtolower($result['IsReturn']) == 'true' ? true : false;
            if (count($result)) {
                //				return json_encode($result);
                unset($result['_id']);
                unset($result['_id']);
                unset($result['lilo_id']);
                unset($result['Energy']);
                unset($result['Item']);
                $result['ID'] = intval($result['ID']);
                $result['RequiredEnergy'] = intval($result['RequiredEnergy']);
                $result['Requirement'] = intval($result['Requirement']);
                $result = json_encode($result);
                return $result;
                //				return str_replace('"', "'", $result);
            } else {
                return '';
            }
            //			return json_encode($result);
            break;
            // digunakan oleh quest editor
        // digunakan oleh quest editor
        case 'detail_by_lilo_id':
            $lilo_id = func_arg(1);
            $result = $lilo_mongo->findOne(array('lilo_id' => $lilo_id));
            if (count($result)) {
                //				return json_encode($result);
                $result = json_encode($result);
                return $result;
                //				return str_replace('"', "'", $result);
            } else {
                return '';
            }
            break;
    }
    // default: read
    // read == getall == find
    $quests = array();
    $quests_cursor = $lilo_mongo->find();
    while ($quest = $quests_cursor->getNext()) {
        $quests[] = $quest;
    }
    //	return json_encode($quests);
    $quests = json_encode($quests);
    return $quests;
    //	return str_replace('"', "'", $quests);
}
Exemple #11
0
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;
}
Exemple #12
0
function quest_admin_editdialogstorysubmit()
{
    $params = array();
    parse_str($_REQUEST['serialized_data'], $params);
    // die("Array yg dihasilkan: \n\r" . print_r($params, true));
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Game');
    // Game: DialogStory, Dialog, DialogOption, Quest
    $lilo_mongo->selectCollection('DialogStory');
    $lilo_id = $params['lilo_id'];
    //	$dialog_story_name = $params['dialog_story_name'];
    //	$dialog_story_description = $params['dialog_story_description'];
    unset($params['lilo_id']);
    //	unset($params['dialog_story_name']);
    //	unset($params['dialog_story_description']);
    foreach ($params as $key => $val) {
        //die("params key " . $params[$key]);
        if (strpos($key, 'option_content_quest_') !== false) {
            $params[$key] = intval($val);
        }
    }
    // die("Array yg dihasilkan: \n\r" . print_r($params, true));
    $criteria = array('lilo_id' => $lilo_id);
    $update_data = array('lilo_id' => $lilo_id, 'description' => $params['dialog_story_description'], 'all_variable_2' => $params);
    $lilo_mongo->update_set($criteria, $update_data);
    return 'OK';
}
Exemple #13
0
function mobile_avatar_setbodytype()
{
    $email = func_arg(0);
    $bodysize = func_arg(1);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $query = $lilo_mongo->findOne(array('email' => $email));
    $id = "";
    $isValid = false;
    $config = "";
    $gender = "male";
    if ($query) {
        $id = (string) $query['_id'];
        $username = $query['username'];
        $lilo_mongo->selectCollection('Properties');
        $data = $lilo_mongo->findOne(array('lilo_id' => $id));
        if ($data) {
            $gender = $data['sex'];
            $lilo_mongo->update_set(array('lilo_id' => $id), array('body_size' => $bodysize));
            $isValid = true;
        } else {
            $datatinsert = array('lilo_id' => (string) $id, 'avatarname' => $username, 'fullname' => $username, 'sex' => $gender, 'body_size' => 'medium', 'website' => '', 'link' => '', 'birthday' => '', 'birthday_dd' => '', 'birthday_mm' => '', 'birthday_yy' => '', 'state_mind' => '', 'about' => '', 'picture' => '', 'location' => '', 'handphone' => '', 'twitter' => '');
            $lilo_mongo->insert($datatinsert);
        }
        /// Get and set from the Default Avatar
        $lilo_mongo->selectDB("Assets");
        $lilo_mongo->selectCollection("DefaultAvatar");
        $data2 = $lilo_mongo->findOne(array('gender' => $gender, 'size' => $bodysize));
        if ($data2) {
            $isValid = true;
            $config = str_replace("\"", "", $data2['configuration']);
            $configuration = array('user_id' => $id, 'size' => $bodysize, 'configuration' => $config);
            // Now save our configuration
            $lilo_mongo->selectDB("Users");
            $lilo_mongo->selectCollection('Avatar');
            $data3 = $lilo_mongo->findOne(array('user_id' => $id));
            if (isset($data3)) {
                $lilo_mongo->update_set(array('user_id' => $id), $configuration);
            } else {
                $lilo_mongo->insert($configuration);
            }
        }
    }
    $output = array('id' => $id, 'success' => $isValid, 'bodyType' => $bodysize, 'configuration' => $config);
    return json_encode($output);
}
Exemple #14
0
function user_guest_add_user($args = NULL)
{
    // username, password, email
    if (isset($args) && is_array($args) && count($args) > 0) {
        extract($args);
        $birthday_expl = explode('/', $birthday);
        $birthday_dd = $birthday_expl[0];
        $birthday_mm = $birthday_expl[1];
        $birthday_yy = $birthday_expl[2];
    } else {
        $fullname = $_POST['fullname'];
        $username = $_POST['username'];
        $password = $_POST['password'];
        $email = $_POST['email'];
        $avatarname = $_POST['avatarname'];
        $handphone = $_POST['handphone'];
        $twitter = $_POST['twitter'];
        // 'sex':new_sex,'birthday':new_birthday,'location':new_location,
        $sex = $_POST['sex'];
        $birthday = $_POST['birthday'];
        $birthday_expl = explode('/', $birthday);
        $birthday_dd = $birthday_expl[0];
        $birthday_mm = $birthday_expl[1];
        $birthday_yy = $birthday_expl[2];
        $location = $_POST['location'];
    }
    if (!isset($via_fb)) {
        require_once 'libraries/recaptcha/recaptchalib.php';
        $privatekey = "6Lc4rc0SAAAAAPcmFERN1OCwB05q72wvPipQS5zX";
        $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
        if (!$resp->is_valid) {
            // What happens when the CAPTCHA was entered incorrectly
            return "ERROR - The reCAPTCHA wasn't entered correctly. Try it again.";
            //  [" . $resp->error . "]
            // $_SESSION['pop_error_msg'][] = "The reCAPTCHA wasn't entered correctly. Try it again. [" . $resp->error . "]";
            // header("Location: " . $_SESSION['basepath']);
            // exit;
        }
    }
    $config = $_SESSION['config'];
    // validasi semua input...
    // only alpha numeric allowed for username
    // Revisi 04072012: username sama dengan email
    //	if(!(ctype_alnum($username) && ctype_alnum($password))){
    //		return "ERROR - Use only letters and digits for username and password";
    //	}
    //
    //  if(strlen(trim($username)) < 4){
    //    return "ERROR - Use at least 4 character for username";
    //  }
    if (strlen(trim($password)) < 6) {
        return "ERROR - Use at least 6 character for password";
    }
    // TODO: email validation
    if (!eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})\$", $email)) {
        return "ERROR - Invalid email";
    }
    // Revisi 04072012: username sama dengan email
    // jadi yg dicek redundan: avatar name
    //$username_exists = user_user_redundancy_check('username', $username);
    //if($username_exists){
    //  return "ERROR - Username $username already taken. Use another username.";
    //}
    $avatarname_exists = user_guest_property_redundancy_check('avatarname', $avatarname);
    if ($avatarname_exists) {
        return "ERROR - Avatar name {$avatarname} already taken. Use another avatar name.";
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $email_exists = user_user_redundancy_check('email', $email);
    if ($email_exists) {
        if (isset($via_fb)) {
            // koneksikan kedua account
            // user dapat login dengan username & password PB yg sudah dia daftarkan sebelumnya
            //	dan dia bisa juga login dengan facebook
            //	username: sama dengan email
            //	password: ada 2, password dan fb_password
            //		password adalah password lama
            //		fb_password adalah password yg di-set saat register via facebook (saat ini sama dengan fb id)
            //	jadi, cukup melakukan update di record user dgn email tsb dengan menambahkan field fb_password
            //		saat login, pengecekan password dilakukan pada kedua field (password & fb_password)
            //	yg bisa di update di account setting hanya 'password'
            //	'fb_password' tidak dapat diupdate.
            $criteria = array('email' => $email);
            $newobj = array('fb_password' => md5($fb_id), 'fb_id' => $fb_id);
            $options = array("multiple" => false);
            $lilo_mongo->update_set($criteria, $newobj, $options);
            $user_data = $lilo_mongo->findOne($criteria);
            // perlu langsung login atau tidak?
            $_SESSION['user_id'] = $user_data['lilo_id'];
            $_SESSION['username'] = $user_data['username'];
            $_SESSION['fullname'] = $user_data['$fullname'];
            user_user_login($username, $fb_id);
            return 'OK';
        } else {
            return "ERROR - Email already used. Use another email.";
            // STRING JANGAN DIUBAH, KARENA DIGUNAKAN DI index.php saat registrasi via Facebook
        }
    }
    $join_date = time();
    $act_key = $username . $join_date . rand(0, 9999);
    $activation_key = md5($act_key);
    // masukkan ke DB
    $user_data = array('email' => htmlspecialchars($email), 'password' => md5($password), 'username' => htmlspecialchars($username), 'join_date' => $join_date, 'activation_key' => $activation_key, 'fb_id' => $fb_id);
    $lilo_id = $lilo_mongo->insert($user_data);
    $lilo_mongo->update($user_data, array_merge($user_data, array('lilo_id' => (string) $lilo_id)), array("multiple" => false));
    // masukkan fullname ke table Properties
    // update 28 Juni 2012: tambahkan field handphone & twitter
    $lilo_mongo->selectCollection('Properties');
    $lilo_mongo->insert(array('lilo_id' => (string) $lilo_id, 'fullname' => htmlspecialchars($fullname), 'avatarname' => htmlspecialchars($avatarname), 'handphone' => htmlspecialchars($handphone), 'twitter' => htmlspecialchars($twitter), 'sex' => htmlspecialchars($sex), 'birthday' => htmlspecialchars($birthday), 'birthday_dd' => htmlspecialchars($birthday_dd), 'birthday_mm' => htmlspecialchars($birthday_mm), 'birthday_yy' => htmlspecialchars($birthday_yy), 'location' => htmlspecialchars($location)));
    // daftarkan user ini ke group 'user'
    // sampe seneee...
    $lilo_mongo->selectCollection('Group');
    // dapatkan lilo_id untuk name: 'user'
    $group_ = $lilo_mongo->findOne(array('name' => 'user'));
    $group_id = $group_['lilo_id'];
    $lilo_mongo->selectCollection('GroupMember');
    $lilo_mongo->insert(array('user_id' => (string) $lilo_id, 'group_id' => $group_id));
    $lilo_mongo->close();
    if (isset($_POST['automate_login']) && $_POST['automate_login'] == '1' || isset($automate_login) && $automate_login == '1') {
        $_SESSION['user_id'] = (string) $lilo_id;
        $_SESSION['username'] = $username;
        $_SESSION['fullname'] = $fullname;
        user_user_login($username, $password);
    }
    // semua OK? return 'OK'
    return "OK";
}
Exemple #15
0
function article_admin_updateslide($lilo_id = NULL, $no = NULL, $title = NULL, $description = NULL, $image = NULL, $link = NULL)
{
    if (!isset($lilo_id) || !isset($no) || !isset($title) || !isset($description) || !isset($image)) {
        $lilo_id = $_POST['lilo_id'];
        $no = $_POST['no'];
        $title = $_POST['title'];
        $description = $_POST['description'];
        $image = $_POST['image'];
        $link = $_POST['link'];
    }
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Articles');
    $lilo_mongo->selectCollection('Slideshow');
    // update_set($array_criteria, $array_newobj, $array_options = array("multiple" => true))
    $array_criteria = array('lilo_id' => $lilo_id);
    $array_newobj = array('no' => $no, 'title' => $title, 'description' => $description, 'image' => $image, 'link' => $link);
    $lilo_mongo->update_set($array_criteria, $array_newobj);
    return "OK";
}
Exemple #16
0
function friend_user_ws_deletefromcircle($args = NULL)
{
    if (!isset($args)) {
        $args = $_REQUEST;
    }
    extract($args);
    if (!isset($friend_id) || !isset($circle_name)) {
        return 'Data yang Anda kirimkan tidak lengkap';
    }
    if (!isset($user_id)) {
        $user_id = $_SESSION['user_id'];
    }
    // hapus $friend_id dari circle $circle_name
    // di table Friends untuk user_id = $_SESSION['user_id']
    // dapatkan dulu detail dari Friends
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Social');
    $lilo_mongo->selectCollection('Friends');
    // jika User sudah ada di 'Outer Circle', hapus dari table Friends
    if (trim($circle_name) == 'Outer Circle') {
        $lilo_mongo->remove(array('user_id' => $user_id, 'friend_id' => $friend_id));
        return "1";
    }
    $friend_data = $lilo_mongo->findOne(array('user_id' => $user_id, 'friend_id' => $friend_id));
    $old_friend_data = $friend_data;
    /*
    $friend_data = Array
    (
        [user_id] => 4df6e7192cbfd4e6c000fd9b
        [friend_id] => 4e38df26c1b4ba8c09000001
        [circle_array] => Array
            (
                [0] => M-Stars
                [1] => MU FC
            )
    
        [approval_time] => 1317191174
        [_id] => MongoId Object
            (
                [$id] => 4e82be06c1b4ba6c20000000
            )
    
        [lilo_id] => 4e82be06c1b4ba6c20000000
    )
    */
    $friend_data['circle_array'] = array_diff((array) $friend_data['circle_array'], array($circle_name));
    $lilo_mongo->update_set(array('user_id' => $user_id, 'friend_id' => $friend_id), array('circle_array' => $friend_data['circle_array']));
    return '1';
    //	return "SEMUA DATA, circle: $circle_name, friend_id: $friend_id" . print_r($friend_data, true) . print_r($old_friend_data, true);
    //	return "User ID Anda: $user_id, Data yang Anda kirim: " . $friend_id . ", " . $circle_name;
}
Exemple #17
0
function unity_user_userid()
{
    $email = func_arg(0);
    $userid = func_arg(1);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Account');
    $retValid = FALSE;
    $retMessage = "Gagal mengubah userid!";
    $cekada = $lilo_mongo->findOne(array("email" => $email, '_id' => $lilo_mongo->mongoid((string) $_SESSION['a_id'])));
    if ($cekada) {
        $cekada2 = $lilo_mongo->findOne(array("username" => $userid));
        if (!$cekada) {
            $datatinsert = array('username' => $userid);
            $lilo_mongo->update_set(array('_id' => $lilo_mongo->mongoid($cekada['_id'])), $datatinsert);
            $retValid = TRUE;
            $retMessage = "UserId berhasil di ubah!";
        } else {
            $retMessage = "UserId telah digunakan, user id gagal di ubah!";
        }
    } else {
        $retMessage = "Session login telah habis!";
    }
    $ret = array('valid' => $retValid, 'message' => $retMessage);
    return json_encode($ret);
}
Exemple #18
0
function asset_admin_channel_delete($channel_id = NULL)
{
    $channel_id_ = isset($channel_id) ? $channel_id : func_arg(0);
    // pastikan channel ini tidak ada yg sedang online
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('Channel');
    $channel = $lilo_mongo->findOne(array('lilo_id' => $channel_id_));
    if (intval($channel['current_ccu']) == 0) {
        $lilo_mongo->remove(array('lilo_id' => $channel_id_));
        // update Level.channel_number
        $level_id = $channel['level_id'];
        $lilo_mongo->selectCollection('Level');
        $level = $lilo_mongo->findOne(array('lilo_id' => $level_id));
        $channel_number = $level['channel_number'] - 1;
        if ($channel_number < 0) {
            $channel_number = 0;
        }
        $lilo_mongo->update_set(array('lilo_id' => $level_id), array('channel_number' => $channel_number));
        return "1";
    }
    return "Channel tidak dapat dihapus. Masih ada pemain yang menggunakan channel ini.";
}
Exemple #19
0
function ui_user_new_avatar_name()
{
    $avatar_name = func_arg(0);
    $avatar_name = htmlspecialchars($avatar_name);
    // update properties avatarname utk lilo_id = $user_id
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection('Properties');
    $lilo_mongo->update_set(array('lilo_id' => $_SESSION['user_id']), array('avatarname' => $avatar_name));
    $_SESSION['avatarname'] = $avatar_name;
    header('Location: ' . $_SESSION['basepath']);
    exit;
}
Exemple #20
0
/**
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;
}