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


PHP OC_Filesystem::file_exists方法代码示例

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


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

示例1: getThumbnail

 public function getThumbnail($path)
 {
     $gallery_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/gallery';
     if (file_exists($gallery_path . $path)) {
         return new \OC_Image($gallery_path . $path);
     }
     if (!\OC_Filesystem::file_exists($path)) {
         \OC_Log::write(self::TAG, 'File ' . $path . ' don\'t exists', \OC_Log::WARN);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromFile(\OC_Filesystem::getLocalFile($path));
     if (!$image->valid()) {
         return false;
     }
     $image->fixOrientation();
     $ret = $image->preciseResize(floor(150 * $image->width() / $image->height()), 150);
     if (!$ret) {
         \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR);
         unset($image);
         return false;
     }
     $image->save($gallery_path . '/' . $path);
     return $image;
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:25,代码来源:managers.php

示例2: thumb

function thumb($path)
{
    $thumb_path = \OCP\Config::getSystemValue('datadirectory') . '/' . \OC_User::getUser() . '/reader';
    if (file_exists($thumb_path . $path)) {
        return new \OC_Image($thumb_path . $path);
    }
    if (!\OC_Filesystem::file_exists($path)) {
        return false;
    }
}
开发者ID:netcon-source,项目名称:apps,代码行数:10,代码来源:thumbnail.php

示例3: createDataScope

 public static function createDataScope($appUrl, $userAddress, $dataScope)
 {
     $token = uniqid();
     self::addToken($token, $appUrl, $userAddress, $dataScope);
     //TODO: input checking on $userAddress and $dataScope
     list($userName, $userHost) = explode('@', $userAddress);
     OC_Util::setupFS(OC_User::getUser());
     $scopePathParts = array('remoteStorage', 'webdav', $userHost, $userName, $dataScope);
     for ($i = 0; $i <= count($scopePathParts); $i++) {
         $thisPath = '/' . implode('/', array_slice($scopePathParts, 0, $i));
         if (!OC_Filesystem::file_exists($thisPath)) {
             OC_Filesystem::mkdir($thisPath);
         }
     }
     return $token;
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:16,代码来源:owncloud_apps_remoteStorage_lib_remoteStorage.php

示例4: createCategories

 public static function createCategories($appUrl, $categories)
 {
     $token = uniqid();
     OC_Util::setupFS(OC_User::getUser());
     self::addToken($token, $appUrl, $categories);
     foreach (explode(',', $categories) as $category) {
         //TODO: input checking on $category
         $scopePathParts = array('remoteStorage', $category);
         for ($i = 0; $i <= count($scopePathParts); $i++) {
             $thisPath = '/' . implode('/', array_slice($scopePathParts, 0, $i));
             if (!OC_Filesystem::file_exists($thisPath)) {
                 OC_Filesystem::mkdir($thisPath);
             }
         }
     }
     return base64_encode('remoteStorage:' . $token);
 }
开发者ID:nethad,项目名称:experiments,代码行数:17,代码来源:lib_remoteStorage.php

示例5: handleStoreSettings

function handleStoreSettings($root, $order)
{
    if (!OC_Filesystem::file_exists($root)) {
        OCP\JSON::error(array('cause' => 'No such file or directory'));
        return;
    }
    if (!OC_Filesystem::is_dir($root)) {
        OCP\JSON::error(array('cause' => $root . ' is not a directory'));
        return;
    }
    $current_root = OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'root', '/');
    $root = trim($root);
    $root = rtrim($root, '/') . '/';
    $rescan = $current_root == $root ? 'no' : 'yes';
    OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'root', $root);
    OCP\Config::setUserValue(OCP\USER::getUser(), 'gallery', 'order', $order);
    OCP\JSON::success(array('rescan' => $rescan));
}
开发者ID:blablubli,项目名称:owncloudapps,代码行数:18,代码来源:galleryOp.php

示例6: header

         // Check if item id is set in session
     } else {
         if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) {
             // Prompt for password
             $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest');
             $tmpl->assign('URL', OCP\Util::linkToPublic('files') . '&file=' . $_GET['file']);
             $tmpl->printPage();
             exit;
         }
     }
 }
 $path = $linkItem['path'];
 if (isset($_GET['path'])) {
     $path .= $_GET['path'];
     $dir .= $_GET['path'];
     if (!OC_Filesystem::file_exists($path)) {
         header('HTTP/1.0 404 Not Found');
         $tmpl = new OCP\Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     }
 }
 // Download the file
 if (isset($_GET['download'])) {
     if (isset($_GET['dir'])) {
         if (isset($_GET['files'])) {
             // download selected files
             OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
         } else {
             if (isset($_GET['path']) && $_GET['path'] != '') {
                 // download a file from a shared directory
开发者ID:noci2012,项目名称:owncloud,代码行数:31,代码来源:public.php

示例7: getHttpFile

 /**
  * Get the file by an URL
  * @param URL of the file
  */
 public static function getHttpFile($file, $pr_transfer = NULL)
 {
     try {
         if (!self::remoteFileExists($file)) {
             return 'The file does not exists ...';
         }
         if (!isset($pr_transfer)) {
             $fileinfo = pathinfo($file);
         } else {
             $fileinfo = pathinfo($pr_transfer);
         }
         $filename = strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? preg_replace('/\\./', '%2e', $fileinfo['basename'], substr_count($fileinfo['basename'], '.') - 1) : $fileinfo['basename'];
         if (strpos($filename, 'rsapi.cgi')) {
             $filename = substr($filename, 0, strpos($filename, '&'));
         }
         if (OC_Filesystem::file_exists('/Downloads/' . $filename)) {
             $filename = md5(rand()) . '_' . $filename;
         }
         $fs = OC_Filesystem::fopen('/Downloads/' . $filename, 'w');
         $size = self::getRemoteFileSize($file);
         if ($size == 0) {
             return 'Error ! Null file size.';
         }
         switch (strtolower($fileinfo['extension'])) {
             case 'exe':
                 $ctype = 'application/octet-stream';
                 break;
             case 'zip':
                 $ctype = 'application/zip';
                 break;
             case 'mp3':
                 $ctype = 'audio/mpeg';
                 break;
             case 'mpg':
                 $ctype = 'video/mpeg';
                 break;
             case 'avi':
                 $ctype = 'video/x-msvideo';
                 break;
             case 'png':
                 $ctype = 'image/png';
                 break;
             default:
                 $ctype = 'application/force-download';
         }
         $seek_end = empty($seek_end) ? $size - 1 : min(abs(intval($seek_end)), $size - 1);
         $seek_start = empty($seek_start) || $seek_end < abs(intval($seek_start)) ? 0 : max(abs(intval($seek_start)), 0);
         /*header("Cache-Control: cache, must-revalidate");  
           header("Pragma: public");
           header('Content-Type: ' . $ctype);
           header('Content-Disposition: attachment; filename="' . $filename . '"');
           header('Content-Length: ' . ($seek_end - $seek_start + 1));*/
         $fp = fopen($file, 'rb');
         set_time_limit(0);
         while (!feof($fp)) {
             $data = fread($fp, 1024 * 8);
             if ($data == '') {
                 break;
             }
             fwrite($fs, $data);
         }
         fclose($fp);
         fclose($fs);
         return array('ok' => 'Transfer completed successfully. The file has been moved in your Downloads folder.');
     } catch (exception $e) {
         return array('error' => $e->getMessage());
     }
 }
开发者ID:blablubli,项目名称:owncloudapps,代码行数:72,代码来源:ocDownloaderFile.class.php

示例8: childExists

 /**
  * Checks if a child exists.
  *
  * @param string $name
  * @return bool
  */
 public function childExists($name)
 {
     $path = $this->path . '/' . $name;
     return OC_Filesystem::file_exists($path);
 }
开发者ID:ryanshoover,项目名称:core,代码行数:11,代码来源:directory.php

示例9: buildNotExistingFileName

 /**
  * Adds a suffix to the name in case the file exists
  *
  * @param $path
  * @param $filename
  * @return string
  */
 public static function buildNotExistingFileName($path, $filename)
 {
     if ($path === '/') {
         $path = '';
     }
     if ($pos = strrpos($filename, '.')) {
         $name = substr($filename, 0, $pos);
         $ext = substr($filename, $pos);
     } else {
         $name = $filename;
     }
     $newpath = $path . '/' . $filename;
     $newname = $filename;
     $counter = 2;
     while (OC_Filesystem::file_exists($newpath)) {
         $newname = $name . ' (' . $counter . ')' . $ext;
         $newpath = $path . '/' . $newname;
         $counter++;
     }
     return $newpath;
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:28,代码来源:helper.php

示例10: get

 /**
  * return the content of a file or return a zip file containning multiply files
  *
  * @param dir  $dir
  * @param file $file ; seperated list of files to download
  */
 public static function get($dir, $files)
 {
     if (strpos($files, ';')) {
         $files = explode(';', $files);
     }
     if (is_array($files)) {
         $zip = new ZipArchive();
         $filename = sys_get_temp_dir() . "/ownCloud.zip";
         if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
             exit("cannot open <{$filename}>\n");
         }
         foreach ($files as $file) {
             $file = $dir . '/' . $file;
             if (OC_Filesystem::is_file($file)) {
                 $tmpFile = OC_Filesystem::toTmpFile($file);
                 self::$tmpFiles[] = $tmpFile;
                 $zip->addFile($tmpFile, basename($file));
             } elseif (OC_Filesystem::is_dir($file)) {
                 self::zipAddDir($file, $zip);
             }
         }
         $zip->close();
     } elseif (OC_Filesystem::is_dir($dir . '/' . $files)) {
         $zip = new ZipArchive();
         $filename = sys_get_temp_dir() . "/ownCloud.zip";
         if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
             exit("cannot open <{$filename}>\n");
         }
         $file = $dir . '/' . $files;
         self::zipAddDir($file, $zip);
         $zip->close();
     } else {
         $zip = false;
         $filename = $dir . '/' . $files;
     }
     if ($zip or OC_Filesystem::is_readable($filename)) {
         header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
         header('Content-Transfer-Encoding: binary');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         if ($zip) {
             header('Content-Type: application/zip');
             header('Content-Length: ' . filesize($filename));
         } else {
             header('Content-Type: ' . OC_Filesystem::getMimeType($filename));
             header('Content-Length: ' . OC_Filesystem::filesize($filename));
         }
     } elseif ($zip or !OC_Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->assign('file', $filename);
         $tmpl->printPage();
         // 			die('404 Not Found');
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     @ob_end_clean();
     if ($zip) {
         readfile($filename);
         unlink($filename);
     } else {
         OC_Filesystem::readfile($filename);
     }
     foreach (self::$tmpFiles as $tmpFile) {
         if (file_exists($tmpFile) and is_file($tmpFile)) {
             unlink($tmpFile);
         }
     }
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:77,代码来源:owncloud_lib_files.php

示例11: postFopen

 public function postFopen($path, &$result)
 {
     if (!$result) {
         return $result;
     }
     $meta = stream_get_meta_data($result);
     if (self::isEncrypted($path)) {
         fclose($result);
         $result = fopen('crypt://' . $path, $meta['mode']);
     } elseif (self::shouldEncrypt($path) and $meta['mode'] != 'r' and $meta['mode'] != 'rb') {
         if (OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path) > 0) {
             //first encrypt the target file so we don't end up with a half encrypted file
             OCP\Util::writeLog('files_encryption', 'Decrypting ' . $path . ' before writing', OCP\Util::DEBUG);
             $tmp = fopen('php://temp');
             OCP\Files::streamCopy($result, $tmp);
             fclose($result);
             OC_Filesystem::file_put_contents($path, $tmp);
             fclose($tmp);
         }
         $result = fopen('crypt://' . $path, $meta['mode']);
     }
     return $result;
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:23,代码来源:proxy.php

示例12: getThumbnailInfo

 public function getThumbnailInfo($path)
 {
     $arr = DatabaseManager::getInstance()->getFileData($path);
     if (!$arr) {
         if (!\OC_Filesystem::file_exists($path)) {
             \OC_Log::write(self::TAG, 'File ' . $path . ' don\'t exists', \OC_Log::WARN);
             return false;
         }
         $image = new \OC_Image();
         $image->loadFromFile(\OC_Filesystem::getLocalFile($path));
         if (!$image->valid()) {
             return false;
         }
         $arr = DatabaseManager::getInstance()->setFileData($path, $this->getThumbnailWidth($image), self::THUMBNAIL_HEIGHT);
     }
     $ret = array('filepath' => $arr['path'], 'width' => $arr['width'], 'height' => $arr['height']);
     return $ret;
 }
开发者ID:blablubli,项目名称:owncloudapps,代码行数:18,代码来源:managers.php

示例13: flush

     flush();
     break;
 case 'scanFile':
     echo OC_MEDIA_SCANNER::scanFile($arguments['path']) ? 'true' : 'false';
     break;
 case 'get_artists':
     OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getArtists($arguments['search']));
     break;
 case 'get_albums':
     OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'], $arguments['search']));
     break;
 case 'get_songs':
     OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getSongs($arguments['artist'], $arguments['album'], $arguments['search']));
     break;
 case 'get_path_info':
     if (OC_Filesystem::file_exists($arguments['path'])) {
         $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
         if ($songId == 0) {
             unset($_SESSION['collection']);
             $songId = OC_MEDIA_SCANNER::scanFile($arguments['path']);
         }
         if ($songId > 0) {
             $song = OC_MEDIA_COLLECTION::getSong($songId);
             $song['artist'] = OC_MEDIA_COLLECTION::getArtistName($song['song_artist']);
             $song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
             OC_JSON::encodedPrint($song);
         }
     }
     break;
 case 'play':
     ob_end_clean();
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_apps_media_ajax_api.php

示例14: stripslashes

<?php

// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
// Get data
$dir = stripslashes($_GET["dir"]);
$file = stripslashes($_GET["file"]);
$target = stripslashes(rawurldecode($_GET["target"]));
if (OC_Filesystem::file_exists($target . '/' . $file)) {
    OCP\JSON::error(array("data" => array("message" => "Could not move {$file} - File with this name already exists")));
    exit;
}
if (OC_Files::move($dir, $file, $target, $file)) {
    OCP\JSON::success(array("data" => array("dir" => $dir, "files" => $file)));
} else {
    OCP\JSON::error(array("data" => array("message" => "Could not move {$file}")));
}
开发者ID:ryanshoover,项目名称:core,代码行数:18,代码来源:move.php

示例15: header

* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* 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\User::checkLoggedIn();
$filename = $_GET["file"];
if (!OC_Filesystem::file_exists($filename)) {
    header("HTTP/1.0 404 Not Found");
    $tmpl = new OCP\Template('', '404', 'guest');
    $tmpl->assign('file', $filename);
    $tmpl->printPage();
    exit;
}
$ftype = OC_Filesystem::getMimeType($filename);
header('Content-Type:' . $ftype);
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
OCP\Response::disableCaching();
header('Content-Length: ' . OC_Filesystem::filesize($filename));
@ob_end_clean();
OC_Filesystem::readfile($filename);
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:31,代码来源:download.php


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