Esempio n. 1
0
<?php

$target_dir = $root . "uploads/" . $user->id . "/";
if (!file_exists($target_dir)) {
    mkdir($target_dir);
}
$target_file = $target_dir . intTime() . "_" . basename($_FILES["uFile"]["name"]);
$imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if (isset($_POST["submit"])) {
    $check = getimagesize($_FILES["uFile"]["tmp_name"]);
    if ($check !== false) {
    } else {
        $errors[] = "File is not an image.";
    }
}
// Check file size
if ($_FILES["uFile"]["size"] > 5000000) {
    $errors[] = "Sorry, your file is too large.";
}
// Allow certain file formats
if (!in_array($imageFileType, ["jpg", "png", "jpeg"])) {
    $errors[] = "Sorry, only JPG, JPEG, & PNG files are allowed.";
}
if (isset($errors)) {
    $errors[] = "Sorry, your file was not uploaded.";
} else {
    if (move_uploaded_file($_FILES["uFile"]["tmp_name"], $target_file)) {
        $data = "The file " . basename($_FILES["uFile"]["name"]) . " has been uploaded.";
    } else {
        $errors[] = "Sorry, there was an error uploading your file.";
Esempio n. 2
0
 public function __construct($user)
 {
     global $db, $errors;
     if (!isset($user->wwuid)) {
         $errors[] = "invalid user";
         return false;
     }
     $dbuser = $db["people"]->select("users", "*", ["wwuid" => $user->wwuid]);
     if (!$dbuser) {
         $errors[] = "user does not exist";
         return false;
     } else {
         if (isset($user->token)) {
             $dbuser[0]["token"] = $user->token;
         }
     }
     $user = $dbuser[0];
     foreach ($user as $key => $value) {
         if (!in_array($key, ["auth_salt", "auth_time"])) {
             $this->{$key} = $value;
         }
     }
     $photo = $db["people"]->select("profiles", "wwuid,photo", "user_id='" . $this->id . "'");
     if ($photo && isset($photo[0])) {
         $this->photo = $photo[0]["photo"];
     } else {
         $db["people"]->insert("profiles", ["id" => uniqid(), "user_id" => $this->id, "wwuid" => $this->wwuid, "username" => $this->username, "fullname" => $this->fullname, "updated_at" => intTime()]);
         $this->photo = "";
     }
     if (!isset($this->token)) {
         $this->token = $this->generate_token();
     }
 }
Esempio n. 3
0
 /**
  * @return array
  */
 public function getMeta()
 {
     $collection = Collection::first();
     return ['mod' => $collection->getMod(), 'scm' => $collection->getScm(), 'usn' => $collection->getUsn(), 'ts' => intTime(), 'musn' => 0, 'msg' => '', 'cont' => true];
 }