• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP http_response_code函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sendHeaders

 /**
  *
  */
 protected function sendHeaders()
 {
     http_response_code($this->httpResponseCode);
     foreach ($this->headers as $name => $value) {
         header($name . ': ' . $value);
     }
 }
开发者ID:freyr,项目名称:envelope,代码行数:10,代码来源:Response.php


示例2: get

 /**
  * Convert request to data result
  *
  * @access public
  * @fixme  Authentication / request validation
  * @return void
  */
 public function get($forecast = false, $data = false)
 {
     $validRequest = $this->_validateRequest() !== False;
     $validAuth = $this->_validateAuth() !== False;
     $post = $data !== false ? $data : $this->input->post();
     $post["download"] = false;
     if (isset($post["region"])) {
         $post["multiple"] = true;
     } else {
         $post["multiple"] = false;
     }
     if ($validRequest && $validAuth) {
         $source = new Source($post);
         $res = $source->get($this->_user);
         if ($forecast != false) {
             if ($this->_user) {
                 $result = $source->gatherForecast($this->_user);
                 if (isset($result[0])) {
                     array_push($res, $result[0]);
                 }
             }
         }
         echo json_encode($res);
     } else {
         http_response_code(400);
         echo json_encode(["message" => $this->_message]);
     }
     exit;
 }
开发者ID:kukua,项目名称:kukua-dashboard,代码行数:36,代码来源:Sensordata.php


示例3: input

 public function input()
 {
     if ($this->input === NULL) {
         $in = file_get_contents("php://input");
         if ($in != "" && $in != NULL) {
             $this->input = json_decode($in, true);
             if (json_last_error() != JSON_ERROR_NONE) {
                 // we have to do a raw write here...
                 http_response_code(400);
                 if (config('app.debug') === true) {
                     \Log::debug("Invalid JSON in this request: " . $in);
                 }
                 echo json_encode(["message" => "Error: Malformed JSON"]);
                 exit;
             }
             if (isset($this->input['payload']) && !empty($this->input['payload'])) {
                 $this->payload = $this->input['payload'];
             }
             if (isset($this->input['meta']) && !empty($this->input['meta'])) {
                 $this->meta = $this->input['meta'];
             }
         } else {
             $this->input = "";
         }
     }
     return $this->input;
 }
开发者ID:Neo-Desktop,项目名称:wm-browser,代码行数:27,代码来源:BaseController.php


示例4: response_error

function response_error($msg)
{
    http_response_code(400);
    $response = (object) ['msg' => $msg];
    echo json_encode($response);
    exit(1);
}
开发者ID:madbob,项目名称:VoiceHub,代码行数:7,代码来源:vh.js.php


示例5: set_headers

 private function set_headers()
 {
     header("HTTP/1.1" . $this->_code . " " . http_response_code($this->get_status_message()));
     //http_response_code($this->get_status_message());
     header("Content-Type:" . $this->_content_type);
     $this->logger->write("INFO :", "_code......" . $this->_code . "get_status_message..." . $this->get_status_message() . "_content_type...." . $this->_content_type);
 }
开发者ID:Rajeshwar90,项目名称:Referralio,代码行数:7,代码来源:Rest.inc.php


示例6: dumpError

function dumpError($error)
{
    http_response_code(500);
    echoHtmlHead();
    echo "<h3 style=\"background-color:orangered;padding:10px;\">{$error}</h3>";
    exit(1);
}
开发者ID:asylgrp,项目名称:workbench,代码行数:7,代码来源:setup.php


示例7: OnLoadPageData

 public function OnLoadPageData()
 {
     require_once 'stoolball/competition-manager.class.php';
     $manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection());
     if ($this->season_id) {
         $manager->ReadById(null, array($this->season_id));
     } else {
         $manager->ReadById(array($this->competition_id));
     }
     $this->competition = $manager->GetFirst();
     $this->season = $this->competition->GetWorkingSeason();
     unset($manager);
     # If the competition was requested, redirect to the current season
     if ($this->competition_id) {
         http_response_code(303);
         header("Location: " . $this->season->GetMapUrl());
         return;
     }
     $this->has_map = count($this->season->GetTeams());
     # Get other seasons
     require_once 'stoolball/season-manager.class.php';
     $a_comp_ids = array($this->competition->GetId());
     $o_season_manager = new SeasonManager($this->GetSettings(), $this->GetDataConnection());
     $o_season_manager->ReadByCompetitionId($a_comp_ids);
     $a_other_seasons = $o_season_manager->GetItems();
     $this->competition->SetSeasons(array());
     foreach ($a_other_seasons as $season) {
         if ($season->GetId() == $this->season->GetId()) {
             $this->competition->AddSeason($this->season, true);
         } else {
             $this->competition->AddSeason($season, false);
         }
     }
 }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:34,代码来源:map.php


示例8: create_topic

function create_topic($request)
{
    Authenticator::assert_manager_or_professor($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale']);
    try {
        $raw_input = $request->getBody();
        $content_type = explode(';', $request->type)[0];
        if ($content_type !== 'application/json') {
            Util::output_errors_and_die('', 415);
        }
        $input_data = json_decode($raw_input, true);
        if (empty($input_data)) {
            Util::output_errors_and_die('', 400);
        }
        $model = new Model();
        if (!isset($input_data['name'])) {
            $input_data['name'] = '';
        }
        $topic_id = $model->create_topic($input_data['name']);
        if ($topic_id) {
            http_response_code(201);
            header('Content-Type: text/plain');
            echo '/topics/' . $topic_id;
            die;
        } else {
            Util::output_errors_and_die('', 400);
        }
    } catch (ConflictException $e) {
        Util::output_errors_and_die($e->getMessage(), 409);
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
开发者ID:OrgAindaSemTitulo,项目名称:Sistema,代码行数:35,代码来源:create_topic.php


示例9: sendHeaders

 /**
  * Sent HTTP headers and HTTP response code.
  */
 protected function sendHeaders()
 {
     http_response_code($this->status);
     foreach ($this->headers as $name => $value) {
         header("{$name}: {$value}");
     }
 }
开发者ID:gbv,项目名称:jskos-php,代码行数:10,代码来源:Response.php


示例10: throw400

 static function throw400($msg)
 {
     http_response_code(400);
     header('Content-Type: text/plain');
     echo $msg;
     exit;
 }
开发者ID:kba,项目名称:rssscrpr,代码行数:7,代码来源:Utils.php


示例11: combineChunks

 public function combineChunks($uploadDirectory, $name = null)
 {
     $uuid = $_POST['qquuid'];
     if ($name === null) {
         $name = $this->getName();
     }
     $targetFolder = $this->chunksFolder . DIRECTORY_SEPARATOR . $uuid;
     $totalParts = isset($_REQUEST['qqtotalparts']) ? (int) $_REQUEST['qqtotalparts'] : 1;
     $targetPath = join(DIRECTORY_SEPARATOR, array($uploadDirectory, $uuid, $name));
     $this->uploadName = $name;
     if (!file_exists($targetPath)) {
         mkdir(dirname($targetPath), 0777, true);
     }
     $target = fopen($targetPath, 'wb');
     for ($i = 0; $i < $totalParts; $i++) {
         $chunk = fopen($targetFolder . DIRECTORY_SEPARATOR . $i, "rb");
         stream_copy_to_stream($chunk, $target);
         fclose($chunk);
     }
     // Success
     fclose($target);
     for ($i = 0; $i < $totalParts; $i++) {
         unlink($targetFolder . DIRECTORY_SEPARATOR . $i);
     }
     rmdir($targetFolder);
     if (!is_null($this->sizeLimit) && filesize($targetPath) > $this->sizeLimit) {
         unlink($targetPath);
         http_response_code(413);
         return array("success" => false, "uuid" => $uuid, "preventRetry" => true);
     }
     return array("success" => true, "uuid" => $uuid);
 }
开发者ID:fineuploader,项目名称:php-traditional-server,代码行数:32,代码来源:handler.php


示例12: modAction

 /**
  * This is a general purpose hook, allowing modules to respond to routes
  * of the form module.php?mod=FOO&mod_action=BAR
  *
  * @param string $mod_action
  */
 public function modAction($mod_action)
 {
     switch ($mod_action) {
         case 'admin_config':
             $this->config();
             break;
         case 'admin_delete':
             $this->delete();
             $this->config();
             break;
         case 'admin_edit':
             $this->edit();
             break;
         case 'admin_movedown':
             $this->movedown();
             $this->config();
             break;
         case 'admin_moveup':
             $this->moveup();
             $this->config();
             break;
         case 'show':
             $this->show();
             break;
         default:
             http_response_code(404);
     }
 }
开发者ID:tunandras,项目名称:webtrees,代码行数:34,代码来源:FrequentlyAskedQuestionsModule.php


示例13: sendErrorAndDie

function sendErrorAndDie($code, $msg)
{
    error_log($msg);
    include 'error.php';
    http_response_code($code);
    die;
}
开发者ID:pinkiesky,项目名称:aoim-web,代码行数:7,代码来源:message.php


示例14: test_auto_marking_sc

function test_auto_marking_sc($request)
{
    Authenticator::assert_manager_or_professor($request->cookies['authToken']);
    $msg = new Messages($GLOBALS['locale'], '/new-question/errors');
    try {
        $model = new Model();
        $raw_input = $request->getBody();
        $content_type = explode(';', $request->type)[0];
        if ($content_type !== 'application/json') {
            Util::output_errors_and_die($msg->_('invalid-format'), 415);
        }
        $input_data = json_decode($raw_input, true);
        if (empty($input_data) || !isset($input_data['question']) || !isset($input_data['source-code']) || !is_string($input_data['source-code'])) {
            Util::output_errors_and_die($msg->_('invalid-format'), 400);
        }
        $extra = !empty($input_data['extra']) ? $input_data['extra'] : [];
        $qd = $input_data['question'];
        set_empty_if_undefined($qd['type']);
        if ($qd['type'] != 'source-code') {
            Util::output_errors_and_die('', 400);
        }
        $q = new QuestionSC($qd, Question::FROM_USER, $extra);
        $q->mark_automatically(array('source-code' => $input_data['source-code']), $log, $result);
        http_response_code(200);
        header('Content-Type: application/json');
        echo my_json_encode($result);
    } catch (DatabaseException $e) {
        Util::output_errors_and_die($e->getMessage(), 503);
    } catch (Exception $e) {
        Util::output_errors_and_die($e->getMessage(), 400);
    }
}
开发者ID:OrgAindaSemTitulo,项目名称:Sistema,代码行数:32,代码来源:test_auto_marking_sc.php


示例15: initDashboard

function initDashboard()
{
    include_once ABSPATH . "/php/CDBConn.php";
    include_once ABSPATH . "/php/hostconfig.php";
    $conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123");
    if (!$conn->connect_no_localhost()) {
        http_response_code(503);
        exit;
    }
    $cur_login = $_SESSION['g_username'];
    $get_hostel_id_sql = "SELECT hostel_id FROM users WHERE login = '{$cur_login}'";
    $conn->run_query($get_hostel_id_sql);
    $line = $conn->fetch_array();
    // We almost now from which hostel is user
    $hostel_id = $line['hostel_id'];
    // in case if hostel id is not set, it's an indicator that hostel  definetely has not been configured yet.
    if ($hostel_id === NULL) {
        header("Location: /configure/index.php");
        exit;
    }
    $get_is_configured_sql = "SELECT is_configured FROM hostels WHERE id = {$hostel_id}";
    $conn->run_query($get_is_configured_sql);
    $line = $conn->fetch_array();
    $is_configured = $line['is_configured'];
    // This is the case when user almost configured not
    if ($is_configured === 'f') {
        header("Location: /configure/index.php");
        // exit();
    }
    $conn->close();
}
开发者ID:nuriyevn,项目名称:jetpms,代码行数:31,代码来源:initDashboard.php


示例16: init

 function init()
 {
     try {
         $connection_string = 'mysql:host=' . \Idno\Core\Idno::site()->config()->dbhost . ';dbname=' . \Idno\Core\Idno::site()->config()->dbname . ';charset=utf8';
         if (!empty(\Idno\Core\Idno::site()->config()->dbport)) {
             $connection_string .= ';port=' . \Idno\Core\Idno::site()->config()->dbport;
         }
         $this->client = new \PDO($connection_string, \Idno\Core\Idno::site()->config()->dbuser, \Idno\Core\Idno::site()->config()->dbpass, array(\PDO::MYSQL_ATTR_LOCAL_INFILE => 1));
         $this->client->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         //$this->client->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
     } catch (\Exception $e) {
         error_log($e->getMessage());
         if (!empty(\Idno\Core\Idno::site()->config()->forward_on_empty)) {
             header('Location: ' . \Idno\Core\Idno::site()->config()->forward_on_empty);
             exit;
         } else {
             http_response_code(500);
             if (\Idno\Core\Idno::site()->config()->debug) {
                 $message = '<p>' . $e->getMessage() . '</p>';
                 $message .= '<p>' . $connection_string . '</p>';
             }
             error_log($e->getMessage());
             include \Idno\Core\Idno::site()->config()->path . '/statics/db.php';
             exit;
         }
     }
     $this->database = \Idno\Core\Idno::site()->config()->dbname;
     $this->checkAndUpgradeSchema();
 }
开发者ID:d6-9b,项目名称:Known,代码行数:29,代码来源:MySQL.php


示例17: createAction

 /**
  * @return void
  */
 public function createAction()
 {
     if ($this->isAJAX() && $this->isRequestMethod('POST')) {
         $status = 400;
         $data = array("error" => 'bad_request');
         $request = json_decode(file_get_contents('php://input'));
         if (filter_var($request->{'_csrf_token_register'}, FILTER_SANITIZE_STRING) && filter_var($request->{'_username'}, FILTER_VALIDATE_REGEXP, array("options" => array("regexp" => '/^[a-zA-Z0-9]{3,15}$/'))) && filter_var($request->{'_password'}, FILTER_VALIDATE_REGEXP, array("options" => array("regexp" => '/^[a-zA-Z0-9]{6,20}$/')))) {
             $status = 400;
             $data = array("error" => 'bad_request');
             $csrf_token_register = htmlspecialchars($request->{'_csrf_token_register'}, ENT_QUOTES);
             if ($csrf_token_register == hash('sha256', Security::getCSRFToken('csrf_token_register'))) {
                 $username = htmlspecialchars($request->{'_username'}, ENT_QUOTES);
                 $password = htmlspecialchars($request->{'_password'}, ENT_QUOTES);
                 $user = $this->loadModel('User');
                 $user->Username = $username;
                 $user->Password = $password;
                 $status = 409;
                 $data = array('error' => 'username_is_taken');
                 if (!$user->isUsernameTaken()) {
                     $id = $user->Save(array('username' => $username, 'password' => $user->Password));
                     if ($id > 0) {
                         $role = $this->loadModel('Role');
                         $role->Save(array('user_id' => $id, 'role_id' => 1));
                         $status = 201;
                         $data = array('id' => $id);
                     }
                 }
             }
         }
         http_response_code($status);
         echo json_encode($data);
     } else {
         Helper::redirectTo(WEB . 'register');
     }
 }
开发者ID:emrahsifoglu,项目名称:simple-news-portal,代码行数:38,代码来源:RegisterController.php


示例18: setHeader

 public function setHeader($header, $value)
 {
     $code = http_response_code();
     header($header . ': ' . $value, true);
     http_response_code($code);
     $this->flushed = false;
 }
开发者ID:tomaka17,项目名称:niysu,代码行数:7,代码来源:HTTPResponseGlobal.php


示例19: __construct

 /**
  * Create the chart controller
  *
  * @param int $show_full needed for use by charts module
  */
 public function __construct($show_full = 1)
 {
     global $WT_TREE;
     parent::__construct();
     $rootid = Filter::get('rootid', WT_REGEX_XREF);
     $this->root = Individual::getInstance($rootid, $WT_TREE);
     if (!$this->root) {
         // Missing root individual? Show the chart for someone.
         $this->root = $this->getSignificantIndividual();
     }
     if (!$this->root || !$this->root->canShowName()) {
         http_response_code(404);
         $this->error_message = I18N::translate('This individual does not exist or you do not have permission to view it.');
     }
     // Extract parameter from form
     if ($show_full) {
         $this->show_full = Filter::getInteger('show_full', 0, 1, $WT_TREE->getPreference('PEDIGREE_FULL_DETAILS'));
     } else {
         $this->show_full = 0;
     }
     $this->box = new \stdClass();
     if ($this->showFull()) {
         $this->box->width = Theme::theme()->parameter('chart-box-x');
         $this->box->height = Theme::theme()->parameter('chart-box-y');
     } else {
         $this->box->width = Theme::theme()->parameter('compact-chart-box-x');
         $this->box->height = Theme::theme()->parameter('compact-chart-box-y');
     }
 }
开发者ID:pal-saugstad,项目名称:webtrees,代码行数:34,代码来源:ChartController.php


示例20: maybe_a_freemius_webhook

 /**
  * Used from an external API call to wp admin ajax to handle
  * freemius installations and uninstallations
  *
  */
 public static function maybe_a_freemius_webhook()
 {
     $input = @file_get_contents('php://input');
     $event_json = json_decode($input);
     if (!isset($event_json->id)) {
         self::ajax_fail('Hey man! This be no webhook.');
         exit;
     }
     require_once EDD_SEGMENT_PATH . '/controllers/add-ons/freemius-sdk/Freemius.php';
     $fs = new Freemius_Api('plugin', EDD_SEG_IO_FREEMIUS_PLUGIN_ID, EDD_SEG_IO_FREEMIUS_PUBLIC_KEY, EDD_SEG_IO_FREEMIUS_PRIVATE_KEY);
     $fs_event = $fs->Api("/events/{$event_json->id}.json");
     $props = array('email' => $fs_event->objects->user->email, 'name' => $fs_event->objects->user->first . ' ' . $fs_event->objects->user->last, 'site_url' => $fs_event->objects->install->url);
     switch ($fs_event->type) {
         case 'install.installed':
             self::new_install($props);
             break;
         case 'install.uninstalled':
             $fs_uninstall = $fs->Api("/installs/{$fs_event->install_id}/uninstall.json");
             $props['uninstall_code'] = $fs_uninstall->reason_id;
             $props['uninstall_reason'] = $fs_uninstall->reason;
             $props['uninstall_reason_info'] = $fs_uninstall->reason_info;
             self::new_uninstall($props);
             break;
     }
     http_response_code(200);
     exit;
 }
开发者ID:SproutApps,项目名称:segment-io,代码行数:32,代码来源:Freemius_Webhook.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP http_script函数代码示例发布时间:2022-05-15
下一篇:
PHP http_request函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap