Example #1
0
 public function register()
 {
     RoutingEngine::setPage("runnDAILY User Register", "PV__400");
     $user = new User($_POST);
     $user->password = md5($user->password);
     $user->cookie_hash = md5(time());
     if ($user->create()) {
         if (isset($_FILES['user_img'])) {
             $updir = PUBLIC_ROOT . "/img/user/";
             $path_part = pathinfo($_FILES['user_img']['name']);
             $upfile = User::$current_user->uid % 100 . "/" . User::$current_user->uid . "." . $path_part["extension"];
             if (move_uploaded_file($_FILES['user_img']['tmp_name'], $updir . $upfile)) {
                 $user->updateImage($upfile);
             }
         }
         $_SESSION["userData"] = $user;
         Notification::add("Your account has been created.");
         Page::redirect("/");
     } else {
         Notification::add("There was an error creating your account.  Try again please.");
         Page::redirect("/register");
     }
 }
Example #2
0
function updateUserImage()
{
    $results = array();
    //echo $type;
    $user = new User($_POST);
    $user->id = $_POST['userId'];
    if (isset($_FILES["image"])) {
        $imageName = "image";
        $type = "user";
        $typeId = $_POST['userId'];
        $imageLocation = IMAGE_UPLOAD_LOCATION;
        $user->icon_link = uploadImage($imageName, $imageLocation, $type, $typeId);
    } else {
        $user->icon_link = DEFAULT_IMAGE_LOCATION;
    }
    //print_r($_POST);
    if ($user->updateImage()) {
        $results['successMessage'] = "Updated image successfully.";
        require TEMPLATE_PATH . "/updateForm.php";
    }
}