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


PHP Filesystem::file_get_contents方法代码示例

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


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

示例1: showPad

 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * @return TemplateResponse
  */
 public function showPad($file, $dir)
 {
     /* Retrieve file content to find pad’s URL */
     $content = \OC\Files\Filesystem::file_get_contents($dir . "/" . $file);
     preg_match('/URL=(.*)$/', $content, $matches);
     $url = $matches[1];
     $title = $file;
     $params = ['urlGenerator' => $this->urlGenerator, 'url' => $url, 'title' => $title];
     $response = new TemplateResponse($this->appName, 'viewer', $params, 'blank');
     return $response;
 }
开发者ID:attacfr,项目名称:ownpad,代码行数:17,代码来源:displaycontroller.php

示例2: showPad

 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * @return TemplateResponse
  */
 public function showPad($file, $dir)
 {
     /* Retrieve file content to find pad’s URL */
     $content = \OC\Files\Filesystem::file_get_contents($dir . "/" . $file);
     preg_match('/URL=(.*)$/', $content, $matches);
     $url = $matches[1];
     $title = $file;
     /* Not totally sure that this is the right way to proceed…
      *
      * First we decode the URL (to avoid double encode), then we
      * replace spaces with underscore (as they are converted as
      * such by Etherpad), then we encode the URL properly (and we
      * avoid to urlencode() the protocol scheme).
      *
      * Magic urlencode() function was stolen from this answer on
      * StackOverflow: <http://stackoverflow.com/a/7974253>.
      */
     $url = urldecode($url);
     $url = str_replace(' ', '_', $url);
     $url = preg_replace_callback('#://([^/]+)/([^?]+)#', function ($match) {
         return '://' . $match[1] . '/' . join('/', array_map('rawurlencode', explode('/', $match[2])));
     }, $url);
     $params = ['urlGenerator' => $this->urlGenerator, 'url' => $url, 'title' => $title];
     $response = new TemplateResponse($this->appName, 'viewer', $params, 'blank');
     /* Allow Etherpad and Ethercalc domains to the
      * Content-Security-frame- list.
      *
      * This feature was introduced in ownCloud 8.1.
      */
     $policy = new ContentSecurityPolicy();
     $appConfig = \OC::$server->getAppConfig();
     $policy->addAllowedFrameDomain($appConfig->getValue('ownpad', 'ownpad_etherpad_host', ''));
     $policy->addAllowedFrameDomain($appConfig->getValue('ownpad', 'ownpad_ethercalc_host', ''));
     $response->setContentSecurityPolicy($policy);
     return $response;
 }
开发者ID:mjensemble,项目名称:ownpad,代码行数:42,代码来源:displaycontroller.php

示例3: loadFromFile


//.........这里部分代码省略.........
         case IMAGETYPE_GIF:
             if (imagetypes() & IMG_GIF) {
                 $this->resource = imagecreatefromgif($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_JPEG:
             if (imagetypes() & IMG_JPG) {
                 $this->resource = imagecreatefromjpeg($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_PNG:
             if (imagetypes() & IMG_PNG) {
                 $this->resource = imagecreatefrompng($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_XBM:
             if (imagetypes() & IMG_XPM) {
                 $this->resource = imagecreatefromxbm($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, XBM/XPM images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_WBMP:
             if (imagetypes() & IMG_WBMP) {
                 $this->resource = imagecreatefromwbmp($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_BMP:
             $this->resource = $this->imagecreatefrombmp($imagePath);
             break;
             /*
             case IMAGETYPE_TIFF_II: // (intel byte order)
             	break;
             case IMAGETYPE_TIFF_MM: // (motorola byte order)
             	break;
             case IMAGETYPE_JPC:
             	break;
             case IMAGETYPE_JP2:
             	break;
             case IMAGETYPE_JPX:
             	break;
             case IMAGETYPE_JB2:
             	break;
             case IMAGETYPE_SWC:
             	break;
             case IMAGETYPE_IFF:
             	break;
             case IMAGETYPE_ICO:
             	break;
             case IMAGETYPE_SWF:
             	break;
             case IMAGETYPE_PSD:
             	break;
             */
         /*
         case IMAGETYPE_TIFF_II: // (intel byte order)
         	break;
         case IMAGETYPE_TIFF_MM: // (motorola byte order)
         	break;
         case IMAGETYPE_JPC:
         	break;
         case IMAGETYPE_JP2:
         	break;
         case IMAGETYPE_JPX:
         	break;
         case IMAGETYPE_JB2:
         	break;
         case IMAGETYPE_SWC:
         	break;
         case IMAGETYPE_IFF:
         	break;
         case IMAGETYPE_ICO:
         	break;
         case IMAGETYPE_SWF:
         	break;
         case IMAGETYPE_PSD:
         	break;
         */
         default:
             // this is mostly file created from encrypted file
             $this->resource = imagecreatefromstring(\OC\Files\Filesystem::file_get_contents(\OC\Files\Filesystem::getLocalPath($imagePath)));
             $iType = IMAGETYPE_PNG;
             OC_Log::write('core', 'OC_Image->loadFromFile, Default', OC_Log::DEBUG);
             break;
     }
     if ($this->valid()) {
         $this->imageType = $iType;
         $this->mimeType = image_type_to_mime_type($iType);
         $this->filePath = $imagePath;
     }
     return $this->resource;
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:101,代码来源:image.php

示例4: loadFromFile


//.........这里部分代码省略.........
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_JPEG:
             if (imagetypes() & IMG_JPG) {
                 $this->resource = imagecreatefromjpeg($imagePath);
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_PNG:
             if (imagetypes() & IMG_PNG) {
                 $this->resource = imagecreatefrompng($imagePath);
                 // Preserve transparency
                 imagealphablending($this->resource, true);
                 imagesavealpha($this->resource, true);
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_XBM:
             if (imagetypes() & IMG_XPM) {
                 $this->resource = imagecreatefromxbm($imagePath);
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_WBMP:
             if (imagetypes() & IMG_WBMP) {
                 $this->resource = imagecreatefromwbmp($imagePath);
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_BMP:
             $this->resource = $this->imagecreatefrombmp($imagePath);
             break;
             /*
             case IMAGETYPE_TIFF_II: // (intel byte order)
             	break;
             case IMAGETYPE_TIFF_MM: // (motorola byte order)
             	break;
             case IMAGETYPE_JPC:
             	break;
             case IMAGETYPE_JP2:
             	break;
             case IMAGETYPE_JPX:
             	break;
             case IMAGETYPE_JB2:
             	break;
             case IMAGETYPE_SWC:
             	break;
             case IMAGETYPE_IFF:
             	break;
             case IMAGETYPE_ICO:
             	break;
             case IMAGETYPE_SWF:
             	break;
             case IMAGETYPE_PSD:
             	break;
             */
         /*
         case IMAGETYPE_TIFF_II: // (intel byte order)
         	break;
         case IMAGETYPE_TIFF_MM: // (motorola byte order)
         	break;
         case IMAGETYPE_JPC:
         	break;
         case IMAGETYPE_JP2:
         	break;
         case IMAGETYPE_JPX:
         	break;
         case IMAGETYPE_JB2:
         	break;
         case IMAGETYPE_SWC:
         	break;
         case IMAGETYPE_IFF:
         	break;
         case IMAGETYPE_ICO:
         	break;
         case IMAGETYPE_SWF:
         	break;
         case IMAGETYPE_PSD:
         	break;
         */
         default:
             // this is mostly file created from encrypted file
             $this->resource = imagecreatefromstring(\OC\Files\Filesystem::file_get_contents(\OC\Files\Filesystem::getLocalPath($imagePath)));
             $iType = IMAGETYPE_PNG;
             $this->logger->debug('OC_Image->loadFromFile, Default', array('app' => 'core'));
             break;
     }
     if ($this->valid()) {
         $this->imageType = $iType;
         $this->mimeType = image_type_to_mime_type($iType);
         $this->filePath = $imagePath;
     }
     return $this->resource;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:101,代码来源:image.php

示例5: session_write_close

/**
 * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
OCP\JSON::callCheck();
session_write_close();
if (isset($_POST['progresskey']) && isset($_POST['getprogress'])) {
    echo OCP\JSON::success(array('percent' => OC_Cache::get($_POST['progresskey'])));
    exit;
}
$file = \OC\Files\Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);
if (!$file) {
    OCP\JSON::error(array('error' => '404'));
}
$file = Sabre\VObject\StringUtil::convertToUTF8($file);
$import = new OC_Calendar_Import($file);
$import->setUserID(OCP\User::getUser());
$import->setTimeZone(OC_Calendar_App::$tz);
$import->enableProgressCache();
$import->setProgresskey($_POST['progresskey']);
if (!$import->isValid()) {
    OCP\JSON::error(array('error' => 'notvalid'));
    exit;
}
$newcal = false;
if ($_POST['method'] == 'new') {
开发者ID:omusico,项目名称:isle-web-framework,代码行数:30,代码来源:import.php

示例6: importVcards

 /**
  * @NoAdminRequired
  */
 public function importVcards()
 {
     $pProgresskey = $this->params('progresskey');
     $pGetprogress = $this->params('getprogress');
     $pPath = $this->params('path');
     $pFile = $this->params('file');
     $pMethod = $this->params('method');
     $pAddressbook = $this->params('addressbookname');
     $pIsDragged = $this->params('isDragged');
     $pId = $this->params('id');
     $pOverwrite = $this->params('overwrite');
     \OC::$server->getSession()->close();
     if (isset($pProgresskey) && isset($pGetprogress)) {
         $aCurrent = \OC::$server->getCache()->get($pProgresskey);
         $aCurrent = json_decode($aCurrent);
         $numVC = isset($aCurrent->{'all'}) ? $aCurrent->{'all'} : 0;
         $currentVCCount = isset($aCurrent->{'current'}) ? $aCurrent->{'current'} : 0;
         $currentFn = isset($aCurrent->{'currentFn'}) ? $aCurrent->{'currentFn'} : '';
         $percent = isset($aCurrent->{'percent'}) ? $aCurrent->{'percent'} : '';
         if ($percent == '') {
             $percent = 0;
         }
         $params = ['status' => 'success', 'percent' => $percent, 'currentmsg' => $currentFn . ' ' . $percent . '% (' . $currentVCCount . '/' . $numVC . ')'];
         $response = new JSONResponse($params);
         return $response;
     }
     if ($pIsDragged === 'true') {
         //OCP\JSON::error(array('error'=>'404'));
         $file = explode(',', $pFile);
         $file = end($file);
         $file = base64_decode($file);
     } else {
         $file = \OC\Files\Filesystem::file_get_contents($pPath . '/' . $pFile);
     }
     if (!$file) {
         $params = ['status' => 'error', 'error' => '404'];
         $response = new JSONResponse($params);
         return $response;
     }
     $file = \Sabre\VObject\StringUtil::convertToUTF8($file);
     $import = new Import($file);
     $import->setUserID($this->userId);
     $import->setProgresskey($pProgresskey);
     $import->enableProgressCache();
     \OCP\Util::writeLog($this->appName, ' PROG: ' . $pProgresskey, \OCP\Util::DEBUG);
     if (!$import->isValid()) {
         $params = ['status' => 'error', 'error' => 'notvalid'];
         $response = new JSONResponse($params);
         return $response;
     }
     $newAddressbook = false;
     if ($pMethod == 'new') {
         $id = Addressbook::add($this->userId, $pAddressbook);
         if ($id) {
             Addressbook::setActive($id, 1);
             $newAddressbook = true;
         }
     } else {
         $id = $pId;
         Addressbook::find($id);
         $import->setOverwrite($pOverwrite);
     }
     //\OCP\Util::writeLog($this->appName,' METHOD: '.$pMethod.'ID:'.$id, \OCP\Util::DEBUG);
     $import->setAddressbookId($id);
     try {
         $import->import();
     } catch (\Exception $e) {
         $params = ['status' => 'error', 'message' => $this->l10n->t('Import failed')];
         $response = new JSONResponse($params);
         return $response;
     }
     $count = $import->getCount();
     $errorCount = $import->getErrorCount();
     if ($count == 0) {
         if ($newAddressbook) {
             Addressbook::delete($id);
         }
         $params = ['status' => 'error', 'message' => $this->l10n->t('The file contained either no vcard or all vcards are already saved in your addessbook.')];
         $response = new JSONResponse($params);
         return $response;
     } else {
         if ($newAddressbook) {
             $params = ['status' => 'success', 'message' => $count . ' ' . $this->l10n->t('vcards has been saved in the new addressbook') . ' ' . strip_tags($pAddressbook)];
             $response = new JSONResponse($params);
             return $response;
         } else {
             $params = ['status' => 'success', 'message' => $errorCount . ' Error - ' . $count . ' ' . $this->l10n->t('vcards has been saved in your addressbook')];
             $response = new JSONResponse($params);
             return $response;
         }
     }
 }
开发者ID:BacLuc,项目名称:newGryfiPage,代码行数:95,代码来源:importcontroller.php

示例7: importEvents

 /**
  * @NoAdminRequired
  */
 public function importEvents()
 {
     $pProgresskey = $this->params('progresskey');
     $pGetprogress = $this->params('getprogress');
     $pPath = $this->params('path');
     $pFile = $this->params('file');
     $pMethod = $this->params('method');
     $pCalname = $this->params('calname');
     $pCalcolor = $this->params('calcolor');
     $pId = $this->params('id');
     $pOverwrite = $this->params('overwrite');
     $pIsDragged = $this->params('isDragged');
     $pIsSub = $this->params('isSub');
     $pSubUri = $this->params('subUri');
     $pSubUri = isset($pSubUri) ? $pSubUri : '';
     \OC::$server->getSession()->close();
     if (isset($pProgresskey) && isset($pGetprogress)) {
         $aCurrent = \OC::$server->getCache()->get($pProgresskey);
         $aCurrent = json_decode($aCurrent);
         $numVO = isset($aCurrent->{'all'}) ? $aCurrent->{'all'} : 0;
         $currentVOCount = isset($aCurrent->{'current'}) ? $aCurrent->{'current'} : 0;
         $currentSummary = isset($aCurrent->{'currentSummary'}) ? $aCurrent->{'currentSummary'} : '';
         $percent = isset($aCurrent->{'percent'}) ? $aCurrent->{'percent'} : '';
         if ($percent == '') {
             $percent = 0;
         }
         $params = ['status' => 'success', 'percent' => $percent, 'currentmsg' => $currentSummary . ' ' . $percent . '% (' . $currentVOCount . '/' . $numVO . ')'];
         $response = new JSONResponse($params);
         return $response;
     }
     if ($pIsDragged === 'true') {
         //OCP\JSON::error(array('error'=>'404'));
         $file = explode(',', $pFile);
         $file = end($file);
         $file = base64_decode($file);
     } elseif ($pIsSub === 'true') {
         $file = $pFile;
     } else {
         $file = \OC\Files\Filesystem::file_get_contents($pPath . '/' . $pFile);
     }
     if (!$file) {
         $params = ['status' => 'error', 'error' => '404'];
         $response = new JSONResponse($params);
         return $response;
     }
     $file = \Sabre\VObject\StringUtil::convertToUTF8($file);
     $import = new Import($file);
     $import->setUserID($this->userId);
     $import->setTimeZone(CalendarApp::$tz);
     $import->enableProgressCache();
     $import->setProgresskey($pProgresskey);
     $bUriImport = $pIsSub === 'true' ? true : false;
     $import->setImportFromUri($bUriImport);
     if (!$import->isValid()) {
         $params = ['status' => 'error', 'error' => 'notvalid'];
         $response = new JSONResponse($params);
         return $response;
     }
     $newcal = false;
     if ($pMethod == 'new') {
         $calendars = CalendarCalendar::allCalendars($this->userId);
         foreach ($calendars as $calendar) {
             if ($calendar['displayname'] == $pCalname) {
                 $id = $calendar['id'];
                 $newcal = false;
                 break;
             }
             $newcal = true;
         }
         if ($newcal) {
             $isSubscribed = 0;
             if ($pIsSub === 'true') {
                 $isSubscribed = 1;
             }
             $id = CalendarCalendar::addCalendar($this->userId, strip_tags($pCalname), 'VEVENT,VTODO,VJOURNAL', null, 0, strip_tags($pCalcolor), $isSubscribed, $pSubUri);
             CalendarCalendar::setCalendarActive($id, 1);
         }
     } else {
         $id = $pId;
         $calendar = CalendarApp::getCalendar($id);
         if ($calendar['userid'] != $this->userId) {
             $params = ['status' => 'error', 'error' => 'missingcalendarrights'];
             $response = new JSONResponse($params);
             return $response;
         }
         $import->setOverwrite($pOverwrite);
     }
     $import->setCalendarID($id);
     try {
         $import->import();
     } catch (\Exception $e) {
         $params = ['status' => 'error', 'message' => $this->l10n->t('Import failed')];
         $response = new JSONResponse($params);
         return $response;
     }
     $count = $import->getCount();
     if ($count == 0) {
//.........这里部分代码省略.........
开发者ID:Rotzbua,项目名称:calendarplus,代码行数:101,代码来源:importcontroller.php

示例8: testMoveFileToFolder

 /**
  * @dataProvider usersProvider
  */
 function testMoveFileToFolder($userId)
 {
     $view = new \OC\Files\View('/' . self::TEST_ENCRYPTION_SHARE_USER1);
     $filename = '/tmp-' . $this->getUniqueID();
     $folder = '/folder' . $this->getUniqueID();
     \OC\Files\Filesystem::mkdir($folder);
     // Save long data as encrypted file using stream wrapper
     $cryptedFile = \OC\Files\Filesystem::file_put_contents($folder . $filename, $this->dataShort);
     // Test that data was successfully written
     $this->assertInternalType('int', $cryptedFile);
     // Get file decrypted contents
     $decrypt = \OC\Files\Filesystem::file_get_contents($folder . $filename);
     $this->assertEquals($this->dataShort, $decrypt);
     $subFolder = $folder . '/subfolder' . $this->getUniqueID();
     \OC\Files\Filesystem::mkdir($subFolder);
     // get the file info from previous created file
     $fileInfo = \OC\Files\Filesystem::getFileInfo($folder);
     $this->assertInstanceOf('\\OC\\Files\\FileInfo', $fileInfo);
     // share the folder
     \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL);
     // check that the share keys exist
     $this->assertTrue($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey'));
     $this->assertTrue($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
     // move the file into the subfolder as the test user
     self::loginHelper($userId);
     \OC\Files\Filesystem::rename($folder . $filename, $subFolder . $filename);
     self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1);
     // Get file decrypted contents
     $newDecrypt = \OC\Files\Filesystem::file_get_contents($subFolder . $filename);
     $this->assertEquals($this->dataShort, $newDecrypt);
     // check if additional share key for user2 exists
     $this->assertTrue($view->file_exists('files_encryption/keys' . $subFolder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey'));
     $this->assertTrue($view->file_exists('files_encryption/keys' . $subFolder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
     // check that old keys were removed/moved properly
     $this->assertFalse($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey'));
     $this->assertFalse($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
     // tear down
     \OC\Files\Filesystem::unlink($subFolder);
     \OC\Files\Filesystem::unlink($folder);
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:43,代码来源:share.php

示例9: prepare

 /**
  * @NoAdminRequired
  */
 public function prepare()
 {
     $request = $this->request;
     $params = $this->request->urlParams;
     $addressBookId = $params['addressBookId'];
     $format = $params['importType'];
     $response = new JSONResponse();
     $filename = $request->post['filename'];
     $path = $request->post['path'];
     $view = \OCP\Files::getStorage('contacts');
     if (!$view->file_exists('imports')) {
         $view->mkdir('imports');
     }
     $content = \OC\Files\Filesystem::file_get_contents($path . '/' . $filename);
     if ($view->file_put_contents('/imports/' . $filename, $content)) {
         $progresskey = 'contacts-import-' . rand();
         $response->setParams(array('filename' => $filename, 'progresskey' => $progresskey, 'backend' => $params['backend'], 'addressBookId' => $params['addressBookId'], 'importType' => $params['importType']));
     } else {
         $response->bailOut(App::$l10n->t('Error moving file to imports folder.'));
     }
     return $response;
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:25,代码来源:importcontroller.php

示例10: isset

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// Init owncloud
// Check if we are a user
OCP\JSON::checkLoggedIn();
// Set the session key for the file we are about to edit.
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$filename = isset($_GET['file']) ? $_GET['file'] : '';
if (!empty($filename)) {
    $path = $dir . '/' . $filename;
    $writeable = \OC\Files\Filesystem::isUpdatable($path);
    $mime = \OC\Files\Filesystem::getMimeType($path);
    $mtime = \OC\Files\Filesystem::filemtime($path);
    $filecontents = \OC\Files\Filesystem::file_get_contents($path);
    $encoding = mb_detect_encoding($filecontents . "a", "UTF-8, WINDOWS-1252, ISO-8859-15, ISO-8859-1, ASCII", true);
    if ($encoding == "") {
        // set default encoding if it couldn't be detected
        $encoding = 'ISO-8859-15';
    }
    $filecontents = iconv($encoding, "UTF-8", $filecontents);
    OCP\JSON::success(array('data' => array('filecontents' => $filecontents, 'writeable' => $writeable, 'mime' => $mime, 'mtime' => $mtime)));
} else {
    OCP\JSON::error(array('data' => array('message' => 'Invalid file path supplied.')));
}
开发者ID:samj1912,项目名称:repo,代码行数:31,代码来源:loadfile.php

示例11: testMoveFolder

 /**
  * test if additional share keys are added if we move a folder to a shared parent
  * @medium
  */
 function testMoveFolder()
 {
     $view = new \OC\Files\View('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
     $filename = '/tmp-' . uniqid();
     $folder = '/folder' . uniqid();
     \OC\Files\Filesystem::mkdir($folder);
     // Save long data as encrypted file using stream wrapper
     $cryptedFile = \OC\Files\Filesystem::file_put_contents($folder . $filename, $this->dataShort);
     // Test that data was successfully written
     $this->assertTrue(is_int($cryptedFile));
     // Get file decrypted contents
     $decrypt = \OC\Files\Filesystem::file_get_contents($folder . $filename);
     $this->assertEquals($this->dataShort, $decrypt);
     $newFolder = '/newfolder/subfolder' . uniqid();
     \OC\Files\Filesystem::mkdir('/newfolder');
     // get the file info from previous created file
     $fileInfo = \OC\Files\Filesystem::getFileInfo('/newfolder');
     $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
     // share the folder
     \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL);
     \OC\Files\Filesystem::rename($folder, $newFolder);
     // Get file decrypted contents
     $newDecrypt = \OC\Files\Filesystem::file_get_contents($newFolder . $filename);
     $this->assertEquals($this->dataShort, $newDecrypt);
     // check if additional share key for user2 exists
     $this->assertTrue($view->file_exists('files_encryption/share-keys' . $newFolder . '/' . $filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
     // tear down
     \OC\Files\Filesystem::unlink($newFolder);
     \OC\Files\Filesystem::unlink('/newfolder');
 }
开发者ID:Combustible,项目名称:core,代码行数:34,代码来源:share.php

示例12: file_get_contents

 /**
  * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  */
 public static function file_get_contents($path)
 {
     return \OC\Files\Filesystem::file_get_contents($path);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:7,代码来源:filesystem.php

示例13: header

* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once 'lib/impress.php';
// Check if we are a user
OCP\User::checkLoggedIn();
OCP\JSON::checkAppEnabled('impress');
$filename = OCP\Util::sanitizeHTML($_GET['file']);
$title = OCP\Util::sanitizeHTML($_GET['name']);
if (!\OC\Files\Filesystem::file_exists($filename)) {
    header("HTTP/1.0 404 Not Found");
    $tmpl = new OCP\Template('', '404', 'guest');
    $tmpl->assign('file', $filename);
    $tmpl->printPage();
    exit;
}
$data = \OC\Files\Filesystem::file_get_contents($filename);
if (stripos($data, '<html') != false or stripos($data, '<head') != false or stripos($data, '<body') != false) {
    echo '<br /><center>This is not a valid impress file. Please check the documentation.</center>';
    exit;
}
if (stripos($data, '<script') != false) {
    echo '<br /><center>Please don\'t use javascript in impress files.</center>';
    exit;
}
header('Content-Type: text/html', true);
OCP\Response::disableCaching();
@ob_end_clean();
\OCA_Impress\Storage::showHeader($title);
\OC\Files\Filesystem::readfile($filename);
\OCA_Impress\Storage::showFooter();
开发者ID:DOM-Digital-Online-Media,项目名称:apps,代码行数:31,代码来源:player.php

示例14: getListing

 public function getListing($FOLDER, $showdel)
 {
     // Get the listing from the database
     $requery = false;
     $uid = \OCP\User::getUser();
     $query = \OCP\DB::prepare("SELECT id, name, grouping, mtime, deleted FROM *PREFIX*ownnote WHERE uid=? ORDER BY name");
     $results = $query->execute(array($uid))->fetchAll();
     $results2 = $results;
     if ($results) {
         foreach ($results as $result) {
             foreach ($results2 as $result2) {
                 if ($result['id'] != $result2['id'] && $result['name'] == $result2['name'] && $result['grouping'] == $result2['grouping']) {
                     // We have a duplicate that should not exist. Need to remove the offending record first
                     $delid = -1;
                     if ($result['mtime'] == $result2['mtime']) {
                         // If the mtime's match, delete the oldest ID.
                         $delid = $result['id'];
                         if ($result['id'] > $result2['id']) {
                             $delid = $result2['id'];
                         }
                     } elseif ($result['mtime'] > $result2['mtime']) {
                         // Again, delete the oldest
                         $delid = $result2['id'];
                     } elseif ($result['mtime'] < $result2['mtime']) {
                         // The only thing left is if result is older
                         $delid = $result['id'];
                     }
                     if ($delid != -1) {
                         $delquery = \OCP\DB::prepare("DELETE FROM *PREFIX*ownnote WHERE id=?");
                         $delquery->execute(array($delid));
                         $requery = true;
                     }
                 }
             }
         }
     }
     if ($requery) {
         $query = \OCP\DB::prepare("SELECT id, name, grouping, mtime, deleted FROM *PREFIX*ownnote WHERE uid=? ORDER BY name");
         $results = $query->execute(array($uid))->fetchAll();
         $requery = false;
     }
     // Tests to add a bunch of notes
     //$now = new DateTime();
     //for ($x = 0; $x < 199; $x++) {
     //saveNote('', "Test ".$x, '', '', $now->getTimestamp());
     //}
     $farray = array();
     if ($FOLDER != '') {
         // Create the folder if it doesn't exist
         if (!\OC\Files\Filesystem::is_dir($FOLDER)) {
             if (!\OC\Files\Filesystem::mkdir($FOLDER)) {
                 echo "ERROR: Could not create ownNote directory.";
                 exit;
             }
         }
         // Synchronize files to the database
         $filearr = array();
         if ($listing = \OC\Files\Filesystem::opendir($FOLDER)) {
             if (!$listing) {
                 echo "ERROR: Error listing directory.";
                 exit;
             }
             while (($file = readdir($listing)) !== false) {
                 $tmpfile = $file;
                 if ($tmpfile == "." || $tmpfile == "..") {
                     continue;
                 }
                 if (!$this->endsWith($tmpfile, ".htm") && !$this->endsWith($tmpfile, ".html")) {
                     continue;
                 }
                 if ($info = \OC\Files\Filesystem::getFileInfo($FOLDER . "/" . $tmpfile)) {
                     // Check for EVERNOTE but wait to rename them to get around:
                     // https://github.com/owncloud/core/issues/16202
                     if ($this->endsWith($tmpfile, ".html")) {
                         $this->checkEvernote($FOLDER, $tmpfile);
                     }
                     // Separate the name and group name
                     $name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $tmpfile);
                     $group = "";
                     if (substr($name, 0, 1) == "[") {
                         $end = strpos($name, ']');
                         $group = substr($name, 1, $end - 1);
                         $name = substr($name, $end + 1, strlen($name) - $end + 1);
                         $name = trim($name);
                     }
                     // Set array for later checking
                     $filearr[] = $tmpfile;
                     // Check to see if the file is in the DB
                     $fileindb = false;
                     if ($results) {
                         foreach ($results as $result) {
                             if ($result['deleted'] == 0) {
                                 if ($name == $result['name'] && $group == $result['grouping']) {
                                     $fileindb = true;
                                     // If it is in the DB, check if the filesystem file is newer than the DB
                                     if ($result['mtime'] < $info['mtime']) {
                                         // File is newer, this could happen if a user updates a file
                                         $html = "";
                                         $html = \OC\Files\Filesystem::file_get_contents($FOLDER . "/" . $tmpfile);
                                         $this->saveNote('', $result['name'], $result['grouping'], $html, $info['mtime']);
//.........这里部分代码省略.........
开发者ID:tumstech,项目名称:ownnote,代码行数:101,代码来源:backend.php

示例15: editNote

function editNote($FOLDER, $id) {
	$ret = "";
	if ($html = \OC\Files\Filesystem::file_get_contents($FOLDER."/".$id)) {
		$ret = $html;
	}
	return $ret;
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:7,代码来源:backend.php


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