Example #1
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);
}
Example #2
0
function mobile_social_delcommentnews()
{
    $user_email = func_arg(0);
    $user_id = _get_id_user($user_email);
    $news_id = func_arg(1);
    $_id = func_arg(2);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Social');
    $lilo_mongo->selectCollection('NewsComments');
    $data = $lilo_mongo->delete(array("user_id" => $user_id, "_id" => $lilo_mongo->mongoid($_id)));
    $output['count'] = $lilo_mongo->count(array("news_id" => $news_id));
    return json_encode($output);
}