Example #1
0
function StoreUserPic($tempfile, $userid)
{
    $loc = "piclib.php->StoreUserPic";
    $id = StorePicture($tempfile);
    if ($id === false) {
        return false;
    }
    // Delete old pic, if any...
    $sql = 'DELETE FROM UserPics WHERE UserID=' . intval($userid);
    SqlQuery($loc, $sql);
    $sql = 'INSERT INTO UserPics (PicId, UserID) VALUES (';
    $sql .= '  ' . intval($id);
    // PicID
    $sql .= ', ' . intval($userid);
    // UserID
    $sql .= ')';
    $result = SqlQuery($loc, $sql);
    log_msg($loc, 'User Picture Successfully Stored. PicID= ' . $id . ', UserID = ' . $userid);
    return $id;
}
Example #2
0
function PicFileUpload($FileInfo)
{
    $loc = rmabs(__FILE__ . ".PicFileUpload");
    DenyGuest();
    // Don't allow guests to do this.
    $missing = "";
    if (!isset($FileInfo["name"])) {
        $missing .= '"name" ';
    }
    if (!isset($FileInfo["type"])) {
        $missing .= '"type" ';
    }
    if (!isset($FileInfo["tmp_name"])) {
        $missing .= '"tmp_name" ';
    }
    if (!isset($FileInfo["error"])) {
        $missing .= '"error" ';
    }
    if (!isset($FileInfo["size"])) {
        $missing .= '"size" ';
    }
    if (!empty($missing)) {
        echo 'missing';
        log_error($loc, array("Error on Pic Upload.", "Input Array missing elements:", $missing));
        return false;
    }
    $name = $FileInfo["name"];
    $type = $FileInfo["type"];
    $tmpfile = $FileInfo["tmp_name"];
    $errors = $FileInfo["error"];
    $size = $FileInfo["size"];
    if ($errors != 0) {
        echo 'error not zero';
        log_error($loc, array("Error on Pic Upload." . "Error Not Zero."));
        return false;
    }
    if ($size <= 0) {
        echo 'size';
        log_error($loc, "Error on Pic Upload.  Size is zero.");
        return false;
    }
    if ($type != "image/jpeg") {
        echo 'type';
        log_error($loc, "Error on Pic Upload.  Wrong Type, should be image/jpeg.  Found: " . $type);
        return false;
    }
    $picid = StorePicture($tmpfile, true);
    return $picid;
}