getHttpHost() public method

The port name will be appended to the host if it's non-standard.
public getHttpHost ( ) : string
return string
Example #1
0
 /**
  * @param Dispatch $dispatcher
  * @param Request  $request
  */
 public function __construct(Dispatch $dispatcher, Request $request)
 {
     $this->_dispatcher = $dispatcher;
     $this->_request = $request;
     $this->_httpHost = $this->_request->getHttpHost();
     $this->_mapper = new DirectoryMapper($dispatcher->getBaseDirectory(), $dispatcher->getConfig());
     $this->_mapper->setHashMap(ValueAs::arr($dispatcher->getConfig()->getItem('hashtable', [])));
 }
Example #2
0
 /**
  * Performs route matching & dispatch and sends the response.
  *
  * @return $this
  */
 public function run()
 {
     // Route
     $match = $this->router->match($this->request->getPathInfo(), $this->request->getMethod(), $this->request->getHttpHost(false));
     // Dispatch
     $this->dispatch($match);
     // Respond
     $this->response->send();
 }
 public function buildForPreprocessor(Request $request, Route $preprocessorRoute)
 {
     // Localhost case
     if ($preprocessorRoute->getDefault('_http_host') === $request->getHttpHost()) {
         $this->logger->info("InternalForwarder built for preprocessor: Localhost forwarder.", ['host' => $request->getHttpHost()]);
         return $this->container->get('prestashop.public_writer.protocol.internal_forwarder.localhost');
     }
     // Error case: localhost case was not matching, but there is no other forwarder available.
     $this->logger->error("InternalForwarder built for preprocessor: NO forwarder found to reach distant host.", ['host' => $request->getHttpHost()]);
     throw new \ErrorException("InternalForwarder building for preprocessor: NO forwarder found to reach distant host: " . $request->getHttpHost());
 }
 public function serialize(JsonSerializationVisitor $visitor, OwnerData $owner, array $type)
 {
     $scheme = $this->request->getScheme() . '://' . $this->request->getHttpHost();
     $data = $owner->getData();
     if ($owner->getAvatarFileName()) {
         $data['avatar_file_path'] = $this->uh->asset($owner, 'avatar');
     } else {
         $data['avatar_file_path'] = $scheme . $owner->getDefaultAvatar();
     }
     return $data;
 }
Example #5
0
 /**
  * @Route("/lostPassword", name="lost_password_route")
  */
 public function lostPasswordAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $reset = false;
     if ($request->request->get('reset') == "true") {
         $reset = true;
     }
     if ($reset) {
         $user = $em->getRepository('BackendBundle:User')->findOneByEmail($request->request->get('email'));
         if (!is_null($user)) {
             $rb = uniqid(rand(), true);
             $random = md5($user->getEmail() . $rb);
             //guardar en la base de datos
             $restorer = $em->getRepository('BackendBundle:Restorer')->findOneByUser($user);
             if (is_null($restorer)) {
                 $restorer = new Restorer();
             }
             $restorer->setUser($user);
             $restorer->setTime(new \DateTime());
             $restorer->setAuth(md5($random));
             $em->persist($restorer);
             $em->flush();
             $baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
             $url = $baseurl . '/resetPassword?token=' . $random;
             $message = \Swift_Message::newInstance()->setSubject('Recuperación de contraseña')->setFrom('*****@*****.**')->setTo(array($user->getEmail()))->setBody('<html>' . ' <head></head>' . ' <body>' . ' Hola, usa este link para recuperar tu contraseña: ' . '<a href="' . $url . '">' . $url . '</a></br>' . ' Si no pediste recuperar contraseña omite este email. (No responda este email)</body>' . '</html>', 'text/html');
             $this->get('mailer')->send($message);
         }
     }
     return $this->render('security/lostPassword.html.twig', array('reset' => $reset));
 }
Example #6
0
 /**
  * @param Request $request
  * @param string $slug
  * @param boolean $isJournalHosting
  * @return Response
  */
 public function archiveIndexAction(Request $request, $slug, $isJournalHosting = false)
 {
     /**
      * @todo we should check if it is base domain initialized
      */
     $currentHost = $request->getHttpHost();
     /*
     $base_host = $container->getParameter('base_host');
     if($currentHost == $base_host){
         $this->throw404IfNotFound(0);
     }
     */
     $em = $this->getDoctrine()->getManager();
     /** @var BlockRepository $blockRepo */
     $blockRepo = $em->getRepository('OjsJournalBundle:Block');
     /** @var Journal $journal */
     $journal = $em->getRepository('OjsJournalBundle:Journal')->findOneBy(['slug' => $slug]);
     $this->throw404IfNotFound($journal);
     if ($journal->getStatus() !== JournalStatuses::STATUS_PUBLISHED || $journal->getPublisher()->getStatus() !== PublisherStatuses::STATUS_COMPLETE) {
         $journal = null;
         $this->throw404IfNotFound($journal);
     }
     $data['groupedIssues'] = $em->getRepository(Issue::class)->getByYear($journal, true);
     $data['page'] = 'archive';
     $data['blocks'] = $blockRepo->journalBlocks($journal);
     $data['journal'] = $journal;
     $data['isJournalHosting'] = $isJournalHosting;
     $data['displayModes'] = ['all' => IssueDisplayModes::SHOW_ALL, 'title' => IssueDisplayModes::SHOW_TITLE, 'volumeAndNumber' => IssueDisplayModes::SHOW_VOLUME_AND_NUMBER];
     return $this->render('OjsSiteBundle::Journal/archive_index.html.twig', $data);
 }
 /**
  * Action for locale switch
  *
  * @param Request $request
  *
  * @throws \InvalidArgumentException
  * @return RedirectResponse
  */
 public function switchAction(Request $request)
 {
     $_locale = $request->attributes->get('_locale', $request->getLocale());
     $statusCode = $request->attributes->get('statusCode', $this->statusCode);
     $useReferrer = $request->attributes->get('useReferrer', $this->useReferrer);
     $redirectToRoute = $request->attributes->get('route', $this->redirectToRoute);
     $metaValidator = $this->metaValidator;
     if (!$metaValidator->isAllowed($_locale)) {
         throw new \InvalidArgumentException(sprintf('Not allowed to switch to locale %s', $_locale));
     }
     // Redirect the User
     if ($useReferrer && $request->headers->has('referer')) {
         $response = new RedirectResponse($request->headers->get('referer'), $statusCode);
     } elseif ($this->router && $redirectToRoute) {
         $target = $this->router->generate($redirectToRoute, array('_locale' => $_locale));
         if ($request->getQueryString()) {
             if (!strpos($target, '?')) {
                 $target .= '?';
             }
             $target .= $request->getQueryString();
         }
         $response = new RedirectResponse($target, $statusCode);
     } else {
         // TODO: this seems broken, as it will not handle if the site runs in a subdir
         // TODO: also it doesn't handle the locale at all and can therefore lead to an infinite redirect
         $response = new RedirectResponse($request->getScheme() . '://' . $request->getHttpHost() . '/', $statusCode);
     }
     return $response;
 }
Example #8
0
 public function indexAction(Request $request)
 {
     $form = $request->request->all();
     $no_js = $request->query->get('no-js') || 0;
     $script = $no_js == 1 ? 0 : 1;
     $db_dir = $this->get('kernel')->getBundle('EUREKAG6KBundle', true)->getPath() . "/Resources/data/databases";
     try {
         $this->datasources = new \SimpleXMLElement($db_dir . "/DataSources.xml", LIBXML_NOWARNING, true);
         $datasourcesCount = $this->datasources->DataSource->count();
     } catch (\Exception $e) {
         $datasourcesCount = 0;
     }
     $userManager = $this->get('fos_user.user_manager');
     $users = $userManager->findUsers();
     $finder = new Finder();
     $simu_dir = $this->get('kernel')->getBundle('EUREKAG6KBundle', true)->getPath() . "/Resources/data/simulators";
     $finder->depth('== 0')->files()->name('*.xml')->in($simu_dir);
     $simulatorsCount = $finder->count();
     $finder = new Finder();
     $views_dir = $this->get('kernel')->getBundle('EUREKAG6KBundle', true)->getPath() . "/Resources/views";
     $finder->depth('== 0')->ignoreVCS(true)->exclude(array('admin', 'base', 'Theme'))->directories()->in($views_dir);
     $viewsCount = $finder->count();
     $hiddens = array();
     $hiddens['script'] = $script;
     $silex = new Application();
     $silex->register(new MobileDetectServiceProvider());
     try {
         return $this->render('EUREKAG6KBundle:admin/pages:index.html.twig', array('ua' => $silex["mobile_detect"], 'path' => $request->getScheme() . '://' . $request->getHttpHost(), 'nav' => 'home', 'datasourcesCount' => $datasourcesCount, 'usersCount' => count($users), 'simulatorsCount' => $simulatorsCount, 'viewsCount' => $viewsCount, 'hiddens' => $hiddens));
     } catch (\Exception $e) {
         echo $e->getMessage();
         throw $this->createNotFoundException($this->get('translator')->trans("This template does not exist"));
     }
 }
Example #9
0
 public function clearAction(Request $request, $env = 'prod')
 {
     $form = $request->request->all();
     $no_js = $request->query->get('no-js') || 0;
     $script = $no_js == 1 ? 0 : 1;
     if (!$this->get('security.context')->isGranted('ROLE_ADMIN')) {
         throw $this->AccessDeniedException($this->get('translator')->trans("Access Denied!"));
     }
     $cache_dir = dirname($this->get('kernel')->getCacheDir());
     $this->log[] = "<b>" . $this->get('translator')->trans("cache directory : %cachedir%", array('%cachedir%' => $cache_dir)) . "</b>";
     if (is_dir($cache_dir)) {
         if (basename($cache_dir) == "cache") {
             $this->log[] = "<br/><br/><b>" . $this->get('translator')->trans("clearing cache") . " :</b>";
             $this->cc($cache_dir, $env);
             $this->log[] = "<br/><br/><b>" . $this->get('translator')->trans("done !") . "</b>";
         } else {
             $this->log[] = "<br/> " . $this->get('translator')->trans("Error : %cachedir% is not a named cache", array('%cachedir%' => $cache_dir));
         }
     } else {
         $this->log[] = "<br/> " . $this->get('translator')->trans("Error : %cachedir% is not a directory", array('%cachedir%' => $cache_dir));
     }
     $hiddens = array();
     $hiddens['script'] = $script;
     $silex = new Application();
     $silex->register(new MobileDetectServiceProvider());
     try {
         return $this->render('EUREKAG6KBundle:admin/pages:cache-clear.html.twig', array('ua' => $silex["mobile_detect"], 'path' => $request->getScheme() . '://' . $request->getHttpHost(), 'nav' => 'caches', 'log' => $this->log, 'hiddens' => $hiddens));
     } catch (\Exception $e) {
         throw $this->createNotFoundException($this->get('translator')->trans("This template does not exist"));
     }
 }
 /**
  * Return a DIC-IT container, using adapter to respect Pyrite interface.
  *
  * @param Request $request       Current request object.
  * @param string  $containerPath Path to load config from.
  *
  * @return \Pyrite\Container\Container
  */
 public static function build(Request $request, $containerPath)
 {
     $config = new NullConfig();
     if (null !== $containerPath && preg_match('/.*yml$/', $containerPath)) {
         $config = new YML($containerPath);
     }
     if (null !== $containerPath && preg_match('/.*php$/', $containerPath)) {
         $config = new PHP($containerPath);
     }
     $activator = new ActivatorFactory();
     $container = new DICITAdapter($config, $activator);
     $activator->addActivator('security', $container->get('SecurityActivator'), false);
     // initialize the translation engine
     $translationManager = $container->get('TranslationEngine');
     $host = $request->getHttpHost();
     $locale = $container->getParameter('default_locale.' . str_replace('.', '_', $host));
     if ($locale === null) {
         $locale = $container->getParameter('default_locale.default');
     }
     $container->setParameter('current_locale', $locale);
     $translationManager->setLocale($locale);
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function ($class) {
         return class_exists($class);
     });
     $container->bind('AnnotationReader', $reader);
     $director = $container->get('PyRestDirector');
     $packages = $container->getParameter('crud.packages');
     foreach ($packages as $packageName => $packageConfiguration) {
         $director->buildAll($packageName);
     }
     return $container;
 }
Example #11
0
 /**
  * Action for locale switch
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param                                           $_locale The locale to set
  *
  * @return \Symfony\Bundle\FrameworkBundle\Controller\RedirectResponse
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function switchAction(Request $request, $_locale)
 {
     // Check if the Language is allowed
     if (!in_array(\Locale::getPrimaryLanguage($_locale), $this->allowedLanguages)) {
         throw new NotFoundHttpException('This language is not available');
     }
     // tries to detect a Region from the user-provided locales
     $providedLanguages = $request->getLanguages();
     $locales = array();
     foreach ($providedLanguages as $locale) {
         if (strpos($locale . '_', $_locale) !== false && strlen($locale) > 2) {
             $locales[] = $locale;
         }
     }
     if (count($locales) > 0) {
         $this->session->set('localeIdentified', $locales[0]);
     } else {
         $this->session->set('localeIdentified', $_locale);
     }
     // Add the listener
     $this->session->set('setLocaleCookie', true);
     // Redirect the User
     if ($request->headers->has('referer') && true === $this->useReferrer) {
         return new RedirectResponse($request->headers->get('referer'));
     }
     if (null !== $this->redirectToRoute) {
         return new RedirectResponse($this->router->generate($this->redirectToRoute));
     }
     return new RedirectResponse($request->getScheme() . '://' . $request->getHttpHost() . $this->redirectToUrl);
 }
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     $data = ['request-id' => $request->headers->get('X-Request-Id'), 'datetime' => date('Y-m-d H:i:s'), 'method' => $request->getMethod(), 'scheme' => $request->getScheme(), 'host' => $request->getHttpHost(), 'uri' => $request->getRequestUri(), 'route' => $request->get('_route')];
     /*
     if (isset($this['current_user'])) {
         $data['username'] = $this['current_user']->getName();
     }
     */
     $data['address'] = $request->getClientIp();
     if ($request->getSession()) {
         $data['session-id'] = $request->getSession()->getId();
     }
     if ($request->headers->has('User-Agent')) {
         $data['agent'] = $request->headers->get('User-Agent');
     }
     if ($request->headers->has('referer')) {
         $data['referer'] = $request->headers->get('referer');
     }
     $this->log($data);
     $response = $this->app->handle($request, $type, $catch);
     /*
     // response details
     $data['status'] = $response->getStatusCode();
     if ($response->headers->has('Content-Type')) {
         $data['content-type'] = $response->headers->get('content-type');
     }
     */
     return $response;
 }
Example #13
0
 public function indexAction(Request $request)
 {
     $mobile = $this->setting('mobile', array());
     if (empty($mobile['enabled'])) {
         return $this->createMessageResponse('info', '客户端尚未开启!');
     }
     return $this->render('TopxiaWebBundle:Mobile:index.html.twig', array('host' => $request->getHttpHost()));
 }
 /**
  * Save an image and resize it.
  *
  * @param Request $request
  *
  * @return Response
  *
  * @Route("/save", name="prh_image_save")
  * @Method("POST")
  */
 public function saveAction(Request $request)
 {
     $imageService = $this->get('prh.blog.service.image');
     $path = $this->getParameter('kernel.root_dir') . '/../web/uploads/images';
     /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */
     $file = $request->files->get('file');
     $imageService->createResizedImages($path, $file);
     return new Response(sprintf('%s://%s/uploads/images/%s', $request->getScheme(), $request->getHttpHost(), $imageService->appendSizeExt($file->getClientOriginalName(), 'b')));
 }
Example #15
0
 public function indexAction(Request $request)
 {
     $mobile = $this->setting('mobile', array());
     if (empty($mobile['enabled'])) {
         return $this->createMessageResponse('info', '客户端尚未开启!');
     }
     $result = CloudAPIFactory::create('leaf')->get('/me');
     return $this->render('TopxiaWebBundle:Mobile:index.html.twig', array('host' => $request->getHttpHost(), 'mobileCode' => array_key_exists("mobileCode", $result) && !empty($result["mobileCode"]) ? $result["mobileCode"] : "edusoho", 'mobile' => $mobile));
 }
 /**
  * @Route("/res/{t}", name="_res")
  */
 public function resAction(Request $request, $t = 1)
 {
     if (!in_array($t, array(1, 2, 3))) {
         $t = 1;
     }
     $session = $request->getSession();
     $session->set('resType', $t);
     $session->set('wx_share_url', 'http://' . $request->getHttpHost() . $this->generateUrl('_share', array('t' => $t)));
     return $this->render('AppBundle:default:res.html.twig', array('t' => $t, 'wx_share_success_url' => '' . $this->generateUrl('_info'), 'wechat_img_url' => 'images/share' . $t . '.jpg'));
 }
Example #17
0
 /**
  * @param Request $request
  * @param int     $type
  * @param bool    $catch
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     $host = $request->getHttpHost();
     $sites = $this->config->get('default_site_id');
     $site = str_replace('.', '_', $host);
     $sid = isset($sites[$site]) ? $sites[$site] : $sites['default'];
     $this->config->set('side_id', $sid);
     $this->config->set('current_site_id', $sid);
     return $this->app->handle($request, $type, $catch);
 }
Example #18
0
 public function videoFingerprintAction(Request $request)
 {
     $userId = $request->query->get('userId');
     $user = $this->getUserService()->getUser($userId);
     if (empty($user)) {
         return new Response('');
     }
     $host = $request->getHttpHost();
     return new Response("{$host} {$user['nickname']}");
 }
Example #19
0
 /**
  * @param Request $request
  *
  * @throws \Exception
  *
  * @return string
  *
  * resolves the locale from httpHost or host
  */
 public function resolveFromDomain(Request $request)
 {
     $host = $request->getHost();
     $httpHost = $request->getHttpHost();
     if (array_key_exists($host, $this->localeDomainConfig)) {
         return $this->localeDomainConfig[$host];
     } elseif (array_key_exists($httpHost, $this->localeDomainConfig)) {
         return $this->localeDomainConfig[$httpHost];
     }
     return $request->getLocale();
 }
 public function checkDomainsValidity(Request $request)
 {
     $baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
     //var_dump($baseurl);
     switch (true) {
         case $baseurl == 'http://agente3w.com':
             return 'core_dashboard';
             break;
     }
     return NULL;
 }
Example #21
0
 /**
  * Checks if the user should be forced to use SSL connections.
  *
  * @param Request $request Request to check.
  * @return boolean|\Symfony\Component\HttpFoundation\RedirectResponse False
  *   if the redirect is not needed and redirect response object otherwise.
  */
 protected function sslRedirect(Request $request)
 {
     $need_redirect = Settings::get('enablessl') == '1' && Settings::get('forcessl') == '1' && !$request->isSecure();
     if (!$need_redirect) {
         return false;
     }
     if (null !== ($qs = $request->getQueryString())) {
         $qs = '?' . $qs;
     }
     $path = 'https://' . $request->getHttpHost() . $request->getBasePath() . $request->getPathInfo() . $qs;
     return $this->redirect($path);
 }
Example #22
0
 /**
  * @param Request $request
  *
  * @throws \Exception
  *
  * @return string
  *
  * resolves the locale from httpHost or host
  */
 public function resolveFromDomain(Request $request)
 {
     $host = $request->getHost();
     $httpHost = $request->getHttpHost();
     if (array_key_exists($host, $this->localeDomainConfig)) {
         return $this->localeDomainConfig[$host];
     } elseif (array_key_exists($httpHost, $this->localeDomainConfig)) {
         return $this->localeDomainConfig[$httpHost];
     }
     error_log(sprintf('Host "%s" is not defined in your locale_pattern_table in app/config/victoire_core.yml (%s available), using default locale (%s) instead', $httpHost, implode(',', $this->localeDomainConfig), $this->defaultLocale));
     return $request->getLocale();
 }
Example #23
0
 public function start(Request $request, AuthenticationException $authException = null)
 {
     $request->getSession()->start();
     if ($request->query->has('target')) {
         $target = $request->query->get('target');
         $parsed = parse_url($target);
         if (!isset($parsed['host']) || $parsed['host'] !== $request->getHttpHost()) {
             $request->getSession()->setFlash('sensiolabs_connect.oauth.target_path', $target);
         }
     }
     return new RedirectResponse($this->oauthConsumer->getAuthorizationUri($this->httpUtils->generateUri($request, $this->oauthCallback)));
 }
Example #24
0
 protected function appendRealmToName(Request $request)
 {
     if (!$this->options->getBoolean('restrict_realm')) {
         return;
     }
     $name = $this->session->getName();
     $realm = '_' . md5($request->getHttpHost() . $request->getBaseUrl());
     if (substr($name, -strlen($realm)) === $realm) {
         // name ends with realm
         return;
     }
     $this->session->setName($name . $realm);
 }
Example #25
0
 /**
  * @param Request $request
  *
  * @throws \Exception
  * @return string
  *
  * resolves the locale from httpHost or host
  */
 public function resolveFromDomain(Request $request)
 {
     $host = $request->getHost();
     $httpHost = $request->getHttpHost();
     if (array_key_exists($host, $this->localeDomainConfig)) {
         return $this->localeDomainConfig[$host];
     } else {
         if (array_key_exists($httpHost, $this->localeDomainConfig)) {
             return $this->localeDomainConfig[$httpHost];
         }
     }
     throw new \Exception(sprintf('Host "%s" is not defined in your locale_pattern_table in app/config/victoire_core.yml', $httpHost));
 }
 /**
  * Returns resource locator and format of current request.
  *
  * @param PortalInformation $portalInformation
  * @param Request $request
  *
  * @return array
  */
 private function getResourceLocatorFromRequest(PortalInformation $portalInformation, Request $request)
 {
     $path = $request->getPathInfo();
     // extract file and extension info
     $pathParts = explode('/', $path);
     $fileInfo = explode('.', array_pop($pathParts));
     $path = rtrim(implode('/', $pathParts), '/') . '/' . $fileInfo[0];
     $formatResult = null;
     if (count($fileInfo) > 1) {
         $formatResult = end($fileInfo);
     }
     $resourceLocator = substr($request->getHttpHost() . $path, strlen($portalInformation->getUrl()));
     return [$resourceLocator, $formatResult];
 }
Example #27
0
 public function doInstall(Request $request)
 {
     set_time_limit(360);
     $servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
     $dbConn = null;
     $database_host = $request->request->get('hostname');
     $database_port = $request->request->get('port');
     $database_user = $request->request->get('user');
     $database_password = $request->request->get('db_password');
     $appbox_name = $request->request->get('ab_name');
     $databox_name = $request->request->get('db_name');
     try {
         $abInfo = ['host' => $database_host, 'port' => $database_port, 'user' => $database_user, 'password' => $database_password, 'dbname' => $appbox_name];
         /** @var Connection $abConn */
         $abConn = $this->app['dbal.provider']($abInfo);
         $abConn->connect();
     } catch (\Exception $e) {
         return $this->app->redirectPath('install_step2', ['error' => $this->app->trans('Appbox is unreachable')]);
     }
     try {
         if ($databox_name) {
             $dbInfo = ['host' => $database_host, 'port' => $database_port, 'user' => $database_user, 'password' => $database_password, 'dbname' => $databox_name];
             /** @var Connection $dbConn */
             $dbConn = $this->app['dbal.provider']($dbInfo);
             $dbConn->connect();
         }
     } catch (\Exception $e) {
         return $this->app->redirectPath('install_step2', ['error' => $this->app->trans('Databox is unreachable')]);
     }
     $this->app['dbs.options'] = array_merge($this->app['db.options.from_info']($dbInfo), $this->app['db.options.from_info']($abInfo), $this->app['dbs.options']);
     $this->app['orm.ems.options'] = array_merge($this->app['orm.em.options.from_info']($dbInfo), $this->app['orm.em.options.from_info']($abInfo), $this->app['orm.ems.options']);
     $email = $request->request->get('email');
     $password = $request->request->get('password');
     $template = $request->request->get('db_template');
     $dataPath = $request->request->get('datapath_noweb');
     try {
         $installer = $this->app['phraseanet.installer'];
         $binaryData = [];
         foreach (['php_binary' => $request->request->get('binary_php'), 'swf_extract_binary' => $request->request->get('binary_swfextract'), 'pdf2swf_binary' => $request->request->get('binary_pdf2swf'), 'swf_render_binary' => $request->request->get('binary_swfrender'), 'unoconv_binary' => $request->request->get('binary_unoconv'), 'ffmpeg_binary' => $request->request->get('binary_ffmpeg'), 'mp4box_binary' => $request->request->get('binary_MP4Box'), 'pdftotext_binary' => $request->request->get('binary_xpdf')] as $key => $path) {
             $binaryData[$key] = $path;
         }
         $user = $installer->install($email, $password, $abConn, $servername, $dataPath, $dbConn, $template, $binaryData);
         $this->app->getAuthenticator()->openAccount($user);
         return $this->app->redirectPath('admin', ['section' => 'taskmanager', 'notice' => 'install_success']);
     } catch (\Exception $e) {
         return $this->app->redirectPath('install_step2', ['error' => $this->app->trans('an error occured : %message%', ['%message%' => $e->getMessage()])]);
     }
 }
Example #28
0
 /**
  * @param Request $request
  * @param int     $type
  * @param bool    $catch
  *
  * @return Response
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     $host = $request->getHttpHost();
     $requestedLocal = str_replace('.', '_', $host);
     $requestedLanguageId = str_replace('.', '_', $host);
     $locales = $this->config->get('default_locale');
     $languageIds = $this->config->get('languages');
     $locale = isset($locales[$requestedLocal]) ? $locales[$requestedLocal] : ($defaultLocale = $locales['default']);
     $languageId = isset($languageIds[$requestedLanguageId]) ? $languageIds[$requestedLanguageId] : ($defaultLanguage = $languageIds['default']);
     $this->config->set('current_locale', $locale);
     $this->config->set('language_id', $languageId);
     $this->config->set('default_language_id', $languageIds['default']);
     $this->config->set('default_locale', $locales['default']);
     $this->config->set('available_locales', $locales['all']);
     return $this->app->handle($request, $type, $catch);
 }
 public function videoFingerprintAction(Request $request)
 {
     $userId = $request->query->get('userId');
     $user = $this->getUserService()->getUser($userId);
     if (empty($user)) {
         return new Response('');
     }
     // @todo 如果配置用户的关键信息,这个方法存在信息泄漏风险,更换新播放器后解决这个问题。
     $pattern = $this->setting('magic.video_fingerprint');
     if ($pattern) {
         $fingerprint = $this->parsePattern($pattern, $user);
     } else {
         $host = $request->getHttpHost();
         $fingerprint = "{$host} {$user['nickname']}";
     }
     return new Response($fingerprint);
 }
Example #30
-1
 /**
  *
  * @param Request $request
  * @throws AppException
  * @return ApplicationUri
  */
 public function match($request)
 {
     $found = null;
     $uris = ApplicationUriQuery::create()->joinApplication()->filterByHttphost($request->getHttpHost())->find();
     $requestUri = Text::create($request->getRequestUri())->trimRight('/');
     foreach ($uris as $uri) {
         $basepath = new Text($uri->getBasepath());
         // either request uri and uri basepath are both empty
         // or request uri starts with basepath
         if ($basepath->isEmpty() && $uri->getHttphost() == $request->getHttpHost() || $requestUri->startsWith($basepath)) {
             // assign when it's the first found
             if ($found === null) {
                 $found = $uri;
             } else {
                 if ($basepath->count('/') > Text::create($found->getBasepath())->count('/')) {
                     $found = $uri;
                 }
             }
         }
     }
     if ($found === null) {
         throw new AppException(sprintf('No app found on %s', $request->getUri()), 404);
     }
     $this->destination = str_replace($found->getBasepath(), '', $request->getRequestUri());
     return $found;
 }