elFinder\elFinderVolumeDriver::encode PHP Метод

encode() защищенный Метод

Encode path into hash
Автор: Dmitry (dio) Levashov
Автор: Troex Nevelin
protected encode ( $path ) : string
Результат string
    protected function encode($path)
    {
        if ($path !== '') {
            // cut ROOT from $path for security reason, even if hacker decodes the path he will not know the root
            $p = $this->_relpath($path);
            // if reqesting root dir $path will be empty, then assign '/' as we cannot leave it blank for crypt
            if ($p === '') {
                $p = DIRECTORY_SEPARATOR;
            }
            // TODO crypt path and return hash
            $hash = $this->crypt($p);
            // hash is used as id in HTML that means it must contain vaild chars
            // make base64 html safe and append prefix in begining
            $hash = strtr(base64_encode($hash), '+/=', '-_.');
            // remove dots '.' at the end, before it was '=' in base64
            $hash = rtrim($hash, '.');
            // append volume id to make hash unique
            return $this->id . $hash;
        }
    }