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


PHP Response::build方法代码示例

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


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

示例1: do_upload

 public function do_upload($dir = '', $filename = 'userfile', $is_ajax = false)
 {
     if (!$this->ion_auth->logged_in() or !$this->ion_auth->is_admin()) {
         redirect('auth/login', 'refresh');
     } else {
         /* Conf */
         $config['upload_path'] = './upload/' . $dir;
         $config['allowed_types'] = 'gif|jpg|png';
         $config['max_size'] = 2048;
         $config['max_width'] = 1024;
         $config['max_height'] = 1024;
         $config['file_ext_tolower'] = TRUE;
         $this->load->library('upload', $config);
         /* Breadcrumbs */
         $this->breadcrumbs->unshift(2, lang('menu_files'), 'admin/files');
         $this->data['breadcrumb'] = $this->breadcrumbs->show();
         if (!$this->upload->do_upload($filename)) {
             /* Data */
             $this->data['error'] = $this->upload->display_errors();
             if ($is_ajax) {
                 Response::build(-1, 'error', $this->data)->show();
             } else {
                 $this->template->admin_render('admin/files/index', $this->data);
             }
         } else {
             /* Data */
             $this->data['upload_data'] = $this->upload->data();
             if ($is_ajax) {
                 Response::build(-1, 'error', $this->data)->show();
             } else {
                 $this->template->admin_render('admin/files/upload', $this->data);
             }
         }
     }
 }
开发者ID:joeseesun,项目名称:testYou,代码行数:35,代码来源:Files.php

示例2: interest

 public function interest($category_id = 1)
 {
     $page_num = 3;
     $page = rand(1, 3);
     $this->data['questions'] = $this->question_model->get_question(array("question_category_id" => $category_id, "sort_by" => 'update_time', 'sort_direction' => 'desc', "pid" => 'NULL', 'limit' => $page_num, 'offset' => ($page - 1) * $page_num));
     Response::build(0, 'ok', $this->data['questions'])->show();
 }
开发者ID:joeseesun,项目名称:testYou,代码行数:7,代码来源:Question.php

示例3: del

     }
 }
 public function del()
 {
     $ret = $this->answer_model->delete_answer(array('id' => $this->input->post('id')));
     if ($ret) {
         Response::build(0, 'ok')->show();
     } else {
         Response::build(-1, "delete error")->show();
开发者ID:joeseesun,项目名称:testYou,代码行数:9,代码来源:Answer.php

示例4: del

     //    $this->output->enable_profiler(TRUE);
 }
 public function del()
 {
     $id = $this->input->post("id");
     //$result = $this->result_model->get_result(array("id"=>$id));
     $ret = $this->result_model->delete_result(array("id" => $id));
     if ($ret) {
         Response::build(0, 'ok', $id)->show();
     } else {
         Response::build(-1, "delete result fail")->show();
开发者ID:joeseesun,项目名称:testYou,代码行数:11,代码来源:Result.php

示例5: keepAlive

 public function keepAlive()
 {
     if (!$this->isVerified()) {
         $response = new Response(401, 'You are not verified! Check the documentation.');
         $response->build();
         return;
     }
     $_SESSION['time'] = time();
     $response = new Response(200, 'Session is keeped alive for 2 minutes.');
     $response->build();
 }
开发者ID:demag0gue,项目名称:Crawler,代码行数:11,代码来源:auth.php

示例6: handle

 public function handle(Request $req, Response $res) : Response
 {
     // Skip if it is the path where the user is supposed to sign up
     if ($this->signUpPath && $this->signUpPath === trim($req->getUrl()->getPath(), '/')) {
         return $res;
     }
     // A way to validate the user credentials is required
     if (!$this->authStrategy) {
         throw new \InvalidArgumentException('An authentication strategy must be provided in order to identify the users in the system');
     }
     // Access forbidden if no credentials are provided
     if (!$_SERVER['PHP_AUTH_USER']) {
         return $res->build(HttpStatus::Unauthorized, ['WWW-Authenticate' => 'Basic'], ['title' => 'Unauthenticated', 'detail' => 'The information you are trying to access requires authentication']);
     }
     $user = $_SERVER['PHP_AUTH_USER'];
     $pass = $_SERVER['PHP_AUTH_PW'];
     // Validate the user-provided credentials
     if (!$this->authStrategy->checkCredentials($user, $pass)) {
         return $res->build(HttpStatus::Unauthorized, [], ['title' => 'Wrong password', 'detail' => 'The password provided is not correct for the username']);
     }
     return $res;
 }
开发者ID:inad9300,项目名称:bed.php,代码行数:22,代码来源:BasicAuth.php

示例7: get

 public function get($date = null)
 {
     if ($date == null) {
         $date = date('j.n.Y');
     }
     if (file_exists(path . 'saved/' . $date . '.json')) {
         $content = file_get_contents(path . 'saved/' . $date . '.json');
         $response = new Response(200, json_decode($content));
         $response->build();
     } else {
         $response = new Response(404, 'Date ' . $date . ' does not exist.');
         $response->build();
     }
 }
开发者ID:demag0gue,项目名称:Crawler,代码行数:14,代码来源:plan.php

示例8: __construct

 public function __construct()
 {
     if (@$_GET['url'] == null) {
         $response = new Response(400, 'You are wrong here! Check the documentation.');
         $response->build();
         return;
     }
     $url = rtrim($_GET['url'], '/');
     $url = filter_var($url, FILTER_SANITIZE_URL);
     $url = explode('/', $url);
     if (!file_exists(path . 'modules/' . $url[0] . '.php')) {
         $response = new Response(404, 'Module ' . $url[0] . ' does not exist! Check the documenation.');
         $response->build();
         return;
     }
     require path . 'modules/' . $url[0] . '.php';
     $module = new $url[0]();
     if ($url[1] == null || !method_exists($module, $url[1])) {
         $response = new Response(404, 'You are wrong here. Check the documentation.');
         $response->build();
         return;
     }
     switch (sizeof($url) - 2) {
         case 0:
             $module->{$url}[1]();
             break;
         case 1:
             $module->{$url}[1]($url[2]);
             break;
         case 2:
             $module->{$url}[1]($url[2], $url[3]);
             break;
         case 3:
             $module->{$url}[1]($url[2], $url[3], $url[4]);
             break;
     }
 }
开发者ID:demag0gue,项目名称:Crawler,代码行数:37,代码来源:app.php

示例9: del

 public function del()
 {
     $ret = $this->question_model->delete_question(array("id" => $this->input->post('id')));
     if ($ret > 0) {
         $this->answer_model->delete_answer(array("sub_question_id" => $this->input->post('id')));
         Response::build(0, "ok", "删除成功")->show();
     } else {
         Response::build(-1, "删除失败")->show();
     }
 }
开发者ID:joeseesun,项目名称:testYou,代码行数:10,代码来源:Question.php

示例10: get

 public function get()
 {
     $content = file_get_contents(path . 'saved/teacher/teacher.json');
     $response = new Response(200, json_decode($content));
     $response->build();
 }
开发者ID:demag0gue,项目名称:Crawler,代码行数:6,代码来源:teacher.php


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