コード例 #1
0
ファイル: PDF.php プロジェクト: ndreynolds/arcs
 /**
  * Constructor
  *
  * @param string $path file path to a PDF.
  */
 public function __construct($path, $options = array())
 {
     # Make sure it exists and is readable.
     if (!is_file($path) || !is_readable($path)) {
         throw new \Exception('File does not exist, or could not be read.');
     }
     # Make sure it's a PDF.
     $mtype = Mime::mime($path);
     if ($mtype != 'application/pdf' && $mtype != 'application/x-pdf') {
         throw new \Exception('File is not a PDF.');
     }
     $this->path = $path;
     $this->pathinfo = pathinfo($path);
     $this->info = $this->getInfo();
     $this->npages = $this->info['Pages'];
     $this->options = array_merge($this->defaults, $options);
     if ($this->options['verbose']) {
         $this->verbose = true;
     }
     if (is_null($this->options['basename'])) {
         $this->options['basename'] = $this->pathinfo['filename'];
     }
     if ($this->options['resolution'] == 0) {
         $this->options['resolution'] = $this->getResolution();
     }
 }
コード例 #2
0
ファイル: Mime.class.php プロジェクト: nahakiole/cloudrexx
 /**
  * Return the MIME type for the extension provided.
  *
  * Takes a full file name, or a file extension with or without
  * the dot as an argument, i.e. 'contrexx.zip', '.gif, or 'txt'.
  * Returns the string 'application/octet-stream' for any unknown ending.
  * Use {@link isKnownExtension()} to test exactly that.
  * @static
  * @param   string     $strExtension    The file extension
  * @return  string                      The corresponding MIME type
  * @author  Reto Kohli <*****@*****.**>
  */
 static function getMimeTypeForExtension($strExtension)
 {
     // Make sure only the extension is present.
     // Chop the file name up to and including  the last dot
     $strChoppedExtension = preg_replace('/^.*\\./', '', $strExtension);
     if (Mime::isKnownExtension($strChoppedExtension)) {
         return self::$arrExtensions2MimeTypes[$strChoppedExtension];
     }
     return self::$strDefaultType;
 }
コード例 #3
0
 public function __init($response_type = Mime::JSON)
 {
     $accept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null;
     if (!empty($accept) && $accept !== '*/*' && strpos($accept, ',') === false && Mime::isDefined($accept)) {
         $response_type = $accept;
     }
     parent::__init($response_type);
     if ($response_type === Mime::JSON) {
         $jsonp_callback_name = $this->request->get(static::JSONP_CALLBACK_PARAM_NAME);
         $this->_allow_jsonp = true;
         $this->_jsonp_callback = !empty($jsonp_callback_name) ? $jsonp_callback_name : null;
     }
 }
コード例 #4
0
ファイル: Image.php プロジェクト: ndreynolds/arcs
 /**
  * Create a preview image given a source image.
  *
  * @param  string $src
  * @param  string $dst
  * @return bool
  */
 public static function preview($src, $dst, $options = array())
 {
     if (!is_readable($src)) {
         return false;
     }
     if (Mime::mime($src) == 'application/pdf') {
         $src .= '[0]';
     }
     $image = new static($src);
     $image->format('jpeg');
     $image->scale(700, 700);
     return $image->save($dst);
 }
コード例 #5
0
ファイル: httpful.test.php プロジェクト: nickl-/httpful
function testShortMime()
{
    // Valid short ones
    assert(Mime::JSON === Mime::getFullMime('json'));
    assert(Mime::XML === Mime::getFullMime('xml'));
    assert(Mime::HTML === Mime::getFullMime('html'));
    // Valid long ones
    assert(Mime::JSON === Mime::getFullMime(Mime::JSON));
    assert(Mime::XML === Mime::getFullMime(Mime::XML));
    assert(Mime::HTML === Mime::getFullMime(Mime::HTML));
    // No false positives
    assert(Mime::XML !== Mime::getFullMime(Mime::HTML));
    assert(Mime::JSON !== Mime::getFullMime(Mime::XML));
    assert(Mime::HTML !== Mime::getFullMime(Mime::JSON));
}
コード例 #6
0
ファイル: Validator.php プロジェクト: goragod/kotchasan
 /**
  * ฟังก์ชั่นตรวจสอบไฟล์อัปโหลดว่าเป็นรูปภาพหรือไม่
  *
  * @param array $excepts ชนิดของไฟล์ที่ยอมรับเช่น array('jpg', 'gif', 'png')
  * @param array $file_upload รับค่ามาจาก $_FILES
  * @return array|bool คืนค่าแอเรย์ [width, height, mime] ของรูปภาพ หรือ  false ถ้าไม่ใช่รูปภาพ
  */
 public static function isImage($excepts, $file_upload)
 {
     // ext
     $imageinfo = explode('.', $file_upload['name']);
     $imageinfo = array('ext' => strtolower(end($imageinfo)));
     if (in_array($imageinfo['ext'], $excepts)) {
         // Exif
         $info = getImageSize($file_upload['tmp_name']);
         if ($info[0] == 0 || $info[1] == 0 || !Mime::check($excepts, $info['mime'])) {
             return false;
         } else {
             $imageinfo['width'] = $info[0];
             $imageinfo['height'] = $info[1];
             $imageinfo['mime'] = $info['mime'];
             return $imageinfo;
         }
     } else {
         return false;
     }
 }
コード例 #7
0
 /**
  * Build attachment for sending
  * 
  * @return string
  */
 public function build()
 {
     $nl = GlobalConstants::NEW_LINE;
     // Fail if missing data
     if (is_null($this->content) && is_null($this->path)) {
         throw new MailAttachmentNoContentException($this->path);
     }
     // Extract name from path
     if (!$this->name && $this->path) {
         $this->name = basename($this->path);
     }
     // Extract mime type from path
     if (!$this->mime_type && $this->name) {
         $this->mime_type = Mime::getFromFile($this->name);
     }
     // Set Content-Type part header
     $source = 'Content-Type: ' . $this->mime_type . ($this->name ? '; name="' . $this->name . '"' : '') . $nl;
     // Set Content-Transfer-Encoding part header
     if ($this->transfer_encoding) {
         $source .= 'Content-Transfer-Encoding: ' . $this->transfer_encoding . $nl;
     }
     // Set Content-Disposition part header
     $source .= 'Content-Disposition: ' . $this->disposition . ($this->name ? '; filename="' . $this->name . '"' : '') . $nl;
     // Set Content-ID part header (for embedded attachments)
     if ($this->cid) {
         $source .= 'Content-ID: ' . $this->cid . $nl;
     }
     // Get file data
     $content = $this->content ? $this->content : file_get_contents($this->path);
     // Encode file data if needed
     switch ($this->transfer_encoding) {
         case 'base64':
             $content = chunk_split(base64_encode($content));
             break;
     }
     $source .= $nl . $content . $nl;
     return $source;
 }
コード例 #8
0
ファイル: request.php プロジェクト: acmadi/diantaksi
 /**
  * Magic method allows for neatly setting other headers in a
  * similar syntax as the other setters.  This method also allows
  * for the sends* syntax.
  * @return Request this
  * @param string $method "missing" method name called
  *    the method name called should be the name of the header that you
  *    are trying to set in camel case without dashes e.g. to set a
  *    header for Content-Type you would use contentType() or more commonly
  *    to add a custom header like X-My-Header, you would use xMyHeader().
  *    To promote readability, you can optionally prefix these methods with
  *    "with"  (e.g. withXMyHeader("blah") instead of xMyHeader("blah")).
  * @param array $args in this case, there should only ever be 1 argument provided
  *    and that argument should be a string value of the header we're setting
  */
 public function __call($method, $args)
 {
     // This method supports the sends* methods
     // like sendsJSON, sendsForm
     //!method_exists($this, $method) &&
     if (substr($method, 0, 5) === 'sends') {
         $mime = strtolower(substr($method, 5));
         if (Mime::supportsMimeType($mime)) {
             $this->sends(Mime::getFullMime($mime));
             return $this;
         }
         // else {
         //     throw new \Exception("Unsupported Content-Type $mime");
         // }
     }
     if (substr($method, 0, 7) === 'expects') {
         $mime = strtolower(substr($method, 7));
         if (Mime::supportsMimeType($mime)) {
             $this->expects(Mime::getFullMime($mime));
             return $this;
         }
         // else {
         //     throw new \Exception("Unsupported Content-Type $mime");
         // }
     }
     // This method also adds the custom header support as described in the
     // method comments
     if (count($args) === 0) {
         return;
     }
     // Strip the sugar.  If it leads with "with", strip.
     // This is okay because: No defined HTTP headers begin with with,
     // and if you are defining a custom header, the standard is to prefix it
     // with an "X-", so that should take care of any collisions.
     if (substr($method, 0, 4) === 'with') {
         $method = substr($method, 4);
     }
     // Precede upper case letters with dashes, uppercase the first letter of method
     $header = ucwords(implode('-', preg_split('/([A-Z][^A-Z]*)/', $method, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY)));
     $this->addHeader($header, $args[0]);
     return $this;
 }
コード例 #9
0
ファイル: Part.php プロジェクト: ParticleBits/zend-mime
 /**
  * Get the Content of the current Mime Part in the given encoding.
  *
  * @param string $EOL
  * @return string
  */
 public function getContent($EOL = Mime::LINEEND)
 {
     if ($this->isStream) {
         $encodedStream = $this->getEncodedStream($EOL);
         $encodedStreamContents = stream_get_contents($encodedStream);
         $streamMetaData = stream_get_meta_data($encodedStream);
         if (isset($streamMetaData['seekable']) && $streamMetaData['seekable']) {
             rewind($encodedStream);
         }
         return $encodedStreamContents;
     }
     return Mime::encode($this->content, $this->encoding, $EOL);
 }
コード例 #10
0
ファイル: adm_mime.php プロジェクト: kractos26/orfeo
 */
session_start();
$ruta_raiz = "../..";
include $ruta_raiz . '/config.php';
// incluir configuracion.
define('ADODB_ASSOC_CASE', 1);
include $ADODB_PATH . '/adodb.inc.php';
// $ADODB_PATH configurada en config.php
$error = 0;
$dsn = $driver . "://" . $usuario . ":" . $contrasena . "@" . $servidor . "/" . $db;
$conn = NewADOConnection($dsn);
if ($conn) {
    $conn->SetFetchMode(ADODB_FETCH_ASSOC);
    //$conn->debug=true;
    include $ruta_raiz . '/include/class/mime.class.php';
    $obj_tmp = new Mime($conn);
    $ver = 'mime';
    if (isset($_POST['btn_accion'])) {
        switch ($_POST['btn_accion']) {
            case 'Agregar':
                $sql = "insert into ANEXOS_TIPO(ANEX_TIPO_CODI, ANEX_TIPO_DESC, ANEX_TIPO_EXT) ";
                $sql .= "values (" . $_POST['txtId'] . ",'" . $_POST['txtDesc'] . "','" . $_POST['txtUsua'] . "')";
                $conn->Execute($sql) ? $error = 3 : ($error = 2);
                break;
            case 'Modificar':
                $sql = "update ANEXOS_TIPO set ANEX_TIPO_DESC = '" . $_POST['txtDesc'] . "',ANEX_TIPO_EXT = '" . $_POST['txtUsua'] . "' ";
                $sql .= "where ANEX_TIPO_CODI = " . $_POST['txtId'];
                $conn->Execute($sql) ? $error = 4 : ($error = 2);
                break;
            case 'Eliminar':
                $ok = $obj_tmp->SetDelDatos($_POST['slc_cmb2']);
コード例 #11
0
ファイル: File.php プロジェクト: romartyn/cogear
 /**
  * Upload file
  *
  * @param string $name
  * @param array $options
  * @return string|boolean
  */
 public function upload()
 {
     if (!isset($_FILES[$this->name])) {
         return FALSE;
     }
     $file = $_FILES[$this->name];
     $cogear = getInstance();
     event('file.preupload', $file);
     switch ($file['error']) {
         case UPLOAD_ERR_CANT_WRITE:
             $this->errors[] = t('Can\'t upload file. Check write permission for temporary folder.', 'File Errors');
             break;
         case UPLOAD_ERR_INI_SIZE:
             $this->errors[] = t('File size is bigger that it\'s allowed in <b>php.ini</b> (%s).', 'File Errors', ini_get('upload_max_filesize'));
             break;
         case UPLOAD_ERR_NO_FILE:
             $this->isRequired && ($this->errors[] = t('You didn\'t choose file to upload.', 'File Errors'));
             break;
         case UPLOAD_ERR_PARTIAL:
             $this->errors[] = t('Please, upload file once again.', 'File Errors');
             break;
         case UPLOAD_ERR_NO_TMP_DIR:
             $this->errors[] = t('Temporary directory is not corrected.', 'File Errors');
             break;
     }
     if ($file['error'] == UPLOAD_ERR_OK) {
         if ($this->options->allowed_types) {
             $types = is_string($this->options->allowed_types) ? new Core_ArrayObject(preg_split('#[^a-z]#', $this->options->allowed_types, -1, PREG_SPLIT_NO_EMPTY)) : $this->options->allowed_types;
             $ext = pathinfo($file['name'], PATHINFO_EXTENSION);
             $result = FALSE;
             foreach ($types as $type) {
                 $type == $ext && ($result = TRUE);
             }
             !$result && ($this->errors[] = t('Only following types of files are allowed: <b>%s</b>.', 'File Errors', $types->toString('</b>, <b>')));
         }
         $result = Mime::check($file['name'], $file['type']);
         if ($result !== TRUE) {
             $this->errors[] = t('File you are trying to upload has unusual MIME-type. It is like <b>%s</b>, but it was expected to be <b>%s</b>', 'File Errors', $file['type'], $result);
         }
         $this->options->maxsize && $this->checkMaxSize($file['size'], $this->options->maxsize);
         if (!$this->options->path) {
             $this->errors[] = t('Upload path is not defined.', 'File Erros');
         }
         strpos($this->options->path, ROOT) !== FALSE or $this->options->path = UPLOADS . DS . $this->options->path;
         Filesystem::makeDir($this->options->path);
         if (!is_dir($this->options->path)) {
             $this->errors[] = t('Upload path <b>%s</b> doesn\'t exist.', 'File Errors', $this->options->path);
         }
         $file['name'] = $this->prepareFileName($file['name']);
         $file['path'] = $this->options->path . DS . $file['name'];
         $this->file = new Core_ArrayObject($file);
         return !$this->errors ? $this->processUpload() : FALSE;
     }
     return NULL;
 }
コード例 #12
0
ファイル: response.php プロジェクト: acmadi/diantaksi
 /**
  * After we've parse the headers, let's clean things
  * up a bit and treat some headers specially
  */
 public function _interpretHeaders()
 {
     // Parse the Content-Type and charset
     $content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : '';
     $content_type = explode(';', $content_type);
     $this->content_type = $content_type[0];
     if (count($content_type) == 2 && strpos($content_type[1], '=') !== false) {
         list($nill, $this->charset) = explode('=', $content_type[1]);
     }
     // RFC 2616 states "text/*" Content-Types should have a default
     // charset of ISO-8859-1. "application/*" and other Content-Types
     // are assumed to have UTF-8 unless otherwise specified.
     // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1
     // http://www.w3.org/International/O-HTTP-charset.en.php
     if (!isset($this->charset)) {
         $this->charset = substr($this->content_type, 5) === 'text/' ? 'iso-8859-1' : 'utf-8';
     }
     // Is vendor type? Is personal type?
     if (strpos($this->content_type, '/') !== false) {
         list($type, $sub_type) = explode('/', $this->content_type);
         $this->is_mime_vendor_specific = substr($sub_type, 0, 4) === 'vnd.';
         $this->is_mime_personal = substr($sub_type, 0, 4) === 'prs.';
     }
     // Parent type (e.g. xml for application/vnd.github.message+xml)
     $this->parent_type = $this->content_type;
     if (strpos($this->content_type, '+') !== false) {
         list($vendor, $this->parent_type) = explode('+', $this->content_type, 2);
         $this->parent_type = Mime::getFullMime($this->parent_type);
     }
 }
コード例 #13
0
ファイル: seguridadImagen.php プロジェクト: kractos26/orfeo
            $rsVerif = $db->conn->Execute($sql);
            if ($rsVerif && $rsVerif->EOF) {
                $verradPermisos = "otro";
            }
        } else {
            require "{$ruta_raiz}/Administracion/usuario/SecSuperClass.php";
            $SecSuperAux = new SecSuperClass($db);
            $SecSuperAux->SecSuperFill($_SESSION['usua_doc']);
            include "{$ruta_raiz}/tx/verifSession.php";
        }
    } else {
        $verradPermisos = "Full";
    }
    if ($verradPermisos == "Full") {
        $nombre = substr($ruta, strripos($ruta, "/") + 1);
        $tipo = Mime::tipoMime($ruta);
        header("Content-type: {$tipo}");
        header('Content-Disposition: inline; filename="' . $nombre . '"');
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: " . filesize($ruta));
        readfile($ruta);
    } else {
        $numRad = $verrad;
        $radi_depe_actu = $verDependencia;
        $radi_usua_actu = $verCodusuario;
        include "{$ruta_raiz}/seguridad/sinPermisoRadicado.php";
        die("-");
    }
} else {
    header("Location: error/HTTP_NOT_FOUND.html");
}
コード例 #14
0
ファイル: GUI.class.php プロジェクト: eheb/renater-decide
 /**
  * Include favicon
  */
 public static function includeFavicon()
 {
     $location = self::favicon();
     if (!$location) {
         return;
     }
     echo '<link type="' . Mime::getFromFile($location) . '" rel="icon" href="' . self::path($location) . '" />' . "\n";
 }
コード例 #15
0
ファイル: email.class.php プロジェクト: bilel99/oge
 /**
  * Attache un fichier comme pièce jointe de l'email
  * 
  * @param string $filename     Chemin vers le fichier
  * @param string $name         Nom de fichier
  * @param string $type         Type MIME du fichier
  * @param string $disposition  Disposition
  * 
  * @access public
  * @return Mime_Part
  */
 public function attach($filename, $name = '', $type = '', $disposition = '')
 {
     if (!is_readable($filename)) {
         throw new Exception("Cannot read file '{$filename}'");
     }
     if (empty($name)) {
         $name = $filename;
     }
     if (empty($type)) {
         $type = Mime::getType($filename);
     }
     return $this->attachFromString(file_get_contents($filename), $name, $type, $disposition);
 }
コード例 #16
0
ファイル: LocalFile.class.php プロジェクト: Niggu/cloudrexx
 public function getMimeType()
 {
     return \Mime::getMimeTypeForExtension(pathinfo($this->file, PATHINFO_EXTENSION));
 }
コード例 #17
0
 /**
  * Returns the start point of the file as a Timecode object if available, otherwise returns null.
  *
  * @access public
  * @author Oliver Lillie
  * @param string $file_path 
  * @param boolean $read_from_cache 
  * @return mixed Returns a string 'audio' or 'video' if media is audio or video, otherwise returns null.
  */
 public function getFileType($file_path, $read_from_cache = true)
 {
     $cache_key = 'media_prober/' . md5(realpath($file_path)) . '_parsed_type';
     if ($read_from_cache === true && ($data = $this->_cacheGet($cache_key, -1)) !== -1) {
         return $data;
     }
     //          get the raw data
     $raw_data = $this->getFileRawInformation($file_path, $read_from_cache);
     //          grab the start times from all the streams and evaluate the earliest.
     $data = null;
     if (preg_match_all('/codec_type=(audio|video)/', $raw_data, $matches) > 0) {
         $type = null;
         foreach ($matches[1] as $key => $codec_type) {
             if ($type === null || $type === 'audio') {
                 $type = $codec_type;
             }
         }
         if ($type === 'video' && strpos(Mime::get($file_path), 'image/') !== false) {
             $type = 'image';
         }
         $data = $type;
     }
     $this->_cacheSet($cache_key, $data);
     return $data;
 }
コード例 #18
0
ファイル: CommandLine.php プロジェクト: ndreynolds/arcs
 /**
  * Constructor
  *
  * Parses arguments, looks for a command, and hands off command
  * options to another Relic library function.
  */
 public function __construct()
 {
     $this->_parseArgs();
     if (array_key_exists($this->command, $this->commands)) {
         $args = $this->_parseOpts($this->commands[$this->command]['options'], $this->commands[$this->command]['params']);
         switch ($this->command) {
             case 'thumb':
                 Image::thumbnail($args['params']['image'], $args['params']['dst'], $args['options']);
                 break;
             case 'split':
                 PDF::split($args);
                 break;
             case 'metadata':
                 $mime = Mime::mime($args['params']['file']);
                 if (in_array($mime, array('image/jpg', 'image/jpeg', 'image/tiff'))) {
                     $image = new Image($args['params']['file']);
                     $this->prettyPrint($image->exif());
                 } else {
                     if ($mime == 'application/pdf') {
                         $pdf = new PDF($args['params']['file']);
                         $this->prettyPrint($pdf->info);
                     }
                 }
                 break;
             case 'mime':
                 Mime::printMime($args['params']['file']);
                 break;
         }
     } else {
         $this->_usage(false, 'Unknown command.');
         exit(1);
     }
 }
コード例 #19
0
 /**
  * Returns the start point of the file as a Timecode object if available, otherwise returns null.
  *
  * @access public
  * @author Oliver Lillie
  * @param string $file_path 
  * @param boolean $read_from_cache 
  * @return mixed Returns a string 'audio' or 'video' if media is audio or video, otherwise returns null.
  */
 public function getFileType($file_path, $read_from_cache = true)
 {
     $cache_key = 'media_parser/' . md5(realpath($file_path)) . '_parsed_type';
     if ($read_from_cache === true && ($data = $this->_cacheGet($cache_key, -1)) !== -1) {
         return $data;
     }
     //          get the raw data
     $raw_data = $this->getFileRawInformation($file_path, $read_from_cache);
     //          grab the type
     $data = null;
     if (preg_match('/Stream.*:\\s+Video:\\s+.*/', $raw_data, $matches) > 0) {
         //              special check to see if the file is actually an image and not a video.
         if (strpos(Mime::get($file_path), 'image/') !== false) {
             $data = 'image';
         } elseif (strpos(Mime::get($file_path), 'audio/') !== false) {
             $data = 'audio';
         } else {
             $data = 'video';
         }
     } else {
         if (preg_match('/Stream.*:\\s+Audio:\\s+.*/', $raw_data, $matches) > 0) {
             $data = 'audio';
         } else {
             $data = null;
         }
     }
     $this->_cacheSet($cache_key, $data);
     return $data;
 }
コード例 #20
0
ファイル: mimeTest.php プロジェクト: limweb/kotchasan
 /**
  * Generated from @assert (array('jpg','gif','png')) [==] "image/jpeg,image/gif,image/png".
  *
  * @covers Mime::getEccept
  */
 public function testGetEccept()
 {
     $this->assertEquals("image/jpeg,image/gif,image/png", \Mime::getEccept(array('jpg', 'gif', 'png')));
 }
コード例 #21
0
ファイル: Part.php プロジェクト: vincenta/stato
 public function getContent()
 {
     return Mime::encode($this->content, $this->getEncoding(), $this->lineLength, $this->eol);
 }
コード例 #22
0
ファイル: mime.class.php プロジェクト: bilel99/oge
 /**
  * @access public
  * @return string
  */
 public function __toString()
 {
     if ($this->headers->get('Content-Type') == null) {
         $this->headers->set('Content-Type', 'application/octet-stream');
     }
     $body = $this->body;
     if ($this->isMultiPart()) {
         $this->boundary = '--=_Part_' . md5(microtime());
         $this->headers->get('Content-Type')->param('boundary', $this->boundary);
         if ($body != '') {
             $body .= "\r\n\r\n";
         }
         foreach ($this->subparts as $subpart) {
             $body .= '--' . $this->boundary . "\r\n";
             $body .= !is_string($subpart) ? $subpart->__toString() : $subpart;
             $body .= "\r\n";
         }
         $body .= '--' . $this->boundary . "--\r\n";
     } else {
         if ($encoding = $this->headers->get('Content-Transfer-Encoding')) {
             $encoding = strtolower($encoding->value);
         }
         if (!in_array($encoding, array('7bit', '8bit', 'quoted-printable', 'base64', 'binary'))) {
             $this->headers->remove('Content-Transfer-Encoding');
             $encoding = '7bit';
         }
         switch ($encoding) {
             case 'quoted-printable':
                 /**
                  * Encodage en chaîne à guillemets
                  * 
                  * @see RFC 2045#6.7
                  */
                 $body = Mime::quotedPrintableEncode($body);
                 break;
             case 'base64':
                 /**
                  * Encodage en base64
                  * 
                  * @see RFC 2045#6.8
                  */
                 $body = rtrim(chunk_split(base64_encode($body)));
                 break;
             case '7bit':
             case '8bit':
                 $body = preg_replace("/\r\n?|\n/", "\r\n", $body);
                 /**
                  * Limitation sur les longueurs des lignes de texte.
                  * La limite basse est de 78 caractères par ligne.
                  * En tout état de cause, chaque ligne ne DOIT PAS
                  * faire plus de 998 caractères.
                  * 
                  * @see RFC 2822#2.1.1
                  */
                 $body = Mime::wordwrap($body, $this->wraptext ? 78 : 998);
                 break;
         }
     }
     return $this->headers->__toString() . "\r\n" . $body;
 }
コード例 #23
0
ファイル: Part.php プロジェクト: yakamoz-fang/concrete
 /**
  * Get the Content of the current Mime Part in the given encoding.
  *
  * @param string $EOL
  * @return string
  */
 public function getContent($EOL = Mime::LINEEND)
 {
     if ($this->isStream) {
         $encodedStream = $this->getEncodedStream($EOL);
         $encodedStreamContents = stream_get_contents($encodedStream);
         rewind($encodedStream);
         return $encodedStreamContents;
     }
     return Mime::encode($this->content, $this->encoding, $EOL);
 }
コード例 #24
0
ファイル: File.php プロジェクト: ncaneldiee/sampadeh
 public static function info($file)
 {
     $temp = [];
     $temp['name'] = self::name($file);
     $temp['path'] = realpath($file);
     $temp['size'] = self::size($file);
     $temp['mime'] = Mime::get($file);
     $temp['extension'] = self::extension($file);
     $temp['permission'] = self::permission($file);
     $temp['time']['change'] = filemtime($file);
     $temp['time']['access'] = fileatime($file);
     return $temp;
 }
コード例 #25
0
ファイル: Part.php プロジェクト: royaltyclubvp/BuzzyGals
 /**
  * Get the Content of the current Mime Part in the given encoding.
  *
  * @param string $EOL
  * @return string
  */
 public function getContent($EOL = Mime::LINEEND)
 {
     if ($this->isStream) {
         return stream_get_contents($this->getEncodedStream($EOL));
     }
     return Mime::encode($this->content, $this->encoding, $EOL);
 }
コード例 #26
0
ファイル: File.php プロジェクト: froq/froq-file
 /**
  * Set extension.
  * @param  string $type
  * @return self
  */
 public final function setExtension(string $type) : self
 {
     $this->extension = Mime::getExtension($type);
     return $this;
 }