Suppose that an index.php file instantiates this request object:
* http://localhost/index.php returns an empty string
* http://localhost/index.php/page returns an empty string
* http://localhost/web/index.php returns '/web'
* http://localhost/we%20b/index.php returns '/we%20b'
public getBasePath ( ) : string | ||
리턴 | string | The raw path (i.e. not urldecoded) |
public function thumbAction(Request $request, Application $app) { $source = $request->get('src', false); $width = $request->get('width', 250); // Do requested thumbnail in correct format already exists ? if ($app['flysystems']['thumbs']->has($width . "/" . $source)) { return $app->redirect($request->getBasePath() . '/thumbs/' . $width . '/' . $source, 301); } // Do requested file exists ? if (!$source || !$app['flysystems']['local']->has($source)) { return new Response("Source file not found.", 404); } try { $contents = $app['flysystems']['local']->read($source); $imageManager = new ImageManager(); $image = $imageManager->make($contents); $image->resize($width, null, function ($constraint) { $constraint->aspectRatio(); }); $info = $app['flysystems']['local']->getWithMetadata($source, ['mimetype']); $image->encode($info['mimetype']); $app['flysystems']['thumbs']->put($width . "/" . $source, $image); return $app->redirect($request->getBasePath() . '/thumbs/' . $width . '/' . $source, 301); } catch (\Exception $e) { return new Response("Erreur !", 500); } // Should not happen, everything failed. Display not found image :( return $app->redirect($request->getBasePath() . '/assets/img/' . $width . '_not-found.png', 302); }
/** * Handles an access denied failure redirecting to home page * * @param Request $request * @param AccessDeniedException $accessDeniedException * * @return Response may return null */ public function handle(Request $request, AccessDeniedException $accessDeniedException) { $this->logger->error('User tried to access: ' . $request->getUri()); if ($request->isXmlHttpRequest()) { return new JsonResponse(['message' => $accessDeniedException->getMessage(), 'trace' => $accessDeniedException->getTraceAsString(), 'exception' => get_class($accessDeniedException)], Response::HTTP_SERVICE_UNAVAILABLE); } else { $url = $request->getBasePath() !== "" ? $request->getBasePath() : "/"; $response = new RedirectResponse($url); $response->setStatusCode(Response::HTTP_FORBIDDEN); $response->prepare($request); return $response->send(); } }
/** * @param ConfigureMenuEvent $event */ public function onNavigationConfigure(ConfigureMenuEvent $event) { if (!$this->entryPoint || !$this->securityContext->getToken() || !$this->securityContext->isGranted('ROLE_ADMINISTRATOR')) { return; } $uri = '/' . $this->entryPoint; if ($this->request) { $uri = $this->request->getBasePath() . $uri; } /** @var ItemInterface $systemTabMenuItem */ $systemTabMenuItem = $event->getMenu()->getChild('system_tab'); if ($systemTabMenuItem) { $systemTabMenuItem->addChild('package_manager', ['label' => 'oro.distribution.package_manager.label', 'uri' => $uri, 'linkAttributes' => ['class' => 'no-hash'], 'extras' => ['position' => '110']]); } }
public function sendFileAction(Request $request, Application $app) { $file = $request->query->get('file', ''); $locale = $request->getLocale(); $base_path = $request->getBasePath(); $base_path = $base_path . 'download/' . $locale; $file_path = $base_path . '/' . $file; $finder = new Finder(); $finder->files()->in($base_path)->name('*' . $file . '*'); $file = null; foreach ($finder as $archivo) { /** @var SplFileInfo $file */ $file = $archivo; break; } if (null === $file) { return $app->redirect('/'); } $log = $app['monolog']; $nombre = $file->getBasename('.' . $file->getExtension()); $nombre = $app['translator']->trans(sprintf("%s.%s", 'archivo', $nombre)); $nombre = $nombre . '.' . $file->getExtension(); $log->addInfo($nombre); $log->addInfo(sprintf('Se ha solicitado el archivo: %s', $file_path)); return $app->sendFile($file)->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $nombre); }
/** * @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)); }
/** * Returns the base path. * * @return string|null The base path */ private function getPath() { if (null === $this->request) { return null; } return $this->request->getBasePath(); }
public function logoutAction(Request $request) { if ($this->getAuth()->hasAuthenticatedUser()) { $this->getAuth()->deauthenticate(); } return new RedirectResponse($request->getBasePath() . '/account/login'); }
/** * Generates JavaScript code that starts client side application. * * @param Request $request Incoming request. * @param array $operator Current operator. * @return string JavaScript code that starts "users" client side * application. */ protected function startJsApplication(Request $request, $operator) { // Load dialogs style options $chat_style = new ChatStyle(ChatStyle::getCurrentStyle()); $chat_style_config = $style_config = $chat_style->getConfigurations(); // Load page style options $page_style_config = $style_config = $this->getStyle()->getConfigurations(); return sprintf('jQuery(document).ready(function() {Mibew.Application.start(%s);});', json_encode(array('server' => array('url' => $this->generateUrl('users_update'), 'requestsFrequency' => Settings::get('updatefrequency_operator')), 'agent' => array('id' => $operator['operatorid']), 'page' => array('mibewBasePath' => $request->getBasePath(), 'mibewBaseUrl' => $request->getBaseUrl(), 'showOnlineOperators' => Settings::get('showonlineoperators') == '1', 'showVisitors' => Settings::get('enabletracking') == '1', 'showPopup' => Settings::get('enablepopupnotification') == '1', 'threadTag' => $page_style_config['users']['thread_tag'], 'visitorTag' => $page_style_config['users']['visitor_tag'], 'agentLink' => $request->getBaseUrl() . '/operator/chat', 'geoLink' => Settings::get('geolink'), 'trackedLink' => $request->getBaseUrl() . '/operator/history/user-track', 'banLink' => $request->getBaseUrl() . '/operator/ban', 'inviteLink' => $request->getBaseUrl() . '/operator/invite', 'chatWindowParams' => $chat_style_config['chat']['window'], 'geoWindowParams' => Settings::get('geolinkparams'), 'trackedUserWindowParams' => $page_style_config['tracked']['user_window'], 'trackedVisitorWindowParams' => $page_style_config['tracked']['visitor_window'], 'banWindowParams' => $page_style_config['ban']['window'], 'inviteWindowParams' => $chat_style_config['chat']['window'])))); }
/** * This action applies a given filter to a given image, saves the image and * outputs it to the browser at the same time * * @param string $path * @param string $filter * * @return Response */ public function filter($path, $filter) { $path = '/' . ltrim($path, '/'); //TODO: find out why I need double urldecode to get a valid path $browserPath = urldecode(urldecode($this->cachePathResolver->getBrowserPath($path, $filter))); $basePath = $this->request->getBaseUrl(); if (!empty($basePath) && 0 === strpos($browserPath, $basePath)) { $browserPath = substr($browserPath, strlen($basePath)); } // if cache path cannot be determined, return 404 if (null === $browserPath) { throw new NotFoundHttpException('Image doesn\'t exist'); } $realPath = $this->webRoot . $browserPath; $sourcePath = $this->sourceRoot . $path; // if the file has already been cached, we're probably not rewriting // correctly, hence make a 301 to proper location, so browser remembers if (file_exists($realPath)) { return new Response('', 301, array('location' => $this->request->getBasePath() . $browserPath)); } if (!file_exists($sourcePath)) { throw new NotFoundHttpException(sprintf('Source image not found in "%s"', $sourcePath)); } $dir = pathinfo($realPath, PATHINFO_DIRNAME); if (!is_dir($dir)) { if (false === $this->filesystem->mkdir($dir)) { throw new \RuntimeException(sprintf('Could not create directory %s', $dir)); } } ob_start(); try { $format = $this->filterManager->getOption($filter, "format", "png"); // TODO: get rid of hard-coded quality and format $this->filterManager->get($filter)->apply($this->imagine->open($sourcePath))->save($realPath, array('quality' => $this->filterManager->getOption($filter, "quality", 100), 'format' => $this->filterManager->getOption($filter, "format", null)))->show($format); $type = 'image/' . $format; $length = ob_get_length(); $content = ob_get_clean(); // TODO: add more media headers return new Response($content, 201, array('content-type' => $type, 'content-length' => $length)); } catch (\Exception $e) { ob_end_clean(); throw $e; } }
/** * (non-PHPdoc) * * @see RenderInterface::render() */ public function render(Request $request, Response $response, ResponseContent $content) { $path = (string) Configuration::getInstance()->templates->path; $template = $request->getBasePath(); if (!$template) { $template = "index"; } $response->setContent($this->getIncludeContents("{$path}/{$template}.phtml", $content)); return $response; }
/** * @param Request $request * * @return \Symfony\Component\HttpFoundation\Response */ public function indexAction(Request $request) { if (null === $this->slider_id) { return new Response(); } /** @var \Doctrine\ORM\EntityManager $em */ $em = $this->get('doctrine.orm.entity_manager'); $slider = $em->find('SliderModule:Slider', $this->slider_id); $this->node->addFrontControl('manage_slider')->setTitle('Управление слайдами')->setUri($this->generateUrl('smart_module.slider.admin_slider', ['id' => $this->slider_id])); return $this->get('twig')->render('SliderModule::' . $slider->getLibrary() . '.html.twig', ['slider' => $slider, 'imgPath' => $request->getBasePath() . '/' . $this->get('smart_module.slider')->getWebPath()]); }
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; }
/** * Sets all needed values from the request. * * @param Request $request A request to get values from. */ public function setRequest(Request $request) { $this->setScheme($request->getScheme()); $this->setHost($request->getHost()); $this->setBasePath($request->getBasePath()); if ($request->isSecure()) { $this->setHttpsPort($request->getPort()); } else { $this->setHttpPort($request->getPort()); } }
protected function appendRealmToName(Request $request) { if (!$this->options->getBoolean('restrict_realm')) { return; } $name = $this->session->getName(); $realm = '_' . md5($request->getHttpHost() . $request->getBasePath()); if (substr($name, -strlen($realm)) === $realm) { // name ends with realm return; } $this->session->setName($name . $realm); }
/** * (non-PHPdoc) * * @see RenderInterface::render() */ public function render(Request $request, Response $response, ResponseContent $content) { $renderer = new XMLRenderer(); $xml = $renderer->to_domdocument($content); $xsl = new DOMDocument(); $path = Configuration::getInstance()->templates; $template = $request->getBasePath(); $xsl->load("{$path}/{$template}.xsl"); $proc = new XSLTProcessor(); $proc->importStyleSheet($xsl); $response->setContent($proc->transformToXML($xml)); return $response; }
/** * Constructor. * * @param Request $request The base path to be prepended to relative paths * @param string $rootDir The asset root directory * @param string $summaryFile Grunt filerev summary file * @param string $cacheDir Kernel cache dir * @param string $debug Debug? */ public function __construct(Request $request, $rootDir, $summaryFile, $cacheDir, $debug) { parent::__construct($rootDir, $summaryFile, $cacheDir, $debug); $basePath = $request->getBasePath(); if (!$basePath) { $this->basePath = '/'; } else { if ('/' != $basePath[0]) { $basePath = '/' . $basePath; } $this->basePath = rtrim($basePath, '/') . '/'; } }
/** * A controller for processing the upload images form. * Validations: a jpg or png, under 1M and file must not already exist. * The image path will be stored in the db. * * @param request object * @param app object * * @return twig template */ public function processImageUploadAction(Request $request, Application $app) { $file = $request->files->get('image'); $pic = $file->getClientOriginalName(); $constraint = new Assert\Image(array('mimeTypes' => array('image/jpeg', 'image/png'), 'maxSize' => '2M')); $validfile = true; $message = ''; $errors = $app['validator']->validate($file, $constraint); if (count($errors) > 0) { foreach ($errors as $error) { $message = $error->getPropertyPath() . ' ' . $error->getMessage() . "\n"; } $validfile = false; } if (file_exists($request->getBasePath() . 'images/' . $file->getClientOriginalName())) { $message = 'Sorry, file already exists'; $validfile = false; } # if the validation variable is false, re-render the upload form with an error message if ($validfile == false) { $args_array = array('user' => $app['session']->get('user'), 'result' => $message); $templateName = '_uploadImageForm'; return $app['twig']->render($templateName . '.html.twig', $args_array); } elseif ($validfile == true) { $file->move($request->getBasePath() . 'images/', $file->getClientOriginalName()); $path = $file->getClientOriginalName(); $newImage = new Image(); $newImage->setImagePath($path); $image = $newImage->getImagePath(); $db = new DbRepository($app['dbh']); $result = $db->uploadImage($image); $images = $db->viewImages(); $content = $db->getAllPagesContent(); $args_array = array('user' => $app['session']->get('user'), 'result' => $result, 'images' => $images, 'content' => $content); $templateName = '_viewImages'; return $app['twig']->render($templateName . '.html.twig', $args_array); } }
/** * Generates the robots.txt content when available in the database and falls back to normal robots.txt if exists * * @Route(path="/robots.txt", name="KunstmaanSeoBundle_robots", defaults={"_format": "txt"}) * @Template(template="@KunstmaanSeo/Admin/Robots/index.html.twig") * @param Request $request * * @return array */ public function indexAction(Request $request) { $entity = $this->get('doctrine')->getRepository('KunstmaanSeoBundle:Robots')->findOneBy(array()); $robots = $this->container->getParameter('robots_default'); if ($entity && $entity->getRobotsTxt()) { $robots = $entity->getRobotsTxt(); } else { $file = $request->getBasePath() . "robots.txt"; if (file_exists($file)) { $robots = file_get_contents($file); } } return array('robots' => $robots); }
/** * Method to handle API docs generation via Swagger. * * @todo Add swagger scan options * * @param Application $app * @param Request $request * * @return Response */ public function __invoke(Application $app, Request $request) { // Get swagger options $swaggerOptions = $app['vars']->get('swagger'); // Scan for Swagger documentation $swagger = \Swagger\scan($swaggerOptions['servicePath'], []); // Set some env specified parameters $swagger->host = $request->getHttpHost(); $swagger->basePath = $request->getBasePath(); // Convert to JSON $json = (string) $swagger; // Create response $response = Response::create($json, 200, ['Content-Type' => 'application/json']); $response->setEtag(md5($json)); $response->isNotModified($request); return $response; }
/** * {@inheritDoc} */ public function resolve(Request $request, $path, $filter) { $browserPath = $this->decodeBrowserPath($this->getBrowserPath($path, $filter)); $this->basePath = $request->getBaseUrl(); $targetPath = $this->getFilePath($path, $filter); // if the file has already been cached, we're probably not rewriting // correctly, hence make a 301 to proper location, so browser remembers if (file_exists($targetPath)) { // Strip the base URL of this request from the browserpath to not interfere with the base path. $baseUrl = $request->getBaseUrl(); if ($baseUrl && 0 === strpos($browserPath, $baseUrl)) { $browserPath = substr($browserPath, strlen($baseUrl)); } return new RedirectResponse($request->getBasePath() . $browserPath); } return $targetPath; }
private function sendEmailToAdmin(Request $request, $admin) { $url = $request->getSchemeAndHttpHost() . $request->getBasePath(); $body = <<<EOF <html> <head></head> <body> <h1>Hi {$admin['uname']}!</h1> <p>Zikula has been successfully installed at <a href="{$url}">{$url}</a>. If you have further questions, visit <a href="http://zikula.org">zikula.org</a></p> </body> EOF; $message = \Swift_Message::newInstance()->setSubject(__('Zikula installation completed!'))->setFrom(\System::getVar('adminmail'))->setTo($admin['email'])->setBody($body)->setContentType('text/html'); /** * @var Swift_Mailer $mailer */ $mailer = $this->container->get('mailer'); return $mailer->send($message); }
public function clientAction(Request $request) { $uri = substr($this->generateUrl('moocsy_apis_xml_server'), 12) . '?wsdl'; $baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath() . $uri; /** * API XML */ //$client = new \SoapClient($baseurl); $token = "5FZ2Z8QIkA7UTZ4BYkoC=="; $username = "******"; $email = "*****@*****.**"; $sku = "EABR-K14"; //$registrar = $client->registrar($token, $username, $email, $sku); /** * Service */ $api = $this->get('moocsy.api_xml'); $registrar = $api->registrar($token, $username, $email, $sku); return new Response($registrar); }
/** * Formats the data and return serialized string * * @return Response */ private function format() { $request_uri = sprintf('%s %s', $this->request->getMethod(), $this->request->getBasePath() . $this->request->getPathInfo()); $ret = ['meta' => ['api_version' => V1::VERSION, 'request' => $request_uri, 'response_time' => $this->responseTime, 'http_code' => $this->code, 'error_type' => $this->errorType, 'error_message' => $this->errorMessage, 'error_details' => $this->errorDetails, 'charset' => 'UTF-8'], 'response' => $this->data]; switch ($this->responseType) { case self::FORMAT_JSON: default: return new JsonResponse($ret); case self::FORMAT_YAML: if ($ret['response'] instanceof \stdClass) { $ret['response'] = []; } $dumper = new Dumper(); return new Response($dumper->dump($ret, 8)); case self::FORMAT_JSONP: $response = new JsonResponse($ret); $response->setCallback(trim($this->request->get('callback'))); return $response; break; } }
public function checkShorturlAction(Application $app, Request $request) { $enabledExtentions = $app['extensions']->getEnabled(); $config = $enabledExtentions['Shorturl']->config; $shorturl = $request->query->get('shorturl'); $recordId = $request->query->get('recordId'); $response = new \stdClass(); $response->status = 'ok'; if ($config['host'] == "*") { $host = $app['paths']['hosturl'] . $request->getBasePath(); } else { $host = "http://" . $config['host']; } $url = $host . '/' . ($config['prefix'] ? $config['prefix'] . '/' : '') . $shorturl; $response->msg = 'This record will be accessible via <a href="' . $url . '" target="_blank">' . $url . '</a>.'; // Check length & chars if (!preg_match('/[a-zA-Z0-9\\-_.]{2,' . $config['maxlength'] . '}$/', $shorturl)) { $response->status = 'error'; $response->msg = 'Shorturl must at least have two characters and can only contain a-z, A-Z, 0-9, ".", "-" and "_".'; } // check if unique $contentTypes = $app['config']->get('contenttypes'); foreach ($contentTypes as $name => $contentType) { foreach ($contentType['fields'] as $key => $field) { if ($field['type'] === 'shorturl') { $contentTypeContent = $app['storage']->getContent($name, array()); foreach ($contentTypeContent as $content) { if ($content['id'] !== $recordId && !empty($content[$key]) && $content[$key] == $shorturl) { $response->status = 'error'; $response->msg = 'Shorturl already exists.'; break; } } } } } return $app->json($response); }
/** * Receive uploaded images from Mercury and return url as JSON */ public function imagesAction(Request $request) { if (!$this->can_edit()) { throw new \Exception('Permission denied'); } if (!$request->isXmlHttpRequest()) { // Ajax Call? throw new \Exception('This URL should only be called using AJAX'); } // param name is "image[image]" $uploadedFile = $request->files->get("image"); $uploadedFile = $uploadedFile['image']; $path = $this->get('kernel')->getRootDir() . "/../web/uploads/"; // TODO use config for upload dir $name = $this->getUniqueFilename($path, $uploadedFile->getClientOriginalName()); $file = $uploadedFile->move($path, $name); // Return {"image": {"url": "__url__"}} $image['image']['url'] = $request->getBasePath() . "/uploads/" . $name; // TODO use config for upload dir $response = new Response(json_encode($image)); $response->headers->set('Content-Type', 'application/json'); return $response; }
public function testGetBasePath() { $request = new Request(); $this->assertEquals('', $request->getBasePath()); $server = array(); $server['SCRIPT_FILENAME'] = '/some/where/index.php'; $request->initialize(array(), array(), array(), array(), array(), $server); $this->assertEquals('', $request->getBasePath()); $server = array(); $server['SCRIPT_FILENAME'] = '/some/where/index.php'; $server['SCRIPT_NAME'] = '/index.php'; $request->initialize(array(), array(), array(), array(), array(), $server); $this->assertEquals('', $request->getBasePath()); $server = array(); $server['SCRIPT_FILENAME'] = '/some/where/index.php'; $server['PHP_SELF'] = '/index.php'; $request->initialize(array(), array(), array(), array(), array(), $server); $this->assertEquals('', $request->getBasePath()); $server = array(); $server['SCRIPT_FILENAME'] = '/some/where/index.php'; $server['ORIG_SCRIPT_NAME'] = '/index.php'; $request->initialize(array(), array(), array(), array(), array(), $server); $this->assertEquals('', $request->getBasePath()); }
/** * APIリクエスト処理 * * @param Request $request * @param $authKey * @param $url * @return array */ private function getRequestApi(Request $request, $authKey, $url) { $opts = array('http' => array('method' => 'GET', 'ignore_errors' => false, 'timeout' => 60, 'header' => array('Authorization: ' . base64_encode($authKey), 'x-eccube-store-url: ' . base64_encode($request->getSchemeAndHttpHost() . $request->getBasePath()), 'x-eccube-store-version: ' . base64_encode(Constant::VERSION)))); $context = stream_context_create($opts); $json = @file_get_contents($url, false, $context); return array($json, $http_response_header); }
/** * Constructor. * * @param Request $request A Request instance * @param string|array $baseURLs The domain URL or an array of domain URLs * @param string $version The version * @param array $packages Asset packages indexed by name */ public function __construct(Request $request, $baseURLs = array(), $version = null, $packages = array()) { parent::__construct($request->getBasePath(), $baseURLs, $version, $packages); }
/** * @param Request $request * * @return \Symfony\Component\HttpFoundation\JsonResponse */ protected function generatePlaintTextAction(Request $request) { $dataArray = array(); $mode = $request->request->get('mode'); $custom = $request->request->get('custom'); $id = $request->request->get('id'); $parser = new PlainTextHelper(array('base_url' => $request->getSchemeAndHttpHost() . $request->getBasePath())); if ($mode == 'custom') { // Convert placeholders into raw tokens BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($custom); $dataArray['text'] = $parser->setHtml($custom)->getText(); } else { $session = $this->factory->getSession(); $contentName = 'mautic.emailbuilder.' . $id . '.content'; $content = $session->get($contentName, array()); if (strpos($id, 'new') === false) { $entity = $this->factory->getModel('email')->getEntity($id); $existingContent = $entity->getContent(); $content = array_merge($existingContent, $content); } // Convert placeholders into raw tokens BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($content); $content = implode("<br /><br />", $content); $dataArray['text'] = $parser->setHtml($content)->getText(); } return $this->sendJsonResponse($dataArray); }
/** * Returns the session cookie name without the secure/insecure prefix. * * @param \Symfony\Component\HttpFoundation\Request $request * The request. * * @returns string * The session name without the prefix (SESS/SSESS). */ protected function getUnprefixedName(Request $request) { if ($test_prefix = $this->drupalValidTestUa()) { $session_name = $test_prefix; } elseif (isset($this->options['cookie_domain'])) { // If the user specifies the cookie domain, also use it for session name. $session_name = $this->options['cookie_domain']; } else { // Otherwise use $base_url as session name, without the protocol // to use the same session identifiers across HTTP and HTTPS. $session_name = $request->getHost() . $request->getBasePath(); // Replace "core" out of session_name so core scripts redirect properly, // specifically install.php. $session_name = preg_replace('#/core$#', '', $session_name); } return substr(hash('sha256', $session_name), 0, 32); }