function createRows()
{
    $dbh = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD);
    $user_insert = <<<EOF
insert into users 
    (id, active, approved, username, display_name, email) 
    values
    (:id, 1, 1, :username, :full_name, :email)
EOF;
    $user_stmt = $dbh->prepare($user_insert);
    $user_stmt->bindParam(':id', $user_id);
    $user_stmt->bindParam(':username', $username);
    $user_stmt->bindParam(':full_name', $full_name);
    $user_stmt->bindParam(':email', $email);
    $group_insert = <<<EOF
insert into users_groups 
    (id, active, name, user_id) 
    values
    (:id, 1, :username, :user_id)
EOF;
    $group_stmt = $dbh->prepare($group_insert);
    $group_stmt->bindParam(':id', $group_id);
    $group_stmt->bindParam(':username', $username);
    $group_stmt->bindParam(':user_id', $user_id);
    $student_insert = <<<EOF
insert into tg_student
    (user_id, first_name, last_name)
    values
    (:user_id, :first_name, :last_name)        
EOF;
    $student_stmt = $dbh->prepare($student_insert);
    $student_stmt->bindParam(':user_id', $user_id);
    $student_stmt->bindParam(':first_name', $first_name);
    $student_stmt->bindParam(':last_name', $last_name);
    $user_id_result = $dbh->query('select id from users_seq', PDO::FETCH_ASSOC);
    $lastUserId = $user_id_result->fetchColumn();
    $group_id_result = $dbh->query('select id from users_groups_seq', PDO::FETCH_ASSOC);
    $lastGroupId = $group_id_result->fetchColumn();
    for ($i = 1; $i <= STUDENT_LIMIT; $i++) {
        $user_id = $lastUserId + $i;
        $group_id = $lastGroupId + $i;
        $first_name = getName(1);
        $last_name = getName(2);
        $full_name = "{$first_name} {$last_name}";
        $username = makeUsername($first_name, $last_name);
        $email = $username . '@appstate.edu';
        $user_stmt->execute();
        $group_stmt->execute();
        $student_stmt->execute();
        echo "Created user {$username}\n";
    }
    $user_seq_stmt = 'update users_seq set id=' . $user_id;
    $dbh->exec($user_seq_stmt);
    $group_seq_stmt = 'update users_groups_seq set id=' . $group_id;
    $dbh->exec($group_seq_stmt);
}
Beispiel #2
0
function signup()
{
    global $Userservice;
    global $SKADATE_BOL_AccountTypeToGenderDao;
    global $BOL_AvatarService_inst;
    //global $EmailVerifyService;
    global $SKAPI_BOL_Service_inst;
    global $language;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    //Lang Call Start
    $hammu_lang_id = $app->request()->params("lang_id");
    if (!empty($hammu_lang_id)) {
        getCurrentLanguages($hammu_lang_id);
    }
    //Lang Call end
    //$match_sex = $app->request()->params('match_sex');
    //$preferences_or_services = $app->request()->params('preferences_or_services');
    //$photo = $app->request()->params('photo');
    //$photo_data = $_FILES["photo"];
    $username = $app->request()->params('username');
    $email = $app->request()->params('email');
    $password = $app->request()->params('password');
    $realname = $app->request()->params('realname');
    $sex = $app->request()->params('sex');
    $i_m_using = $app->request()->params(HAMMU_DB_IM_USING_HAMMU_AS_KEY);
    $googlemap_location = $app->request()->params('googlemap_location');
    $birthdate = $app->request()->params('birthdate');
    $mobile_number = $app->request()->params(HAMMU_DB_MOBILE_NUMBER_KEY);
    $meeting_point = $app->request()->params(HAMMU_DB_METTING_POINT_KEY);
    $pay_pal_address = $app->request()->params(HAMMU_DB_PAYMENT_TYPE_KEY);
    //hardik edited
    $HOTEL_SERVICE = $app->request()->params(HAMMU_HOTEL_SERVICE);
    $HOME_VISIT = $app->request()->params(HAMMU_HOME_VISIT);
    $HAMMU_AVAILABLE_AT = urldecode($app->request()->params(HAMMU_AVAILABLE_AT));
    $SECRET_FANTASY = $app->request()->params(HAMMU_SECRET_FANTASY);
    $HAMMU_LANGUAGE = $app->request()->params(HAMMU_LANGUAGE);
    $HAMMU_COUNTRY = $app->request()->params(HAMMU_COUNTRY);
    //
    $token = $app->request()->params('token');
    $type = $app->request()->params('type');
    $preferences = $app->request()->params(HAMMU_DB_SERVICES_KEY);
    $lang = $app->request()->params(HAMMU_LANG);
    $deviceId = $token;
    $deviceType = $type;
    $preferenceArr = explode(",", $preferences);
    $langArr = explode(",", $lang);
    //print_r($preferenceArr);
    $preVal = 0;
    foreach ($preferenceArr as $key => $value) {
        $preVal = $preVal + $value;
    }
    $langVal = 0;
    foreach ($langArr as $key => $value) {
        $langVal = $langVal + $value;
    }
    //
    $HAMMU_AVAILABLE_ATArr = explode(",", $HAMMU_AVAILABLE_AT);
    //print_r($HAMMU_AVAILABLE_ATArr);
    // die;
    //    $preVal1 = 0;
    //    foreach ($HAMMU_AVAILABLE_ATArr as $key => $value) {
    //        $preVal1 = $preVal1 + $value;
    //    }
    $data["email"] = urldecode($email);
    $data["username"] = $username;
    $data['password'] = $password;
    $data["googlemap_location"] = $googlemap_location;
    $data["birthdate"] = $birthdate;
    $data[HAMMU_DB_MOBILE_NUMBER_KEY] = $mobile_number;
    $data["sex"] = $sex;
    $today_date_timestamp = strtotime(date("d-m-Y"));
    $birth_date_timestamp = strtotime($birthdate);
    if ($birth_date_timestamp > $today_date_timestamp) {
        $message = $language->text("hammu", "signup_error_prorper_date");
        //"Please Provide Proper Date!";
        $return_data = array("response_status" => "0", "response_message" => $message);
        $app->response->setBody(json_encode($return_data));
    } else {
        $crdata = checkuserexists($data);
        if (count($crdata) > 0) {
            $app->response->setBody(json_encode($crdata));
        } else {
            $username = trim(preg_replace('/[^\\w]/', '', $username));
            $username = makeUsername($username);
            $data['realname'] = $username;
            $newUser = false;
            $accountdata = $SKADATE_BOL_AccountTypeToGenderDao->findByGenderValue($sex);
            $accounttype = $accountdata[0]->accountType;
            $user = $Userservice->createUser($username, $password, $data["email"], $accounttype, false);
            $check_exist_value = $SKAPI_BOL_Service_inst->findValueExistOrNot($user->id);
            if ($check_exist_value) {
                $table_id = $check_exist_value[0]->id;
                if ($table_id) {
                    $user_skapi_id = $check_exist_value[0]->id;
                } else {
                    $user_skapi_id = "";
                }
            } else {
                $user_skapi_id = "";
            }
            $user_details = $SKAPI_BOL_Service_inst->createUserDetails($user->id, $deviceId, $deviceType, $user_skapi_id);
            sendUserVerificationMail($user);
            $newUser = true;
            unset($data['email']);
            unset($data['password']);
            unset($data['username']);
            //Geo location settings on address
            $price = $app->request()->params(HAMMU_DB_PRICE_KEY);
            if (!empty($data["googlemap_location"])) {
                $urlencode_address = urlencode($data["googlemap_location"]);
                $geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $urlencode_address . '&sensor=false');
                $output = json_decode($geocode);
                if (!empty($output->results[0]->formatted_address)) {
                    $data_location[HAMMU_DB_PRICE_KEY] = $price;
                    $data_location['googlemap_location']['address'] = $output->results[0]->formatted_address;
                    $data_location['googlemap_location']['latitude'] = $output->results[0]->geometry->location->lat;
                    $data_location['googlemap_location']['longitude'] = $output->results[0]->geometry->location->lng;
                    $data_location['googlemap_location']['northEastLat'] = $output->results[0]->geometry->bounds->northeast->lat;
                    $data_location['googlemap_location']['northEastLng'] = $output->results[0]->geometry->bounds->northeast->lng;
                    $data_location['googlemap_location']['southWestLat'] = $output->results[0]->geometry->bounds->southwest->lat;
                    $data_location['googlemap_location']['southWestLng'] = $output->results[0]->geometry->bounds->southwest->lng;
                    $data_location['googlemap_location']['json'] = json_encode($output->results[0]);
                    $data_location['birthdate'] = $data["birthdate"];
                    $data_location['sex'] = $sex;
                    $data_location['realname'] = $realname;
                    $data_location[HAMMU_DB_MOBILE_NUMBER_KEY] = $data[HAMMU_DB_MOBILE_NUMBER_KEY];
                    $data_location[HAMMU_DB_SERVICES_KEY] = $preVal;
                    $data_location[HAMMU_DB_PAYMENT_TYPE_KEY] = $pay_pal_address;
                    $data_location[HAMMU_DB_IM_USING_HAMMU_AS_KEY] = $i_m_using;
                    $data_location[HAMMU_DB_METTING_POINT_KEY] = $meeting_point;
                    //hardik edited
                    $data_location[HAMMU_HOTEL_SERVICE] = $HOTEL_SERVICE;
                    $data_location[HAMMU_HOME_VISIT] = $HOME_VISIT;
                    $data_location[HAMMU_AVAILABLE_AT] = $HAMMU_AVAILABLE_ATArr;
                    $data_location[HAMMU_SECRET_FANTASY] = $SECRET_FANTASY;
                    $data_location[HAMMU_LANGUAGE] = $HAMMU_LANGUAGE;
                    $data_location[HAMMU_COUNTRY] = $HAMMU_COUNTRY;
                    $data_location[HAMMU_LANG] = $langVal;
                    //
                }
            }
            //            print_r($data_location);
            //            die;
            $store_to_question = cleanArray($data_location);
            BOL_QuestionService::getInstance()->saveQuestionsData($store_to_question, $user->id);
            if (!empty($_FILES)) {
                $files = $_FILES;
                //PHOTO_BOL_PhotoService::getInstance()->getPhotoPath($data["photoId"], $data["hash"], 'original');
                $path = $_FILES['photo']['tmp_name'];
                $avtar = $BOL_AvatarService_inst->setUserAvatar($user->id, $path);
            }
            $event = new OW_Event(OW_EventManager::ON_USER_REGISTER, array('method' => 'native', 'userId' => $user->id, 'params' => array()));
            OW::getEventManager()->trigger($event);
            $avatars = $BOL_AvatarService_inst->getAvatarsUrlList(array($user->id));
            $filed_array = array(HAMMU_DB_PREFRENCES_KEY, HAMMU_DB_SERVICES_KEY);
            $all_services_preferences = getallquestions(array("user_id" => $user->id, "fields" => $filed_array));
            if ($i_m_using == "1") {
                $sex_type = $language->text("hammu", "login_client");
                //"client";
                $type = "preferences";
            } else {
                $sex_type = $language->text("hammu", "login_escort");
                //"escort";
                $type = "services";
            }
            $messages = $language->text("hammu", "email_verification_code");
            //"Your Verification code has been sent to your Email Address";
            $return_data = array("response_status" => '1', "response_message" => $messages, "data" => array("user_id" => $user->id, "user_name" => $username, "email" => urldecode($email), "profile_picture" => $avatars[$user->id], "phone_number" => $mobile_number, "birthday" => $birthdate, "user_type" => $sex_type, $type => $all_services_preferences[0]['userSelectedLabel']));
            $app->response->setBody(json_encode($return_data));
        }
    }
}
Beispiel #3
0
function facebookLogin()
{
    //$data = $_POST;
    global $Userservice;
    global $QuestionService;
    global $getPluginManager;
    global $BOL_AvatarService_inst;
    global $getEventManager;
    $data = array();
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    $facebookid = $app->request()->params('facebookid');
    $email = $app->request()->params('email');
    $sex = $app->request()->params('gender');
    $birthdate = $app->request()->params('birthdate');
    $token = $app->request()->params('token');
    $type = $app->request()->params('type');
    $deviceId = $token;
    $deviceType = $type;
    $facebookId = $facebookid;
    //        $data = json_decode($params['data'], true);
    //    $facebookId = (int) $data['facebookid'];
    //    $email = (int) $data['email'];
    //    echo "got her";
    //    $authAdapter = new OW_RemoteAuthAdapter($facebookId, 'facebook');
    //echo "got her 2";
    $email = trim($email);
    $params = array("email" => $email, "deviceid" => $deviceId, "device_type" => $deviceType);
    $return_data = checkfacebookuserexists($params);
    //echo "got here 41";
    //print_r($return_data);
    if ($return_data) {
        // print_r($return_data);
        $app->response->setBody(json_encode($return_data));
        // exit();
    } else {
        //echo "got her 1";
        $password = uniqid();
        $tmpUsername = explode('@', $email);
        $username = $tmpUsername[0];
        $username = trim(preg_replace('/[^\\w]/', '', $username));
        //echo "got her 2";
        $username = makeUsername($username);
        // echo "got her 3";
        $newUser = false;
        $data['realname'] = $username;
        $accountype = $sex == "female" ? "8cc28eaddb382d7c6a94aeea9ec029fb" : "808aa8ca354f51c5a3868dad5298cd72";
        //(int) $data["sex"]; //(1 = Female, 2 = Male)
        if ($accountype == "8cc28eaddb382d7c6a94aeea9ec029fb") {
            $sex = 2;
            //$type = "services";
            $sex_type = "lady";
        } else {
            //$type = "preferences";
            $sex = 1;
            $sex_type = "gentleman";
        }
        $data["sex"] = $sex;
        //$accountype;
        $UserDob = date("Y/m/d", strtotime($birthdate));
        $data["birthdate"] = $UserDob;
        // echo "got her 3 1";
        // echo "come";
        $user = $Userservice->createUser($username, $password, $email, $accountype, true);
        $newUser = true;
        // echo "got her 3 1 2";
        //        if (!empty($data["address"])) {
        //            $urlencode_address = urlencode($data["address"]);
        //            $geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $urlencode_address . '&sensor=false');
        //            $output = json_decode($geocode);
        ////echo print_r(json_encode($output->results));
        //            if (!empty($output->results[0]->formatted_address)) {
        //                $data['googlemap_location']['address'] = $output->results[0]->formatted_address;
        //                $data['googlemap_location']['latitude'] = $output->results[0]->geometry->location->lat;
        //                $data['googlemap_location']['longitude'] = $output->results[0]->geometry->location->lng;
        //                $data['googlemap_location']['northEastLat'] = $output->results[0]->geometry->bounds->northeast->lat;
        //                $data['googlemap_location']['northEastLng'] = $output->results[0]->geometry->bounds->northeast->lng;
        //                $data['googlemap_location']['southWestLat'] = $output->results[0]->geometry->bounds->southwest->lat;
        //                $data['googlemap_location']['southWestLng'] = $output->results[0]->geometry->bounds->southwest->lng;
        //                $data['googlemap_location']['json'] = json_encode($output->results[0]);
        //            }
        //        }
        //        echo "got here";
        $QuestionService->saveQuestionsData(array_filter($data), $user->id);
        $avatarUrl = 'http://graph.facebook.com/' . $facebookid . '/picture?type=large&height=400&width=400';
        //$pluginfilesDir = OW_DIR_ROOT;
        $pluginfilesDir = $getPluginManager->getPlugin('skapi')->getPluginFilesDir();
        $ext = 'jpg';
        $tmpFile = $pluginfilesDir . uniqid('avatar-') . (empty($ext) ? '' : '.' . $ext);
        // echo "cal copy";
        //move_uploaded_file($avatarUrl, $tmpFile);
        //  if (!file_exists($path)) {
        //mkdir($pluginfilesDir, 0777);
        chmod($pluginfilesDir, 0777);
        //  }
        //        error_reporting(E_ALL);
        //        ini_set('display_errors', true);
        //copy($avatarUrl, $tmpFile);
        @copy($avatarUrl, $tmpFile);
        //echo "failed to copy";
        if (file_exists($tmpFile)) {
            $BOL_AvatarService_inst->setUserAvatar($user->id, $tmpFile);
            //@unlink($tmpFile);
        }
        if ($newUser) {
            $event = new OW_Event(OW_EventManager::ON_USER_REGISTER, array('method' => 'facebook', 'userId' => $user->id, 'params' => array()));
            $getEventManager->trigger($event);
        }
        //echo "suceees 3";
        //$userdata = $this->respondUserData($user->id, $data);
        //echo json_encode($userdata);
        //echo "got her 3 2 11";
        $avatars = $BOL_AvatarService_inst->getAvatarsUrlList(array($user->id));
        $messages = "Login Successfully";
        $return_data = array("response_status" => '1', "response_message" => $messages, "data" => array("user_id" => $user->id, "user_name" => $username, "email" => $email, "profile_picture" => $avatars[$user->id], "user_type" => $sex_type));
        $app->response->setBody(json_encode($return_data));
    }
}
function signup()
{
    global $Userservice;
    global $SKADATE_BOL_AccountTypeToGenderDao;
    global $BOL_AvatarService_inst;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    //$match_sex = $app->request()->params('match_sex');
    //$preferences_or_services = $app->request()->params('preferences_or_services');
    //$photo = $app->request()->params('photo');
    //$photo_data = $_FILES["photo"];
    $username = $app->request()->params('username');
    $email = $app->request()->params('email');
    $password = $app->request()->params('password');
    $realname = $app->request()->params('realname');
    $sex = $app->request()->params('sex');
    $i_m_using = $app->request()->params(HAMMU_DB_IM_USING_HAMMU_AS_KEY);
    $googlemap_location = $app->request()->params('googlemap_location');
    $birthdate = $app->request()->params('birthdate');
    $mobile_number = $app->request()->params(HAMMU_DB_MOBILE_NUMBER_KEY);
    $meeting_point = $app->request()->params(HAMMU_DB_METTING_POINT_KEY);
    $pay_pal_address = $app->request()->params(HAMMU_DB_PAYMENT_TYPE_KEY);
    $token = $app->request()->params('token');
    $type = $app->request()->params('type');
    $preferences = $app->request()->params(HAMMU_DB_SERVICES_KEY);
    $deviceId = $token;
    $deviceType = $type;
    $preferenceArr = explode(",", $preferences);
    $preVal = 0;
    foreach ($preferenceArr as $key => $value) {
        $preVal = $preVal + $value;
    }
    $data["email"] = urldecode($email);
    $data["username"] = $username;
    $data['password'] = $password;
    $data["googlemap_location"] = $googlemap_location;
    $data["birthdate"] = $birthdate;
    $data[HAMMU_DB_MOBILE_NUMBER_KEY] = $mobile_number;
    $data["sex"] = $sex;
    $today_date_timestamp = strtotime(date("d-m-Y"));
    $birth_date_timestamp = strtotime($birthdate);
    if ($birth_date_timestamp > $today_date_timestamp) {
        $return_data = array("response_status" => "0", "response_message" => "Please Provide Proper Date!");
        $app->response->setBody(json_encode($return_data));
    } else {
        $crdata = checkuserexists($data);
        if (count($crdata) > 0) {
            $app->response->setBody(json_encode($crdata));
        } else {
            $username = trim(preg_replace('/[^\\w]/', '', $username));
            $username = makeUsername($username);
            $data['realname'] = $username;
            $newUser = false;
            $accountdata = $SKADATE_BOL_AccountTypeToGenderDao->findByGenderValue($sex);
            $accounttype = $accountdata[0]->accountType;
            $user = BOL_UserService::getInstance()->createUser($username, $password, $data["email"], $accounttype, false);
            $newUser = true;
            unset($data['email']);
            unset($data['password']);
            unset($data['username']);
            //Geo location settings on address
            $price = $app->request()->params(HAMMU_DB_PRICE_KEY);
            if (!empty($price)) {
                $final_price = $price;
            } else {
                $final_price = "";
            }
            if (!empty($data["googlemap_location"])) {
                $urlencode_address = urlencode($data["googlemap_location"]);
                $geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $urlencode_address . '&sensor=false');
                $output = json_decode($geocode);
                if (!empty($output->results[0]->formatted_address)) {
                    $data_location[HAMMU_DB_PRICE_KEY] = $final_price;
                    $data_location['googlemap_location']['address'] = $output->results[0]->formatted_address;
                    $data_location['googlemap_location']['latitude'] = $output->results[0]->geometry->location->lat;
                    $data_location['googlemap_location']['longitude'] = $output->results[0]->geometry->location->lng;
                    $data_location['googlemap_location']['northEastLat'] = $output->results[0]->geometry->bounds->northeast->lat;
                    $data_location['googlemap_location']['northEastLng'] = $output->results[0]->geometry->bounds->northeast->lng;
                    $data_location['googlemap_location']['southWestLat'] = $output->results[0]->geometry->bounds->southwest->lat;
                    $data_location['googlemap_location']['southWestLng'] = $output->results[0]->geometry->bounds->southwest->lng;
                    $data_location['googlemap_location']['json'] = json_encode($output->results[0]);
                    $data_location['birthdate'] = $data["birthdate"];
                    $data_location['sex'] = $sex;
                    $data_location['realname'] = $realname;
                    $data_location[HAMMU_DB_MOBILE_NUMBER_KEY] = $data[HAMMU_DB_MOBILE_NUMBER_KEY];
                    $data_location[HAMMU_DB_SERVICES_KEY] = $preVal;
                    $data_location[HAMMU_DB_PAYMENT_TYPE_KEY] = $pay_pal_address;
                    $data_location[HAMMU_DB_IM_USING_HAMMU_AS_KEY] = $i_m_using;
                    $data_location[HAMMU_DB_METTING_POINT_KEY] = $meeting_point;
                }
            }
            if ($i_m_using == "1") {
                array_shift($data_location);
            }
            //            print_r($data_location);
            //            exit;
            BOL_QuestionService::getInstance()->saveQuestionsData(array_filter($data_location), $user->id);
            if (!empty($_FILES)) {
                $files = $_FILES;
                //PHOTO_BOL_PhotoService::getInstance()->getPhotoPath($data["photoId"], $data["hash"], 'original');
                $path = $_FILES['photo']['tmp_name'];
                $avtar = $BOL_AvatarService_inst->setUserAvatar($user->id, $path);
            }
            $event = new OW_Event(OW_EventManager::ON_USER_REGISTER, array('method' => 'native', 'userId' => $user->id, 'params' => array()));
            OW::getEventManager()->trigger($event);
            $avatars = $BOL_AvatarService_inst->getAvatarsUrlList(array($user->id));
            $filed_array = array(HAMMU_DB_PREFRENCES_KEY, HAMMU_DB_SERVICES_KEY);
            $all_services_preferences = getallquestions(array("user_id" => $user->id, "fields" => $filed_array));
            if ($i_m_using == "1") {
                $sex_type = "client";
                $type = "preferences";
            } else {
                $sex_type = "escort";
                $type = "services";
            }
            $messages = "SignUp Successfully";
            $return_data = array("response_status" => '1', "response_message" => $messages, "data" => array("user_id" => $user->id, "user_name" => $username, "email" => urldecode($email), "profile_picture" => $avatars[$user->id], "phone_number" => $mobile_number, "birthday" => $birthdate, "user_type" => $sex_type, $type => $all_services_preferences[0]['userSelectedLabel']));
            $app->response->setBody(json_encode($return_data));
        }
    }
}