Example #1
0
function __store_bodypart($email, $tipe, $filter, $id_brand, $start, $limit)
{
    $userDetails = __getUserDetails($email);
    $output = array();
    if ($userDetails) {
        $bodytype = !isset($userDetails['bodytype']) || $userDetails['bodytype'] == "" ? "medium" : $userDetails['bodytype'];
        $gender = $userDetails['gender'];
        $mongo = new LiloMongo();
        $mongo->selectDB("Assets");
        $mongo->selectCollection("Avatar");
        $avatar = null;
        $count = 0;
        if ($tipe == "hat") {
            $avatar = $mongo->find_pagging(array('tipe' => $tipe, "brand_id" => $id_brand), $start, $limit, array());
            $count = $mongo->count(array('tipe' => $tipe, "brand_id" => $id_brand));
        } else {
            if ($tipe == "shoes") {
                $avatar = $mongo->find_pagging(array('tipe' => $tipe, "brand_id" => $id_brand), $start, $limit, array());
                $count = $mongo->count(array('tipe' => $tipe, "brand_id" => $id_brand));
            } else {
                $avatar = $mongo->find_pagging(array('tipe' => $tipe, 'size' => $bodytype, 'gender' => $gender, "brand_id" => $id_brand), $start, $limit, array());
                $count = $mongo->count(array('tipe' => $tipe, 'size' => $bodytype, 'gender' => $gender, "brand_id" => $id_brand));
            }
        }
        if ($avatar) {
            $output = __explode_avatar_items($avatar, $gender, $count);
        }
    }
    return $output;
}
Example #2
0
function __style_mix($email)
{
    $mongo = new LiloMongo();
    $userDetails = __getUserDetails($email);
    $id = $userDetails["id"];
    $gender = $userDetails['gender'];
    $bodytype = $userDetails['bodytype'];
    //echo $gender. " " . $bodytype;
    $mongo->selectDB("Users");
    $mongo->selectCollection("AvatarMix");
    $query = $mongo->find_pagging(array('gender' => $gender, 'bodytype' => $bodytype));
    $count = $mongo->count(array('gender' => $gender, 'bodytype' => $bodytype));
    $output = array();
    $output['count'] = $count;
    if ($query) {
        foreach ($query as $item) {
            $json = $item['configuration'];
            $output['data'][] = array('tipe' => 'Mix', 'title' => $item['name'], 'picture' => $item['picture'], 'action' => '/AvatarPreview?f=character' . '&id=' . (string) $item['_id'] . "&v=" . $json, 'value' => '');
        }
    }
    return $output;
}
Example #3
0
function __features_part($email, $type, $start, $limit)
{
    $userData = __getUserDetails($email);
    $bodytype = $userData['bodytype'];
    $gender = $userData['gender'];
    $output = array();
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Assets');
    $lilo_mongo->selectCollection('Avatar');
    $query1 = $lilo_mongo->find_pagging(array('tipe' => $type, 'gender' => $gender, 'size' => $bodytype), $start, $limit, array('last_update' => -1));
    $count1 = $lilo_mongo->count();
    $newType = str_replace("face_part_", "", $type);
    //echo "........... ". $newType . ".......";
    foreach ($query1 as $item) {
        if ($newType != $type) {
            $element = array('tipe' => $newType, 'element' => str_replace(".unity3d", "", $item['material']));
        } else {
            $element = array('gender' => $gender, 'tipe' => $newType, 'element' => str_replace(".unity3d", "", $item['element']), 'material' => str_replace(".unity3d", "", $item['material']));
        }
        $json = str_replace("\"", "'", json_encode($element));
        $output['data'][] = array('tipe' => $type, 'title' => $item['name'], 'picture' => $item['preview_image'], 'action' => '/AvatarPreview?f=' . $type . "&id=" . (string) $item['_id'] . "&v=" . $json, 'value' => '');
    }
    $query2 = $lilo_mongo->find_pagging(array('tipe' => $type, 'gender' => 'unisex'), $start, $limit, array('last_update' => -1));
    $count2 = $lilo_mongo->count();
    foreach ($query2 as $item) {
        if ($newType != $type) {
            $element = array('tipe' => $newType, 'element' => str_replace(".unity3d", "", $item['material']));
        } else {
            $element = array('gender' => $gender, 'tipe' => $newType, 'element' => str_replace(".unity3d", "", $item['element']), 'material' => str_replace(".unity3d", "", $item['material']));
        }
        $json = str_replace("\"", "'", json_encode($element));
        $output['data'][] = array('tipe' => $type, 'title' => $item['name'], 'picture' => $item['preview_image'], 'action' => '/AvatarPreview?f=' . $type . "&id=" . (string) $item['_id'] . "&v=" . $json, 'value' => (string) $item['_id']);
    }
    $output['count'] = $count1 + $count2;
    return json_encode($output);
}
Example #4
0
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);
}
Example #5
0
function mobile_avatar_getgender()
{
    $email = func_arg(0);
    $userDetails = __getUserDetails($email);
    $id = $userDetails['id'];
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Users');
    $lilo_mongo->selectCollection("Properties");
    $data = $lilo_mongo->findOne(array('lilo_id' => $id));
    $isValid = false;
    $status = "";
    if ($data) {
        $isValid = true;
        $status = $data['state_of_mind'];
    }
    $output = array('id' => $userDetails['id'], 'success' => $isValid, 'gender' => $userDetails['gender'], 'bodyType' => $userDetails['bodytype'], 'status' => $status == NULL ? "" : $status);
    return json_encode($output);
}