Example #1
0
 /**
  * Get file name
  *
  * @param array $args $_REQUEST array
  *
  * @return success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $filename = $this->trimmed('filename');
     $path = null;
     if ($filename && File::validFilename($filename)) {
         $path = File::path($filename);
     }
     if (empty($path) or !file_exists($path)) {
         $this->clientError(_('No such file.'), 404);
         return false;
     }
     if (!is_readable($path)) {
         $this->clientError(_('Cannot read file.'), 403);
         return false;
     }
     $this->path = $path;
     return true;
 }
Example #2
0
 /**
  * Get file name
  *
  * @param array $args $_REQUEST array
  *
  * @return success flag
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $filename = $this->trimmed('filename');
     $path = null;
     if ($filename && File::validFilename($filename)) {
         $path = File::path($filename);
     }
     if (empty($path) or !file_exists($path)) {
         // TRANS: Client error displayed when requesting a non-existent file.
         $this->clientError(_('No such file.'), 404);
     }
     if (!is_readable($path)) {
         // TRANS: Client error displayed when requesting a file without having read access to it.
         $this->clientError(_('Cannot read file.'), 403);
     }
     $this->path = $path;
     return true;
 }