Пример #1
0
function build(&$a)
{
    if (isset($a['auth'])) {
        $response = new \Symfony\Component\HttpFoundation\RedirectResponse('/');
        $response->send();
    }
}
Пример #2
0
 /**
  * Constructor.
  *
  * @deprecated since 1.4.0 return a Symfony\Component\HttpFoundation\RedirectResponse instead
  *
  * @param string  $url  Url.
  * @param integer $type Default 302.
  */
 public function __construct($url, $type = 302)
 {
     $this->url = $url;
     $this->type = $type;
     $response = new Symfony\Component\HttpFoundation\RedirectResponse(System::normalizeUrl($url), $type);
     $response->send();
     exit;
 }
Пример #3
0
 public static function Redirect($url, &$vars = null)
 {
     if (isset($vars)) {
         Http::SetSession($vars);
     }
     $response = new \Symfony\Component\HttpFoundation\RedirectResponse($url);
     $response->send();
     exit(0);
 }
Пример #4
0
 /**
  * Registra os erros em arquivo enquanto direciona o usuário para uma página genérica de erro.
  *
  * @param \Exception $ex
  */
 public static function logProduction(\Exception $ex)
 {
     $message = $ex->getMessage();
     $code = $ex->getCode();
     $file = $ex->getFile();
     $line = $ex->getLine();
     $trace = $ex->getTraceAsString();
     $log_folder = SYS_ROOT . 'errors' . DS;
     $log = fopen($log_folder . 'errors.log', 'a+');
     fwrite($log, 'message: ' . $message . PHP_EOL);
     fwrite($log, 'code: ' . $code . PHP_EOL);
     fwrite($log, 'file: ' . $file . PHP_EOL);
     fwrite($log, 'line: ' . $line . PHP_EOL);
     fwrite($log, 'trace: ' . $trace . PHP_EOL);
     fwrite($log, '================================================================================' . PHP_EOL);
     fclose($log);
     //RedirectResponse('http://example.com/');
     $redirect = new \Symfony\Component\HttpFoundation\RedirectResponse('/erro');
     $redirect->send();
 }
Пример #5
0
 /**
  * @param string $url
  */
 public static function redirect($url)
 {
     $redirect = new Symfony\Component\HttpFoundation\RedirectResponse($url);
     $redirect->send();
 }
Пример #6
0
 /**
  * Carry out a redirect.
  *
  * @param string  $redirecturl       URL to redirect to.
  * @param array   $additionalheaders Array of header strings to send with redirect.
  * @param integer $type              Number type of the redirect.
  * @param mixed   $response          unused
  *
  * @deprecated since 1.4.0 - from a controller, return RedirectResponse
  *
  * @throws \Exception
  */
 public static function redirect($redirecturl, $additionalheaders = array(), $type = 302, $response = false)
 {
     // very basic input validation against HTTP response splitting
     $redirecturl = str_replace(array('\\r', '\\n', '%0d', '%0a'), '', $redirecturl);
     // check if the headers have already been sent
     if (headers_sent()) {
         throw new \Exception(__('Unable to redirect. Headers already sent.'));
     }
     // Always close session before redirect
     session_write_close();
     $redirecturl = self::normalizeUrl($redirecturl);
     $response = new \Symfony\Component\HttpFoundation\RedirectResponse($redirecturl, $type);
     if (!empty($additionalheaders)) {
         $response->headers->add($additionalheaders);
     }
     $response->send();
     exit;
 }
Пример #7
0
 private function redirecting($url)
 {
     $response = new \Symfony\Component\HttpFoundation\RedirectResponse($url);
     foreach ($this->_cookies as $cookie) {
         $response->headers->setCookie($cookie);
     }
     foreach ($this->_cookiestodelete as $cookie) {
         $response->headers->clearCookie($cookie);
     }
     $response->send();
 }
Пример #8
0
<?php

/**
 * Copyright Zikula Foundation 2009 - Zikula Application Framework
 *
 * This work is contributed to the Zikula Foundation under one or more
 * Contributor Agreements and licensed to You under the following license:
 *
 * @license GNU/LGPLv3 (or at your option, any later version).
 * @package Zikula
 *
 * Please see the NOTICE file distributed with this source code for further
 * information regarding copyright and licensing.
 */
use Zikula_Request_Http as Request;
include 'lib/bootstrap.php';
$request = Request::createFromGlobals();
$core->getContainer()->set('request', $request);
$core->init(Zikula_Core::STAGE_ALL, $request);
$url = $core->getContainer()->get('router')->generate('zikulaadminmodule_admin_adminpanel', array(), \Symfony\Component\Routing\RouterInterface::ABSOLUTE_URL);
$url = str_replace('/admin.php', '', $url);
$response = new \Symfony\Component\HttpFoundation\RedirectResponse($url);
$response->send();
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public static function create($url = "", $status = 302, $headers = array())
 {
     return Symfony\Component\HttpFoundation\RedirectResponse::create($url, $status, $headers);
 }
Пример #10
0
 /**
  * Authenticate a user's credentials against an authentication module, logging him into the Zikula system.
  *
  * If the user is already logged in, then this function should behave as if {@link authenticateUserUsing()} was called.
  *
  * This function is used to check that a user is who he says he is, and that he has a valid user account with the
  * Zikula system. If so, the user is logged in to the Zikula system (if he is not already logged in). This function
  * should be used only to log a user into the Zikula system.
  *
  * This function differs from {@link checkPasswordUsing()} in that it attempts to look up a Zikula account
  * record for the user, and takes the user's account status into account when returning a value. Additionally,
  * the user is logged into the Zikula system if his credentials are verified with the authentication module specified.
  *
  * This function differs from {@link authenticateUserUsing()} in that it attempts to log the user into the Zikula system,
  * if he is not already logged in. If he is already logged in, then it should behave similarly to authenticateUserUsing().
  *
  * ATTENTION: The authentication module function(s) called during this process may redirect the user to an external server
  * to perform authorization and/or authentication. The function calling loginUsing must already have anticipated
  * the reentrant nature of this process, must already have saved pertinent user state, must have supplied a
  * reentrant URL pointing to a function that will handle reentry into the login process silently, and must clear
  * any save user state immediately following the return of this function.
  *
  * @param array   $authenticationMethod Auth module name.
  * @param array   $authenticationInfo   Auth info array.
  * @param boolean $rememberMe           Whether or not to remember login.
  * @param string  $reentrantURL         If the authentication module needs to redirect to an external authentication server (e.g., OpenID), then
  *                                          this is the URL to return to in order to re-enter the log-in process. The pertinent user
  *                                          state must have already been saved by the function calling loginUsing(), and the URL must
  *                                          point to a Zikula_AbstractController function that is equipped to detect reentry, restore the
  *                                          saved user state, and get the user back to the point where loginUsing is re-executed. This
  *                                          is only optional if the authentication module identified by $authenticationMethod reports that it is not
  *                                          reentrant (e.g., Users is guaranteed to not be reentrant), or if $checkPassword is false.
  * @param boolean $checkPassword        Whether or not to check the password.
  * @param boolean $preauthenticatedUser Whether ot not is a preauthenticated user.
  *
  * @return array|bool The user account record of the user that has logged in successfully, otherwise false
  *
  * @throws InvalidArgumentException|AccessDeniedException
  */
 public static function loginUsing(array $authenticationMethod, array $authenticationInfo, $rememberMe = false, $reentrantURL = null, $checkPassword = true, $preauthenticatedUser = null)
 {
     $userObj = false;
     if (self::preAuthenticationValidation($authenticationMethod, $authenticationInfo, $reentrantURL)) {
         // Authenticate the loginID and userEnteredPassword against the specified authentication module.
         // This should return the uid of the user logging in. Note that there are two routes here, both get a uid.
         // We do the authentication check first, before checking any account status information, because if the
         // person logging in cannot supply the proper credentials, then we should not show any detailed account status
         // to them. Instead they should just get the generic "no such user found or bad password" message.
         if ($checkPassword) {
             $authenticatedUid = self::internalAuthenticateUserUsing($authenticationMethod, $authenticationInfo, $reentrantURL, true);
         } elseif (isset($preauthenticatedUser)) {
             if (is_numeric($preauthenticatedUser)) {
                 $authenticatedUid = $preauthenticatedUser;
             } elseif (is_array($preauthenticatedUser)) {
                 $authenticatedUid = $preauthenticatedUser['uid'];
                 $userObj = $preauthenticatedUser;
             } else {
                 throw new \InvalidArgumentException();
             }
         } else {
             $authArgs = array('authentication_info' => $authenticationInfo, 'authentication_method' => $authenticationMethod);
             $authenticatedUid = ModUtil::apiFunc($authenticationMethod['modname'], 'Authentication', 'getUidForAuththenticationInfo', $authArgs, 'Zikula_Api_AbstractAuthentication');
         }
         $userObj = self::internalUserAccountValidation($authenticatedUid, true, isset($userObj) ? $userObj : null);
         if ($userObj && is_array($userObj)) {
             // BEGIN ACTUAL LOGIN
             // Made it through all the checks. We can actually log in now.
             // Give any interested module one last chance to prevent the login from happening.
             $eventArgs = array('authentication_method' => $authenticationMethod, 'uid' => $userObj['uid']);
             $event = new GenericEvent($userObj, $eventArgs);
             $event = EventUtil::dispatch('user.login.veto', $event);
             if ($event->isPropagationStopped()) {
                 // The login attempt has been vetoed by one or more modules.
                 $eventData = $event->getData();
                 if (isset($eventData['retry']) && $eventData['retry']) {
                     $sessionVarName = 'Users_Controller_User_login';
                     $sessionNamespace = 'Zikula_Users';
                     $redirectURL = ModUtil::url('ZikulaUsersModule', 'user', 'login', array('csrftoken' => SecurityUtil::generateCsrfToken()));
                 } elseif (isset($eventData['redirect_func'])) {
                     if (isset($eventData['redirect_func']['session'])) {
                         $sessionVarName = $eventData['redirect_func']['session']['var'];
                         $sessionNamespace = isset($eventData['redirect_func']['session']['namespace']) ? $eventData['redirect_func']['session']['namespace'] : '';
                     }
                     $redirectURL = ModUtil::url($eventData['redirect_func']['modname'], $eventData['redirect_func']['type'], $eventData['redirect_func']['func'], $eventData['redirect_func']['args']);
                 }
                 if (isset($redirectURL)) {
                     if (isset($sessionVarName)) {
                         SessionUtil::requireSession();
                         $sessionVars = SessionUtil::getVar('Users_User_Controller_login', array(), 'Zikula_Users', false, false);
                         $sessionVars = array('returnpage' => isset($sessionVars['returnpage']) ? $sessionVars['returnpage'] : '', 'authentication_info' => $authenticationInfo, 'authentication_method' => $authenticationMethod, 'rememberme' => $rememberMe, 'user_obj' => $userObj);
                         SessionUtil::setVar($sessionVarName, $sessionVars, $sessionNamespace, true, true);
                     }
                     $userObj = false;
                     $response = new \Symfony\Component\HttpFoundation\RedirectResponse($redirectURL);
                     $response->send();
                     exit;
                 } else {
                     throw new AccessDeniedException();
                 }
             } else {
                 // The login has not been vetoed
                 // This is what really does the Zikula login
                 self::setUserByUid($userObj['uid'], $rememberMe, $authenticationMethod);
             }
         }
     }
     return $userObj;
 }