当前位置: 首页>>代码示例>>PHP>>正文


PHP AttachmentFile类代码示例

本文整理汇总了PHP中AttachmentFile的典型用法代码示例。如果您正苦于以下问题:PHP AttachmentFile类的具体用法?PHP AttachmentFile怎么用?PHP AttachmentFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AttachmentFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFile

 function getFile()
 {
     if (!$this->file && $this->getFileId()) {
         $this->file = AttachmentFile::lookup($this->getFileId());
     }
     return $this->file;
 }
开发者ID:pkdevboxy,项目名称:osTicket-1.7,代码行数:7,代码来源:class.attachment.php

示例2: syncExistingAttachments

 function syncExistingAttachments()
 {
     $matches = array();
     if (!preg_match_all('/"cid:([\\w.-]{32})"/', $this->getBody(), $matches)) {
         return;
     }
     // Purge current attachments
     $this->attachments->deleteInlines();
     foreach ($matches[1] as $hash) {
         if ($file = AttachmentFile::getIdByHash($hash)) {
             $this->attachments->upload($file, true);
         }
     }
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:14,代码来源:class.draft.php

示例3: run

 function run($runtime)
 {
     $errors = array();
     $i18n = new Internationalization('en_US');
     $tpls = $i18n->getTemplate('email_template_group.yaml')->getData();
     foreach ($tpls as $t) {
         // If the email template group specifies an id attribute, remove
         // it for upgrade because we cannot assume that the id slot is
         // available
         unset($t['id']);
         EmailTemplateGroup::create($t, $errors);
     }
     $files = $i18n->getTemplate('file.yaml')->getData();
     foreach ($files as $f) {
         $id = AttachmentFile::create($f, $errors);
         // Ensure the new files are never deleted (attached to Disk)
         $sql = 'INSERT INTO ' . ATTACHMENT_TABLE . ' SET object_id=0, `type`=\'D\', inline=1' . ', file_id=' . db_input($id);
         db_query($sql);
     }
 }
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:20,代码来源:d51f303a-dad45ca2.task.php

示例4: next

 /**
  * Processes the next item on the work queue. Emits a JSON messages to
  * indicate current progress.
  *
  * Returns:
  * TRUE/NULL if the migration was successful
  */
 function next()
 {
     # Fetch next item -- use the last item so the array indices don't
     # need to be recalculated for every shift() operation.
     $info = array_pop($this->queue);
     # Attach file to the ticket
     if (!($info['data'] = @file_get_contents($info['path']))) {
         # Continue with next file
         return $this->skip($info['attachId'], sprintf('%s: Cannot read file contents', $info['path']));
     }
     # Get the mime/type of each file
     # XXX: Use finfo_buffer for PHP 5.3+
     if (function_exists('mime_content_type')) {
         //XXX: function depreciated in newer versions of PHP!!!!!
         $info['type'] = mime_content_type($info['path']);
     } elseif (function_exists('finfo_file')) {
         // PHP 5.3.0+
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
         $info['type'] = finfo_file($finfo, $info['path']);
     }
     # TODO: Add extension-based mime-type lookup
     if (!($fileId = AttachmentFile::save($info))) {
         return $this->skip($info['attachId'], sprintf('%s: Unable to migrate attachment', $info['path']));
     }
     # Update the ATTACHMENT_TABLE record to set file_id
     db_query('update ' . TICKET_ATTACHMENT_TABLE . ' set file_id=' . db_input($fileId) . ' where attach_id=' . db_input($info['attachId']));
     # Remove disk image of the file. If this fails, the migration for
     # this file would not be retried, because the file_id in the
     # TICKET_ATTACHMENT_TABLE has a nonzero value now
     if (!@unlink($info['path'])) {
         //XXX: what should we do on failure?
         $this->error(sprintf('%s: Unable to remove file from disk', $info['path']));
     }
     # TODO: Log an internal note to the ticket?
     return true;
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:43,代码来源:class.migrater.php

示例5: next

 /**
  * Processes the next item on the work queue. Emits a JSON messages to
  * indicate current progress.
  *
  * Returns:
  * TRUE/NULL if the migration was successful
  */
 function next()
 {
     # Fetch next item -- use the last item so the array indices don't
     # need to be recalculated for every shift() operation.
     $info = array_pop($this->queue);
     # Attach file to the ticket
     if (!($info['data'] = @file_get_contents($info['path']))) {
         # Continue with next file
         return $this->error(sprintf('%s: Cannot read file contents', $info['path']));
     }
     # Get the mime/type of each file
     # XXX: Use finfo_buffer for PHP 5.3+
     $info['type'] = mime_content_type($info['path']);
     if (!($fileId = AttachmentFile::save($info))) {
         return $this->error(sprintf('%s: Unable to migrate attachment', $info['path']));
     }
     # Update the ATTACHMENT_TABLE record to set file_id
     db_query('update ' . TICKET_ATTACHMENT_TABLE . ' set file_id=' . db_input($fileId) . ' where attach_id=' . db_input($info['attachId']));
     # Remove disk image of the file. If this fails, the migration for
     # this file would not be retried, because the file_id in the
     # TICKET_ATTACHMENT_TABLE has a nonzero value now
     if (!@unlink($info['path'])) {
         $this->error(sprintf('%s: Unable to remove file from disk', $info['path']));
     }
     # TODO: Log an internal note to the ticket?
     return true;
 }
开发者ID:nicolap,项目名称:osTicket-1.7,代码行数:34,代码来源:class.attachment.migrate.php

示例6: Copyright

    file.php

    File download facilitator for clients

    Peter Rotich <peter@osticket.com>
    Jared Hancock <jared@osticket.com>
    Copyright (c)  2006-2014 osTicket
    http://www.osticket.com

    Released under the GNU General Public License WITHOUT ANY WARRANTY.
    See LICENSE.TXT for details.

    vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require 'client.inc.php';
require_once INCLUDE_DIR . 'class.file.php';
//Basic checks
if (!$_GET['key'] || !$_GET['signature'] || !$_GET['expires'] || !($file = AttachmentFile::lookup($_GET['key']))) {
    Http::response(404, __('Unknown or invalid file'));
}
// Validate session access hash - we want to make sure the link is FRESH!
// and the user has access to the parent ticket!!
if ($file->verifySignature($_GET['signature'], $_GET['expires'])) {
    if (($s = @$_GET['s']) && strpos($file->getType(), 'image/') === 0) {
        return $file->display($s);
    }
    // Download the file..
    $file->download(@$_GET['disposition'] ?: false, $_GET['expires']);
}
// else
Http::response(404, __('Unknown or invalid file'));
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:31,代码来源:file.php

示例7: send

 function send($to, $subject, $message, $options = null)
 {
     global $ost;
     //Get the goodies
     require_once PEAR_DIR . 'Mail.php';
     // PEAR Mail package
     require_once PEAR_DIR . 'Mail/mime.php';
     // PEAR Mail_Mime packge
     //do some cleanup
     $to = preg_replace("/(\r\n|\r|\n)/s", '', trim($to));
     $subject = stripslashes(preg_replace("/(\r\n|\r|\n)/s", '', trim($subject)));
     $body = stripslashes(preg_replace("/(\r\n|\r)/s", "\n", trim($message)));
     /* Message ID - generated for each outgoing email */
     $messageId = sprintf('<%s%d-%s>', Misc::randCode(6), time(), $this->getEmail() ? $this->getEmail()->getEmail() : '@osTicketMailer');
     $headers = array('From' => $this->getFromAddress(), 'To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Message-ID' => $messageId, 'X-Mailer' => 'osTicket Mailer', 'Content-Type' => 'text/html; charset="UTF-8"');
     $mime = new Mail_mime();
     $mime->setTXTBody($body);
     //XXX: Attachments
     if ($attachments = $this->getAttachments()) {
         foreach ($attachments as $attachment) {
             if ($attachment['file_id'] && ($file = AttachmentFile::lookup($attachment['file_id']))) {
                 $mime->addAttachment($file->getData(), $file->getType(), $file->getName(), false);
             } elseif ($attachment['file'] && file_exists($attachment['file']) && is_readable($attachment['file'])) {
                 $mime->addAttachment($attachment['file'], $attachment['type'], $attachment['name']);
             }
         }
     }
     //Desired encodings...
     $encodings = array('head_encoding' => 'quoted-printable', 'text_encoding' => 'quoted-printable', 'html_encoding' => 'base64', 'html_charset' => 'utf-8', 'text_charset' => 'utf-8', 'head_charset' => 'utf-8');
     //encode the body
     $body = $mime->get($encodings);
     //encode the headers.
     $headers = $mime->headers($headers);
     if ($smtp = $this->getSMTPInfo()) {
         //Send via SMTP
         $mail = mail::factory('smtp', array('host' => $smtp['host'], 'port' => $smtp['port'], 'auth' => $smtp['auth'], 'username' => $smtp['username'], 'password' => $smtp['password'], 'timeout' => 20, 'debug' => false));
         $result = $mail->send($to, $headers, $body);
         if (!PEAR::isError($result)) {
             return $messageId;
         }
         $alert = sprintf("Unable to email via SMTP:%s:%d [%s]\n\n%s\n", $smtp['host'], $smtp['port'], $smtp['username'], $result->getMessage());
         $this->logError($alert);
     }
     //No SMTP or it failed....use php's native mail function.
     $mail = mail::factory('mail');
     return PEAR::isError($mail->send($to, $headers, $body)) ? false : $messageId;
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:47,代码来源:class.mailer.php

示例8: deleteAttachments

 function deleteAttachments()
 {
     $deleted = 0;
     // Clear reference table
     $res = db_query('DELETE FROM ' . TICKET_ATTACHMENT_TABLE . ' WHERE ticket_id=' . db_input($this->getId()));
     if ($res && db_affected_rows()) {
         $deleted = AttachmentFile::deleteOrphans();
     }
     return $deleted;
 }
开发者ID:nicolap,项目名称:osTicket-1.7,代码行数:10,代码来源:class.ticket.php

示例9: foreach

     data-signature="<?php
         echo Format::htmlchars(Format::viewableImages($signature)); ?>"
     data-signature-field="signature" data-dept-field="deptId"
     placeholder="Intial response for the ticket"
     name="response" id="response" cols="21" rows="8"
     style="width:80%;"><?php echo $info['response']; ?></textarea>
 <table border="0" cellspacing="0" cellpadding="2" width="100%">
 <?php
 if($cfg->allowAttachments()) { ?>
     <tr><td width="100" valign="top">Attachments:</td>
         <td>
             <div class="canned_attachments">
             <?php
             if($info['cannedattachments']) {
                 foreach($info['cannedattachments'] as $k=>$id) {
                     if(!($file=AttachmentFile::lookup($id))) continue;
                     $hash=$file->getKey().md5($file->getId().session_id().$file->getKey());
                     echo sprintf('<label><input type="checkbox" name="cannedattachments[]"
                             id="f%d" value="%d" checked="checked"
                             <a href="file.php?h=%s">%s</a>&nbsp;&nbsp;</label>&nbsp;',
                             $file->getId(), $file->getId() , $hash, $file->getName());
                 }
             }
             ?>
             </div>
             <div class="uploads"></div>
             <div class="file_input">
                 <input type="file" class="multifile" name="attachments[]" size="30" value="" />
             </div>
         </td>
     </tr>
开发者ID:Jride,项目名称:OSTicket-Thaiconnections,代码行数:31,代码来源:ticket-open.inc.php

示例10: Copyright

<?php

/*********************************************************************
    image.php

    Simply downloads the file...on hash validation as follows;

    * Hash must be 64 chars long.
    * First 32 chars is the perm. file hash
    * Next 32 chars  is md5(file_id.session_id().file_hash)

    Peter Rotich <peter@osticket.com>
    Copyright (c)  2006-2013 osTicket
    http://www.osticket.com

    Released under the GNU General Public License WITHOUT ANY WARRANTY.
    See LICENSE.TXT for details.

    vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require 'staff.inc.php';
require_once INCLUDE_DIR . 'class.file.php';
$h = trim($_GET['h']);
//basic checks
if (!$h || strlen($h) != 64 || !($file = AttachmentFile::lookup(substr($h, 0, 32))) || strcasecmp($h, $file->getDownloadHash())) {
    //next 32 is file id + session hash.
    die('Unknown or invalid file. #' . Format::htmlchars($_GET['h']));
}
$file->display();
开发者ID:pkdevboxy,项目名称:osTicket-1.7,代码行数:29,代码来源:image.php

示例11: deleteAttachments

 function deleteAttachments()
 {
     global $cfg;
     $deleted = 0;
     if ($attachments = $this->getAttachments()) {
         //Clear reference table - XXX: some attachments might be orphaned
         db_query('DELETE FROM ' . TICKET_ATTACHMENT_TABLE . ' WHERE ticket_id=' . db_input($this->getId()));
         //Delete file from DB IF NOT inuse.
         foreach ($attachments as $attachment) {
             if (($file = AttachmentFile::lookup($attachment['file_id'])) && !$file->isInuse() && $file->delete()) {
                 $deleted++;
             }
         }
     }
     return $deleted;
 }
开发者ID:ryan1432,项目名称:osTicket-1.7fork,代码行数:16,代码来源:class.ticket.php

示例12: getValue

 function getValue()
 {
     $data = $this->field->getSource();
     $ids = array();
     // Handle manual uploads (IE<10)
     if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES[$this->name])) {
         foreach (AttachmentFile::format($_FILES[$this->name]) as $file) {
             try {
                 $ids[] = $this->field->uploadFile($file);
             } catch (FileUploadError $ex) {
             }
         }
         return array_merge($ids, parent::getValue() ?: array());
     } elseif ($data && is_array($data) && !isset($data[$this->name])) {
         return array();
     }
     return parent::getValue();
 }
开发者ID:gizur,项目名称:osticket,代码行数:18,代码来源:class.forms.php

示例13: viewableImages

 function viewableImages($html, $script = false)
 {
     return preg_replace_callback('/"cid:([\\w._-]{32})"/', function ($match) use($script) {
         $hash = $match[1];
         if (!($file = AttachmentFile::lookup($hash))) {
             return $match[0];
         }
         return sprintf('"%s" data-cid="%s"', $file->getDownloadUrl(false, 'inline', $script), $match[1]);
     }, $html);
 }
开发者ID:gizur,项目名称:osticket,代码行数:10,代码来源:class.format.php

示例14: send

 function send($to, $subject, $message, $options = null)
 {
     global $ost;
     //Get the goodies
     require_once PEAR_DIR . 'Mail.php';
     // PEAR Mail package
     require_once PEAR_DIR . 'Mail/mime.php';
     // PEAR Mail_Mime packge
     //do some cleanup
     $to = preg_replace("/(\r\n|\r|\n)/s", '', trim($to));
     $subject = preg_replace("/(\r\n|\r|\n)/s", '', trim($subject));
     //We're decoding html entities here becasuse we only support plain text for now - html support comming.
     $body = Format::htmldecode(preg_replace("/(\r\n|\r)/s", "\n", trim($message)));
     /* Message ID - generated for each outgoing email */
     $messageId = sprintf('<%s%d-%s>', Misc::randCode(6), time(), $this->getEmail() ? $this->getEmail()->getEmail() : '@osTicketMailer');
     $headers = array('From' => $this->getFromAddress(), 'To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Message-ID' => $messageId, 'X-Mailer' => 'osTicket Mailer');
     //Set bulk/auto-response headers.
     if ($options && ($options['autoreply'] or $options['bulk'])) {
         $headers += array('X-Autoreply' => 'yes', 'X-Auto-Response-Suppress' => 'ALL, AutoReply', 'Auto-Submitted' => 'auto-replied');
         if ($options['bulk']) {
             $headers += array('Precedence' => 'bulk');
         } else {
             $headers += array('Precedence' => 'auto_reply');
         }
     }
     if ($options) {
         if (isset($options['inreplyto']) && $options['inreplyto']) {
             $headers += array('In-Reply-To' => $options['inreplyto']);
         }
         if (isset($options['references']) && $options['references']) {
             if (is_array($options['references'])) {
                 $headers += array('References' => implode(' ', $options['references']));
             } else {
                 $headers += array('References' => $options['references']);
             }
         }
     }
     $mime = new Mail_mime();
     $mime->setTXTBody($body);
     //XXX: Attachments
     if ($attachments = $this->getAttachments()) {
         foreach ($attachments as $attachment) {
             if ($attachment['file_id'] && ($file = AttachmentFile::lookup($attachment['file_id']))) {
                 $mime->addAttachment($file->getData(), $file->getType(), $file->getName(), false);
             } elseif ($attachment['file'] && file_exists($attachment['file']) && is_readable($attachment['file'])) {
                 $mime->addAttachment($attachment['file'], $attachment['type'], $attachment['name']);
             }
         }
     }
     //Desired encodings...
     $encodings = array('head_encoding' => 'quoted-printable', 'text_encoding' => 'base64', 'html_encoding' => 'base64', 'html_charset' => 'utf-8', 'text_charset' => 'utf-8', 'head_charset' => 'utf-8');
     //encode the body
     $body = $mime->get($encodings);
     //encode the headers.
     $headers = $mime->headers($headers, true);
     if ($smtp = $this->getSMTPInfo()) {
         //Send via SMTP
         $mail = mail::factory('smtp', array('host' => $smtp['host'], 'port' => $smtp['port'], 'auth' => $smtp['auth'], 'username' => $smtp['username'], 'password' => $smtp['password'], 'timeout' => 20, 'debug' => false));
         $result = $mail->send($to, $headers, $body);
         if (!PEAR::isError($result)) {
             return $messageId;
         }
         $alert = sprintf("Unable to email via SMTP:%s:%d [%s]\n\n%s\n", $smtp['host'], $smtp['port'], $smtp['username'], $result->getMessage());
         $this->logError($alert);
     }
     //No SMTP or it failed....use php's native mail function.
     $mail = mail::factory('mail');
     return PEAR::isError($mail->send($to, $headers, $body)) ? false : $messageId;
 }
开发者ID:pkdevboxy,项目名称:osTicket-1.7,代码行数:69,代码来源:class.mailer.php

示例15: deleteAttachments

 function deleteAttachments()
 {
     $deleted = 0;
     $sql = 'DELETE FROM ' . FAQ_ATTACHMENT_TABLE . ' WHERE faq_id=' . db_input($this->getId());
     if (db_query($sql) && db_affected_rows()) {
         $deleted = AttachmentFile::deleteOrphans();
     }
     return $deleted;
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:9,代码来源:class.faq.php


注:本文中的AttachmentFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。