当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Helper::tmpFile方法代码示例

本文整理汇总了PHP中OC_Helper::tmpFile方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Helper::tmpFile方法的具体用法?PHP OC_Helper::tmpFile怎么用?PHP OC_Helper::tmpFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC_Helper的用法示例。


在下文中一共展示了OC_Helper::tmpFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getThumbnail

 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     // TODO: use proc_open() and stream the source file ?
     $absPath = \OC_Helper::tmpFile();
     $tmpPath = \OC_Helper::tmpFile();
     $handle = $fileview->fopen($path, 'rb');
     // we better use 5MB (1024 * 1024 * 5 = 5242880) instead of 1MB.
     // in some cases 1MB was no enough to generate thumbnail
     $firstmb = stream_get_contents($handle, 5242880);
     file_put_contents($absPath, $firstmb);
     if (self::$avconvBinary) {
         $cmd = self::$avconvBinary . ' -an -y -ss 5' . ' -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -vsync 1 ' . escapeshellarg($tmpPath) . ' > /dev/null 2>&1';
     } else {
         $cmd = self::$ffmpegBinary . ' -y -ss 5' . ' -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1' . ' -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . escapeshellarg($tmpPath) . ' > /dev/null 2>&1';
     }
     exec($cmd, $output, $returnCode);
     unlink($absPath);
     if ($returnCode === 0) {
         $image = new \OC_Image();
         $image->loadFromFile($tmpPath);
         unlink($tmpPath);
         return $image->valid() ? $image : false;
     }
     return false;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:25,代码来源:movies.php

示例2: checkMigrate

 /**
  * @param \Doctrine\DBAL\Schema\Schema $targetSchema
  * @throws \OC\DB\MigrationException
  *
  * For sqlite we simple make a copy of the entire database, and test the migration on that
  */
 public function checkMigrate(\Doctrine\DBAL\Schema\Schema $targetSchema)
 {
     $dbFile = $this->connection->getDatabase();
     $tmpFile = \OC_Helper::tmpFile('.db');
     copy($dbFile, $tmpFile);
     $connectionParams = array('path' => $tmpFile, 'driver' => 'pdo_sqlite');
     $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
     try {
         $this->applySchema($targetSchema, $conn);
         $conn->close();
         unlink($tmpFile);
     } catch (DBALException $e) {
         $conn->close();
         unlink($tmpFile);
         throw new MigrationException('', $e->getMessage());
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:23,代码来源:sqlitemigrator.php

示例3: generateThumbNail

 /**
  * @param int $maxX
  * @param int $maxY
  * @param string $absPath
  * @param int $second
  * @return bool|\OCP\IImage
  */
 private function generateThumbNail($maxX, $maxY, $absPath, $second)
 {
     $tmpPath = \OC_Helper::tmpFile();
     if (self::$avconvBinary) {
         $cmd = self::$avconvBinary . ' -an -y -ss ' . escapeshellarg($second) . ' -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -vsync 1 ' . escapeshellarg($tmpPath) . ' > /dev/null 2>&1';
     } else {
         $cmd = self::$ffmpegBinary . ' -y -ss ' . escapeshellarg($second) . ' -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1' . ' -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . escapeshellarg($tmpPath) . ' > /dev/null 2>&1';
     }
     exec($cmd, $output, $returnCode);
     if ($returnCode === 0) {
         $image = new \OC_Image();
         $image->loadFromFile($tmpPath);
         unlink($tmpPath);
         return $image->valid() ? $image : false;
     }
     unlink($tmpPath);
     return false;
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:25,代码来源:movie.php

示例4: toTmpFile

 /**
  * @param string $path
  * @return string
  */
 protected function toTmpFile($path)
 {
     //no longer in the storage api, still useful here
     $source = $this->fopen($path, 'r');
     if (!$source) {
         return false;
     }
     if ($pos = strrpos($path, '.')) {
         $extension = substr($path, $pos);
     } else {
         $extension = '';
     }
     $tmpFile = \OC_Helper::tmpFile($extension);
     $target = fopen($tmpFile, 'w');
     \OC_Helper::streamCopy($source, $target);
     fclose($target);
     return $tmpFile;
 }
开发者ID:evanjt,项目名称:core,代码行数:22,代码来源:localtempfiletrait.php

示例5: getPackage

 public static function getPackage($url, $version)
 {
     self::$package = \OC_Helper::tmpFile();
     if (!self::$package) {
         throw new \Exception('Unable to create a temporary file');
     }
     try {
         if (file_put_contents(self::$package, self::fetch($url)) === false) {
             throw new \Exception("Error storing package content");
         }
         if (preg_match('/\\.zip$/i', $url)) {
             rename(self::$package, self::$package . '.zip');
             self::$package .= '.zip';
         } elseif (preg_match('/(\\.tgz|\\.tar\\.gz)$/i', $url)) {
             rename(self::$package, self::$package . '.tgz');
             self::$package .= '.tgz';
         } elseif (preg_match('/\\.tar\\.bz2$/i', $url)) {
             rename(self::$package, self::$package . '.tar.bz2');
             self::$package .= '.tar.bz2';
         } else {
             throw new \Exception('Unable to extract package');
         }
         $extractDir = self::getPackageDir($version);
         Helper::mkdir($extractDir, true);
         $archive = \OC_Archive::open(self::$package);
         if (!$archive || !$archive->extract($extractDir)) {
             throw new \Exception(self::$package . " extraction error");
         }
     } catch (\Exception $e) {
         App::log('Retrieving ' . $url);
         self::cleanUp($version);
         throw $e;
     }
     Helper::removeIfExists(self::$package);
     //  Prepare extracted data
     //  to have '3rdparty', 'apps' and 'core' subdirectories
     $sources = Helper::getSources($version);
     $baseDir = $extractDir . '/' . self::PACKAGE_ROOT;
     @rename($baseDir . '/' . Helper::THIRDPARTY_DIRNAME, $sources[Helper::THIRDPARTY_DIRNAME]);
     @rename($baseDir . '/' . Helper::APP_DIRNAME, $sources[Helper::APP_DIRNAME]);
     @rename($baseDir, $sources[Helper::CORE_DIRNAME]);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:42,代码来源:downloader.php

示例6: getThumbnail

 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     require_once 'PHPExcel/Classes/PHPExcel.php';
     require_once 'PHPExcel/Classes/PHPExcel/IOFactory.php';
     $absPath = $fileview->toTmpFile($path);
     $tmpPath = \OC_Helper::tmpFile();
     $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF;
     $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/3rdparty/dompdf';
     \PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
     $phpexcel = new \PHPExcel($absPath);
     $excel = \PHPExcel_IOFactory::createWriter($phpexcel, 'PDF');
     $excel->save($tmpPath);
     $pdf = new \imagick($tmpPath . '[0]');
     $pdf->setImageFormat('jpg');
     unlink($absPath);
     unlink($tmpPath);
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     return $image->valid() ? $image : false;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:20,代码来源:office-fallback.php

示例7: testUpdateApp

 public function testUpdateApp()
 {
     $pathOfOldTestApp = __DIR__;
     $pathOfOldTestApp .= '/../data/';
     $pathOfOldTestApp .= 'testapp.zip';
     $oldTmp = OC_Helper::tmpFile('.zip');
     OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
     $oldData = array('path' => $oldTmp, 'source' => 'path');
     $pathOfNewTestApp = __DIR__;
     $pathOfNewTestApp .= '/../data/';
     $pathOfNewTestApp .= 'testapp2.zip';
     $newTmp = OC_Helper::tmpFile('.zip');
     OC_Helper::copyr($pathOfNewTestApp, $newTmp);
     $newData = array('path' => $newTmp, 'source' => 'path');
     OC_Installer::installApp($oldData);
     $oldVersionNumber = OC_App::getAppVersion(self::$appid);
     OC_Installer::updateApp($newData);
     $newVersionNumber = OC_App::getAppVersion(self::$appid);
     $this->assertNotEquals($oldVersionNumber, $newVersionNumber);
 }
开发者ID:evanjt,项目名称:core,代码行数:20,代码来源:installer.php

示例8: getPackage

 public static function getPackage($url, $version)
 {
     self::$package = \OC_Helper::tmpFile();
     try {
         if (!copy($url, self::$package)) {
             throw new \Exception("Failed to download {$url} package");
         }
         if (preg_match('/\\.zip$/i', $url)) {
             rename(self::$package, self::$package . '.zip');
             self::$package .= '.zip';
         } elseif (preg_match('/(\\.tgz|\\.tar\\.gz)$/i', $url)) {
             rename(self::$package, self::$package . '.tgz');
             self::$package .= '.tgz';
         } elseif (preg_match('/\\.tar\\.bz2$/i', $url)) {
             rename(self::$package, self::$package . '.tar.bz2');
             self::$package .= '.tar.bz2';
         } else {
             throw new \Exception('Unable to extract package');
         }
         $extractDir = self::getPackageDir($version);
         Helper::mkdir($extractDir, true);
         $archive = \OC_Archive::open(self::$package);
         if ($archive) {
             $archive->extract($extractDir);
         } else {
             throw new \Exception(self::$package . " extraction error");
         }
     } catch (\Exception $e) {
         self::cleanUp($version);
         throw $e;
     }
     Helper::removeIfExists(self::$package);
     //  Prepare extracted data
     //  to have '3rdparty', 'apps' and 'core' subdirectories
     $sources = Helper::getSources($version);
     $baseDir = $extractDir . '/' . self::PACKAGE_ROOT;
     @rename($baseDir . '/' . Helper::THIRDPARTY_DIRNAME, $sources[Helper::THIRDPARTY_DIRNAME]);
     @rename($baseDir . '/' . Helper::APP_DIRNAME, $sources[Helper::APP_DIRNAME]);
     @rename($baseDir, $sources[Helper::CORE_DIRNAME]);
 }
开发者ID:netcon-source,项目名称:apps,代码行数:40,代码来源:downloader.php

示例9: getPackage

 public static function getPackage($url, $version)
 {
     $path = \OC_Helper::tmpFile();
     if (!copy($url, $path)) {
         \OC_Log::write(App::APP_ID, "Failed to download {$url} package to {$path}", \OC_Log::ERROR);
         return false;
     }
     //Mimetype bug workaround
     $mime = rtrim(\OC_Helper::getMimeType($path), ';');
     if ($mime == 'application/zip') {
         rename($path, $path . '.zip');
         $path .= '.zip';
     } elseif ($mime == 'application/x-gzip') {
         rename($path, $path . '.tgz');
         $path .= '.tgz';
     } elseif ($mime == 'application/x-bzip2') {
         rename($path, $path . '.tar.bz2');
         $path .= '.tar.bz2';
     } else {
         \OC_Log::write(App::APP_ID, 'Archives of type ' . $mime . ' are not supported', \OC_Log::ERROR);
         return false;
     }
     $extractDir = self::getPackageDir($version);
     if (!mkdir($extractDir, 0777, true)) {
         \OC_Log::write(App::APP_ID, 'Unable to create temporary directory', \OC_Log::ERROR);
         return false;
     }
     $archive = \OC_Archive::open($path);
     if ($archive) {
         $archive->extract($extractDir);
     } else {
         \OC_Log::write(App::APP_ID, "Failed to open package {$path}", \OC_Log::ERROR);
         \OC_Helper::rmdirr($extractDir);
         @unlink($path);
         return false;
     }
     return $extractDir . DIRECTORY_SEPARATOR . self::PACKAGE_ROOT;
 }
开发者ID:blablubli,项目名称:owncloudapps,代码行数:38,代码来源:downloader.php

示例10: fopen

 public function fopen($path, $mode)
 {
     $path = $this->normalizePath($path);
     switch ($mode) {
         case 'r':
         case 'rb':
             $stat = $this->stat($path);
             if (is_array($stat)) {
                 try {
                     return $this->objectStore->readObject($this->getURN($stat['fileid']));
                 } catch (\Exception $ex) {
                     \OCP\Util::writeLog('objectstore', 'Could not get object: ' . $ex->getMessage(), \OCP\Util::ERROR);
                     return false;
                 }
             } else {
                 return false;
             }
         case 'w':
         case 'wb':
         case 'a':
         case 'ab':
         case 'r+':
         case 'w+':
         case 'wb+':
         case 'a+':
         case 'x':
         case 'x+':
         case 'c':
         case 'c+':
             if (strrpos($path, '.') !== false) {
                 $ext = substr($path, strrpos($path, '.'));
             } else {
                 $ext = '';
             }
             $tmpFile = \OC_Helper::tmpFile($ext);
             \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
             if ($this->file_exists($path)) {
                 $source = $this->fopen($path, 'r');
                 file_put_contents($tmpFile, $source);
             }
             self::$tmpFiles[$tmpFile] = $path;
             return fopen('close://' . $tmpFile, $mode);
     }
     return false;
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:45,代码来源:objectstorestorage.php

示例11: detectString

 /**
  * detect mimetype based on the content of a string
  *
  * @param string $data
  * @return string
  */
 public function detectString($data)
 {
     if (function_exists('finfo_open') and function_exists('finfo_file')) {
         $finfo = finfo_open(FILEINFO_MIME);
         return finfo_buffer($finfo, $data);
     } else {
         $tmpFile = \OC_Helper::tmpFile();
         $fh = fopen($tmpFile, 'wb');
         fwrite($fh, $data, 8024);
         fclose($fh);
         $mime = $this->detect($tmpFile);
         unset($tmpFile);
         return $mime;
     }
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:21,代码来源:detection.php

示例12: get

 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $file ; separated list of files to download
  * @param boolean $only_header ; boolean to only send header of the request
  */
 public static function get($dir, $files, $only_header = false)
 {
     $xsendfile = false;
     if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
         $xsendfile = true;
     }
     if (is_array($files) && count($files) == 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         if ($xsendfile) {
             $filename = OC_Helper::tmpFileNoClean('.zip');
         } else {
             $filename = OC_Helper::tmpFile('.zip');
         }
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             exit("cannot open <{$filename}>\n");
         }
         foreach ($files as $file) {
             $file = $dir . '/' . $file;
             if (\OC\Files\Filesystem::is_file($file)) {
                 $tmpFile = \OC\Files\Filesystem::toTmpFile($file);
                 self::$tmpFiles[] = $tmpFile;
                 $zip->addFile($tmpFile, basename($file));
             } elseif (\OC\Files\Filesystem::is_dir($file)) {
                 self::zipAddDir($file, $zip);
             }
         }
         $zip->close();
         $basename = basename($dir);
         if ($basename) {
             $name = $basename . '.zip';
         } else {
             $name = 'owncloud.zip';
         }
         set_time_limit($executionTime);
     } elseif (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         if ($xsendfile) {
             $filename = OC_Helper::tmpFileNoClean('.zip');
         } else {
             $filename = OC_Helper::tmpFile('.zip');
         }
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             exit("cannot open <{$filename}>\n");
         }
         $file = $dir . '/' . $files;
         self::zipAddDir($file, $zip);
         $zip->close();
         $name = $files . '.zip';
         set_time_limit($executionTime);
     } else {
         $zip = false;
         $filename = $dir . '/' . $files;
         $name = $files;
     }
     OC_Util::obEnd();
     if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
         if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
             header('Content-Disposition: attachment; filename="' . rawurlencode($name) . '"');
         } else {
             header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($name) . '; filename="' . rawurlencode($name) . '"');
         }
         header('Content-Transfer-Encoding: binary');
         OC_Response::disableCaching();
         if ($zip) {
             ini_set('zlib.output_compression', 'off');
             header('Content-Type: application/zip');
             header('Content-Length: ' . filesize($filename));
             self::addSendfileHeader($filename);
         } else {
             header('Content-Type: ' . \OC\Files\Filesystem::getMimeType($filename));
             header("Content-Length: " . \OC\Files\Filesystem::filesize($filename));
             list($storage) = \OC\Files\Filesystem::resolvePath($filename);
             if ($storage instanceof \OC\Files\Storage\Local) {
                 self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
             }
         }
     } elseif ($zip or !\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->assign('file', $name);
         $tmpl->printPage();
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
//.........这里部分代码省略.........
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:101,代码来源:files.php

示例13: fopen

 public function fopen($path, $mode)
 {
     $path = $this->normalizePath($path);
     switch ($mode) {
         case 'r':
         case 'rb':
             $tmpFile = \OC_Helper::tmpFile();
             self::$tmpFiles[$tmpFile] = $path;
             try {
                 $object = $this->container->getObject($path);
             } catch (ClientErrorResponseException $e) {
                 \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
                 return false;
             } catch (Exception\ObjectNotFoundException $e) {
                 \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
                 return false;
             }
             try {
                 $objectContent = $object->getContent();
                 $objectContent->rewind();
                 $stream = $objectContent->getStream();
                 file_put_contents($tmpFile, $stream);
             } catch (Exceptions\IOError $e) {
                 \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
                 return false;
             }
             return fopen($tmpFile, 'r');
         case 'w':
         case 'wb':
         case 'a':
         case 'ab':
         case 'r+':
         case 'w+':
         case 'wb+':
         case 'a+':
         case 'x':
         case 'x+':
         case 'c':
         case 'c+':
             if (strrpos($path, '.') !== false) {
                 $ext = substr($path, strrpos($path, '.'));
             } else {
                 $ext = '';
             }
             $tmpFile = \OC_Helper::tmpFile($ext);
             \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
             if ($this->file_exists($path)) {
                 $source = $this->fopen($path, 'r');
                 file_put_contents($tmpFile, $source);
             }
             self::$tmpFiles[$tmpFile] = $path;
             return fopen('close://' . $tmpFile, $mode);
     }
 }
开发者ID:pinoniq,项目名称:core,代码行数:54,代码来源:swift.php

示例14: installApp

 /**
  * @brief Installs an app
  * @param $data array with all information
  * @returns integer
  *
  * This function installs an app. All information needed are passed in the
  * associative array $data.
  * The following keys are required:
  *   - source: string, can be "path" or "http"
  *
  * One of the following keys is required:
  *   - path: path to the file containing the app
  *   - href: link to the downloadable file containing the app
  *
  * The following keys are optional:
  *   - pretend: boolean, if set true the system won't do anything
  *   - noinstall: boolean, if true appinfo/install.php won't be loaded
  *   - inactive: boolean, if set true the appconfig/app.sample.php won't be
  *     renamed
  *
  * This function works as follows
  *   -# fetching the file
  *   -# unzipping it
  *   -# check the code
  *   -# installing the database at appinfo/database.xml
  *   -# including appinfo/install.php
  *   -# setting the installed version
  *
  * It is the task of oc_app_install to create the tables and do whatever is
  * needed to get the app working.
  */
 public static function installApp($data = array())
 {
     if (!isset($data['source'])) {
         OC_Log::write('core', 'No source specified when installing app', OC_Log::ERROR);
         return false;
     }
     //download the file if necesary
     if ($data['source'] == 'http') {
         $path = OC_Helper::tmpFile();
         if (!isset($data['href'])) {
             OC_Log::write('core', 'No href specified when installing app from http', OC_Log::ERROR);
             return false;
         }
         copy($data['href'], $path);
     } else {
         if (!isset($data['path'])) {
             OC_Log::write('core', 'No path specified when installing app from local file', OC_Log::ERROR);
             return false;
         }
         $path = $data['path'];
     }
     //detect the archive type
     $mime = OC_Helper::getMimeType($path);
     if ($mime == 'application/zip') {
         rename($path, $path . '.zip');
         $path .= '.zip';
     } elseif ($mime == 'application/x-gzip') {
         rename($path, $path . '.tgz');
         $path .= '.tgz';
     } else {
         OC_Log::write('core', 'Archives of type ' . $mime . ' are not supported', OC_Log::ERROR);
         return false;
     }
     //extract the archive in a temporary folder
     $extractDir = OC_Helper::tmpFolder();
     OC_Helper::rmdirr($extractDir);
     mkdir($extractDir);
     if ($archive = OC_Archive::open($path)) {
         $archive->extract($extractDir);
     } else {
         OC_Log::write('core', 'Failed to open archive when installing app', OC_Log::ERROR);
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     //load the info.xml file of the app
     if (!is_file($extractDir . '/appinfo/info.xml')) {
         //try to find it in a subdir
         $dh = opendir($extractDir);
         while ($folder = readdir($dh)) {
             if (substr($folder, 0, 1) != '.' and is_dir($extractDir . '/' . $folder)) {
                 if (is_file($extractDir . '/' . $folder . '/appinfo/info.xml')) {
                     $extractDir .= '/' . $folder;
                 }
             }
         }
     }
     if (!is_file($extractDir . '/appinfo/info.xml')) {
         OC_Log::write('core', 'App does not provide an info.xml file', OC_Log::ERROR);
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         return false;
     }
     $info = OC_App::getAppInfo($extractDir . '/appinfo/info.xml', true);
     $basedir = OC::$APPSROOT . '/apps/' . $info['id'];
//.........这里部分代码省略.........
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:101,代码来源:installer.php

示例15: get

 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $file ; separated list of files to download
  * @param boolean $only_header ; boolean to only send header of the request
  */
 public static function get($dir, $files, $only_header = false)
 {
     $xsendfile = false;
     if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
         $xsendfile = true;
     }
     if (is_array($files) && count($files) == 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         $filename = OC_Helper::tmpFile('.zip');
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             $l = OC_L10N::get('lib');
             throw new Exception($l->t('cannot open "%s"', array($filename)));
         }
         foreach ($files as $file) {
             $file = $dir . '/' . $file;
             if (\OC\Files\Filesystem::is_file($file)) {
                 $tmpFile = \OC\Files\Filesystem::toTmpFile($file);
                 self::$tmpFiles[] = $tmpFile;
                 $zip->addFile($tmpFile, basename($file));
             } elseif (\OC\Files\Filesystem::is_dir($file)) {
                 self::zipAddDir($file, $zip);
             }
         }
         $zip->close();
         if ($xsendfile) {
             $filename = OC_Helper::moveToNoClean($filename);
         }
         $basename = basename($dir);
         if ($basename) {
             $name = $basename . '.zip';
         } else {
             $name = 'download.zip';
         }
         set_time_limit($executionTime);
     } elseif (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
         self::validateZipDownload($dir, $files);
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         $zip = new ZipArchive();
         $filename = OC_Helper::tmpFile('.zip');
         if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
             $l = OC_L10N::get('lib');
             throw new Exception($l->t('cannot open "%s"', array($filename)));
         }
         $file = $dir . '/' . $files;
         self::zipAddDir($file, $zip);
         $zip->close();
         if ($xsendfile) {
             $filename = OC_Helper::moveToNoClean($filename);
         }
         $name = $files . '.zip';
         set_time_limit($executionTime);
     } else {
         $zip = false;
         $filename = $dir . '/' . $files;
         $name = $files;
         if ($xsendfile && OC_App::isEnabled('files_encryption')) {
             $xsendfile = false;
         }
     }
     OC_Util::obEnd();
     if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
         OC_Response::setContentDispositionHeader($name, 'attachment');
         header('Content-Transfer-Encoding: binary');
         OC_Response::disableCaching();
         if ($zip) {
             ini_set('zlib.output_compression', 'off');
             header('Content-Type: application/zip');
             header('Content-Length: ' . filesize($filename));
             self::addSendfileHeader($filename);
         } else {
             $filesize = \OC\Files\Filesystem::filesize($filename);
             header('Content-Type: ' . \OC\Files\Filesystem::getMimeType($filename));
             if ($filesize > -1) {
                 header("Content-Length: " . $filesize);
             }
             if ($xsendfile) {
                 list($storage) = \OC\Files\Filesystem::resolvePath(\OC\Files\Filesystem::getView()->getAbsolutePath($filename));
                 /**
                  * @var \OC\Files\Storage\Storage $storage
                  */
                 if ($storage->instanceOfStorage('\\OC\\Files\\Storage\\Local')) {
                     self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
                 }
             }
         }
     } elseif ($zip or !\OC\Files\Filesystem::file_exists($filename)) {
//.........这里部分代码省略.........
开发者ID:hjimmy,项目名称:owncloud,代码行数:101,代码来源:files.php


注:本文中的OC_Helper::tmpFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。