public function make_thumbnail($from, $to, $maxwidth, $maxheight) { $ext = EFileSystem::get_file_extension($from); if (!(list($width, $height, $type, $attr) = getimagesize($from))) { ELog::error("{$from} |"); } if ($width > $height) { $x = $width / $maxwidth; $fwidth = floor($width / $x); $fheight = floor($height / $x); } if ($width < $height) { $x = $height / $maxheight; $fheight = floor($height / $x); $fwidth = floor($width / $x); } if ($width == $height) { if ($maxwidth > $maxheight) { $max = $maxheight; } else { $max = $maxwidth; } $x = $height / $max; $fheight = floor($height / $x); $fwidth = floor($width / $x); } $thumb = imagecreatetruecolor($fwidth, $fheight); if ($ext == "jpg" or $ext == "jpeg") { $source = imagecreatefromjpeg($from); } if ($ext == "png") { $source = imagecreatefrompng($from); } imagecopyresized($thumb, $source, 0, 0, 0, 0, $fwidth, $fheight, $width, $height); if ($ext == "jpg" or $ext == "jpeg") { imagejpeg($thumb, $to, 100); } if ($ext == "png") { imagepng($thumb, $to, 1); } if ($ext != "jpg" or $ext != "jpeg" or $ext != "png") { return false; } else { return true; } }
public static function load_all() { EConfig::$data = array(); //enters in conf directory chdir(ELoader::$config_path); //parse every single conf file and place it in an associative array foreach (glob("*") as $filename) { $name = EFileSystem::get_file_name($filename); EConfig::$data[$name] = EConfig::parse_file($filename); } }
public function delete() { //EDatabase::q("DELETE FROM ocs_content WHERE id=".$this->id." LIMIT 1"); EDatabase::q("DELETE FROM ocs_content WHERE id=" . $this->id . " LIMIT 1"); EDatabase::q("DELETE FROM ocs_comment WHERE content=" . $this->id); EFileSystem::rmdir("content/" . $this->id); }
<?php include "gfx3/lib.php"; $prevpage = EPageProperties::get_previous_page(); $idcontent = EHeaderDataParser::db_post("idcontent"); if (!empty($_FILES['localfile'])) { $tmp_name = $_FILES['localfile']['tmp_name']; $name = $_FILES['localfile']['name']; $client = new OCSClient(); $client->set_auth_info(EUser::nick(), EUser::password()); $abs_name = EFileSystem::rename_file($tmp_name, "/tmp/" . $name); $client->set_upload_file("/tmp/" . $name); $result = $client->post("v1/content/uploaddownload/{$idcontent}"); if ($result["ocs"]["meta"]["statuscode"] == "100") { header("Location: {$prevpage}"); } else { //echo $client->get_last_raw_result(); ELog::error("something went wrong"); } }
public static function rmdir($path) { if (is_dir($path)) { EFileSystem::clean_all_files_in($path); rmdir($path); } }