public static function zipTree($dirname, $zipFilename, $flags = 0, $localname = '') { $zip = new self(); $zip->open($zipFilename, $flags); $zip->addTree($dirname, $localname); $zip->close(); }
/** * Build a migration file using a given table. * * @param Table $table * @return mixed */ public static function build(Table $table) { $squasher = new self($table); $squasher->content = $squasher->init(); $squasher->fillInTableData(); $squasher->content .= $squasher->close(); return str_replace("\n", PHP_EOL, $squasher->content); }
public static function zipTree($dirname, $zipFilename, $flags = 0, $localname = '') { $zip = new self(); if (file_exists($zipFilename)) { unlink($zipFilename); } $zip->open($zipFilename, ZipArchive::CREATE); $zip->addTree($dirname, $localname); $zip->close(); }
public static function checkConnectivity($host, $port, $security, $username, $password) { $smtp = new self($host, $port, $security, 10); $username != '' && $smtp->auth($username, $password); $smtp->close(); }
/** * * @param string $tmp_name path to file * @param string $type mime type * @return self * @throws Exception */ public static function createFromFile($tmp_name, $type) { $mime_type = ElggFile::detectMimeType($tmp_name, $type); if (false == in_array($mime_type, array("image/jpeg", "image/jpg"))) { register_error(elgg_echo("gallery_field:only_jpg")); return null; } $ext = "jpg"; $file = new self(); $thumb_file = new ElggFile(); $random_guid = self::genGUID(); $file->setFilename($random_guid . "." . $ext); $thumb_file->setFilename($random_guid . "_thumb." . $ext); $file->setMimeType($mime_type); $thumb_file->setMimeType($mime_type); $imgsizearray = getimagesize($tmp_name); if ($imgsizearray == false) { register_error("bad file"); return null; } $width = $imgsizearray[0]; $height = $imgsizearray[1]; $file->open("write"); $file->write(self::cropImage($tmp_name, $width, $height, 760, 580)); $file->close(); $file->access_id = 2; $thumb_file->open("write"); $thumb_file->write(self::cropImage($tmp_name, $width, $height, 200, 140)); $thumb_file->close(); $thumb_file->access_id = 2; $thumb_file->save(); $file->thumb_file_guid = $thumb_file->guid; $file->save(); return $file; }
public static function yeah($cmd, $block, $cwd = null, $env = null) { if (!is_callable($block)) { throw new YeahException("block is not callable"); } $p = new self($cmd, $cwd, $env); $block($p->pid(), $p->stdin(), $p->stdout(), $p->stderr()); return $p->close(); }
public static function thumbnail($source, $destination, $maxwidth = 150, $maxheight = 150, $scale = true) { if (file_exists($destination)) { return true; } $img = new self(); $img->createfromfile($source); $img->resize($maxwidth, $maxheight, $scale); $img->interlace(); $ret = $img->save($destination); $img->close(); return $ret; }