本文整理汇总了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());
}
示例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));
}
示例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();
}
}