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


PHP Response::output方法代码示例

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


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

示例1: renderAjax

 protected final function renderAjax($errorCode, $errorMessage = '', $otherParams = array())
 {
     $otherParams['errorCode'] = $errorCode;
     $otherParams['errorMessage'] = $errorMessage;
     Response::output($otherParams, 'json', Router::$CALLBACK);
     // debug
     Debug::p('PHP End');
     if (isset($_COOKIE['ajaxdebug']) && Router::$IS_AJAX) {
         Debug::show();
     }
     exit;
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:12,代码来源:BaseController.class.php

示例2: logException

 public static function logException($e)
 {
     // 如果不是BaseException,那么由handle捕获
     if (!is_subclass_of($e, 'BaseException')) {
         Logger::error('handle', $e);
     }
     if (class_exists('Router', false) && Router::$IS_AJAX) {
         $content = array('errorCode' => E_USER_ERROR, 'errorMessage' => '服务器繁忙,请稍后再试!');
         Response::output($content, 'json', Router::$CALLBACK);
         exit;
     } else {
         Url::redirect404();
     }
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:14,代码来源:ErrorHandler.class.php

示例3: output

 public function output()
 {
     if (!headers_sent()) {
         // Default content type. This may be overwritten in the superclass when the addHeader function is used to
         // add the Content-Type header. If the response body is empty this header will always be used because the
         // parent doesn't set any header when the output is empty.
         header('Content-Type: text/plain', true);
         if ($this->httpResponseCodeHeader) {
             // Response code header must be added here because parent output will only add headers if the output
             // isn't empty but we do allow empty output.
             header($this->httpResponseCodeHeader, true);
         }
     }
     parent::output();
 }
开发者ID:projectwife,项目名称:tesitoo-opencart,代码行数:15,代码来源:response.php

示例4: watchAction

 public function watchAction()
 {
     $problemId = Request::getGET('problem-id');
     $file = Request::getGET('file');
     // 处理文件名
     if (!$this->checkFile($file) || empty($problemId)) {
         Response::output('参数错误!', 'html');
         return;
     }
     // 删除文件
     $path = '/home/judge/data/' . $problemId . '/' . $file;
     // 是否存在
     if (!is_file($path)) {
         Response::output('文件不存在!', 'html');
         return;
     }
     $content = file_get_contents($path);
     $content = htmlspecialchars($content);
     $content = "<pre>{$content}</pre>";
     Response::output($content, 'html');
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:21,代码来源:DataManagerController.class.php

示例5: select

 public static function select($type, $sql, $params = array(), $single = false)
 {
     $response = new Response();
     try {
         $db = PDO::getConnection();
         $stmt = $db->prepare($sql);
         foreach ($params as $param => $paramValue) {
             $stmt->bindParam($param, $paramValue[0], $paramValue[1]);
         }
         $stmt->execute();
         $result = $stmt->fetchAll(PDO::FETCH_OBJ);
         $db = null;
         if ($single && is_array($result) && isset($result[0])) {
             $result = $result[0];
         }
         $response->setData($type, $result);
     } catch (\Exception $e) {
         $response->setError($e->getCode(), $e->getMessage());
     }
     $response->output();
 }
开发者ID:grzchr15,项目名称:phplist-plugin-restapi,代码行数:21,代码来源:common.php

示例6: listsSubscriber

 /**
  * Get Lists a Subscriber is Member of.
  * 
  * <p><strong>Parameters:</strong><br/>
  * [*subscriber_id] {integer} the Subscriber-ID.
  * <p><strong>Returns:</strong><br/>
  * Array of lists where the subscriber is assigned to.
  * </p>
  */
 public static function listsSubscriber($subscriber_id = 0)
 {
     $response = new Response();
     if ($subscriber_id == 0) {
         $subscriber_id = sprintf('%d', $_REQUEST['subscriber_id']);
     }
     $sql = 'SELECT * FROM ' . $GLOBALS['tables']['list'] . ' WHERE id IN 
       (SELECT listid FROM ' . $GLOBALS['tables']['listuser'] . ' WHERE userid=:subscriber_id) ORDER BY listorder;';
     if (!is_numeric($subscriber_id) || empty($subscriber_id)) {
         Response::outputErrorMessage('invalid call');
     }
     try {
         $db = PDO::getConnection();
         $stmt = $db->prepare($sql);
         $stmt->bindParam('subscriber_id', $subscriber_id, PDO::PARAM_INT);
         $stmt->execute();
         $result = $stmt->fetchAll(PDO::FETCH_OBJ);
         $db = null;
         $response->setData('Lists', $result);
         $response->output();
     } catch (\Exception $e) {
         Response::outputError($e);
     }
     die(0);
 }
开发者ID:grzchr15,项目名称:phplist-plugin-restapi,代码行数:34,代码来源:lists.php

示例7: strtotime

<?php

require_once 'inc/init.php';
$task_id = $_POST['task-status-id'];
$date = strtotime($_POST['task-status']);
$task = new Task();
$task->load('id = ?', [$task_id]);
$task->status = $_POST['task-status'];
if ($task->save()) {
    Response::write('message', 'Task status updated');
} else {
    Response::write('status', false);
    Response::write('message', 'Task status failed to update.');
}
Response::output();
开发者ID:nasrulhazim,项目名称:to-do-list-server,代码行数:15,代码来源:task-status.php

示例8: Template

    if ($code) {
        $json['success'] = 1;
        $json['share_image'] = HTTP_SERVER . 'share/' . $code . '.jpg';
        $json['share_url'] = HTTP_SERVER . '/share.php?share_id=' . $code . '&point=' . (int) $request->get['point'];
    } else {
        $json['error'] = 'ERROR DB';
    }
    $response->addHeader('Content-Type: application/json');
    $response->setOutput(json_encode($json));
} else {
    $share_id = $request->get['share_id'];
    $point = $request->get['point'];
    $template = new Template();
    $template->base = HTTP_SERVER;
    $template->image = 'share/' . $share_id . '.jpg';
    $template->share_url = HTTP_SERVER . 'share.php?share_id=' . $share_id . '&point=' . $point;
    if ((int) $point > 10) {
        $template->title = 'Я собрал ' . $point . ' ' . getNumEnding($point, array('услугу', 'услуги', 'услуг'));
        $template->description = 'А ты сможешь лучше?';
    } elseif ((int) $point < 10 && (int) $point >= 5) {
        $template->title = 'Я собрал ' . $point . ' ' . getNumEnding($point, array('услугу', 'услуги', 'услуг'));
        $template->description = 'А ты сможешь лучше?';
    } else {
        $template->title = 'Я собрал ' . $point . ' ' . getNumEnding($point, array('услугу', 'услуги', 'услуг'));
        $template->description = 'А ты сможешь лучше?';
    }
    $out = $template->render(DIR_APPLICATION . '/template/share.tpl');
    $response->setOutput($out);
}
$response->output();
开发者ID:casejoke,项目名称:monkey.loc,代码行数:30,代码来源:share.php

示例9: output

 /**
  * Convert this response into a valid HTML response
  */
 function output()
 {
     $type = null;
     foreach ($this->request->accept as $accept) {
         foreach ($accept as $a) {
             switch ($a) {
                 case "xml":
                     $type = "xml";
                     break;
                 case "json":
                 default:
                     $type = "json";
                     break;
             }
             if ($type != null) {
                 break;
             } else {
                 $type = "json";
                 break;
             }
         }
     }
     if ($this->error != null && $this->error_detail != null && is_array($this->error_detail)) {
         $this->body = array("error" => $this->error, "detail" => $this->error_detail);
     } else {
         if ($this->error != null && $this->error_detail != null && is_string($this->error_detail)) {
             $this->body = array("error" => $this->error, "detail" => array("code" => $this->error_detail));
         } else {
             if ($this->error != null) {
                 $this->body = array("error" => $this->error);
             }
         }
     }
     switch ($type) {
         case "json":
         default:
             $this->body = json_encode($this->body);
             $this->addHeader('Content-Type', 'application/json');
             break;
         case "xml":
             $xmlnode = new XMLNode("response");
             if (is_array($this->body)) {
                 foreach ($this->body as $k => $v) {
                     if (is_int($k)) {
                         $k = "item";
                     }
                     if (is_array($v)) {
                         $n = new XMLNode($k);
                         $n->addArray($v);
                         $xmlnode->addValue(null, $n);
                     } else {
                         $xmlnode->addValue($k, $v);
                     }
                 }
             } else {
                 if (is_object($this->body) && method_exists($this->body, "__toString")) {
                     $xmlnode->addValue(get_class($this->body), $this->body->__toString());
                 } else {
                     if (is_object($this->body)) {
                         $xmlnode->addValue(get_class($this->body), "Object");
                     } else {
                         $xmlnode->addValue(null, $this->body);
                     }
                 }
             }
             $this->body = $xmlnode->generate();
             $this->addHeader('Content-Type', 'application/xml');
             break;
     }
     parent::output();
 }
开发者ID:vdchuyen,项目名称:TonicDNS,代码行数:74,代码来源:formatted_response.php

示例10: run

 public function run()
 {
     $response = null;
     list($route_mask, $service_name) = $this->findServiceRoute();
     if (null !== $route_mask) {
         $response = $this->executeServiceRoute($route_mask, $service_name);
         if (null !== $response) {
             $response->generation_time = $this->getTimer();
             $response->generation_mem = $this->getMemory();
             if ($this->application->passport->is_auth()) {
                 $response->setHeader('User access token: ' . $this->application->passport->getSessionToken());
             }
             $response->output($service_name, $route_mask);
             $this->stop();
         }
     }
     // Статичная страница
     /** @var \Service\Pages\Model_Factory $pages_factory */
     $pages_factory = $this->service_factory->factoryPages;
     if (null !== $pages_factory) {
         $url = $this->request->url->toString(false);
         $page = $pages_factory->pages->getBySlug($url);
         if (null !== $page) {
             $service_name = 'Pages';
             $route_mask = new \Service\Pages\Router_Client_Page();
             $route_mask->found_variables[\Service\Pages\Model_Pages_Page::FIELD_SLUG] = $url;
             $response = $this->executeServiceRoute($route_mask, $service_name);
             if (null !== $response) {
                 $response->generation_time = $this->getTimer();
                 $response->generation_mem = $this->getMemory();
                 $response->output($service_name, $route_mask);
                 $this->stop();
             }
         }
     }
     // Есть стандартная страница ошибки
     $this->request->url->path = '/404.html';
     list($route_mask, $service_name) = $this->findServiceRoute();
     if (null !== $route_mask) {
         $response = $this->executeServiceRoute($route_mask, $service_name);
         if (null !== $response) {
             $response->setStatus(Response::HTTP_404_Not_Found);
             $response->generation_time = $this->getTimer();
             $response->generation_mem = $this->getMemory();
             $response->output();
             $this->stop();
         }
     }
     // Нет стандартной страницы ошибки
     $response = new Response();
     $response->setStatus(Response::HTTP_404_Not_Found);
     $response->setBody('Nothing found');
     $response->generation_time = $this->getTimer();
     $response->generation_mem = $this->getMemory();
     $response->output();
     $this->stop();
 }
开发者ID:dekmabot,项目名称:dezen-framework,代码行数:57,代码来源:Init.php

示例11: rendarString

 /**
  * @param $str
  * @param array $headers
  * @return bool
  */
 public function rendarString($str, $headers = array())
 {
     $headers = array_merge(array("Content-Type" => "text/html"), $headers);
     if (Application::DebugMode()) {
         $debug = new Debug();
         $debug->appendRendarDebug($str);
     }
     $response = new Response($str);
     $response->setHeaders($headers);
     $response->output();
     return true;
 }
开发者ID:ateliee,项目名称:pmp,代码行数:17,代码来源:controller.php

示例12: formtokenGet

 public static function formtokenGet()
 {
     $key = md5(time() . mt_rand(0, 10000));
     Sql_Query(sprintf('insert into %s (adminid,value,entered,expires) values(%d,"%s",%d,date_add(now(),interval 1 hour))', $GLOBALS['tables']['admintoken'], $_SESSION['logindetails']['id'], $key, time()), 1);
     $response = new Response();
     $response->setData('formtoken', $key);
     $response->output();
 }
开发者ID:grzchr15,项目名称:phplist-plugin-restapi,代码行数:8,代码来源:Campaigns.php

示例13: outputMessage

 /**
  * Generate and output a generic system message as a response
  * @param string $message System message
  */
 static function outputMessage($message)
 {
     $response = new Response();
     $response->setData('SystemMessage', $message);
     $response->output();
 }
开发者ID:grzchr15,项目名称:phplist-plugin-restapi,代码行数:10,代码来源:Response.php


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