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


PHP Http::response方法代码示例

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


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

示例1: staffOnly

 function staffOnly()
 {
     global $thisstaff;
     if (!$thisstaff || !$thisstaff->isValid()) {
         Http::response(401, sprintf(__('Access Denied. IP %s'), $_SERVER['REMOTE_ADDR']));
     }
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:7,代码来源:class.ajax.php

示例2: api_exit

function api_exit($code, $msg = '')
{
    global $remotehost, $cfg;
    if ($code != EX_SUCCESS && $cfg->alertONMailParseError()) {
        //Error occured...
        $_SESSION['api']['errors'] += 1;
        $_SESSION['api']['time'] = time();
        $alert = sprintf("Possible issues with the API\n\n Error Code: %d\nErrors: %d\nRemote IP:%s\n\n%s", $code, $_SESSION['api']['errors'], $_SERVER['REMOTE_ADDR'], $msg);
        //echo 'API Error(s) '.$msg;
        Misc::alertAdmin('API Error(s)', $msg);
    }
    if ($remotehost) {
        switch ($code) {
            case EX_SUCCESS:
                Http::response(200, $code, 'text/plain');
                break;
            case EX_UNAVAILABLE:
                Http::response(405, $code, 'text/plain');
                break;
            case EX_NOPERM:
                Http::response(403, $code, 'text/plain');
                break;
            case EX_DATAERR:
            case EX_NOINPUT:
            default:
                Http::response(416, $code, 'text/plain');
        }
    }
    exit($code);
}
开发者ID:googlecode-mirror,项目名称:barbos,代码行数:30,代码来源:api.inc.php

示例3: cannedResp

 function cannedResp($id, $format = '')
 {
     global $thisstaff, $_GET;
     include_once INCLUDE_DIR . 'class.canned.php';
     if (!$id || !($canned = Canned::lookup($id)) || !$canned->isEnabled()) {
         Http::response(404, 'No such premade reply');
     }
     //Load ticket.
     if ($_GET['tid']) {
         include_once INCLUDE_DIR . 'class.ticket.php';
         $ticket = Ticket::lookup($_GET['tid']);
     }
     switch ($format) {
         case 'json':
             $resp['id'] = $canned->getId();
             $resp['ticket'] = $canned->getTitle();
             $resp['response'] = $ticket ? $ticket->replaceVars($canned->getResponse()) : $canned->getResponse();
             $resp['files'] = $canned->getAttachments();
             $response = $this->json_encode($resp);
             break;
         case 'txt':
         default:
             $response = $ticket ? $ticket->replaceVars($canned->getResponse()) : $canned->getResponse();
     }
     return $response;
 }
开发者ID:pkdevboxy,项目名称:osTicket-1.7,代码行数:26,代码来源:ajax.kbase.php

示例4: search

 function search()
 {
     $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 25;
     $items = array();
     $ticketid = false;
     if (isset($_GET['id'])) {
         $WHERE = ' WHERE ticketID LIKE \'' . db_input($_GET['id'], false) . '%\'';
         $ticketid = true;
     } elseif (isset($_GET['email'])) {
         $WHERE = ' WHERE email LIKE \'' . db_input(strtolower($_GET['email']), false) . '%\'';
     } else {
         Http::response(400, "id or email argument is required");
     }
     $sql = 'SELECT DISTINCT ticketID,email,name FROM ' . TICKET_TABLE . ' ' . $WHERE . ' ORDER BY created LIMIT ' . $limit;
     $res = db_query($sql);
     if ($res && db_num_rows($res)) {
         while (list($id, $email, $name) = db_fetch_row($res)) {
             $info = $ticketid ? $email : $id;
             $id = $ticketid ? $id : $email;
             # TODO: Return 'name' from email address if 'email' argument
             #       specified?
             $items[] = array('id' => $id, 'value' => $id, 'info' => $info, 'name' => $name);
         }
     }
     return $this->encode(array('results' => $items));
 }
开发者ID:ryan1432,项目名称:osTicket-1.7fork,代码行数:26,代码来源:ajax.tickets.php

示例5: getTipsJson

 function getTipsJson($namespace, $lang = false)
 {
     global $ost, $thisstaff;
     if (!$lang) {
         $lang = $thisstaff ? $thisstaff->getLanguage() : Internationalization::getDefaultLanguage();
     }
     $i18n = new Internationalization($lang);
     $tips = $i18n->getTemplate("help/tips/{$namespace}.yaml");
     if (!$tips || !($data = $tips->getData())) {
         Http::response(404, 'Help content not available');
     }
     // Translate links to the root path of this installation
     foreach ($data as $tip => &$info) {
         if ($ost) {
             $info = $ost->replaceTemplateVariables($info, array('config' => $ost->getConfig()));
         }
         if (isset($info['links'])) {
             foreach ($info['links'] as &$l) {
                 if ($l['href'][0] == '/') {
                     $l['href'] = ROOT_PATH . substr($l['href'], 1);
                 }
             }
         }
     }
     return $this->json_encode($data);
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:26,代码来源:ajax.tips.php

示例6: staffOnly

 function staffOnly()
 {
     global $thisstaff;
     if (!$thisstaff || !$thisstaff->isValid()) {
         Http::response(401, 'Access Denied. IP ' . $_SERVER['REMOTE_ADDR']);
     }
 }
开发者ID:nicolap,项目名称:osTicket-1.7,代码行数:7,代码来源:class.ajax.php

示例7: api_exit

function api_exit($code, $msg = '')
{
    global $remotehost, $cfg;
    if ($code != EX_SUCCESS) {
        //Error occured...
        $_SESSION['api']['errors'] += 1;
        $_SESSION['api']['time'] = time();
        Sys::log(LOG_WARNING, "API error - code #{$code}", $msg);
        //echo "API Error:.$msg";
    }
    if ($remotehost) {
        switch ($code) {
            case EX_SUCCESS:
                Http::response(200, $code, 'text/plain');
                break;
            case EX_UNAVAILABLE:
                Http::response(405, $code, 'text/plain');
                break;
            case EX_NOPERM:
                Http::response(403, $code, 'text/plain');
                break;
            case EX_DATAERR:
            case EX_NOINPUT:
            default:
                Http::response(416, $code, 'text/plain');
        }
    }
    exit($code);
}
开发者ID:nicolap,项目名称:osTicket-1.7,代码行数:29,代码来源:api.inc.php

示例8: saveListItemProperties

 function saveListItemProperties($item_id)
 {
     if (!($item = DynamicListItem::lookup($item_id))) {
         Http::response(404, 'No such list item');
     }
     if (!$item->setConfiguration()) {
         include STAFFINC_DIR . 'templates/list-item-properties.tmpl.php';
     } else {
         $item->save();
     }
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:11,代码来源:ajax.forms.php

示例9: cannedResp

 function cannedResp($id, $format = 'text')
 {
     global $thisstaff, $cfg;
     include_once INCLUDE_DIR . 'class.canned.php';
     if (!$id || !($canned = Canned::lookup($id)) || !$canned->isEnabled()) {
         Http::response(404, 'No such premade reply');
     }
     if (!$cfg->isHtmlThreadEnabled()) {
         $format .= '.plain';
     }
     return $canned->getFormattedResponse($format);
 }
开发者ID:tirix,项目名称:osTicket-1.8,代码行数:12,代码来源:ajax.kbase.php

示例10: createNote

 function createNote($ext_id)
 {
     global $thisstaff;
     if (!$thisstaff) {
         Http::response(403, "Login required");
     } elseif (!isset($_POST['note']) || !$_POST['note']) {
         Http::response(422, "Send `note` parameter");
     } elseif (!($note = QuickNote::create(array('staff_id' => $thisstaff->getId(), 'body' => Format::sanitize($_POST['note']), 'created' => new SqlFunction('NOW'), 'ext_id' => $ext_id)))) {
         Http::response(500, "Unable to create new note");
     } elseif (!$note->save(true)) {
         Http::response(500, "Unable to create new note");
     }
     $show_options = true;
     include STAFFINC_DIR . 'templates/note.tmpl.php';
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:15,代码来源:ajax.note.php

示例11: search

 function search()
 {
     if (!isset($_REQUEST['q'])) {
         Http::response(400, 'Query argument is required');
     }
     $limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit'] : 25;
     $users = array();
     $sql = 'SELECT DISTINCT email, name ' . ' FROM ' . TICKET_TABLE . ' WHERE email LIKE \'%' . db_input(strtolower($_REQUEST['q']), false) . '%\' ' . ' ORDER BY created ' . ' LIMIT ' . $limit;
     if (($res = db_query($sql)) && db_num_rows($res)) {
         while (list($email, $name) = db_fetch_row($res)) {
             $users[] = array('email' => $email, 'name' => $name, 'info' => "{$email} - {$name}");
         }
     }
     return $this->json_encode($users);
 }
开发者ID:pkdevboxy,项目名称:osTicket-1.7,代码行数:15,代码来源:ajax.users.php

示例12: upgrade

 function upgrade()
 {
     global $thisstaff, $ost;
     if (!$thisstaff or !$thisstaff->isAdmin() or !$ost) {
         Http::response(403, 'Access Denied');
     }
     $upgrader = new Upgrader($ost->getDBSignature(), TABLE_PREFIX, SQL_DIR);
     //Just report the next action on the first call.
     if (!$_SESSION['ost_upgrader'] || !$_SESSION['ost_upgrader'][$upgrader->getShash()]['progress']) {
         $_SESSION['ost_upgrader'][$upgrader->getShash()]['progress'] = $upgrader->getNextAction();
         Http::response(200, $upgrader->getNextAction());
         exit;
     }
     if ($upgrader->isAborted()) {
         Http::response(416, "We have a problem ... wait a sec.");
         exit;
     }
     if ($upgrader->getNumPendingTasks() && $upgrader->doTasks()) {
         //More pending tasks - doTasks returns the number of pending tasks
         Http::response(200, $upgrader->getNextAction());
         exit;
     } elseif ($ost->isUpgradePending()) {
         if ($upgrader->isUpgradable()) {
             $version = $upgrader->getNextVersion();
             if ($upgrader->upgrade()) {
                 //We're simply reporting progress here - call back will report next action'
                 Http::response(200, "Upgraded to {$version} ... post-upgrade checks!");
                 exit;
             }
         } else {
             //Abort: Upgrade pending but NOT upgradable - invalid or wrong hash.
             $upgrader->abort(sprintf('Upgrade Failed: Invalid or wrong hash [%s]', $ost->getDBSignature()));
         }
     } elseif (!$ost->isUpgradePending()) {
         $upgrader->setState('done');
         session_write_close();
         Http::response(201, "We're done!");
         exit;
     }
     if ($upgrader->isAborted() || $upgrader->getErrors()) {
         Http::response(416, "We have a problem ... wait a sec.");
         exit;
     }
     Http::response(200, $upgrader->getNextAction());
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:45,代码来源:ajax.upgrader.php

示例13: getLanguageFile

 function getLanguageFile($lang, $key)
 {
     global $cfg;
     $i18n = new Internationalization($lang);
     switch ($key) {
         case 'js':
             $data = $i18n->getTemplate('js/redactor.js')->getRawData();
             $data .= $i18n->getTemplate('js/jquery.ui.datepicker.js')->getRawData();
             // Strings from various javascript files
             $data .= $i18n->getTemplate('js/osticket-strings.js')->getRawData();
             header('Content-Type: text/javascript; charset=UTF-8');
             break;
         default:
             Http::response(404, 'No such i18n data');
     }
     Http::cacheable(md5($data), $cfg->lastModified());
     echo $data;
 }
开发者ID:ayurmedia,项目名称:osTicket-1.8,代码行数:18,代码来源:ajax.i18n.php

示例14: create

 function create($format)
 {
     $this->requireApiKey();
     # Parse request body
     $data = $this->getRequest($format);
     if ($format == "xml") {
         $data = $data["ticket"];
     }
     # Pull off some meta-data
     $alert = $data['alert'] ? $data['alert'] : true;
     $autorespond = $data['autorespond'] ? $data['autorespond'] : true;
     $source = $data['source'] ? $data['source'] : 'API';
     $attachments = $data['attachments'] ? $data['attachments'] : array();
     # TODO: Handle attachment encoding (base64)
     foreach ($attachments as $filename => &$info) {
         if ($info["encoding"] == "base64") {
             # XXX: May fail on large inputs. See
             #      http://us.php.net/manual/en/function.base64-decode.php#105512
             if (!($info["data"] = base64_decode($info["data"], true))) {
                 Http::response(400, sprintf("%s: Poorly encoded base64 data", $filename));
             }
         }
         $info['size'] = strlen($info['data']);
     }
     # Create the ticket with the data (attempt to anyway)
     $errors = array();
     $ticket = Ticket::create($data, $errors, $source, $autorespond, $alert);
     # Return errors (?)
     if (count($errors)) {
         Http::response(400, "Unable to create new ticket: validation errors:\n" . Format::array_implode(": ", "\n", $errors));
     } elseif (!$ticket) {
         Http::response(500, "Unable to create new ticket: unknown error");
     }
     # Save attachment(s)
     foreach ($attachments as &$info) {
         $ticket->saveAttachment($info, $ticket->getLastMsgId(), "M");
     }
     # All done. Return HTTP/201 --> Created
     Http::response(201, $ticket->getExtId());
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:40,代码来源:api.ticket.php

示例15: upgrade

 function upgrade()
 {
     global $thisstaff, $ost;
     if (!$thisstaff or !$thisstaff->isAdmin() or !$ost) {
         Http::response(403, 'Access Denied');
     }
     $upgrader = new Upgrader(TABLE_PREFIX, UPGRADE_DIR . 'streams/');
     if ($upgrader->isAborted()) {
         Http::response(416, __("We have a problem ... wait a sec."));
         exit;
     }
     if ($upgrader->getTask() && $upgrader->doTask()) {
         //More pending tasks - doTasks returns the number of pending tasks
         Http::response(200, $upgrader->getNextAction());
         exit;
     } elseif ($ost->isUpgradePending()) {
         if ($upgrader->isUpgradable()) {
             $version = $upgrader->getNextVersion();
             if ($upgrader->upgrade()) {
                 //We're simply reporting progress here - call back will report next action'
                 Http::response(200, sprintf(__("Upgraded to %s ... post-upgrade checks!"), $version));
                 exit;
             }
         } else {
             //Abort: Upgrade pending but NOT upgradable - invalid or wrong hash.
             $upgrader->abort(sprintf(__('Upgrade Failed: Invalid or wrong hash [%s]'), $ost->getDBSignature()));
         }
     } elseif (!$ost->isUpgradePending()) {
         $upgrader->setState('done');
         session_write_close();
         Http::response(201, __("We're done!"));
         exit;
     }
     if ($upgrader->isAborted() || $upgrader->getErrors()) {
         Http::response(416, __("We have a problem ... wait a sec."));
         exit;
     }
     Http::response(200, $upgrader->getNextAction());
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:39,代码来源:ajax.upgrader.php


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