/** * @inheritdoc */ public function process(array $params, \Smarty_Internal_Template $smarty) { if (isset($params['module'], $params['file']) === true && (bool) preg_match('=/=', $params['module']) === false && (bool) preg_match('=\\./=', $params['file']) === false) { // Do not include the same file multiple times $key = $params['module'] . '/' . $params['file']; if (isset($this->alreadyIncluded[$key]) === false) { if (!empty($params['depends'])) { $this->assets->enableLibraries(explode(',', $params['depends'])); } $this->alreadyIncluded[$key] = true; $script = '<script type="text/javascript" src="%s"></script>'; $module = ucfirst($params['module']); $file = $params['file']; $path = $this->fileResolver->getStaticAssetPath($module . '/Resources/', $module . '/', 'Assets/js', $file . '.js'); if (strpos($path, '/ACP3/Modules/') !== false) { $path = $this->appPath->getWebRoot() . substr($path, strpos($path, '/ACP3/Modules/') + 1); } else { $path = $this->appPath->getWebRoot() . substr($path, strlen(ACP3_ROOT_DIR)); } return sprintf($script, $path); } return ''; } throw new \Exception('Not all necessary arguments for the function ' . __FUNCTION__ . ' were passed!'); }
/** * @param string $text * * @return string */ public function rewriteInternalUri($text) { $rootDir = str_replace('/', '\\/', $this->appPath->getWebRoot()); $host = $this->request->getServer()->get('HTTP_HOST'); $pattern = '/<a([^>]+)href="(http(s?):\\/\\/' . $host . ')?(' . $rootDir . ')?(index\\.php)?(\\/?)((?i:[a-z\\d_\\-]+\\/){2,})"/i'; return preg_replace_callback($pattern, [$this, "rewriteInternalUriCallback"], $text); }
/** * Caches the emoticons * * @return boolean */ public function saveCache() { $emoticons = $this->emoticonRepository->getAll(); $cEmoticons = count($emoticons); $data = []; for ($i = 0; $i < $cEmoticons; ++$i) { $picInfos = getimagesize($this->appPath->getUploadsDir() . 'emoticons/' . $emoticons[$i]['img']); $code = $emoticons[$i]['code']; $description = $emoticons[$i]['description']; $data[$code] = '<img src="' . $this->appPath->getWebRoot() . 'uploads/emoticons/' . $emoticons[$i]['img'] . '" width="' . $picInfos[0] . '" height="' . $picInfos[1] . '" alt="' . $description . '" title="' . $description . '" />'; } return $this->cache->save(static::CACHE_ID, $data); }
/** * Setzt den internen Authentifizierungscookie * * @param int $userId * @param string $token * @param integer|null $expiry * * @return Cookie */ public function setRememberMeCookie($userId, $token, $expiry = null) { if ($expiry === null) { $expiry = static::REMEMBER_ME_COOKIE_LIFETIME; } return new Cookie(self::AUTH_NAME, $userId . '|' . $token, (new \DateTime())->modify('+' . $expiry . ' seconds'), $this->appPath->getWebRoot(), $this->getCookieDomain(), $this->request->getSymfonyRequest()->isSecure()); }
/** * @return $this * @throws Core\ACL\Exception\AccessForbiddenException */ public function preDispatch() { $path = $this->request->getArea() . '/' . $this->request->getFullPathWithoutArea(); if ($this->acl->hasPermission($path) === false) { throw new Core\ACL\Exception\AccessForbiddenException(); } $this->view->assign(['PHP_SELF' => $this->appPath->getPhpSelf(), 'ROOT_DIR' => $this->appPath->getWebRoot(), 'HOST_NAME' => $this->request->getHttpHost(), 'ROOT_DIR_ABSOLUTE' => $this->request->getScheme() . '://' . $this->request->getHttpHost() . $this->appPath->getWebRoot(), 'DESIGN_PATH' => $this->appPath->getDesignPathWeb(), 'DESIGN_PATH_ABSOLUTE' => $this->appPath->getDesignPathAbsolute(), 'LANG_DIRECTION' => $this->translator->getDirection(), 'LANG' => $this->translator->getShortIsoCode()]); return $this; }
/** * @param string $path * @param bool $isAbsolute * @param bool $forceSecure * * @return string */ protected function addUriPrefix($path, $isAbsolute, $forceSecure) { $prefix = ''; if ($isAbsolute === true || $forceSecure === true) { $prefix .= $forceSecure === true ? 'https://' : $this->request->getScheme() . '://'; $prefix .= $this->request->getHost(); } $prefix .= $this->useModRewrite($path) ? $this->appPath->getWebRoot() : $this->appPath->getPhpSelf() . '/'; return $prefix; }
/** * @inheritdoc */ public function destroy($sessionId) { $this->secureSession(); if ($this->request->getCookies()->has(self::SESSION_NAME)) { $cookie = new Cookie(self::SESSION_NAME, '', (new \DateTime())->modify('-3600 seconds'), $this->appPath->getWebRoot(), null, $this->request->getSymfonyRequest()->isSecure()); $this->response->headers->setCookie($cookie); } // Delete the session from the database $this->db->getConnection()->delete($this->db->getPrefix() . 'sessions', ['session_id' => $sessionId]); return true; }
private function applyEmoticons() { $this->config['smiley_path'] = $this->appPath->getWebRoot() . 'uploads/emoticons/'; $this->config['smiley_images'] = $this->config['smiley_descriptions'] = ''; $emoticons = $this->emoticonRepository->getAll(); $cEmoticons = count($emoticons); $images = $descriptions = []; for ($i = 0; $i < $cEmoticons; ++$i) { $images[] = $emoticons[$i]['img']; $descriptions[] = $emoticons[$i]['description']; } $this->config['smiley_images'] = $images; $this->config['smiley_descriptions'] = $descriptions; }
/** * @inheritdoc */ public function getURI($layout = 'layout') { $debug = $this->environment === 'dev'; $filenameHash = $this->generateFilenameHash($this->assetGroup, $layout); $cacheId = 'assets-last-generated-' . $filenameHash; if (false === ($lastGenerated = $this->systemCache->fetch($cacheId))) { $lastGenerated = time(); // Assets are not cached -> set the current time as the new timestamp } $path = $this->buildAssetPath($debug, $this->assetGroup, $filenameHash, $lastGenerated); // If the requested minified StyleSheet and/or the JavaScript file doesn't exist, generate it if (is_file($this->appPath->getUploadsDir() . $path) === false || $debug === true) { // Get the enabled libraries and filter out empty entries $files = array_filter($this->processLibraries($layout), function ($var) { return !empty($var); }); $this->saveMinifiedAsset($files, $this->appPath->getUploadsDir() . $path); // Save the time of the generation if the requested file $this->systemCache->save($cacheId, $lastGenerated); } return $this->appPath->getWebRoot() . 'uploads/' . $path . ($debug === true ? '?v=' . $lastGenerated : ''); }
/** * @return string */ public function getFilemanagerPath() { return $this->appPath->getWebRoot() . 'ACP3/Modules/ACP3/Filemanager/libraries/kcfinder/'; }