function onParseMeta($page) { if (!$page->isError()) { $location = $this->yellow->config->get("blogLocation"); if (!empty($location) && substru($page->location, 0, strlenu($location)) == $location) { if ($page->get("template") == $this->yellow->config->get("template")) { $page->set("template", "blog"); } } } }
function getUserPermission($location, $fileName) { $userPermission = NULL; foreach ($this->yellow->plugins->plugins as $key => $value) { if (method_exists($value["obj"], "onUserPermission")) { $userPermission = $value["obj"]->onUserPermission($location, $fileName, $this->users); if (!is_null($userPermission)) { break; } } } if (is_null($userPermission)) { $userPermission = is_dir(dirname($fileName)) && strlenu(basename($fileName)) < 128; $userPermission &= substru($location, 0, strlenu($this->users->getHome())) == $this->users->getHome(); } return $userPermission; }
function analyseStaticPage($text) { $serverName = $this->yellow->config->get("serverName"); $serverBase = $this->yellow->config->get("serverBase"); $pagination = $this->yellow->config->get("contentPagination"); preg_match_all("/<a(.*?)href=\"([^\"]+)\"(.*?)>/i", $text, $matches); foreach ($matches[2] as $match) { if (preg_match("/^\\w+:\\/+(.*?)(\\/.*)\$/", $match, $tokens)) { if ($tokens[1] != $serverName) { continue; } $match = $tokens[2]; } if (!$this->yellow->toolbox->isLocationArgs($match)) { continue; } if (substru($match, 0, strlenu($serverBase)) != $serverBase) { continue; } $location = rawurldecode(substru($match, strlenu($serverBase))); if (!$this->yellow->toolbox->isLocationArgsPagination($location, $pagination)) { $location = rtrim($location, '/') . '/'; if (is_null($this->locationsArgs[$location])) { $this->locationsArgs[$location] = $location; if (defined("DEBUG") && DEBUG >= 2) { echo "YellowCommandline::analyseStaticPage detected location:{$location}\n"; } } } else { $location = rtrim($location, "0..9"); if (is_null($this->locationsArgsPagination[$location])) { $this->locationsArgsPagination[$location] = $location; if (defined("DEBUG") && DEBUG >= 2) { echo "YellowCommandline::analyseStaticPage detected location:{$location}\n"; } } } } }
function createTextKeywords($text, $keywordsMax = 0) { $tokens = array_unique(preg_split("/[,\\s\\(\\)]/", strtoloweru($text))); foreach ($tokens as $key => $value) { if (strlenu($value) < 3) { unset($tokens[$key]); } } if ($keywordsMax) { $tokens = array_slice($tokens, 0, $keywordsMax); } return implode(", ", $tokens); }
function getImageInfo($fileName, $widthOutput, $heightOutput) { $fileNameShort = substru($fileName, strlenu($this->yellow->config->get("imageDir"))); list($widthInput, $heightInput, $type) = $this->yellow->toolbox->detectImageInfo($fileName); $widthOutput = $this->convertValueAndUnit($widthOutput, $widthInput); $heightOutput = $this->convertValueAndUnit($heightOutput, $heightInput); if ($widthInput == $widthOutput && $heightInput == $heightOutput || $type == "svg") { $src = $this->yellow->config->get("serverBase") . $this->yellow->config->get("imageLocation") . $fileNameShort; $width = $widthOutput; $height = $heightOutput; } else { $fileNameThumb = ltrim(str_replace(array("/", "\\", "."), "-", dirname($fileNameShort) . "/" . pathinfo($fileName, PATHINFO_FILENAME)), "-"); $fileNameThumb .= "-" . $widthOutput . "x" . $heightOutput; $fileNameThumb .= "." . pathinfo($fileName, PATHINFO_EXTENSION); $fileNameOutput = $this->yellow->config->get("imageThumbnailDir") . $fileNameThumb; if ($this->isFileNotUpdated($fileName, $fileNameOutput)) { $image = $this->loadImage($fileName, $type); $image = $this->resizeImage($image, $widthInput, $heightInput, $widthOutput, $heightOutput); if (!$this->saveImage($image, $fileNameOutput, $type) || !$this->yellow->toolbox->modifyFile($fileNameOutput, $this->yellow->toolbox->getFileModified($fileName))) { $this->yellow->page->error(500, "Image '{$fileNameOutput}' can't be saved!"); } } $src = $this->yellow->config->get("serverBase") . $this->yellow->config->get("imageThumbnailLocation") . $fileNameThumb; list($width, $height) = $this->yellow->toolbox->detectImageInfo($fileNameOutput); } return array($src, $width, $height); }
function getUserRestrictions($email, $location, $fileName) { $userRestrictions = null; foreach ($this->yellow->plugins->plugins as $key => $value) { if (method_exists($value["obj"], "onUserRestrictions")) { $userRestrictions = $value["obj"]->onUserRestrictions($email, $location, $fileName, $this->users); if (!is_null($userRestrictions)) { break; } } } if (is_null($userRestrictions)) { $userRestrictions = substru($location, 0, strlenu($this->users->getHome($email))) != $this->users->getHome($email); $userRestrictions |= empty($fileName) || strlenu(dirname($fileName)) > 128 || strlenu(basename($fileName)) > 128; } return $userRestrictions; }
function getSystemLocations() { $locations = array(); $regex = "/\\.(css|ico|js|jpg|png|svg|txt|woff)/"; $fileNames = $this->yellow->toolbox->getDirectoryEntries($this->yellow->config->get("pluginDir"), $regex, false, false); foreach ($fileNames as $fileName) { array_push($locations, $this->yellow->config->get("pluginLocation") . basename($fileName)); } $fileNames = $this->yellow->toolbox->getDirectoryEntries($this->yellow->config->get("themeDir"), $regex, false, false); foreach ($fileNames as $fileName) { array_push($locations, $this->yellow->config->get("themeLocation") . basename($fileName)); } $assetDirLength = strlenu($this->yellow->config->get("assetDir")); $fileNames = $this->yellow->toolbox->getDirectoryEntriesRecursive($this->yellow->config->get("assetDir"), $regex, false, false); foreach ($fileNames as $fileName) { array_push($locations, $this->yellow->config->get("assetLocation") . substru($fileName, $assetDirLength)); } array_push($locations, "/" . $this->yellow->config->get("robotsFile")); return $locations; }
function getUserPermission($location, $fileName) { $userPermission = is_dir(dirname($fileName)) && strlenu(basename($fileName)) < 128; foreach ($this->yellow->plugins->plugins as $key => $value) { if (method_exists($value["obj"], "onUserPermission")) { $userPermission &= $value["obj"]->onUserPermission($location, $fileName, $this->users); } } return $userPermission; }
function onUserPermission($location, $fileName, $users) { return substru($location, 0, strlenu($users->getHome())) == $users->getHome(); }
function isContentFile($fileName) { $contentDirLength = strlenu($this->yellow->config->get("contentDir")); return substru($fileName, 0, $contentDirLength) == $this->yellow->config->get("contentDir"); }
function getCommentFileName($page) { if ($this->yellow->config->get("commentsDir") == "") { $file = $page->fileName; $extension = $this->yellow->config->get("contentExtension"); if (substru($file, strlenu($file) - strlenu($extension)) == $extension) { $file = substru($file, 0, strlenu($file) - strlenu($extension)); } $file .= $this->yellow->config->get("commentsExtension") . $extension; return $file; } else { return $this->yellow->config->get("commentsDir") . $page->get("pageFile"); } }