Exemplo n.º 1
0
function assetPath($url)
{
    $url = asset($url);
    $base = rtrim(\URL::to_asset(''), '/') . '/';
    if (S::unprefix($url, $base)) {
        if (strtok($url, '/') === 'bundles') {
            $bundle = strtok('/');
            $path = strtok(null);
            return \Bundle::path($bundle) . 'public' . DS . ltrim($path, '\\/');
        } else {
            return \path('public') . ltrim($url, '\\/');
        }
    }
}
Exemplo n.º 2
0
 function get_index()
 {
     $source = $this->in('source');
     if ($this->in('hash') !== static::hash($this->in())) {
         return E_DENIED;
     }
     $source = File::storage($source);
     $thumb = static::configure(\ThumbGen::make($source), $this->in());
     $regen = $this->in('regen', false);
     if ($regen and !$this->can('manager') and !$this->can('thumb.regen')) {
         $regen = false;
     }
     $url = $thumb->scaled($regen);
     if (!S::unprefix($url, $thumb->temp())) {
         throw new Exception("Cannot determine thumbnail URL from [{$url}].");
     }
     return Redirect::to(asset("thumbs/{$url}"));
 }
Exemplo n.º 3
0
 function can($feature)
 {
     $perms = $this->perms;
     if (!is_string($feature) or "{$perms}" === '') {
         return false;
     } elseif ($feature === '') {
         return true;
     }
     $hasWildcards = strrchr(ltrim($perms, '*'), '*') !== false;
     $perms = explode(' ', $perms);
     $allBut = S::unprefix($perms, array('*'));
     if ($feature === '*') {
         // Is this a superuser (who can do anything)?
         return $allBut and !$perms;
     } elseif (!$hasWildcards) {
         return (bool) ($allBut ^ in_array($feature, $perms));
     } else {
         $matched = array_first($perms, function ($i, $perm) use($feature) {
             return fnmatch($perm, $feature, FNM_NOESCAPE | FNM_PATHNAME | FNM_CASEFOLD);
         });
         return (bool) ($allBut ^ !!$matched);
     }
 }