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


PHP AttachmentFile::lookup方法代码示例

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


在下文中一共展示了AttachmentFile::lookup方法的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: 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

示例3: render

    function render($how)
    {
        $config = $this->field->getConfiguration();
        $name = $this->field->getFormName();
        $id = substr(md5(spl_object_hash($this)), 10);
        $attachments = $this->field->getFiles();
        $mimetypes = array_filter($config['__mimetypes'], function ($t) {
            return strpos($t, '/') !== false;
        });
        $files = array();
        foreach ($this->value ?: array() as $fid) {
            $found = false;
            foreach ($attachments as $f) {
                if ($f['id'] == $fid) {
                    $files[] = $f;
                    $found = true;
                    break;
                }
            }
            if (!$found && ($file = AttachmentFile::lookup($fid))) {
                $files[] = array('id' => $file->getId(), 'name' => $file->getName(), 'type' => $file->getType(), 'size' => $file->getSize(), 'download_url' => $file->getDownloadUrl());
            }
        }
        ?>
<div id="<?php 
        echo $id;
        ?>
" class="filedrop"><div class="files"></div>
            <div class="dropzone"><i class="icon-upload"></i>
            <?php 
        echo sprintf(__('Drop files here or %s choose them %s'), '<a href="#" class="manual">', '</a>');
        ?>
        <input type="file" multiple="multiple"
            id="file-<?php 
        echo $id;
        ?>
" style="display:none;"
            accept="<?php 
        echo implode(',', $config['__mimetypes']);
        ?>
"/>
        </div></div>
        <script type="text/javascript">
        $(function(){$('#<?php 
        echo $id;
        ?>
 .dropzone').filedropbox({
          url: 'ajax.php/form/upload/<?php 
        echo $this->field->get('id');
        ?>
',
          link: $('#<?php 
        echo $id;
        ?>
').find('a.manual'),
          paramname: 'upload[]',
          fallback_id: 'file-<?php 
        echo $id;
        ?>
',
          allowedfileextensions: <?php 
        echo JsonDataEncoder::encode($config['__extensions'] ?: array());
        ?>
,
          allowedfiletypes: <?php 
        echo JsonDataEncoder::encode($mimetypes);
        ?>
,
          maxfiles: <?php 
        echo $config['max'] ?: 20;
        ?>
,
          maxfilesize: <?php 
        echo ($config['size'] ?: 1048576) / 1048576;
        ?>
,
          name: '<?php 
        echo $name;
        ?>
[]',
          files: <?php 
        echo JsonDataEncoder::encode($files);
        ?>
        });});
        </script>
<?php 
    }
开发者ID:gizur,项目名称:osticket,代码行数:87,代码来源:class.forms.php

示例4: 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

示例5: send


//.........这里部分代码省略.........
         if ($irt = $options['thread']->getEmailMessageId()) {
             // This is an response from an email, like and autoresponse.
             // Web posts will not have a email message-id
             $headers += array('In-Reply-To' => $irt, 'References' => $options['thread']->getEmailReferences());
         } elseif ($parent = $options['thread']->getParent()) {
             // Use the parent item as the email information source. This
             // will apply for staff replies
             $headers += array('In-Reply-To' => $parent->getEmailMessageId(), 'References' => $parent->getEmailReferences());
         }
         // Configure the reply tag and embedded message id token
         $mid_token = $options['thread']->asMessageId($to);
         if ($cfg && $cfg->stripQuotedReply() && (!isset($options['reply-tag']) || $options['reply-tag'])) {
             $reply_tag = $cfg->getReplySeparator() . '<br/><br/>';
         }
     }
     // Use general failsafe default initially
     $eol = "\n";
     // MAIL_EOL setting can be defined in `ost-config.php`
     if (defined('MAIL_EOL') && is_string(MAIL_EOL)) {
         $eol = MAIL_EOL;
     }
     $mime = new Mail_mime($eol);
     // If the message is not explicitly declared to be a text message,
     // then assume that it needs html processing to create a valid text
     // body
     $isHtml = true;
     if (!(isset($options['text']) && $options['text'])) {
         if ($reply_tag || $mid_token) {
             $message = "<div style=\"display:none\"\n                    class=\"mid-{$mid_token}\">{$reply_tag}</div>{$message}";
         }
         $txtbody = rtrim(Format::html2text($message, 90, false)) . ($mid_token ? "\nRef-Mid: {$mid_token}\n" : '');
         $mime->setTXTBody($txtbody);
     } else {
         $mime->setTXTBody($message);
         $isHtml = false;
     }
     if ($isHtml && $cfg && $cfg->isHtmlThreadEnabled()) {
         // Pick a domain compatible with pear Mail_Mime
         $matches = array();
         if (preg_match('#(@[0-9a-zA-Z\\-\\.]+)#', $this->getFromAddress(), $matches)) {
             $domain = $matches[1];
         } else {
             $domain = '@localhost';
         }
         // Format content-ids with the domain, and add the inline images
         // to the email attachment list
         $self = $this;
         $message = preg_replace_callback('/cid:([\\w.-]{32})/', function ($match) use($domain, $mime, $self) {
             if (!($file = AttachmentFile::lookup($match[1]))) {
                 return $match[0];
             }
             $mime->addHTMLImage($file->getData(), $file->getType(), $file->getName(), false, $match[1] . $domain);
             // Don't re-attach the image below
             unset($self->attachments[$file->getId()]);
             return $match[0] . $domain;
         }, $message);
         // Add an HTML body
         $mime->setHTMLBody($message);
     }
     //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);
             }
         }
     }
     //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);
     // Cache smtp connections made during this request
     static $smtp_connections = array();
     if ($smtp = $this->getSMTPInfo()) {
         //Send via SMTP
         $key = sprintf("%s:%s:%s", $smtp['host'], $smtp['port'], $smtp['username']);
         if (!isset($smtp_connections[$key])) {
             $mail = mail::factory('smtp', array('host' => $smtp['host'], 'port' => $smtp['port'], 'auth' => $smtp['auth'], 'username' => $smtp['username'], 'password' => $smtp['password'], 'timeout' => 20, 'debug' => false, 'persist' => true));
             if ($mail->connect()) {
                 $smtp_connections[$key] = $mail;
             }
         } else {
             // Use persistent connection
             $mail = $smtp_connections[$key];
         }
         $result = $mail->send($to, $headers, $body);
         if (!PEAR::isError($result)) {
             return $messageId;
         }
         // Force reconnect on next ->send()
         unset($smtp_connections[$key]);
         $alert = sprintf(__("Unable to email via SMTP:%1\$s:%2\$d [%3\$s]\n\n%4\$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:KM-MFG,项目名称:osTicket-1.8,代码行数:101,代码来源:class.mailer.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: 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

示例8: updatePagesSettings

 function updatePagesSettings($vars, &$errors)
 {
     global $ost;
     $f = array();
     $f['landing_page_id'] = array('type' => 'int', 'required' => 1, 'error' => 'required');
     $f['offline_page_id'] = array('type' => 'int', 'required' => 1, 'error' => 'required');
     $f['thank-you_page_id'] = array('type' => 'int', 'required' => 1, 'error' => 'required');
     if ($_FILES['logo']) {
         $error = false;
         list($logo) = AttachmentFile::format($_FILES['logo']);
         if (!$logo) {
         } elseif ($logo['error']) {
             $errors['logo'] = $logo['error'];
         } elseif (!($id = AttachmentFile::uploadLogo($logo, $error))) {
             $errors['logo'] = sprintf(__('Unable to upload logo image: %s'), $error);
         }
     }
     $company = $ost->company;
     $company_form = $company->getForm();
     $company_form->setSource($_POST);
     if (!$company_form->isValid()) {
         $errors += $company_form->errors();
     }
     if (!Validator::process($f, $vars, $errors) || $errors) {
         return false;
     }
     $company_form->save();
     if (isset($vars['delete-logo'])) {
         foreach ($vars['delete-logo'] as $id) {
             if ($vars['selected-logo'] != $id && ($f = AttachmentFile::lookup($id))) {
                 $f->delete();
             }
         }
     }
     return $this->updateAll(array('landing_page_id' => $vars['landing_page_id'], 'offline_page_id' => $vars['offline_page_id'], 'thank-you_page_id' => $vars['thank-you_page_id'], 'client_logo_id' => is_numeric($vars['selected-logo']) && $vars['selected-logo'] ? $vars['selected-logo'] : false, 'staff_logo_id' => is_numeric($vars['selected-logo-scp']) && $vars['selected-logo-scp'] ? $vars['selected-logo-scp'] : false));
 }
开发者ID:gizur,项目名称:osticket,代码行数:36,代码来源:class.config.php

示例9: foreach

                    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>
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:31,代码来源:ticket-open.inc.php

示例10: getFileList

 function getFileList()
 {
     global $thisstaff;
     if (!$thisstaff) {
         Http::response(403, "Login required for file queries");
     }
     $sql = 'SELECT distinct f.id, COALESCE(a.type, f.ft) FROM ' . FILE_TABLE . ' f LEFT JOIN ' . ATTACHMENT_TABLE . ' a ON (a.file_id = f.id)
         WHERE (a.`type` IN (\'C\', \'F\', \'T\', \'P\') OR f.ft = \'L\')
             AND f.`type` LIKE \'image/%\'';
     if (!($res = db_query($sql))) {
         Http::response(500, 'Unable to lookup files');
     }
     $files = array();
     $folders = array('C' => __('Canned Responses'), 'F' => __('FAQ Articles'), 'T' => __('Email Templates'), 'L' => __('Logos'), 'P' => __('Pages'));
     while (list($id, $type) = db_fetch_row($res)) {
         $f = AttachmentFile::lookup($id);
         $url = $f->getDownloadUrl();
         $files[] = array('thumb' => $url . '&s=128', 'image' => $url, 'title' => $f->getName(), 'folder' => $folders[$type]);
     }
     echo JsonDataEncoder::encode($files);
 }
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:21,代码来源:ajax.draft.php

示例11: run

 function run($args, $options)
 {
     Bootstrap::connect();
     osTicket::start();
     switch ($args['action']) {
         case 'backends':
             // List configured backends
             foreach (FileStorageBackend::allRegistered() as $char => $bk) {
                 print "{$char} -- {$bk::$desc} ({$bk})\n";
             }
             break;
         case 'list':
             // List files matching criteria
             // ORM would be nice!
             $files = FileModel::objects();
             $this->_applyCriteria($options, $files);
             foreach ($files as $f) {
                 printf("% 5d %s % 8d %s % 16s %s\n", $f->id, $f->bk, $f->size, $f->created, $f->type, $f->name);
                 if ($f->attrs) {
                     printf("        %s\n", $f->attrs);
                 }
             }
             break;
         case 'dump':
             $files = FileModel::objects();
             $this->_applyCriteria($options, $files);
             if ($files->count() != 1) {
                 $this->fail('Criteria must select exactly 1 file');
             }
             if (($f = AttachmentFile::lookup($files[0]->id)) && ($bk = $f->open())) {
                 $bk->passthru();
             }
             break;
         case 'load':
             // Load file content from STDIN
             $files = FileModel::objects();
             $this->_applyCriteria($options, $files);
             if ($files->count() != 1) {
                 $this->fail('Criteria must select exactly 1 file');
             }
             $f = AttachmentFile::lookup($files[0]->id);
             try {
                 if ($bk = $f->open()) {
                     $bk->unlink();
                 }
             } catch (Exception $e) {
             }
             if ($options['to']) {
                 $bk = FileStorageBackend::lookup($options['to'], $f);
             } else {
                 // Use the system default
                 $bk = AttachmentFile::getBackendForFile($f);
             }
             $type = false;
             $signature = '';
             $finfo = new finfo(FILEINFO_MIME_TYPE);
             if ($options['file'] && $options['file'] != '-') {
                 if (!file_exists($options['file'])) {
                     $this->fail($options['file'] . ': Cannot open file');
                 }
                 if (!$bk->upload($options['file'])) {
                     $this->fail('Unable to upload file contents to backend');
                 }
                 $type = $finfo->file($options['file']);
                 list(, $signature) = AttachmentFile::_getKeyAndHash($options['file'], true);
             } else {
                 $stream = fopen('php://stdin', 'rb');
                 while ($block = fread($stream, $bk->getBlockSize())) {
                     if (!$bk->write($block)) {
                         $this->fail('Unable to send file contents to backend');
                     }
                     if (!$type) {
                         $type = $finfo->buffer($block);
                     }
                 }
                 if (!$bk->flush()) {
                     $this->fail('Unable to commit file contents to backend');
                 }
             }
             // TODO: Update file metadata
             $sql = 'UPDATE ' . FILE_TABLE . ' SET bk=' . db_input($bk->getBkChar()) . ', created=CURRENT_TIMESTAMP' . ', type=' . db_input($type) . ', signature=' . db_input($signature) . ' WHERE id=' . db_input($f->getId());
             if (!db_query($sql) || db_affected_rows() != 1) {
                 $this->fail('Unable to update file metadata');
             }
             $this->stdout->write("Successfully saved contents\n");
             break;
         case 'migrate':
             if (!$options['to']) {
                 $this->fail('Please specify a target backend for migration');
             }
             if (!FileStorageBackend::isRegistered($options['to'])) {
                 $this->fail('Target backend is not installed. See `backends` action');
             }
             $files = FileModel::objects();
             $this->_applyCriteria($options, $files);
             $count = 0;
             foreach ($files as $m) {
                 $f = AttachmentFile::lookup($m->id);
                 if ($f->getBackend() == $options['to']) {
                     continue;
//.........这里部分代码省略.........
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:101,代码来源:file.php

示例12: deleteAttachment

 function deleteAttachment($fileId)
 {
     $sql = 'DELETE FROM ' . FAQ_ATTACHMENT_TABLE . ' WHERE faq_id=' . db_input($this->getId()) . ' AND file_id=' . db_input($fileId) . ' LIMIT 1';
     if (!db_query($sql) || !db_affected_rows()) {
         return false;
     }
     if (($file = AttachmentFile::lookup($fileId)) && !$file->isInuse()) {
         $file->delete();
     }
     return true;
 }
开发者ID:ryan1432,项目名称:osTicket-1.7fork,代码行数:11,代码来源:class.faq.php

示例13: send

 function send($to, $subject, $message, $options = null)
 {
     global $ost, $cfg;
     //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));
     /* Message ID - generated for each outgoing email */
     $messageId = sprintf('<%s-%s-%s>', substr(md5('mail' . SECRET_SALT), -9), Misc::randCode(9), $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');
     // Add in the options passed to the constructor
     $options = ($options ?: array()) + $this->options;
     if (isset($options['nobounce']) && $options['nobounce']) {
         $headers['Return-Path'] = '<>';
     } elseif ($this->getEmail() instanceof Email) {
         $headers['Return-Path'] = $this->getEmail()->getEmail();
     }
     //Bulk.
     if (isset($options['bulk']) && $options['bulk']) {
         $headers += array('Precedence' => 'bulk');
     }
     //Auto-reply - mark as autoreply and supress all auto-replies
     if (isset($options['autoreply']) && $options['autoreply']) {
         $headers += array('Precedence' => 'auto_reply', 'X-Autoreply' => 'yes', 'X-Auto-Response-Suppress' => 'DR, RN, OOF, AutoReply', 'Auto-Submitted' => 'auto-replied');
     }
     //Notice (sort of automated - but we don't want auto-replies back
     if (isset($options['notice']) && $options['notice']) {
         $headers += array('X-Auto-Response-Suppress' => 'OOF, AutoReply', 'Auto-Submitted' => 'auto-generated');
     }
     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']);
             }
         }
     }
     // The Suhosin patch will muck up the line endings in some
     // cases
     //
     // References:
     // https://github.com/osTicket/osTicket-1.8/issues/202
     // http://pear.php.net/bugs/bug.php?id=12032
     // http://us2.php.net/manual/en/function.mail.php#97680
     if ((extension_loaded('suhosin') || defined("SUHOSIN_PATCH")) && !$this->getSMTPInfo()) {
         $mime = new Mail_mime("\n");
     } else {
         // Use defaults
         $mime = new Mail_mime();
     }
     // If the message is not explicitly declared to be a text message,
     // then assume that it needs html processing to create a valid text
     // body
     $isHtml = true;
     $mid_token = isset($options['thread']) ? $options['thread']->asMessageId($to) : '';
     if (!(isset($options['text']) && $options['text'])) {
         if ($cfg && $cfg->stripQuotedReply() && ($tag = $cfg->getReplySeparator()) && (!isset($options['reply-tag']) || $options['reply-tag'])) {
             $message = "<div style=\"display:none\"\n                    data-mid=\"{$mid_token}\">{$tag}<br/><br/></div>{$message}";
         }
         $txtbody = rtrim(Format::html2text($message, 90, false)) . ($mid_token ? "\nRef-Mid: {$mid_token}\n" : '');
         $mime->setTXTBody($txtbody);
     } else {
         $mime->setTXTBody($message);
         $isHtml = false;
     }
     if ($isHtml && $cfg && $cfg->isHtmlThreadEnabled()) {
         // Pick a domain compatible with pear Mail_Mime
         $matches = array();
         if (preg_match('#(@[0-9a-zA-Z\\-\\.]+)#', $this->getFromAddress(), $matches)) {
             $domain = $matches[1];
         } else {
             $domain = '@localhost';
         }
         // Format content-ids with the domain, and add the inline images
         // to the email attachment list
         $self = $this;
         $message = preg_replace_callback('/cid:([\\w.-]{32})/', function ($match) use($domain, $mime, $self) {
             if (!($file = AttachmentFile::lookup($match[1]))) {
                 return $match[0];
             }
             $mime->addHTMLImage($file->getData(), $file->getType(), $file->getName(), false, $match[1] . $domain);
             // Don't re-attach the image below
             unset($self->attachments[$file->getId()]);
             return $match[0] . $domain;
         }, $message);
         // Add an HTML body
         $mime->setHTMLBody($message);
     }
     //XXX: Attachments
     if ($attachments = $this->getAttachments()) {
         foreach ($attachments as $attachment) {
             if ($attachment['file_id'] && ($file = AttachmentFile::lookup($attachment['file_id']))) {
//.........这里部分代码省略.........
开发者ID:Jride,项目名称:OSTicket-Thaiconnections,代码行数:101,代码来源:class.mailer.php

示例14: WriteHtml

 function WriteHtml()
 {
     static $filenumber = 1;
     $args = func_get_args();
     $text =& $args[0];
     $self = $this;
     $text = preg_replace_callback('/cid:([\\w.-]{32})/', function ($match) use($self, &$filenumber) {
         if (!($file = AttachmentFile::lookup($match[1]))) {
             return $match[0];
         }
         $key = "__attached_file_" . $filenumber++;
         $self->{$key} = $file->getData();
         return 'var:' . $key;
     }, $text);
     call_user_func_array(array('parent', 'WriteHtml'), $args);
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:16,代码来源:class.pdf.php

示例15: pdfExport

 function pdfExport($psize = 'Letter', $notes = false, $printAttachments)
 {
     global $thisstaff;
     require_once INCLUDE_DIR . 'class.pdf.php';
     if (!is_string($psize)) {
         if ($_SESSION['PAPER_SIZE']) {
             $psize = $_SESSION['PAPER_SIZE'];
         } elseif (!$thisstaff || !($psize = $thisstaff->getDefaultPaperSize())) {
             $psize = 'Letter';
         }
     }
     $pdfConverterPath = INCLUDE_DIR . 'pdfConverter/';
     $cmd = " find " . $pdfConverterPath . ' -type f -delete';
     shell_exec($cmd);
     $name = 'Ticket.pdf';
     $pdf = new Ticket2PDF($this, $psize, $notes);
     $pdf->Output($pdfConverterPath . $name, 'F');
     $cmd = "chmod -R 777 " . $pdfConverterPath . $name;
     shell_exec($cmd);
     $pdf = new mPDF('c');
     $pdf->allow_charset_conversion = true;
     // Set by default to TRUE
     $pdf->charset_in = 'windows-1252';
     $pdf->SetImportUse();
     $this->importPdfPages($pdf, $pdfConverterPath . $name);
     $attachmentOrder = 1;
     foreach ($printAttachments as $attachmentId) {
         if (!($f = AttachmentFile::lookup(intval($attachmentId)))) {
             break;
         }
         // $this->logErrors($f->getDownloadUrl());
         // $this->logErrors("http://mailtest.spitzeco.dk/".$f->getDownloadUrl());
         if ($fileData = $f->getData()) {
             // $this->logErrors(json_encode($file['data']));
             $timestamp = date("Y-m-d_H");
             $extension = pathinfo($f->getName(), PATHINFO_EXTENSION);
             // $this->logErrors("fileName  ".$f->getName());
             $stringName = preg_replace('/\\s+/', '', $f->getName());
             // $tempName = $timestamp.basename($stringName, '.'.$extension);
             // give the file a temp name in case the file name contians some blank space and then the command would take effect
             $tempName = "tempFile" . $attachmentOrder;
             file_put_contents($pdfConverterPath . $tempName . "." . $extension, $fileData);
             $originalFileName = $pdfConverterPath . $tempName . "." . $extension;
             $formattedFile = $tempName . "formatted.pdf";
             $cmd = "chmod -R 777 " . $pdfConverterPath . $tempName . "." . $extension;
             shell_exec($cmd);
             // this is a command for changing other format to pdf
             $cmd = 'export HOME=/tmp && /usr/bin/libreoffice5.0 --headless --convert-to pdf --outdir ' . $pdfConverterPath . " " . $pdfConverterPath . $tempName . "." . $extension;
             // $this->logErrors("2222222 ".$cmd);
             system($cmd);
             $cmd = "chmod -R 777 " . $pdfConverterPath . $tempName . ".pdf";
             shell_exec($cmd);
             // this command is for making unformatted files become formatted
             $cmd = 'gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=' . $pdfConverterPath . $formattedFile . ' ' . $pdfConverterPath . $tempName . ".pdf";
             shell_exec($cmd);
             $cmd = "chmod -R 777 " . $pdfConverterPath . $formattedFile;
             shell_exec($cmd);
             try {
                 $this->importPdfPages($pdf, $pdfConverterPath . $formattedFile);
                 $cmd = "chmod -R 777 " . $pdfConverterPath . $tempName . ".pdf";
                 shell_exec($cmd);
             } catch (Exception $e) {
                 logErrors('Caught exception: ', $e->getMessage(), "\n");
                 break;
             }
             $attachmentOrder = $attachmentOrder + 1;
         }
     }
     $name = 'Ticket-' . $this->getNumber() . '.pdf';
     $pdf->Output($name, 'I');
     //Remember what the user selected - for autoselect on the next print.
     $_SESSION['PAPER_SIZE'] = $psize;
     exit;
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:74,代码来源:class.ticket.php


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