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


PHP CakeRequest::host方法代码示例

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


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

示例1: testHost

 /**
  * test host retrieval.
  *
  * @return void
  */
 public function testHost()
 {
     $_SERVER['HTTP_HOST'] = 'localhost';
     $request = new CakeRequest('some/path');
     $this->assertEquals('localhost', $request->host());
 }
开发者ID:nabeelio,项目名称:CakePHP-Base,代码行数:11,代码来源:CakeRequestTest.php

示例2: testHost

 /**
  * Test host retrieval.
  *
  * @return void
  */
 public function testHost()
 {
     $_SERVER['HTTP_HOST'] = 'localhost';
     $_SERVER['HTTP_X_FORWARDED_HOST'] = 'cakephp.org';
     $request = new CakeRequest('some/path');
     $this->assertEquals('localhost', $request->host());
     $this->assertEquals('cakephp.org', $request->host(true));
 }
开发者ID:xMyThoLoGyx,项目名称:centremedicaletp3,代码行数:13,代码来源:CakeRequestTest.php

示例3: add

 /**
  * Create new user
  *
  * @param email, password
  * @return void
  * @throws NotFoundException When the view file could not be found
  *  or MissingViewException in debug mode.
  */
 public function add()
 {
     //$this->authenticate_user();
     //$this->authenticate_admin();
     if ($this->request->is('post')) {
         $this->User->create();
         try {
             $activate_token = sha1(time() . $userEmail . $userPassword);
             $userEmail = $this->request->data["User"]["email"];
             $userPassword = sha1($this->request->data["User"]["password"]);
             $this->request->data["User"]["activate_token"] = $activate_token;
             //var_dump($this->request->data);
             //exit;
             if ($res = $this->User->saveAssociated($this->request->data)) {
                 $admin_emails = array();
                 $this->User->recursive = -1;
                 $conditions = array("User.role >" => 0);
                 $admins = $this->User->find('all', array('conditions' => $conditions));
                 foreach ($admins as $u) {
                     if ($u['User']['email'] != '') {
                         array_push($admin_emails, $u['User']['email']);
                     }
                 }
                 $mail = new CakeEmail();
                 $mail->template('notify_new_user', 'default')->subject('New user notification')->emailFormat('html')->to('admin@diabetesavior.com')->bcc($admin_emails)->from('admin@diabetesavior.com')->send();
                 $baseUrl = "http://" . CakeRequest::host() . $this->request->webroot;
                 $activate_url = $baseUrl . "activate?token=" . $activate_token;
                 $mail = new CakeEmail();
                 $mail->viewVars(array('activate_url' => $activate_url));
                 $mail->template('user_confirmation', 'default')->subject('Activate you account')->emailFormat('html')->to($userEmail)->from('admin@diabetesavior.com')->send();
                 //var_dump($userEmail);
                 $this->redirect("/pages/after_sign_up");
             } else {
                 $errorOutput = "";
                 foreach ($this->User->validationErrors as $attr) {
                     $this->Session->setFlash($this->User->validationErrors);
                     foreach ($attr as $attrErrors) {
                         $errorOutput .= $attrErrors . "\n";
                     }
                 }
                 $errorOutput = nl2br($errorOutput);
                 $this->Session->setFlash($errorOutput, "flash_error");
                 $this->render('sign_up');
             }
         } catch (Exception $e) {
             $this->Session->setFlash($e->getMessage(), "flash_error");
             $this->redirect("/sign_up");
         }
     } else {
         throw new ForbiddenException();
     }
 }
开发者ID:jet77,项目名称:DiabeteSavior,代码行数:60,代码来源:UsersController.php


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