Example #1
0
 public function download()
 {
     $file = $this->getProperty('file');
     $contents = $this->source->getObjectContents($file);
     @session_write_close();
     header("Content-Type: application/force-download");
     header("Content-Disposition: attachment; filename=\"{$contents['basename']}\"");
     echo $contents['content'];
     die;
 }
Example #2
0
 public function process()
 {
     /* format filename */
     $file = rawurldecode($this->getProperty('file', ''));
     $source = $this->getSource();
     if ($source !== true) {
         return $source;
     }
     $this->source = $this->getProperty('source', 1);
     $fileArray = $this->source->getObjectContents($file);
     if (empty($fileArray)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', $fileArray);
 }
Example #3
0
 public function process()
 {
     @session_write_close();
     $src = $this->getProperty('src');
     if (empty($src)) {
         return $this->failure();
     }
     $this->getSource($this->getProperty('source'));
     if (empty($this->source)) {
         $this->failure($this->modx->lexicon('source_err_nf'));
     }
     // Prevent another media sources requests for security reasons
     if ($this->source->getTypeName() != 'WebDAV') {
         $this->failure($this->modx->lexicon('source_err_nfs'));
     }
     $body = $this->source->getObjectContents($src);
     if (empty($body)) {
         $this->failure($this->modx->lexicon('file_err_nf'));
     }
     header('Content-Type: ' . $body['mime']);
     echo $body['content'];
 }
Example #4
0
 public function process()
 {
     /* format filename */
     $file = rawurldecode($this->getProperty('file', ''));
     $loaded = $this->getSource();
     if ($loaded !== true) {
         return $loaded;
     }
     if (!$this->source->checkPolicy('delete')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $fileArray = $this->source->getObjectContents($file);
     if (empty($fileArray)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', $fileArray);
 }
 /**
  * @param array $options
  * @param null $raw
  *
  * @return bool|null
  */
 protected function _phpThumb(array $options = array(), $raw = null)
 {
     if ($this->get('type') != 'image') {
         return false;
     } elseif (!class_exists('modPhpThumb')) {
         /** @noinspection PhpIncludeInspection */
         require MODX_CORE_PATH . 'model/phpthumb/modphpthumb.class.php';
     }
     if (empty($raw)) {
         $prepare = $this->prepareSource();
         if ($prepare !== true) {
             return $prepare;
         }
         $filename = $this->get('path') . $this->get('file');
         $info = $this->mediaSource->getObjectContents($filename);
         if (!is_array($info)) {
             return "Could not retrieve contents of file {$filename} from media source.";
         } elseif (!empty($this->mediaSource->errors['file'])) {
             return "Could not retrieve file {$filename} from media source: " . $this->mediaSource->errors['file'];
         }
         $raw = $info['content'];
     }
     $phpThumb = new modPhpThumb($this->xpdo);
     $phpThumb->initialize();
     $tmp = tempnam(MODX_BASE_PATH, 'uf_');
     file_put_contents($tmp, $raw);
     $phpThumb->setSourceFilename($tmp);
     foreach ($options as $k => $v) {
         $phpThumb->setParameter($k, $v);
     }
     if ($phpThumb->GenerateThumbnail()) {
         ImageInterlace($phpThumb->gdimg_output, true);
         if ($phpThumb->RenderOutput()) {
             @unlink($phpThumb->sourceFilename);
             @unlink($tmp);
             $this->xpdo->log(modX::LOG_LEVEL_INFO, '[Uploadify] phpThumb messages for "' . $this->get('url') . '". ' . print_r($phpThumb->debugmessages, 1));
             return $phpThumb->outputImageData;
         }
     }
     @unlink($phpThumb->sourceFilename);
     @unlink($tmp);
     $this->xpdo->log(modX::LOG_LEVEL_ERROR, '[Uploadify] Could not resize "' . $this->get('url') . '". ' . print_r($phpThumb->debugmessages, 1));
     return false;
 }