Beispiel #1
0
 /**
 Creates a file from binary content.
 
 @param	name		<b>string</b>		File name (relative to working directory)
 @param	bits		<b>string</b>		Binary file content
 */
 public function uploadBits($name, $bits)
 {
     if (!$this->core->auth->check('media,media_admin', $this->core->blog->id)) {
         throw new Exception(__('Permission denied.'));
     }
     $name = files::tidyFileName($name);
     parent::uploadBits($name, $bits);
     return $this->createFile($name, null, null);
 }
Beispiel #2
0
 private function newMediaObject($blog_id, $user, $pwd, $file)
 {
     if (empty($file['name'])) {
         throw new Exception('No file name');
     }
     if (empty($file['bits'])) {
         throw new Exception('No file content');
     }
     $file_name = $file['name'];
     $file_bits = base64_decode($file['bits']);
     $this->setUser($user, $pwd);
     $this->setBlog();
     $media = new dcMedia($this->core);
     $dir_name = path::clean(dirname($file_name));
     $file_name = basename($file_name);
     $dir_name = preg_replace('!^/!', '', $dir_name);
     if ($dir_name != '') {
         $dir = explode('/', $dir_name);
         $cwd = './';
         foreach ($dir as $v) {
             $v = files::tidyFileName($v);
             $cwd .= $v . '/';
             $media->makeDir($v);
             $media->chdir($cwd);
         }
     }
     $media_id = $media->uploadBits($file_name, $file_bits);
     $f = $media->getFile($media_id);
     return array('file' => $file_name, 'url' => $f->file_url, 'type' => files::getMimeType($file_name));
 }
Beispiel #3
0
 /**
 Creates a file from binary content.
 
 @param	name		<b>string</b>		File name (relative to working directory)
 @param	bits		<b>string</b>		Binary file content
 */
 public function uploadBits($name, $bits)
 {
     if (!$this->okt->checkPerm('media') && !$this->okt->checkPerm('media_admin')) {
         throw new Exception(__('Permission denied.'));
     }
     $name = files::tidyFileName($name);
     parent::uploadBits($name, $bits);
     return $this->createFile($name, null, null);
 }