コード例 #1
0
function signUpProfile()
{
    $rm = new Response_Methods();
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        $result = $rm->inValidServerMethod();
        return $result;
    }
    //Check request url is https or not
    if (!empty($_SERVER["HTTPS"])) {
        if ($_SERVER["HTTPS"] !== "off") {
            $username = $rm->cleanData(trim($_POST['username']));
            $password = $rm->cleanData(trim($_POST['password']));
            $email = trim($_POST['email']);
            $deviceId = trim($_POST['deviceId']);
            $petType = $rm->cleanData(trim($_POST['petType']));
            $petBio = $rm->cleanData(trim($_POST['petBio']));
            $petName = $rm->cleanData(trim($_POST['petName']));
            $petDob = trim($_POST['petDob']);
            $petSpecies = $rm->cleanData(trim($_POST['petSpecies']));
            $notifyEvents = $rm->cleanData(trim($_POST['notifyEvents']));
            $profileId = $rm->rand_str(16, 4);
            if ($username == "" || $password == "" || $email == "" || $petType == "" || $petBio == "" || $petName == "" || $petDob == "" || $petSpecies == "" || $notifyEvents == "") {
                $result = $rm->fields_validation();
                return $result;
            } else {
                $checkUser = $rm->checkUserValidation($username, 'user_name_f');
                $checkEmail = $rm->checkUserValidation($email, 'email_f');
                if ($checkUser == 0) {
                    $result = $rm->userExistJson();
                    return $result;
                }
                if ($checkEmail == 0) {
                    $result = $rm->emailExistJson();
                    return $result;
                }
                $status = 0;
                date_default_timezone_set('Asia/Calcutta');
                $createdDate = date('Y-m-d H:i:s');
                $getList = array();
                //preparing list and inserting values in user_details table
                $getInsertFieldValue['user_name_f'] = $username;
                $getInsertFieldValue['email_f'] = $email;
                $getInsertFieldValue['device_id_f'] = $deviceId;
                $getInsertFieldValue['profile_id_f'] = $profileId;
                $getInsertFieldValue['join_date_f'] = $createdDate;
                $getInsertFieldValue['pet_type_f'] = $petType;
                $getInsertFieldValue['pet_name_f'] = $petName;
                $getInsertFieldValue['pet_dob_f'] = $petDob;
                $getInsertFieldValue['description_f'] = $petBio;
                $getInsertFieldValue['species_f'] = $petSpecies;
                $getInsertFieldValue['notify_events_f'] = $notifyEvents;
                $lastInserted_user_id = $rm->insert_record($getInsertFieldValue, 'user_details_t');
                if (!empty($lastInserted_user_id)) {
                    //preparing list and inserting values in login table
                    $getInsertLoginDetails['password_f'] = $password;
                    $getInsertLoginDetails['user_name_f'] = $username;
                    $getInsertLoginDetails['user_id_fk'] = $lastInserted_user_id;
                    $lastInserted_login_id = $rm->insert_record($getInsertLoginDetails, 'login_t');
                    if (empty($lastInserted_login_id)) {
                        $rm->delete('user_details_t', 'user_id', $lastInserted_user_id);
                        $result = $rm->userRegisterFailJson();
                        return $result;
                    }
                    //preparing list and inserting values in friends table
                    $getInsertFriendDetails['friend_one'] = $lastInserted_user_id;
                    $getInsertFriendDetails['friend_two'] = $lastInserted_user_id;
                    $getInsertFriendDetails['created_date_f'] = $createdDate;
                    $getInsertFriendDetails['status'] = 2;
                    $lastInserted_friend_id = $rm->insert_record($getInsertFriendDetails, 'friends_t');
                    if (empty($lastInserted_friend_id)) {
                        $rm->delete('login_t', 'login_id', $lastInserted_login_id);
                        $rm->delete('user_details_t', 'user_id', $lastInserted_user_id);
                        $result = $rm->userRegisterFailJson();
                        return $result;
                    }
                    $IMAGEURLBASEURL = BASEURL . '/images/';
                    $userImageBaseURL = "images/{$username}";
                    if (!is_dir($userImageBaseURL)) {
                        //mkdir - tells that need to create a directory
                        mkdir($userImageBaseURL);
                        mkdir($userImageBaseURL . '/profile_pics/');
                        mkdir($userImageBaseURL . '/post_photos/');
                    }
                    $rand = rand(00, 99999);
                    if (isset($_POST['profile_pic']) and $_POST['profile_pic'] != "") {
                        $profile_pic = trim($_POST['profile_pic']);
                        //blob image data
                        $img = 'data:image/png;base64,' . $profile_pic . '';
                        $img = str_replace('data:image/png;base64,', '', $img);
                        $img = str_replace(' ', '+', $img);
                        $data = base64_decode($img);
                        $image = 'petbestie_user_' . $rand . '.png';
                        file_put_contents($userImageBaseURL . '/profile_pics/' . $image, $data);
                        //file_put_contents($userImageBaseURL.'/profile_pics/'.$image, $data);
                        $IMAGEURL = $IMAGEURLBASEURL . $username . '/profile_pics/' . $image;
                        $getUpdateProfilePic['profile_pic_f'] = $IMAGEURL;
                    } else {
                        $getUpdateProfilePic['profile_pic_f'] = "null";
                    }
                    $updateResult = $rm->update_record($getUpdateProfilePic, 'user_details_t', 'user_id', $lastInserted_user_id);
                    $result = $rm->userRegisterSuccessJson($lastInserted_user_id);
                    return $result;
                } else {
                    $result = $rm->userRegisterFailJson();
                    return $result;
                }
            }
            // end of else first
        } else {
            $result = $rm->ssl_error();
            return $result;
        }
    } else {
        $result = $rm->ssl_error();
        return $result;
    }
}
コード例 #2
0
function addUserDetails()
{
    //$companyId = $_REQUEST['companyId'];
    $userFname = trim($_REQUEST['userFname']);
    $userLname = trim($_REQUEST['userLname']);
    $age = trim($_REQUEST['age']);
    $sex = trim($_REQUEST['sex']);
    $emailId = trim($_REQUEST['emailId']);
    $address = trim($_REQUEST['address']);
    $userType = trim($_REQUEST['userType']);
    $companyID = trim($_REQUEST['companyID']);
    /*
    
    		$userImage = trim($_REQUEST['image']);
    $userImage = trim($_REQUEST['image']['name']);
    */
    $adminId = $_REQUEST['adminId'];
    //$adminId='e-002';// need to be send in request..for time being using hardcoded values.
    $fullName = $userFname . ' ' . $userLname;
    //$Mobile = $_REQUEST['Phone'];
    $rm = new Response_Methods();
    if ($userFname == "" || $userLname == "" || $age == "" || $sex == "" || $emailId == "" || $address == "" || $userType == "") {
        //$sendMail=$rm->sendMailPasswordDetails($adminEmail,'test14521','sdfwd45487','Asif Anwar');
        $result = $rm->fields_validation();
        return $result;
    } else {
        $status = 0;
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        //$max_login_id=$rm->getMaxID('login_t','login_user_id');
        $passWord_Ran = substr(md5(rand(0, 1000000)), 0, 8);
        //$ENCRYPTEDPWD = base64_encode($passWord_Ran);
        $ENCRYPTEDPWD = $passWord_Ran;
        $getList = array();
        //$getFieldValue['emp_id']=$userName;
        $getInsertFieldValue['password'] = $ENCRYPTEDPWD;
        $getInsertFieldValue['usertype'] = $userType;
        $lastInserted_login_user_id = $rm->insert_record($getInsertFieldValue, 'login_t');
        if (!empty($lastInserted_login_user_id)) {
            $threeDigitID = str_pad($lastInserted_login_user_id, 3, "0", STR_PAD_LEFT);
            $userName = "******" . $threeDigitID;
            $sqlUpdate = "update login_t set emp_id='{$userName}' where login_user_id={$lastInserted_login_user_id}";
            mysql_query($sqlUpdate, $GLOBALS['link']);
            //$PROFILE_PICTURE = $userData['profilePicture']['name'];
            /*
            $filTemLoc = $_FILES['image']['tmp_name'];
            $moveresult = move_uploaded_file($filTemLoc,"userPics/".$userImage);
            
            $getRegisterFieldValue['user_image']=$userImage;
            
            user image code commented
            */
            $getRegisterFieldValue['user_fname'] = $userFname;
            $getRegisterFieldValue['user_lname'] = $userLname;
            $getRegisterFieldValue['user_age'] = $age;
            $getRegisterFieldValue['user_sex'] = $sex;
            $getRegisterFieldValue['user_email_id'] = $emailId;
            $getRegisterFieldValue['user_address'] = $address;
            $getRegisterFieldValue['login_user_id'] = $lastInserted_login_user_id;
            $getRegisterFieldValue['company_id'] = $companyID;
            $getRegisterFieldValue['user_created_date'] = $createdDate;
            $lastInserted_user_id = $rm->insert_record($getRegisterFieldValue, 'user_details_t');
            if (!empty($lastInserted_user_id)) {
                if ($adminId) {
                    $adminEmail = $rm->getAdminEmailID($adminId);
                    //$adminEmail="*****@*****.**";
                    //die();
                    $sendMail = $rm->sendMailPasswordDetails($adminEmail, $userName, $passWord_Ran, $fullName);
                }
                $result = $rm->userRegisterSuccessJson($lastInserted_user_id);
                return $result;
            } else {
                $result = $rm->userRegisterFailJson();
                return $result;
            }
        } else {
            $result = $rm->userRegisterFailJson();
            return $result;
        }
    }
}