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


PHP View::fopen方法代码示例

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


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

示例1: stream_open

 public function stream_open($path, $mode, $options, &$opened_path)
 {
     $this->setup();
     $path = substr($path, strlen('oc://'));
     $this->path = $path;
     $this->fileSource = self::$rootView->fopen($path, $mode);
     if (is_resource($this->fileSource)) {
         $this->meta = stream_get_meta_data($this->fileSource);
     }
     return is_resource($this->fileSource);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:11,代码来源:oc.php

示例2: createCertificateBundle

 /**
  * create the certificate bundle of all trusted certificated
  */
 protected function createCertificateBundle()
 {
     $path = $this->getPathToCertificates();
     $certs = $this->listCertificates();
     $fh_certs = $this->view->fopen($path . '/rootcerts.crt', 'w');
     foreach ($certs as $cert) {
         $file = $path . '/uploads/' . $cert->getName();
         $data = $this->view->file_get_contents($file);
         if (strpos($data, 'BEGIN CERTIFICATE')) {
             fwrite($fh_certs, $data);
             fwrite($fh_certs, "\r\n");
         }
     }
     fclose($fh_certs);
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:18,代码来源:certificatemanager.php

示例3: createCertificateBundle

 /**
  * create the certificate bundle of all trusted certificated
  */
 public function createCertificateBundle()
 {
     $path = $this->getPathToCertificates();
     $certs = $this->listCertificates();
     if (!$this->view->file_exists($path)) {
         $this->view->mkdir($path);
     }
     $fhCerts = $this->view->fopen($path . '/rootcerts.crt', 'w');
     // Write user certificates
     foreach ($certs as $cert) {
         $file = $path . '/uploads/' . $cert->getName();
         $data = $this->view->file_get_contents($file);
         if (strpos($data, 'BEGIN CERTIFICATE')) {
             fwrite($fhCerts, $data);
             fwrite($fhCerts, "\r\n");
         }
     }
     // Append the default certificates
     $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
     fwrite($fhCerts, $defaultCertificates);
     // Append the system certificate bundle
     $systemBundle = $this->getCertificateBundle(null);
     if ($this->view->file_exists($systemBundle)) {
         $systemCertificates = $this->view->file_get_contents($systemBundle);
         fwrite($fhCerts, $systemCertificates);
     }
     fclose($fhCerts);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:31,代码来源:CertificateManager.php

示例4: getThumbnail

 /**
  * @param string $path
  * @param int $maxX
  * @param int $maxY
  * @param boolean $scalingup
  * @param \OC\Files\View $fileview
  * @return bool|\OC_Image
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $content = $fileview->fopen($path, 'r');
     $content = stream_get_contents($content);
     //don't create previews of empty text files
     if (trim($content) === '') {
         return false;
     }
     $lines = preg_split("/\r\n|\n|\r/", $content);
     $fontSize = 5;
     //5px
     $lineSize = ceil($fontSize * 1.25);
     $image = imagecreate($maxX, $maxY);
     imagecolorallocate($image, 255, 255, 255);
     $textColor = imagecolorallocate($image, 0, 0, 0);
     foreach ($lines as $index => $line) {
         $index = $index + 1;
         $x = (int) 1;
         $y = (int) ($index * $lineSize) - $fontSize;
         imagestring($image, 1, $x, $y, $line, $textColor);
         if ($index * $lineSize >= $maxY) {
             break;
         }
     }
     $image = new \OC_Image($image);
     return $image->valid() ? $image : false;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:35,代码来源:txt.php

示例5: getFileHandle

 /**
  * Opens a file for reading
  * @throws \RuntimeException
  */
 private function getFileHandle()
 {
     $fileHandle = $this->view->fopen($this->path, "r");
     if ($fileHandle === false) {
         $this->logError('Can not open for reading.', $this->id, $this->path);
         throw new \RuntimeException();
     } else {
         $this->logDebug('Scan started');
         $this->fileHandle = $fileHandle;
     }
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:15,代码来源:item.php

示例6: encryptAll

 /**
  * Encrypt all files in a directory
  * @param string $dirPath the directory whose files will be encrypted
  * @return bool
  * @note Encryption is recursive
  */
 public function encryptAll($dirPath)
 {
     $result = true;
     $found = $this->findEncFiles($dirPath);
     // Disable proxy to prevent file being encrypted twice
     \OC_FileProxy::$enabled = false;
     $versionStatus = \OCP\App::isEnabled('files_versions');
     \OC_App::disable('files_versions');
     $encryptedFiles = array();
     // Encrypt unencrypted files
     foreach ($found['plain'] as $plainFile) {
         //get file info
         $fileInfo = \OC\Files\Filesystem::getFileInfo($plainFile['path']);
         //relative to data/<user>/file
         $relPath = $plainFile['path'];
         //relative to /data
         $rawPath = '/' . $this->userId . '/files/' . $plainFile['path'];
         // keep timestamp
         $timestamp = $fileInfo['mtime'];
         // Open plain file handle for binary reading
         $plainHandle = $this->view->fopen($rawPath, 'rb');
         // Open enc file handle for binary writing, with same filename as original plain file
         $encHandle = fopen('crypt://' . $rawPath . '.part', 'wb');
         if (is_resource($encHandle) && is_resource($plainHandle)) {
             // Move plain file to a temporary location
             $size = stream_copy_to_stream($plainHandle, $encHandle);
             fclose($encHandle);
             fclose($plainHandle);
             $fakeRoot = $this->view->getRoot();
             $this->view->chroot('/' . $this->userId . '/files');
             $this->view->rename($relPath . '.part', $relPath);
             // set timestamp
             $this->view->touch($relPath, $timestamp);
             $encSize = $this->view->filesize($relPath);
             $this->view->chroot($fakeRoot);
             // Add the file to the cache
             \OC\Files\Filesystem::putFileInfo($relPath, array('encrypted' => true, 'size' => $encSize, 'unencrypted_size' => $size, 'etag' => $fileInfo['etag']));
             $encryptedFiles[] = $relPath;
         } else {
             \OCP\Util::writeLog('files_encryption', 'initial encryption: could not encrypt ' . $rawPath, \OCP\Util::FATAL);
             $result = false;
         }
     }
     \OC_FileProxy::$enabled = true;
     if ($versionStatus) {
         \OC_App::enable('files_versions');
     }
     $result = $result && $this->encryptVersions($encryptedFiles);
     return $result;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:56,代码来源:util.php

示例7: stream_open

 /**
  * @param $path raw path relative to data/
  * @param $mode
  * @param $options
  * @param $opened_path
  * @return bool
  */
 public function stream_open($path, $mode, $options, &$opened_path)
 {
     // assume that the file already exist before we decide it finally in getKey()
     $this->newFile = false;
     if (!isset($this->rootView)) {
         $this->rootView = new \OC_FilesystemView('/');
     }
     $this->session = new \OCA\Encryption\Session($this->rootView);
     $this->privateKey = $this->session->getPrivateKey();
     // rawPath is relative to the data directory
     $this->rawPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
     $this->userId = Helper::getUser($this->rawPath);
     $util = new Util($this->rootView, $this->userId);
     // get the key ID which we want to use, can be the users key or the
     // public share key
     $this->keyId = $util->getKeyId();
     // Strip identifier text from path, this gives us the path relative to data/<user>/files
     $this->relPath = Helper::stripUserFilesPath($this->rawPath);
     // if raw path doesn't point to a real file, check if it is a version or a file in the trash bin
     if ($this->relPath === false) {
         $this->relPath = Helper::getPathToRealFile($this->rawPath);
     }
     if ($this->relPath === false) {
         \OCP\Util::writeLog('Encryption library', 'failed to open file "' . $this->rawPath . '" expecting a path to "files", "files_versions" or "cache"', \OCP\Util::ERROR);
         return false;
     }
     // Disable fileproxies so we can get the file size and open the source file without recursive encryption
     $proxyStatus = \OC_FileProxy::$enabled;
     \OC_FileProxy::$enabled = false;
     if ($mode === 'w' or $mode === 'w+' or $mode === 'wb' or $mode === 'wb+') {
         // We're writing a new file so start write counter with 0 bytes
         $this->size = 0;
         $this->unencryptedSize = 0;
     } else {
         if ($this->privateKey === false) {
             // if private key is not valid redirect user to a error page
             \OCA\Encryption\Helper::redirectToErrorPage($this->session);
         }
         $this->size = $this->rootView->filesize($this->rawPath, $mode);
     }
     $this->handle = $this->rootView->fopen($this->rawPath, $mode);
     \OC_FileProxy::$enabled = $proxyStatus;
     if (!is_resource($this->handle)) {
         \OCP\Util::writeLog('Encryption library', 'failed to open file "' . $this->rawPath . '"', \OCP\Util::ERROR);
     } else {
         $this->meta = stream_get_meta_data($this->handle);
     }
     return is_resource($this->handle);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:56,代码来源:stream.php

示例8: writePasswordsToFile

 /**
  * write one-time encryption passwords to a csv file
  *
  * @param array $passwords
  */
 protected function writePasswordsToFile(array $passwords)
 {
     $fp = $this->rootView->fopen('oneTimeEncryptionPasswords.csv', 'w');
     foreach ($passwords as $pwd) {
         fputcsv($fp, $pwd);
     }
     fclose($fp);
     $this->output->writeln("\n");
     $this->output->writeln('A list of all newly created passwords was written to data/oneTimeEncryptionPasswords.csv');
     $this->output->writeln('');
     $this->output->writeln('Each of these users need to login to the web interface, go to the');
     $this->output->writeln('personal settings section "ownCloud basic encryption module" and');
     $this->output->writeln('update the private key password to match the login password again by');
     $this->output->writeln('entering the one-time password into the "old log-in password" field');
     $this->output->writeln('and their current login password');
 }
开发者ID:ErikPel,项目名称:core,代码行数:21,代码来源:encryptall.php

示例9: readHeader

 private function readHeader()
 {
     if ($this->isLocalTmpFile) {
         $handle = fopen($this->localTmpFile, 'r');
     } else {
         $handle = $this->rootView->fopen($this->rawPath, 'r');
     }
     if (is_resource($handle)) {
         $data = fread($handle, Crypt::BLOCKSIZE);
         $header = Crypt::parseHeader($data);
         $this->cipher = Crypt::getCipher($header);
         // remeber that we found a header
         if (!empty($header)) {
             $this->containHeader = true;
         }
         fclose($handle);
     }
 }
开发者ID:Combustible,项目名称:core,代码行数:18,代码来源:stream.php

示例10: show

 public function show()
 {
     if ($this->useOriginal) {
         $fp = @$this->view->fopen($this->path, 'rb');
         $mtime = $this->view->filemtime($this->path);
         $size = $this->view->filesize($this->path);
         $mime = $this->view->getMimetype($this->path);
     } else {
         $fp = @fopen($this->path, 'rb');
         $mtime = filemtime($this->path);
         $size = filesize($this->path);
         $mime = \OC_Helper::getMimetype($this->path);
     }
     if ($fp) {
         \OCP\Response::enableCaching();
         \OCP\Response::setLastModifiedHeader($mtime);
         header('Content-Length: ' . $size);
         header('Content-Type: ' . $mime);
         fpassthru($fp);
     } else {
         \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:23,代码来源:thumbnail.php

示例11: getThumbnail

 /**
  * @param string $path
  * @param int $maxX
  * @param int $maxY
  * @param boolean $scalingup
  * @param \OC\Files\View $fileview
  * @return bool|\OC_Image
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $content = $fileview->fopen($path, 'r');
     $content = stream_get_contents($content);
     //don't create previews of empty text files
     if (trim($content) === '') {
         return false;
     }
     $lines = preg_split("/\r\n|\n|\r/", $content);
     $fontSize = 5;
     //5px
     $lineSize = ceil($fontSize * 1.25);
     $image = imagecreate($maxX, $maxY);
     imagecolorallocate($image, 255, 255, 255);
     $textColor = imagecolorallocate($image, 0, 0, 0);
     $fontFile = __DIR__;
     $fontFile .= '/../../../core';
     $fontFile .= '/fonts/OpenSans-Regular.ttf';
     $canUseTTF = function_exists('imagettftext');
     foreach ($lines as $index => $line) {
         $index = $index + 1;
         $x = (int) 1;
         $y = (int) ($index * $lineSize);
         if ($canUseTTF === true) {
             imagettftext($image, $fontSize, 0, $x, $y, $textColor, $fontFile, $line);
         } else {
             $y -= $fontSize;
             imagestring($image, 1, $x, $y, $line, $textColor);
         }
         if ($index * $lineSize >= $maxY) {
             break;
         }
     }
     $image = new \OC_Image($image);
     return $image->valid() ? $image : false;
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:44,代码来源:txt.php

示例12: stream_open

 /**
  * @param $path
  * @param $mode
  * @param $options
  * @param $opened_path
  * @return bool
  */
 public function stream_open($path, $mode, $options, &$opened_path)
 {
     if (!isset($this->rootView)) {
         $this->rootView = new \OC_FilesystemView('/');
     }
     $this->session = new \OCA\Encryption\Session($this->rootView);
     $this->privateKey = $this->session->getPrivateKey($this->userId);
     $util = new Util($this->rootView, \OCP\USER::getUser());
     $this->userId = $util->getUserId();
     // Strip identifier text from path, this gives us the path relative to data/<user>/files
     $this->relPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
     // rawPath is relative to the data directory
     $this->rawPath = $util->getUserFilesDir() . $this->relPath;
     // Disable fileproxies so we can get the file size and open the source file without recursive encryption
     $proxyStatus = \OC_FileProxy::$enabled;
     \OC_FileProxy::$enabled = false;
     if ($mode === 'w' or $mode === 'w+' or $mode === 'wb' or $mode === 'wb+') {
         // We're writing a new file so start write counter with 0 bytes
         $this->size = 0;
         $this->unencryptedSize = 0;
     } else {
         if ($this->privateKey === false) {
             // if private key is not valid redirect user to a error page
             \OCA\Encryption\Helper::redirectToErrorPage();
         }
         $this->size = $this->rootView->filesize($this->rawPath, $mode);
     }
     $this->handle = $this->rootView->fopen($this->rawPath, $mode);
     \OC_FileProxy::$enabled = $proxyStatus;
     if (!is_resource($this->handle)) {
         \OCP\Util::writeLog('Encryption library', 'failed to open file "' . $this->rawPath . '"', \OCP\Util::ERROR);
     } else {
         $this->meta = stream_get_meta_data($this->handle);
     }
     return is_resource($this->handle);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:43,代码来源:stream.php

示例13: fopen

 public static function fopen($path, $mode)
 {
     return self::$defaultInstance->fopen($path, $mode);
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:4,代码来源:Filesystem.php

示例14: getTrashedNotes

 /**
  * Gets information about trashed notes
  *
  * @NoAdminRequired
  * @NoCSRFRequired
  * @CORS
  *
  * @return string
  */
 public function getTrashedNotes()
 {
     $dir = $this->request->getParam("dir", "");
     $customFileExtensions = $this->request->getParam("extensions", array());
     if (!is_array($customFileExtensions)) {
         $customFileExtensions = array();
     }
     $noteFileExtensions = array_merge(array("md", "txt"), $customFileExtensions);
     // remove leading "/"
     if (substr($dir, 0, 1) === "/") {
         $dir = substr($dir, 1);
     }
     // remove trailing "/"
     if (substr($dir, -1) === "/") {
         $dir = substr($dir, 0, -1);
     }
     $sortAttribute = $this->request->getParam("sort", "mtime");
     $sortDirectionParam = $this->request->getParam("sortdirection", "");
     $sortDirection = $sortDirectionParam !== "" ? $sortDirectionParam === 'desc' : true;
     $filesInfo = array();
     // generate the file list
     try {
         $files = Helper::getTrashFiles("/", $this->user, $sortAttribute, $sortDirection);
         $filesInfo = Helper::formatFileInfos($files);
     } catch (Exception $e) {
     }
     // only return notes (with extension ".txt", ".md" and the custom extensions) in the $dir directory
     $resultFilesInfo = array();
     foreach ($filesInfo as $fileInfo) {
         $pathParts = pathinfo($fileInfo["name"]);
         // if $fileInfo["extraData"] is not set we will have to show the note files from all folders in QOwnNotes
         $isInDir = isset($fileInfo["extraData"]) ? strpos($fileInfo["extraData"], $dir . "/" . $fileInfo["name"]) === 0 : true;
         $isNoteFile = in_array($pathParts["extension"], $noteFileExtensions);
         if ($isInDir && $isNoteFile) {
             $timestamp = (int) ($fileInfo["mtime"] / 1000);
             $fileName = '/files_trashbin/files/' . $fileInfo["name"] . ".d{$timestamp}";
             $view = new \OC\Files\View('/' . $this->user);
             $data = "";
             // load the file data
             $handle = $view->fopen($fileName, 'rb');
             if ($handle) {
                 $chunkSize = 8192;
                 // 8 kB chunks
                 while (!feof($handle)) {
                     $data .= fread($handle, $chunkSize);
                 }
             }
             $resultFilesInfo[] = ["noteName" => $pathParts["filename"], "fileName" => $fileInfo["name"], "timestamp" => $timestamp, "dateString" => $fileInfo["date"], "data" => $data];
         }
     }
     $data = array();
     $data['directory'] = $dir;
     $data['notes'] = $resultFilesInfo;
     return $data;
 }
开发者ID:pbek,项目名称:qownnotesapi,代码行数:64,代码来源:noteapicontroller.php


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