private function editOrSave($action) { $validations = array("title" => "required", "URL" => "ping"); if (POST("code")) { unset($validations["URL"]); } $data = array("ID_User" => SESSION("ZanUserID"), "Start_Date" => now(4), "End_Date" => now(4) + 2419200); if ($action === "edit") { $this->Data->ignore("banner"); } $this->data = $this->Data->proccess($data, $validations); if (isset($this->data["error"])) { return $this->data["error"]; } if (FILES("image", "name")) { if (POST("banner")) { @unlink(POST("banner")); } $dir = "www/lib/files/images/ads/"; $this->Files = $this->core("Files"); $this->data["Banner"] = $this->Files->uploadImage($dir, "image", "normal"); if (!$this->data["Banner"]) { return getAlert("Upload error"); } } else { if (!isset($this->data["Code"])) { return getAlert("You need to upload an image or write the ad code"); } } }
private function editOrSave($action) { $validations = array("exists" => array("Slug" => slug(POST("title", "clean")), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Language" => POST("language")), "title" => "required", "content" => "required"); $this->categories = POST("categories"); $this->tags = POST("tags"); $this->URL = PATH("blog/" . date("Y")) . "/" . date("m") . "/" . date("d") . "/" . slug(POST("title", "clean")); $this->muralExist = POST("mural_exist"); $this->Files = $this->core("Files"); $this->mural = FILES("mural"); if ($this->mural["name"] !== "") { $dir = "www/lib/files/images/mural/"; $this->mural = $this->Files->uploadImage($dir, "mural", "mural"); if (is_array($this->mural)) { return $this->mural["alert"]; } } $dir = "www/lib/files/images/blog/"; $this->image = $this->Files->uploadImage($dir, "image", "resize", TRUE, TRUE, FALSE); $data = array("ID_User" => SESSION("ZanUserID"), "ID_URL" => 1, "Slug" => slug(POST("title", "clean")), "Content" => POST("content", "clean"), "Author" => SESSION("ZanUser"), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Image_Small" => isset($this->image["small"]) ? $this->image["small"] : NULL, "Image_Medium" => isset($this->image["medium"]) ? $this->image["medium"] : NULL, "Pwd" => POST("pwd") ? POST("pwd", "encrypt") : NULL, "Start_Date" => now(4), "Text_Date" => now(2)); $this->Data->ignore(array("categories", "tags", "mural_exists", "mural", "pwd", "category", "language_category", "application", "mural_exist")); $this->data = $this->Data->proccess($data, $validations); if (isset($this->data["error"])) { return $this->data["error"]; } }
public function upload($file) { $this->Files = $this->core("Files"); $this->Files->filename = FILES($file, "name"); $this->Files->fileType = FILES($file, "type"); $this->Files->fileSize = FILES($file, "size"); $this->Files->fileError = FILES($file, "error"); $this->Files->fileTmp = FILES($file, "tmp_name"); $dir = "www/lib/files/images/works/"; if (!file_exists($dir)) { @mkdir($dir, 0777); } $upload = $this->Files->upload($dir); if ($upload["upload"]) { return $dir . $upload["filename"]; } else { $this->error = getAlert($upload["message"]); return FALSE; } }
public function editProfile() { if (POST("edit")) { if (POST("website")) { if (POST("website") !== "http://") { if (!ping(POST("website"))) { $alert = getAlert("Invalid URL"); } } else { $website = ""; } } $ID = POST("ID_User"); if (isset($alert)) { $website = ""; } else { if (POST("website") !== "http://") { $website = POST("website", "decode", "escape"); } } $name = POST("name", "decode", "escape"); $gender = POST("gender", "decode", "escape"); $birthday = POST("birthday", "decode", "escape"); $company = POST("company", "decode", "escape"); $country = POST("country", "decode", "escape"); $district = POST("district", "decode", "escape"); $town = POST("town", "decode", "escape"); $twitter = POST("twitter", "decode", "escape"); $facebook = POST("facebook", "decode", "escape"); $linkedin = POST("linkedin", "decode", "escape"); $google = POST("google", "decode", "escape"); $phone = POST("telephone", "decode", "escape"); $sign = POST("sign", "decode", FALSE); if (!POST("userTwitter")) { $actualAvatar = $this->Db->find($ID, $this->table); if (FILES("file", "name") !== "") { $this->Files = $this->core("Files"); $this->Files->filename = FILES("file", "name"); $this->Files->fileType = FILES("file", "type"); $this->Files->fileSize = FILES("file", "size"); $this->Files->fileError = FILES("file", "error"); $this->Files->fileTmp = FILES("file", "tmp_name"); $dir = "www/lib/files/images/users/"; if (!file_exists($dir)) { mkdir($dir, 0777); } if ($actualAvatar[0]["Avatar"] !== "") { @unlink($actualAvatar[0]["Avatar"]); } $upload = $this->Files->upload($dir); if ($upload["upload"]) { $this->Images = $this->core("Images"); $avatar = $this->Images->getResize("mini", $dir, $upload["filename"], _minOriginal, _maxOriginal); @unlink($dir . $upload["filename"]); } else { $alert2 = getAlert($upload["message"]); } } else { $avatar = ""; } if (isset($alert2)) { $avatar = ""; } } else { $avatar = ""; } if ($avatar === "") { $this->Db->update($this->table, array("Website" => $website, "Sign" => $sign), $ID); if ($update) { $data[0] = $this->Db->find($ID, $this->table); } else { return FALSE; } } else { $this->Db->update($this->table, array("Website" => $website, "Sign" => $sign, "Avatar" => $avatar), $ID); if ($update) { $data[0] = $this->Db->find($ID, $this->table); } else { return FALSE; } } $userInfo = $this->Db->findBySQL("ID_User = '******'", "users_information"); $ID2 = $userinfo[0]["ID_User"]; $data = array("Name" => $name, "Phone" => $phone, "Company" => $company, "Gender" => $gender, "Birthday" => $birthday, "Country" => $country, "District" => $district, "Town" => $town, "Facebook" => $facebook, "Twitter" => $twitter, "Linkedin" => $linkedin, "Google" => $google); $update = $this->Db->update("users_information", $data, $ID2); if ($update) { $data[1] = $this->Db->find($ID2, "users_information"); } else { return FALSE; } if ($data) { $success = TRUE; if (isset($alert)) { $data[2][] = $alert; $success = FALSE; } if (isset($alert2)) { $data[2][] = $alert2; $success = FALSE; } if ($success === TRUE) { $data[2][0] = getAlert("Your profile has been edited correctly", "success"); } return $data; } else { return FALSE; } } else { return FALSE; } }
/** * Upload and resize an image * * @param string $dir * @param string $name = "File" * @return array value */ public function uploadImage($dir, $inputName = "file", $type = "resize", $small = TRUE, $medium = TRUE, $original = TRUE) { if (!is_dir($dir)) { @mkdir($dir, 0777); } if (FILES($inputName, "name")) { $this->filename = FILES($inputName, "name"); $this->fileType = FILES($inputName, "type"); $this->fileSize = FILES($inputName, "size"); $this->fileError = FILES($inputName, "error"); $this->fileTmp = FILES($inputName, "tmp_name"); } else { return FALSE; } $upload = $this->upload($dir); if (!$upload["upload"]) { return FALSE; } $this->Images = $this->core("Images"); $this->Images->load($dir . $upload["filename"]); if ($type === "normal") { return $dir . $upload["filename"]; } elseif ($type === "resize") { if ($small) { $size["small"] = $this->Images->getResize("small", $dir, $upload["filename"]); } if ($medium) { $size["medium"] = $this->Images->getResize("medium", $dir, $upload["filename"], _minMedium, _maxMedium); } if ($original) { $size["original"] = $this->Images->getResize("original", $dir, $upload["filename"], _minOriginal, _maxOriginal); } @unlink($dir . $upload["filename"]); return $size; } elseif ($type === "mural") { if ($this->Images->getWidth() !== _muralWidth and $this->Images->getHeight() !== _muralHeight) { unlink($dir . $upload["filename"]); $alert["alert"] = getAlert("The mural image is too big"); return $alert; } else { return $dir . $upload["filename"]; } } }
public function upload($fname = "file") { $GridFS = $this->Mongo->selectCollection($this->db["dbNoSQLDatabase"], $this->collection)->getGridFS(); $name = FILES($fname, "name"); return $GridFS->storeUpload($fname, $name); }
private function save() { if (is_array(FILES("files", "name"))) { $filecount = count(FILES("files", "name")); $this->Files = $this->core("Files"); $i = 0; $noImage = 0; foreach ($_FILES["files"]["name"] as $file) { if (FILES("files", "name", $i) !== "") { $this->Files->filename = FILES("files", "name", $i); $this->Files->fileType = FILES("files", "type", $i); $this->Files->fileSize = FILES("files", "size", $i); $this->Files->fileError = FILES("files", "error", $i); $this->Files->fileTmp = FILES("files", "tmp_name", $i); if (!$this->category or $this->category === 0) { $dir = "www/lib/files/images/gallery/unknown/"; } else { $data = $this->Db->find($this->category, $this->table); $dir = "www/lib/files/images/gallery/" . $data[0]["Nice"] . "/"; } if (!file_exists($dir)) { mkdir($dir, 0777); } $upload = $this->Files->upload($dir); if ($upload["upload"]) { $this->Images = $this->core("Images"); $this->original = $this->Images->getResize("original", $dir, $upload["filename"], _minOriginal, _maxOriginal); $this->medium = $this->Images->getResize("medium", $dir, $upload["filename"], _minOriginal, _maxOriginal); $this->small = $this->Images->getResize("small", $dir, $upload["filename"], _minOriginal, _maxOriginal); } else { return getAlert($upload["message"]); } $query = "setImage(" . SESSION("ZanUserID") . ", {$this->category}, '{$this->title}', '{$this->nice}', '{$this->description}', '{$this->small}', "; $query .= "'{$this->medium}', '{$this->original}', '{$this->date1}', '{$this->date2}', '{$this->Situation}')"; $data = $this->Db->call($query); } else { $noImage++; } $i++; } } if ($noImage === $filecount) { return getAlert("Selected Image"); } else { return getAlert("The image has been saved correctly", "success"); } }
public function uploading($dir = FALSE) { if (POST("iUpload")) { if (FILES("iFile", "name") !== "") { $this->Files->filename = FILES("iFile", "name"); $this->Files->fileType = FILES("iFile", "type"); $this->Files->fileSize = FILES("iFile", "size"); $this->Files->fileError = FILES("iFile", "error"); $this->Files->fileTmp = FILES("iFile", "tmp_name"); } } elseif (POST("dUpload")) { if (FILES("dFile", "name") !== "") { $this->Files->filename = FILES("dFile", "name"); $this->Files->fileType = FILES("dFile", "type"); $this->Files->fileSize = FILES("dFile", "size"); $this->Files->fileError = FILES("dFile", "error"); $this->Files->fileTmp = FILES("dFile", "tmp_name"); } } $parts = explode("/", $dir); if (count($parts) > 0) { if ($parts[3] === "images") { $extension = "image"; } elseif ($parts[3] === "documents") { $extension = "document"; } } if ($extension === "image") { @chmod($dir, 0777); $upload = $this->Files->upload($dir); if (!$upload["upload"]) { if ($upload["message"] === "The file size exceed the permited limit") { print "<script>window.parent.uploadResponse('1', '" . $this->Files->filename . "');</script>"; } elseif ($upload["message"] === "An error has ocurred") { print "<script>window.parent.uploadResponse('2', '" . $this->Files->filename . "');</script>"; } elseif ($upload["message"] === "The file type is not permited") { print "<script>window.parent.uploadResponse('3', '" . $this->Files->filename . "');</script>"; } elseif ($upload["message"] === "A problem occurred when trying to upload file") { print "<script>window.parent.uploadResponse('4', '" . $this->Files->filename . "');</script>"; } elseif ($upload["message"] === "The file already exists") { print "<script>window.parent.uploadResponse('5', '" . $this->Files->filename . "');</script>"; } } else { if ($this->Files->fileType !== "image/gif") { $this->Images = $this->core("Images"); $original = $this->Images->getResize("original", $dir, $upload["filename"], _minOriginal, _maxOriginal); $original = str_replace($dir, "", $original); @unlink($dir . $upload["filename"]); print "<script>uploadResponse('6', '" . $original . "');</script>"; } else { print "<script>uploadResponse('6', '" . $upload["filename"] . "');</script>"; } } } elseif ($extension === "document") { @chmod($dir, 0777); $upload = $this->Files->upload($dir, "document"); $file = $this->Files->getFileInformation(); if (is_array($file["icon"])) { if ($upload["message"] === "The file size exceed the permited limit") { print "<script>window.parent.uploadDocumentsResponse('1', '" . $this->Files->filename . "', '" . $file["icon"][0] . "', '" . $file["icon"][1] . "');</script>"; } elseif ($upload["message"] === "An error has ocurred") { print "<script>window.parent.uploadDocumentsResponse('2', '" . $this->Files->filename . "', '" . $file["icon"][0] . "', '" . $file["icon"][1] . "');</script>"; } elseif ($upload["message"] === "The file type is not permited") { print "<script>window.parent.uploadDocumentsResponse('3', '" . $this->Files->filename . "', '" . $file["icon"][0] . "', '" . $file["icon"][1] . "');</script>"; } elseif ($upload["message"] === "A problem occurred when trying to upload file") { print "<script>window.parent.uploadDocumentsResponse('4', '" . $this->Files->filename . "', '" . $file["icon"][0] . "', '" . $file["icon"][1] . "');</script>"; } elseif ($upload["message"] === "The file already exists") { print "<script>window.parent.uploadDocumentsResponse('5', '" . $this->Files->filename . "', '" . $file["icon"][0] . "', '" . $file["icon"][1] . "');</script>"; } else { print "<script>window.parent.uploadDocumentsResponse('6', '" . $upload["filename"] . "', '" . $file["icon"][0] . "', '" . $file["icon"][1] . "');</script>"; } } } }
public function upload($fname = "file") { $GridFS = $this->Mongo->selectCollection(DB_NOSQL_DATABASE, $this->collection)->getGridFS(); $name = FILES($fname, "name"); return $GridFS->storeUpload($fname, $name); }
public function uploadImage($dir, $name = "file", $type = "resize", $sizes = array("t", "s", "m", "l", "o")) { if (!is_dir($dir)) { @mkdir($dir, 0777); } if (FILES($name, "name")) { $this->filename = FILES($name, "name"); $this->fileType = FILES($name, "type"); $this->fileSize = FILES($name, "size"); $this->fileError = FILES($name, "error"); $this->fileTmp = FILES($name, "tmp_name"); } else { return false; } $upload = $this->upload($dir); if (!$upload["upload"]) { return false; } $this->Images = $this->core("Images"); $this->Images->load($dir . $upload["filename"]); if ($type === "normal") { return $dir . $upload["filename"]; } elseif ($type === "resize") { if (isset($sizes["t"])) { $size["thumbnail"] = $this->Images->getResize("thumbnail", $dir, $upload["filename"], MIN_THUMBNAIL, MAX_THUMBNAIL); } if (isset($sizes["s"])) { $size["small"] = $this->Images->getResize("small", $dir, $upload["filename"]); } if (isset($sizes["m"])) { $size["medium"] = $this->Images->getResize("medium", $dir, $upload["filename"], MIN_MEDIUM, MAX_MEDIUM); } if (isset($sizes["l"])) { $size["large"] = $this->Images->getResize("large", $dir, $upload["filename"], MIN_LARGE, MAX_LARGE); } if (isset($sizes["o"])) { $size["original"] = $dir . $upload["filename"]; } return $size; } elseif ($type === "mural") { if ($this->Images->getWidth() !== MURAL_WIDTH and $this->Images->getHeight() !== MURAL_HEIGHT) { unlink($dir . $upload["filename"]); $size = MURAL_WIDTH . "x" . MURAL_HEIGHT . __(" exactly."); $alert["alert"] = getAlert(__("The mural image's resolution must be ") . $size); return $alert; } else { return $dir . $upload["filename"]; } } }