本文整理汇总了PHP中Controller::referer方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::referer方法的具体用法?PHP Controller::referer怎么用?PHP Controller::referer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::referer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startup
function startup(Controller $controller)
{
if (!isset($this->settings[$controller->name][$controller->action])) {
return;
}
$settings = $this->settings[$controller->name][$controller->action];
if (!in_array('Filter.Filter', $controller->helpers)) {
$controller->helpers[] = 'Filter.Filter';
}
$sessionKey = sprintf('FilterPlugin.Filters.%s.%s', $controller->name, $controller->action);
if (!$controller->request->is('post') || !isset($controller->request->data['Filter']['filterFormId'])) {
$persistedData = array();
if ($this->Session->check($sessionKey)) {
$persistedData = $this->Session->read($sessionKey);
}
if (empty($persistedData)) {
return;
}
$this->formData = $persistedData;
} else {
$this->formData = $controller->request->data;
$this->Session->write($sessionKey, $this->formData);
$controller->redirect($controller->referer());
}
foreach ($settings as $model => $options) {
if (!isset($controller->{$model})) {
trigger_error(__('Filter model not found: %s', $model));
continue;
}
$controller->{$model}->setFilterValues($this->formData);
}
}
示例2: logout
/**
* Logout user from application and Facebook
*
* @param string|array $redirectUrl
*/
public function logout($redirectUrl = null)
{
if (!$redirectUrl) {
$redirectUrl = $this->Controller->referer();
}
$logoutUrl = $this->getLogoutUrl($redirectUrl);
$this->flash(__('Disconnecting from facebook'), $logoutUrl);
}
示例3: startup
/**
* Called after the Controller::beforeFilter() and before the controller action
*
* @param Controller $controller Controller with components to startup
* @return void
*/
public function startup(Controller $controller)
{
// ファイルアップロード等で post_max_size を超えると $_POSTが空っぽになるため、このタイミングでエラー表示
$contentLength = Hash::get($_SERVER, 'CONTENT_LENGTH');
if ($contentLength > CakeNumber::fromReadableSize(ini_get('post_max_size'))) {
$message = __d('files', 'FileUpload.post_max_size.over');
$controller->NetCommons->setFlashNotification($message, array('class' => 'danger', 'interval' => NetCommonsComponent::ALERT_VALIDATE_ERROR_INTERVAL));
$controller->redirect($controller->referer());
}
}
示例4: startup
/**
* Store the referer information for use later
*/
public function startup(Controller $controller)
{
$redirect = $controller->Session->read($this->_key);
if (!in_array($controller->action, $this->_actions)) {
return;
}
if (!empty($redirect)) {
return;
}
$controller->Session->write($this->_key, $controller->referer());
}
示例5: admin_activate
/**
* undocumented function
*
* @param string $officeId
* @return void
* @access public
*/
function admin_activate($officeId = null)
{
if ($officeId == Configure::read('Office.id')) {
$msg = __('This office is already active.', true);
return $this->Message->add($msg, 'ok');
}
Assert::true(Office::isOwn($officeId), '403');
$office = $this->Office->find('first', array('conditions' => array('Office.id' => $officeId), 'contain' => array('SubOffice', 'ParentOffice')));
Assert::notEmpty($office, '404');
$this->Office->activate($office['Office']['id']);
$msg = __('The office was successfully activated!', true);
return $this->Message->add($msg, 'ok', true, Controller::referer());
}
示例6: _validateId
/**
* Is the passed ID valid ?
*
* By default we assume you want to validate an numeric string
* like a normal incremental ids from MySQL
*
* Change the validateId settings key to "uuid" for UUID check instead
*
* @param mixed $id
* @return boolean
*/
protected function _validateId($id)
{
if (isset($this->settings['validateId'])) {
$type = $this->settings['validateId'];
} else {
$type = $this->_detectPrimaryKeyFieldType();
}
if (!$type) {
return true;
} elseif ($type === 'uuid') {
$valid = Validation::uuid($id);
} else {
$valid = is_numeric($id);
}
if ($valid) {
return true;
}
$subject = $this->trigger('invalidId', compact('id'));
$this->_setFlash('invalid_id.error');
return $this->_redirect($subject, $this->_controller->referer());
}
示例7: startup
/**
* Main execution method. Handles redirecting of invalid users, and processing
* of login form data.
*
* @param Controller $controller A reference to the instantiating controller object
* @return boolean
*/
public function startup(Controller $controller)
{
$methods = array_flip(array_map('strtolower', $controller->methods));
$action = strtolower($controller->request->params['action']);
$isMissingAction = $controller->scaffold === false && !isset($methods[$action]);
if ($isMissingAction) {
return true;
}
if (!$this->_setDefaults()) {
return false;
}
$request = $controller->request;
$url = '';
if (isset($request->url)) {
$url = $request->url;
}
$url = Router::normalize($url);
$loginAction = Router::normalize($this->loginAction);
$allowedActions = $this->allowedActions;
$isAllowed = $this->allowedActions == array('*') || in_array($action, array_map('strtolower', $allowedActions));
if ($loginAction != $url && $isAllowed) {
return true;
}
if ($loginAction == $url) {
if (empty($request->data)) {
if (!$this->Session->check('Auth.redirect') && !$this->loginRedirect && env('HTTP_REFERER')) {
$this->Session->write('Auth.redirect', $controller->referer(null, true));
}
}
return true;
} else {
if (!$this->_getUser()) {
if (!$request->is('ajax')) {
$this->flash($this->authError);
$this->Session->write('Auth.redirect', $request->here());
$controller->redirect($loginAction);
return false;
} elseif (!empty($this->ajaxLogin)) {
$controller->viewPath = 'Elements';
echo $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout);
$this->_stop();
return false;
} else {
$controller->redirect(null, 403);
}
}
}
if (empty($this->authorize) || $this->isAuthorized($this->user())) {
return true;
}
$this->flash($this->authError);
$default = '/';
if (!empty($this->loginRedirect)) {
$default = $this->loginRedirect;
}
$controller->redirect($controller->referer($default), null, true);
return false;
}
示例8: __checkDimensions
function __checkDimensions($filePath)
{
$size = getimagesize($filePath);
if (!$size) {
$this->Session->setFlash('We could not check that image\'s size, so we can\'t upload it.', 'error');
$this->redirect(Controller::referer('/'));
}
$error = '';
if ($size[0] > 800 || $size[1] > 800) {
$this->Session->setFlash('Images cannot be any larger than 800 by 800 pixels.', 'error');
$this->redirect(Controller::referer('/'));
}
}
示例9: testRefererSlash
/**
* Test that the referer is not absolute if it is '/'.
*
* This avoids the base path being applied twice on string urls.
*
* @return void
*/
public function testRefererSlash()
{
$request = $this->getMock('CakeRequest', array('referer'));
$request->base = '/base';
$request->expects($this->any())->method('referer')->will($this->returnValue('/'));
Router::setRequestInfo($request);
$controller = new Controller($request);
$result = $controller->referer('/', true);
$this->assertEquals('/', $result);
$controller = new Controller($request);
$result = $controller->referer('/some/path', true);
$this->assertEquals('/base/some/path', $result);
}
示例10: testReferer
/**
* testReferer method
*
* @access public
* @return void
*/
function testReferer()
{
$Controller = new Controller();
$_SERVER['HTTP_REFERER'] = 'http://cakephp.org';
$result = $Controller->referer(null, false);
$expected = 'http://cakephp.org';
$this->assertIdentical($result, $expected);
$_SERVER['HTTP_REFERER'] = '';
$result = $Controller->referer('http://cakephp.org', false);
$expected = 'http://cakephp.org';
$this->assertIdentical($result, $expected);
$_SERVER['HTTP_REFERER'] = '';
$referer = array('controller' => 'pages', 'action' => 'display', 'home');
$result = $Controller->referer($referer, false);
$expected = 'http://' . env('HTTP_HOST') . '/pages/display/home';
$this->assertIdentical($result, $expected);
$_SERVER['HTTP_REFERER'] = '';
$result = $Controller->referer(null, false);
$expected = '/';
$this->assertIdentical($result, $expected);
$_SERVER['HTTP_REFERER'] = FULL_BASE_URL . $Controller->webroot . '/some/path';
$result = $Controller->referer(null, false);
$expected = '/some/path';
$this->assertIdentical($result, $expected);
$Controller->webroot .= '/';
$_SERVER['HTTP_REFERER'] = FULL_BASE_URL . $Controller->webroot . '/some/path';
$result = $Controller->referer(null, false);
$expected = '/some/path';
$this->assertIdentical($result, $expected);
$_SERVER['HTTP_REFERER'] = FULL_BASE_URL . $Controller->webroot . 'some/path';
$result = $Controller->referer(null, false);
$expected = '/some/path';
$this->assertIdentical($result, $expected);
$Controller->webroot = '/recipe/';
$_SERVER['HTTP_REFERER'] = FULL_BASE_URL . $Controller->webroot . 'recipes/add';
$result = $Controller->referer();
$expected = '/recipes/add';
$this->assertIdentical($result, $expected);
}
示例11: _popupStartup
/**
* _popupStartup
* POPUP型の場合はGetアクセスをはじく
* POSTが来たときは、送信された認証キーとControllerが指定しているmodel, contentId, additionalIdでDBからデータを取り出し
* マッチするか確認する
* 一致しない場合は、前の画面を再度呼び出す
*
* @param Controller $controller Controller with components to startup
* @return void
* @throws ForbiddenException
*/
protected function _popupStartup(Controller $controller)
{
// 現在実行されようとしているActionがガード対象のものであればチェックを走らせる
if ($controller->action == $this->targetAction) {
if ($controller->request->is('post') || $controller->request->is('put')) {
// POPUPのときはここでDBからデータを取り出す
$authKey = $this->AuthorizationKey->getAuthorizationKeyByContentId($this->model, $this->contentId, $this->additionalId);
//
// 入力された認証キーが正しいことを確認する
$data = $this->controller->request->data;
if (!isset($data['AuthorizationKey']['authorization_key']) || $authKey['AuthorizationKey']['authorization_key'] !== $data['AuthorizationKey']['authorization_key']) {
$this->_setErrorMessage();
$controller->redirect($controller->referer());
// 元に戻す
}
} else {
// POPUP型のガード処理でPOST以外で来ているということはURL強制HACK!
// 許さない
throw new ForbiddenException(__d('authorization_keys', 'you can not access without entering authorization key.'));
}
}
// それ以外の場合は何もせず通す
return true;
}
示例12: setReferer
/**
* Sets the referer page
*
* We need to know where were you, to get you back there
*
* @return void
* @see CroogoComponent::redirect()
*/
public function setReferer()
{
$default = array('controller' => $this->_controller->request->params['controller'], 'action' => 'index');
$referer = $this->_controller->referer($default, true);
$this->Session->write('Croogo.referer', array('url' => $referer));
}
示例13: dump
function dump($object = 'options')
{
if ($object == 'view') {
$this->set('header', 'Dumping a View Object');
$this->render('view_dump');
} elseif ($object == 'controller') {
$this->Gatekeeper->restrict_from_app_modes(array('production'), '/demo/gatekeeper/blocked', 'this option is blocked in production mode');
$REPORT = array($this->name => $this);
$this->set('header', 'Dumping the Controller Object');
$this->set('data', $REPORT);
$this->render('report');
} elseif ($object == 'config') {
$REPORT = array('App.mode' => Configure::Read('App.mode'), 'App.domain' => Configure::Read('App.domain'), 'debug' => Configure::read('debug'), 'Configure::Read(\'App\')' => Configure::Read('App'));
$this->set('header', 'Cakewell Context-Specific App Values');
$this->set('data', $REPORT);
$this->render('report');
} elseif ($object == 'phpinfo') {
$this->Gatekeeper->restrict_from_app_modes(array('production'), '/demo/', 'this action is blocked in production mode');
ob_start();
phpinfo();
$phpinfo = ob_get_clean();
$this->set('content_for_view', $phpinfo);
$this->render('blank', 'default');
} elseif ($object == 'request_handler') {
$Report = array('$this->Session->id()' => $this->Session->id(), '$this->Session->id' => $this->Session->id, '$this->RequestHandler->getReferrer()' => $this->RequestHandler->getReferrer(), '$_SERVER[\'HTTP_REFERER\']' => $_SERVER['HTTP_REFERER'], '$_SERVER[\'HTTP_USER_AGENT\']' => $_SERVER['HTTP_USER_AGENT'], 'Controller::referer' => Controller::referer(), '$this->RequestHandler->getClientIP()' => $this->RequestHandler->getClientIP(), 'FULL_BASE_URL + Router::url(\'\', false)' => FULL_BASE_URL . Router::url('', false), '$this->RequestHandler' => $this->RequestHandler);
$this->set('header', 'showing RequestHandler info for client at ip ' . $this->RequestHandler->getClientIP());
$this->set('data', $Report);
$this->render('report');
} elseif ($object == 'referer') {
$Data = array('referer' => $this->referer(), 'SERVER[\'HTTP_REFERER\']' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'NULL', 'Configure::read(\'Security.level\')' => Configure::read('Security.level'));
$this->set('header', 'Checking Referrer');
$this->set('data', $Data);
$this->render('report');
} elseif ($object == 'constants') {
$this->set('header', 'Some CakePHP Constants and Globals (<a href="http://book.cakephp.org/view/122/Core-Definition-Constants">docs</a>)');
$this->set('data', $this->_cake_constants());
$this->render('report');
} else {
$content = <<<EOMENU
<h3>choose an object to dump</h3>
<a href="/demo/dump/controller/">controller object</a><br />
<a href="/demo/dump/view/">view object</a><br />
<a href="/demo/dump/config/">configuration app values</a><br />
<a href="/demo/dump/request_handler/">request handler</a><br />
<a href="/demo/dump/referer/">referrer</a><br />
<a href="/demo/dump/constants/">cakephp constants</a><br />
<a href="/demo/dump/phpinfo/">phpinfo</a><br />
EOMENU;
$this->set('header', 'Object Dumper');
$this->set('content', $content);
$this->render('index');
}
}
示例14: referer
/**
* undocumented function
*
* @return void
*/
function referer($default = null, $local = true)
{
return parent::referer($default, $local);
}
示例15: admin_update_multiple
/**
*
*/
public function admin_update_multiple()
{
$this->autoRender = false;
$modelArray = array_keys($this->data);
if ($modelArray[0] == '_Token') {
$modelArray[0] = $modelArray[1];
}
if (!empty($this->data)) {
$message = $this->{$modelArray[0]}->updateMultiple($this->data);
$this->_message($message, Controller::referer());
}
}