Check if a thumbnail exists
@param array|null $thumbnailParams
@param string $itemPath
@param int $lastModified
@return bool
492872
protected function thumbnailExists($thumbnailParams, $itemPath, $lastModified)
    {
        $thumbnailPath = $this->getThumbnailImagePath($thumbnailParams, $itemPath, $lastModified);

        $fullPath = temp_path(ltrim($thumbnailPath, '/'));

        if (File::exists($fullPath)) {
            return $thumbnailPath;
        }

        return false;
    }
1042955
public function delete($filePath)
    {
        $relativePath = $this->fs->makePathRelative($filePath, $this->root);
        if (preg_match('!(^|/)\.\.!', $relativePath)) {
            throw new \RuntimeException("{$relativePath} does not seem to be managed by the filemanager");
        }
        if ($this->fs->exists($filePath)) {
            $this->fs->remove($filePath);
            $this->dispatchEvent(ResourceEvent::DELETED, $filePath);
            return true;
        }
        return false;
    }
594593
public static function hasChildren($clientPath, $_resourceType)
    {
        $serverPath = CKFinder_Connector_Utils_FileSystem::combinePaths($_resourceType->getDirectory(), $clientPath);

        if (!is_dir($serverPath) || (false === $fh = @opendir($serverPath))) {
            return false;
        }

        $hasChildren = false;
        while (false !== ($filename = readdir($fh))) {
            if ($filename == '.' || $filename == '..') {
                continue;
            } else if (is_dir($serverPath . $filename)) {
                //we have found valid directory
                $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
                $_acl = $_config->getAccessControlConfig();
                $_aclMask = $_acl->getComputedMask($_resourceType->getName(), $clientPath . $filename);
                if ( ($_aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW ) {
                    continue;
                }
                if ($_resourceType->checkIsHiddenFolder($filename)) {
                  continue;
                }

                $hasChildren = true;
                break;
            }
        }

        closedir($fh);

        return $hasChildren;
    }
245810
protected function lintItem($php, $item, $itemPath)
    {
        $success = true;

        if ($item->isFile() && $item->getExtension() == 'php' && !$this->lintFile($php, $itemPath)) {
            $success = false;
        } elseif ($item->isDir() && $this->recursive && !$this->lintDirectory($php, $itemPath . DIRECTORY_SEPARATOR)) {
            $success = false;
        }

        return $success;
    }
1366103
public function onGetSidebarThumbnail()
    {
        $path = Input::get('path');
        $lastModified = Input::get('lastModified');

        $thumbnailParams = $this->getThumbnailParams();
        $thumbnailParams['width'] = 300;
        $thumbnailParams['height'] = 255;
        $thumbnailParams['mode'] = 'auto';

        $path = MediaLibrary::validatePath($path);

        if (!is_numeric($lastModified)) {
            throw new ApplicationException('Invalid input data');
        }

        /*
         * If the thumbnail file exists, just return the thumbnail markup,
         * otherwise generate a new thumbnail.
         */
        $thumbnailPath = $this->thumbnailExists($thumbnailParams, $path, $lastModified);
        if ($thumbnailPath) {
            return [
                'markup' => $this->makePartial('thumbnail-image', [
                    'isError' => $this->thumbnailIsError($thumbnailPath),
                    'imageUrl' => $this->getThumbnailImageUrl($thumbnailPath)
                ])
            ];
        }

        $thumbnailInfo = $thumbnailParams;
        $thumbnailInfo['path'] = $path;
        $thumbnailInfo['lastModified'] = $lastModified;
        $thumbnailInfo['id'] = 'sidebar-thumbnail';

        return $this->generateThumbnail($thumbnailInfo, $thumbnailParams, true);
    }
1238200
public function deleteObject($path)
	{
		if(is_dir($path)) {
			$key = $this->getDynamicPath($path, false);
			$this->s3->batchDelete($key);
			$isDeleted = !$this->isObjectExists($key);
		} else {
			$isDeleted = unlink($path);
		}
		$thumbnail_path = $this->get_thumbnail_path($path);
		$this->deleteThumbnail($thumbnail_path);
		return $isDeleted;
	}
561999
public function getLastModified($_route, $_format) {
//        $stopwatch = $this->get('debug.stopwatch');
//        $stopwatch->start('contentNotModified');

        $event = new ContentEvent();

        // lastmodified de la ruta
        $lastmodified = null;
        if ($this->dispatch($_route . '_lastmodified', $event)) {
            $lastmodified = $event->getLastModified();
        }

        // lastmodified de los ficheros
        $lastmodified_files = $this->getLastModifiedFiles('*.' . $_format . '.twig');

        if ($lastmodified_files > $lastmodified) {
            $lastmodified = $lastmodified_files;
        }

//        $stopwatch->stop('contentNotModified');

        return $lastmodified;
    }
421696
public function satisfiesPath(string $expectedPath = null): bool
    {
        if (empty($expectedPath)) {
            return true;
        }

        if (preg_match('/^' . UriPath::pattern($expectedPath) . '/', $this->uri->path()) >= 1) {
            return true;
        }

        return false;
    }
513251
private function isExpired(string $viewPath) : bool
    {
        $lastModified = DateTime::createFromFormat('U', filemtime($viewPath));

        return $lastModified < new DateTime('-' . $this->lifetime . ' seconds');
    }
672241
protected function thumbnailIsError($thumbnailPath)
    {
        $fullPath = temp_path(ltrim($thumbnailPath, '/'));

        return hash_file('crc32', $fullPath) == $this->getBrokenImageHash();
    }
617205
public static function lastModifiedFolder($path)
    {
        $last_modified = 0;

        /** @var UniformResourceLocator $locator */
        $locator = Grav::instance()['locator'];
        $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
        if ($locator->isStream($path)) {
            $directory = $locator->getRecursiveIterator($path, $flags);
        } else {
            $directory = new \RecursiveDirectoryIterator($path, $flags);
        }
        $filter  = new RecursiveFolderFilterIterator($directory);
        $iterator = new \RecursiveIteratorIterator($filter, \RecursiveIteratorIterator::SELF_FIRST);

        /** @var \RecursiveDirectoryIterator $file */
        foreach ($iterator as $dir) {
            $dir_modified = $dir->getMTime();
            if ($dir_modified > $last_modified) {
                $last_modified = $dir_modified;
            }
        }

        return $last_modified;
    }
1181733
public static synchronized boolean existsStorage(final File pStoragePath) {
        // if file is existing and folder is a tt-dataplace, delete it
        if (pStoragePath.exists()
            && IOUtils.compareStructure(pStoragePath, StorageConfiguration.Paths.values()) == 0) {
            return true;
        } else {
            return false;
        }

    }
1208086
public function refreshThumbnail(Thumbnail $thumbnail)
    {
        $thumbnail->refresh();
        $this->persistenceManager->whiteListObject($thumbnail);
        if (!$this->persistenceManager->isNewObject($thumbnail)) {
            $this->thumbnailRepository->update($thumbnail);
        }
    }
1027622
public static function GetUrlForDetails(int $itemType = GnUrlItemType::Community, string $itemKey = NULL)
    {
        switch ($itemType) {
            case GnUrlItemType::Community:
                return static::$HomeUrl . "/community/index/?profileTag={$itemKey}";
            case GnUrlItemType::Event:
                return static::$HomeUrl . "/event/detail/{$itemKey}";
            case GnUrlItemType::Impression:
                return static::$HomeUrl . "/impression/detail/{$itemKey}";
            case GnUrlItemType::Nose:
                return static::$HomeUrl . "/{$itemKey}";
            case GnUrlItemType::PoI:
                return static::$HomeUrl . "/poi/detail/{$itemKey}";
            case GnUrlItemType::Track:
                return static::$HomeUrl . "/tour/detail/{$itemKey}";
        }

        throw new GnException("unexpected itemType={$itemType}");
    }
1200570
public function isUploadedFile($filePath)
    {
        // If it's a serialized one.
        if (filter_var($filePath, FILTER_VALIDATE_URL)) {
            return true;
        }

        // If it's a normal filename.
        $file = $this->getUploadDir()->getFile($this->getUserDirectoryHash() . '/' . $filePath);
        if ($file->exists()) {
            return true;
        }

        return false;
    }
269509
public function thumbnailExists($type = 'page')
    {
        $thumbs = $this->get('thumbnails');
        if (isset($thumbs[$type])) {
            return true;
        }
        return false;
    }
115456
public function restoreModifiedFiles($installPath)
    {
        DebugPrinter::log('Restoring modified items');
        $tmpRoot = sys_get_temp_dir() . DIRECTORY_SEPARATOR;
        $installPath = trim($installPath, '\\/') . DIRECTORY_SEPARATOR;
        $fsm = new Filesystem;
        DebugPrinter::log(
            'Items to search: %s',
            implode(', ', $this->modifiableFiles)
        );
        foreach ($this->modifiableFiles as $file) {
            $target = $installPath . $file;
            $source = $tmpRoot . md5($target);
            if (!$fsm->exists($source)) {
                DebugPrinter::log('Item `%s` is missing, skipping it', $source);
                continue;
            }
            $args = array($source, $target,);
            DebugPrinter::log('Restoring `%s` to `%s`', $args);
            if ($fsm->exists($target)) {
                $fsm->remove($target);
            }
            $fsm->rename($source, $target, true);
        }
        DebugPrinter::log('Finished restoring modified items');
    }