public function preDispatch(Zend_Controller_Request_Abstract $request) { if ('company' == $request->getControllerName()) { $tsn = $request->tsn ? $request->tsn : $_COOKIE['tsn']; if ($tsn) { $token = Token::create($tsn); $token->update_sync_time(); } else { $token = Token::create_abstract('123'); } if ($token->is_logined() == true) { if ($token->is_expire()) { $token->destroy(); include_once LIB_PATH . '/view_helper/BuildUrl.php'; $url_builder = new Zend_View_Helper_BuildUrl(); $referer = SearchFilter::slashes($url_builder->buildUrl($request->getActionName(), $request->getControllerName(), $request->getModuleName())); $login_url = $url_builder->buildUrl('login', 'auth', 'index', array('redirect' => $referer)); $redirector = new Zend_Controller_Action_Helper_Redirector(); $redirector->gotoUrl($login_url); return; } $token->register(); } else { if ('auth' != $request->getActionName()) { $token->destroy(); $request->setModuleName('index'); $request->setControllerName('auth'); $request->setActionName('login'); } } } }
/** * @group ZF-9859 */ public function testGotoUrlAndSetGotoUrlBehaveTheSame() { $url = 'http://www.example.com'; $gotoUrl = $this->redirector->gotoUrl($url); $setGotoUrl = $this->redirector->setGotoUrl($url); $this->assertSame($gotoUrl, $setGotoUrl); }
public static function redirectIfSessionExpired() { $cusNS = new Zend_Session_Namespace('Customer'); if (isset($cusNS->expired)) { $redirector = new Zend_Controller_Action_Helper_Redirector(); return $redirector->gotoUrl('/error/expire'); } }
public function logoutAction() { $url = explode('.', $this->_hostHttp->getServer('HTTP_HOST'), 2); // уничтожаем информацию об авторизации пользователя Zend_Auth::getInstance()->clearIdentity(); // и отправляем его на главную $this->_redirector->gotoUrl('http://' . $url[1]); }
public function deleteAction() { //echo "<pre>"; print_r($this->_request->getParams()); exit; $formObj = new Application_Model_Form(); $deleteidArray = $this->request->getParam('deleteid'); foreach ($deleteidArray as $formid) { //echo $formid; exit; $formObj->deleteWebformById($formid); } $this->_redirector->gotoUrl('/form/create/'); }
/** * @group ZF-4318 */ public function testServerVariableHttpsToOffDoesNotBuildHttpsUrl() { // Set Preconditions from Issue: $_SERVER['HTTPS'] = "off"; $_SERVER['HTTP_HOST'] = 'localhost'; $_SERVER['SERVER_PORT'] = 80; $this->redirector->setUseAbsoluteUri(true); $this->request->setModuleName('admin')->setControllerName('class')->setActionName('view'); $this->redirector->gotoUrl('/bar/baz'); $test = $this->redirector->getRedirectUrl(); $this->assertNotContains('https://', $test); $this->assertEquals('http://localhost/bar/baz', $test); }
public function preDispatch(Zend_Controller_Request_Abstract $request) { if ($request->getModuleName() === 'painel') { if (My_Auth::getInstance('Painel')->hasIdentity()) { return; } else { if ($request->getControllerName() !== 'auth') { $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); $r = new Zend_Controller_Action_Helper_Redirector(); $r->gotoUrl('painel/auth?u=' . base64_encode($uri))->redirectAndExit(); } } } }
public function testUseAbsoluteUriSetsFullUriInResponse() { $_SERVER['HTTP_HOST'] = 'foobar.example.com'; $_SERVER['SERVER_PORT'] = '4443'; $_SERVER['HTTPS'] = 1; $this->redirector->setUseAbsoluteUri(true); $this->redirector->gotoUrl('/bar/baz'); $headers = $this->response->getHeaders(); $uri = false; foreach ($headers as $header) { if ('Location' == $header['name']) { $uri = $header['value']; } } if (!$uri) { $this->fail('No redirect header set in response'); } $this->assertEquals('https://foobar.example.com:4443/bar/baz', $uri); }
public function deleteAction() { $folderObj = new Application_Model_Folder($this->user); $folderid = $this->request->getParam('id'); //if ($this->user->isSuperAdmin() || $this->session->canImport) { $reportObj = new Application_Model_Report(); if ($reportObj->getTotalSubscriberByFolder($folderid) == 0) { if ($folderObj->deleteFolder($folderid)) { $message = 'Folder Deleted.'; } else { $error = 'Folder error: ' . $folderObj->getError(); } } else { if ($folderObj->deleteFolderWithSubscriber($folderid)) { $message = 'Folder Deleted.'; } else { $error = 'Folder error: ' . $folderObj->getError(); } } //} $this->view->error = $error; $this->view->message = $message; $this->_redirector->gotoUrl('/folder/'); }
/** * gotoUrl() is an alias for setGotoUrl() */ public function testGotoUrl() { $this->redirector->gotoUrl('/foo/bar'); $this->assertEquals('/foo/bar', $this->redirector->getRedirectUrl()); }
/** * ZF-2602 */ public function testPassingEmptyStringToGotoUrlRedirectsToRoot() { $this->redirector->gotoUrl(''); $this->assertEquals('/', $this->redirector->getRedirectUrl()); }
public function editAction() { // action body $request = $this->getRequest(); $id = $request->getParam('id'); if (isset($id)) { $form = new Application_Form_WinsAndWants(); $form->getElement('created')->removeValidator('Db_NoRecordExists'); $winsandwantsMapper = new Application_Model_WinsAndWantsMapper(); $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); $row = $winsandwantsMapper->fetchByIdAndUserId($id, $identity->id); $form->populate($row); if ($request->isPost()) { if ($form->isValid($request->getPost())) { $winsandwantsMapper = new Application_Model_WinsAndWantsMapper(); $winsandwants = new Application_Model_WinsAndWants($form->getValues()); $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); $winsandwants->setUserId($identity->id); $winsandwants->setId($id); /* * The value of the submit buttons are retrieved through the request object parameters * since they do not exist in the $form object */ // Check which button was selected if ($form->save->isChecked()) { $winsandwantsMapper->save($winsandwants); $wins = new Zend_Session_Namespace('wins'); $data = array('id' => $winsandwants->getId(), 'created' => $winsandwants->getCreated(), 'wins_01' => $winsandwants->getWins01(), 'wins_02' => $winsandwants->getWins02(), 'wins_03' => $winsandwants->getWins03(), 'wins_04' => $winsandwants->getWins04(), 'wins_05' => $winsandwants->getWins05(), 'wants_01' => $winsandwants->getWants01(), 'wants_02' => $winsandwants->getWants02(), 'wants_03' => $winsandwants->getWants03(), 'wants_04' => $winsandwants->getWants04(), 'wants_05' => $winsandwants->getWants05(), 'emails' => $winsandwants->getEmails(), 'user_id' => $winsandwants->getUserId()); $wins->data = $data; $this->_redirector->gotoUrl('/wins-and-wants/success/'); } elseif ($form->share->isChecked()) { $winsandwantsMapper->save($winsandwants); $wins = new Zend_Session_Namespace('wins'); $data = array('id' => $winsandwants->getId(), 'created' => $winsandwants->getCreated(), 'wins_01' => $winsandwants->getWins01(), 'wins_02' => $winsandwants->getWins02(), 'wins_03' => $winsandwants->getWins03(), 'wins_04' => $winsandwants->getWins04(), 'wins_05' => $winsandwants->getWins05(), 'wants_01' => $winsandwants->getWants01(), 'wants_02' => $winsandwants->getWants02(), 'wants_03' => $winsandwants->getWants03(), 'wants_04' => $winsandwants->getWants04(), 'wants_05' => $winsandwants->getWants05(), 'emails' => $winsandwants->getEmails(), 'user_id' => $winsandwants->getUserId()); $wins->data = $data; $emails_str = str_replace(" ", "", $winsandwants->getEmails()); // strips whitespace from string $emails = explode(",", $emails_str); // splits string into an array using comma to split $validator = new Zend_Validate_EmailAddress(); foreach ($emails as $email) { if (!$validator->isValid($email)) { array_shift($emails); // Remove invalid emails } } $mail = new Zend_Mail(); $mail->setFrom($identity->email, $identity->username); $mail->addTo($emails); $mail->setSubject('Sharing my winsandwants'); try { $shareMapper = new Application_Model_ShareMapper(); $share = new Application_Model_Share(); $share->setWinsAndWantsId($winsandwants->getId()); $share->setWinsAndWantsUserId($winsandwants->getUserId()); $checked_wins = array(); $checked_wins[] = $winsandwants->getWins01cb() ? '1' : null; $checked_wins[] = $winsandwants->getWins02cb() ? '2' : null; $checked_wins[] = $winsandwants->getWins03cb() ? '3' : null; $checked_wins[] = $winsandwants->getWins04cb() ? '4' : null; $checked_wins[] = $winsandwants->getWins05cb() ? '5' : null; $checked_wins = array_filter($checked_wins); $shared_wins = implode(',', $checked_wins); $share->setSharedWins($shared_wins); $checked_wants = array(); $checked_wants[] = $winsandwants->getWants01cb() ? '1' : null; $checked_wants[] = $winsandwants->getWants02cb() ? '2' : null; $checked_wants[] = $winsandwants->getWants03cb() ? '3' : null; $checked_wants[] = $winsandwants->getWants04cb() ? '4' : null; $checked_wants[] = $winsandwants->getWants05cb() ? '5' : null; $checked_wants = array_filter($checked_wants); $shared_wants = implode(',', $checked_wants); $share->setSharedWants($shared_wants); $sharePrimaryKeys = $shareMapper->save($share); } catch (Exception $e) { throw new Exception($e->getMessage(), $e->getCode()); } $txt = 'http://winsandwants.com/wins-and-wants/share/id/' . $sharePrimaryKeys['id']; $mail->setBodyText($txt, 'UTF-8'); $mail->send(); $this->_redirector->gotoUrl('/wins-and-wants/success/'); } elseif ($form->print->isChecked()) { $wins = new Zend_Session_Namespace('wins'); $data = array('Id' => $winsandwants->getId(), 'Created' => $winsandwants->getCreated(), 'Wins 01' => $winsandwants->getWins01(), 'Wins 02' => $winsandwants->getWins02(), 'Wins 03' => $winsandwants->getWins03(), 'Wins 04' => $winsandwants->getWins04(), 'Wins 05' => $winsandwants->getWins05(), 'Wants 01' => $winsandwants->getWants01(), 'Wants 02' => $winsandwants->getWants02(), 'Wants 03' => $winsandwants->getWants03(), 'Wants 04' => $winsandwants->getWants04(), 'Wants 05' => $winsandwants->getWants05(), 'Emails' => $winsandwants->getEmails(), 'User Id' => $winsandwants->getUserId()); $wins->data = $data; $this->_redirector->gotoUrl('/wins-and-wants/print/'); } } } $this->view->form = $form; } else { $this->_redirector->gotoUrl('/dashboard'); } }