示例#1
0
function signUp($user)
{
    $user = validateFixProfile($user);
    if (is_string($user)) {
        # error msg: invalid info
        return $user;
    }
    if (userExists($user["email"])) {
        return ACCOUNT_ALREADY_EXISTS_ERR;
    }
    $user["password"] = trim($user["password"]);
    $checkPassword = checkPassword($user["password"], $user["confirm_password"]);
    if (is_string($checkPassword)) {
        return $checkPassword;
    }
    $account_type = $user["account_type"];
    if ($account_type !== "Tutor" && $account_type !== "Student") {
        return INVALID_ACCOUNT_TYPE_ERR;
    }
    $gender = $user["gender"];
    if ($gender !== "Male" && $gender !== "Female") {
        return INVALID_GENDER_ERR;
    }
    if (is_uploaded_file($_FILES["profile_pic"]["tmp_name"]) && isValidImg("profile_pic") !== true) {
        return INVALID_IMG_ERR;
    }
    $user_id = insertUser($user);
    if (isNum($user_id)) {
        insertInto($account_type, $user_id);
        if (file_exists($_FILES["profile_pic"]["tmp_name"])) {
            $path = getProfilePicPath($user_id);
            moveFile("profile_pic", getTempPath($user_id), $path);
            changeProfilePic($user_id, $path);
        }
        # else {
        #    changeProfilePic($user_id, DEFAULT_PROFILE_PIC);
        # }
        $u = getFullUserById($user_id);
        if (sendActivationMail($u["email"], $user_id, $u["activation_code"])) {
            return true;
        } else {
            return " Account successfully created but could not send you a verification email. Please request another one. ";
        }
    } else {
        return UNKNOWN_ERR . RETRY_MSG;
    }
}
示例#2
0
<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    print '<div class="post_it"><h3>';
    if (isset($_POST['litter'])) {
        print createPost();
    }
    if (isset($_POST['postComment'])) {
        print postComment();
    }
    if (isset($_POST['reply'])) {
        print replyComment();
    }
    if (isset($_POST['profile_pic'])) {
        print changeProfilePic();
    }
    if (isset($_POST['changeInfo'])) {
        print changeInfo();
    }
    if (isset($_POST['del_user'])) {
        deleteUser();
    }
    if (isset($_POST['del_post'])) {
        print deletePost();
    }
    if (isset($_POST['del_comment'])) {
        print deleteComment();
    }
    if (isset($_POST['recycle'])) {
        print recycle();
    }
示例#3
0
 public function uploadProfilePic()
 {
     $response['signed'] = false;
     $response['succeeded'] = false;
     $response['path'] = '';
     if (isset($_SESSION["user_id"]) && strlen(trim($_SESSION["user_id"])) > 0) {
         if ($_FILES['file']['name']) {
             $path = 'assets/uploaded_images/' . time() . '_' . $_FILES['file']['name'];
             move_uploaded_file($_FILES['file']['tmp_name'], $path);
             $response['path'] = $path;
             $response['succeeded'] = changeProfilePic($_SESSION["user_id"], $path);
         }
         $response['signed'] = true;
     }
     echo json_encode($response);
 }