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


PHP Attachment::lookup方法代码示例

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


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

示例1: archiveTicket

function archiveTicket($id)
{
    $ticket = new Ticket($id);
    $tid = $ticket->getExtId();
    // Delete orphan tickets.
    $owner = $ticket->getOwner();
    if (!$owner) {
        $ticket->delete();
        return;
    }
    $o_name = $owner->getName();
    $threads = $ticket->getThreadEntries(array('M', 'R', 'N'));
    $out = ["id" => $tid, "department" => $ticket->getDeptName(), "subject" => $ticket->getSubject(), "opened" => $ticket->getOpenDate(), "closed" => $ticket->getCloseDate(), "owner" => (isset($o_name->name) ? $o_name->name : '') . " <" . $owner->getEmail() . ">", "thread" => []];
    $date = date("Y-m-d", strtotime($out["opened"]));
    $path = TICKET_PATH . "/" . $date . "/";
    if (!@file_exists($path)) {
        @mkdir($path);
    }
    // Individual messages.
    foreach ($threads as $th) {
        $out["thread"][] = ["id" => $th["id"], "staff_id" => $th["staff_id"], "thread_type" => $th["thread_type"], "poster" => $th["poster"], "title" => $th["title"], "body" => $th["body"], "created" => $th["created"], "updated" => $th["updated"], "attachments" => intval($th["attachments"])];
        // Process attachments.
        if ($th["attachments"] != 0) {
            $entry = $ticket->getThreadEntry($th['id']);
            $attachments = $entry->getAttachments();
            foreach ($attachments as $a) {
                $file = Attachment::lookup($a["attach_id"])->getFile();
                $ext = $ext = strtolower(substr(strrchr($file->getName(), '.'), 1));
                $fname = $tid . "_" . $th["id"] . "." . $ext;
                @file_put_contents(ATTACHMENT_PATH . "/" . $fname, $file->getData());
            }
        }
    }
    // write the ticket to disk
    file_put_contents($path . $tid, json_encode($out, JSON_PRETTY_PRINT));
    // delete the ticket from the db
    $ticket->delete();
}
开发者ID:knadh,项目名称:osticket-archive,代码行数:38,代码来源:archive.php

示例2: Copyright

/*********************************************************************
    attachment.php

    Handles attachment downloads & access validation.

    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.attachment.php');

//Basic checks
if(!$thisstaff || !$_GET['id'] || !$_GET['h']
        || !($attachment=Attachment::lookup($_GET['id']))
        || !($file=$attachment->getFile()))
    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!!
$vhash=md5($attachment->getFileId().session_id().strtolower($file->getKey()));
if(strcasecmp(trim($_GET['h']),$vhash) || !($ticket=$attachment->getTicket()) || !$ticket->checkStaffAccess($thisstaff)) die(__('Access Denied'));

//Download the file..
$file->download();
?>
开发者ID:CarlosAvilesMx,项目名称:CarlosAviles.Mx,代码行数:30,代码来源:attachment.php

示例3: Copyright

<?php

/*********************************************************************
    attachment.php

    Handles attachment downloads & access validation.

    Peter Rotich <peter@osticket.com>
    Copyright (c)  2006-2012 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.attachment.php';
//Basic checks
if (!$thisstaff || !$_GET['id'] || !$_GET['h'] || !($attachment = Attachment::lookup($_GET['id'])) || !($file = $attachment->getFile())) {
    die('Unknown attachment!');
}
//Validate session access hash - we want to make sure the link is FRESH! and the user has access to the parent ticket!!
$vhash = md5($attachment->getFileId() . session_id() . $file->getHash());
if (strcasecmp(trim($_GET['h']), $vhash) || !($ticket = $attachment->getTicket()) || !$ticket->checkStaffAccess($thisstaff)) {
    die('Access Denied');
}
//Download the file..
$file->download();
开发者ID:nicolap,项目名称:osTicket-1.7,代码行数:29,代码来源:attachment.php


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