Exemplo n.º 1
0
 public static function processAvatar($uid)
 {
     $imageProcessor = new image(200, 200);
     system::ensureDirectory(CONTENT_PATH . "/avatars/{$uid}");
     $expectedPics = array("avatar" => CONTENT_PATH . "/avatars/{$uid}");
     $imageProcessor->handleAllUploads($expectedPics);
     return $expectedPics;
 }
Exemplo n.º 2
0
 public static function uploadOnePicture($postName, $postDir = "postImages")
 {
     if (!empty($_POST["picWidth"])) {
         $width = intval($_POST["picWidth"]);
     } else {
         $width = 200;
     }
     if (!empty($_POST["picHeight"])) {
         $heigth = intval($_POST["picHeight"]);
     } else {
         $heigth = 200;
     }
     $path = CONTENT_PATH . "/{$postDir}/{$postName}/";
     if (!is_dir($path) || system::dirIsEmpty($path)) {
         //blog::saveDraft();
         if (!is_dir($path)) {
             mkdir($path, 0777, true);
         }
     }
     $imageProcessor = new image($width, $heigth);
     if ($postDir == "posterImages") {
         $imageProcessor->additionalProcessing("poster", 640, 0);
     }
     $expectedPics = array("picUpld" => $path . time(), "poster" => $path . $postName);
     $imageProcessor->handleAllUploads($expectedPics);
     return $expectedPics;
 }
Exemplo n.º 3
0
 function upload()
 {
     system::$display = false;
     $response = array();
     if (!isset($_POST["token"]) && !$_POST["token"]) {
         $response["error"] = "Token error";
     }
     $token = preg_replace("/[^0-9a-z\\_\\-+\\/\\\\|]/i", '', $_POST["token"]);
     if (!$token) {
         $response["error"] = "Token error";
     }
     $mysql = $this->db->query("SELECT * FROM `tokens` as t, `users` as u WHERE u.`userID`=t.`userID` AND t.`token`='?' LIMIT 1", $token);
     if (!$mysql->getNumRows()) {
         $response["error"] = "Token error";
     }
     if (isset($response["error"])) {
         echo json_encode($response);
         return;
     }
     $userData = $mysql->fetch();
     if (isset($_FILES["screenshot"]) && $_FILES["screenshot"]) {
         $imageProcessor = new image(200, 200);
         $path = CONTENT_PATH . "/screenshots/" . $userData["userID"];
         system::ensureDirectory($path);
         $time = explode(" ", microtime());
         $time[0] = str_replace("0.", '', $time[0]);
         $response["screenshot"] = $path . "/" . implode("_", $time);
         $imageProcessor->handleAllUploads($response);
     } else {
         $response["error"] = "Where is no `screenshot` field in your multipart request. Nothing to do.";
     }
     $response["screenshot"]["userID"] = intval($userData["userID"]);
     echo json_encode($response);
 }