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


PHP Http::status_header方法代码示例

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


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

示例1: handler

 /**
  * package serverを立ち上げる
  *
  * @param string $package_root パッケージ名
  */
 public static function handler($package_root = null)
 {
     if (empty($package_root) || Rhaco::path() == "") {
         $debug = debug_backtrace();
         $first_action = array_pop($debug);
         if ($package_root === null) {
             $package_root = basename(dirname($first_action["file"]));
         }
         if (Rhaco::path() == "") {
             Rhaco::init($first_action["file"]);
         }
     }
     $base_dir = Rhaco::path();
     $request = new Request();
     $package_root_path = str_replace(".", "/", $package_root);
     $preg_quote = (empty($package_root_path) ? "" : preg_quote($package_root_path, "/") . "\\/") . "(.+)";
     $tag = new Tag("rest");
     if (preg_match("/^\\/state\\/" . $preg_quote . "\$/", $request->args(), $match)) {
         $tag->add(new Tag("package", $match[1]));
         if (self::parse_package($package_root_path, $base_dir, $match[1], $tgz_filename)) {
             $tag->add(new Tag("status", "success"));
             $tag->output();
         }
     } else {
         if (preg_match("/^\\/download\\/" . $preg_quote . "\$/", $request->args(), $match)) {
             if (self::parse_package($package_root_path, $base_dir, $match[1], $tgz_filename)) {
                 Http::attach(new File($tgz_filename));
             }
         }
     }
     Http::status_header(403);
     $tag->add(new Tag("status", "fail"));
     $tag->output();
     exit;
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:40,代码来源:Packager.php

示例2: handler

 /**
  * install serverを立ち上げる
  *
  * @param string $package_root パッケージ名
  */
 public static function handler()
 {
     $base_dir = Rhaco::path();
     $request = new Request();
     $tag = new Tag("rest");
     if (preg_match("/^\\/state\\/(.+)\$/", $request->args(), $match)) {
         $tag->add(new Tag("package", $match[1]));
         if (self::parse_package($base_dir, $match[1], $tgz_filename)) {
             $tag->add(new Tag("status", "success"));
             $tag->output();
         }
     } else {
         if (preg_match("/^\\/download\\/(.+)\$/", $request->args(), $match)) {
             if (self::parse_package($base_dir, $match[1], $tgz_filename)) {
                 Http::attach(new File($tgz_filename));
             }
         }
     }
     Http::status_header(403);
     $tag->add(new Tag("status", "fail"));
     $tag->output();
     exit;
 }
开发者ID:hisaboh,项目名称:w2t,代码行数:28,代码来源:Repository.php

示例3: handler

 /**
  * URLのパターンからTemplateを切り替える
  * @param array $urlconf
  */
 public function handler(array $urlconf = array())
 {
     $params = array();
     foreach ($urlconf as $pattern => $conf) {
         if (is_int($pattern)) {
             $pattern = $conf;
             $conf = null;
         }
         if (preg_match("/" . str_replace(array("\\/", "/", "__SLASH__"), array("__SLASH__", "\\/", "\\/"), $pattern) . "/", $this->args(), $params)) {
             if ($conf !== null) {
                 if (is_array($conf)) {
                     if (isset($conf["class"])) {
                         $this->class = $conf["class"];
                     }
                     if (isset($conf["method"])) {
                         $this->method = $conf["method"];
                     }
                     if (isset($conf["template"])) {
                         $this->template = $conf["template"];
                     }
                     if (isset($conf["name"])) {
                         $this->name = $conf["name"];
                     }
                 } else {
                     $this->dict($conf);
                 }
             }
             self::$match_pattern = empty($this->name) ? $params[0] : $this->name;
             if (!empty($this->class)) {
                 if (false !== strrpos($this->class, ".") || !class_exists($this->class)) {
                     $this->class = Rhaco::import($this->class);
                 }
                 if (empty($this->method) && !empty($pattern)) {
                     $method_patterns = array();
                     $patterns = explode("/", $pattern);
                     if ($patterns[0] == "^") {
                         array_shift($patterns);
                     }
                     foreach ($patterns as $p) {
                         if (!preg_match("/[\\w_]/", $p)) {
                             break;
                         }
                         $method_patterns[] = $p;
                     }
                     if (!empty($method_patterns)) {
                         $this->method = implode("_", $method_patterns);
                     }
                 }
             }
             if (empty($this->method) && !empty($this->template)) {
                 $obj = new self();
                 $obj->copy_module($this, true);
                 $obj->template($this->template);
             } else {
                 $method = empty($this->method) ? "index" : $this->method;
                 if (!method_exists($this->class, $method)) {
                     throw new Exception("Not found " . $this->class . "::" . $method);
                 }
                 array_shift($params);
                 try {
                     $class = $this->class;
                     $action = new $class();
                     $action->copy_module($this, true);
                     if ($action instanceof self) {
                         $action->handled();
                     }
                     $obj = call_user_func_array(array($action, $method), $params);
                 } catch (Exception $e) {
                     Log::debug($e);
                     $on_error = Rhaco::def("core.Flow@on_error");
                     if ($on_error === null) {
                         throw $e;
                     }
                     if (isset($on_error[0])) {
                         Http::status_header((int) $on_error[0]);
                     }
                     if (isset($on_error[2])) {
                         Http::redirect($on_error[2]);
                     }
                     if (isset($on_error[1])) {
                         $template = new Template();
                         $template->output($on_error[1]);
                     }
                     exit;
                 }
             }
             if ($obj instanceof self) {
                 $obj = $obj->templ();
             }
             if (!$obj instanceof Template) {
                 throw new Exception("Forbidden " . $this->args());
             }
             $obj->path($this->path());
             $obj->url($this->url());
             $this->templ = $obj;
             if (!$this->isTemplate()) {
//.........这里部分代码省略.........
开发者ID:hisaboh,项目名称:w2t,代码行数:101,代码来源:Flow.php

示例4: load

 /**
  * xml定義からhandlerを処理する
  * @param string $file アプリケーションXMLのファイルパス
  */
 public static final function load($file = null)
 {
     if (!isset($file)) {
         $file = App::mode() . App::called_filename();
     }
     if (!self::$is_app_cache || !Store::has($file)) {
         $parse_app = self::parse_app($file, false);
         if (self::$is_app_cache) {
             Store::set($file, $parse_app);
         }
     }
     if (self::$is_app_cache) {
         $parse_app = Store::get($file);
     }
     if (empty($parse_app['apps'])) {
         throw new RuntimeException('undef app');
     }
     $app_result = null;
     $in_app = $match_handle = false;
     $app_index = 0;
     try {
         foreach ($parse_app['apps'] as $app) {
             switch ($app['type']) {
                 case 'handle':
                     $self = new self('_inc_session_=false');
                     foreach ($app['modules'] as $module) {
                         $self->add_module(self::import_instance($module));
                     }
                     if ($self->has_module('flow_handle_begin')) {
                         $self->call_module('flow_handle_begin', $self);
                     }
                     try {
                         if ($self->handler($app['maps'], $app_index++)->is_pattern()) {
                             $self->cp(self::execute_var($app['vars']));
                             $src = $self->read();
                             if ($self->has_module('flow_handle_end')) {
                                 $self->call_module('flow_handle_end', $src, $self);
                             }
                             print $src;
                             $in_app = true;
                             $match_handle = true;
                             if (!$parse_app["handler_multiple"]) {
                                 exit;
                             }
                         }
                     } catch (Exception $e) {
                         Log::warn($e);
                         if (isset($app['on_error']['status'])) {
                             Http::status_header((int) $app['on_error']['status']);
                         }
                         if (isset($app['on_error']['redirect'])) {
                             $this->save_exception($e);
                             $this->redirect($app['on_error']['redirect']);
                         } else {
                             if (isset($app['on_error']['template'])) {
                                 if (!$e instanceof Exceptions) {
                                     Exceptions::add($e);
                                 }
                                 $self->output($app['on_error']['template']);
                             } else {
                                 throw $e;
                             }
                         }
                     }
                     break;
                 case 'invoke':
                     $class_name = isset($app['class']) ? Lib::import($app['class']) : get_class($app_result);
                     $ref_class = new ReflectionClass($class_name);
                     foreach ($app['methods'] as $method) {
                         $invoke_class = $ref_class->getMethod($method['method'])->isStatic() ? $class_name : (isset($app['class']) ? new $class_name() : $app_result);
                         $args = array();
                         foreach ($method['args'] as $arg) {
                             if ($arg['type'] === 'result') {
                                 $args[] =& $app_result;
                             } else {
                                 $args[] = $arg['value'];
                             }
                         }
                         if (is_object($invoke_class)) {
                             foreach ($app['modules'] as $module) {
                                 $invoke_class->add_module(self::import_instance($module));
                             }
                         }
                         $app_result = call_user_func_array(array($invoke_class, $method['method']), $args);
                         $in_app = true;
                     }
                     break;
             }
         }
         if (!$match_handle) {
             Log::debug("nomatch");
             if ($parse_app["nomatch_redirect"] !== null) {
                 Http::redirect(App::url($parse_app["nomatch_redirect"]));
             }
             if ($parse_app["nomatch_template"] !== null) {
                 Http::status_header(404);
//.........这里部分代码省略.........
开发者ID:satully,项目名称:dev_socialapp,代码行数:101,代码来源:Flow.php

示例5: not_found

 /**
  * not found (http status 404)
  */
 protected function not_found(Exception $e)
 {
     Log::debug('404');
     Http::status_header(404);
     $this->output('error/not_found.html');
     exit;
 }
开发者ID:nequal,项目名称:Openpear,代码行数:10,代码来源:OpenpearLogin.php

示例6: handler

 /**
  * リポジトリサーバの実行
  */
 public static function handler()
 {
     Log::disable_display();
     $request = new Request("_inc_session_=false");
     if (strpos($request->args(), "/check") === 0) {
         exit;
     }
     $repository = new Repository();
     self::lib($repository);
     self::app($repository);
     Object::C(__CLASS__)->call_module("repository", $repository);
     foreach ($repository->names as $type) {
         if (preg_match("/^\\/" . $type . "\\/download\\/(.+)\$/", $request->args(), $match)) {
             if (self::is_tgz($type, $match[1], $filename)) {
                 self::dl($filename);
             }
         }
         if (preg_match("/^\\/" . $type . "\\/state\\/(.+)\$/", $request->args(), $match)) {
             if (self::is_tgz($type, $match[1], $filename)) {
                 exit;
             }
         }
         if (preg_match("/^\\/" . $type . "\\/list\$/", $request->args(), $match)) {
             print self::read_xml($type);
             exit;
         }
         if (preg_match("/^\\/" . $type . "\\/list\\/json\$/", $request->args(), $match)) {
             if (Tag::setof($tag, self::read_xml($type))) {
                 Text::output_jsonp($tag, $request->in_vars("callback"));
             }
         }
     }
     Http::status_header(403);
     exit;
 }
开发者ID:satully,项目名称:dev_socialapp,代码行数:38,代码来源:Repository.php


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