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


PHP OC_Filesystem::fopen方法代码示例

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


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

示例1: file_assemble

 public function file_assemble($path)
 {
     $absolutePath = OC_Filesystem::normalizePath(OC_Filesystem::getView()->getAbsolutePath($path));
     $data = '';
     // use file_put_contents as method because that best matches what this function does
     if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) && OC_Filesystem::isValidPath($path)) {
         $path = OC_Filesystem::getView()->getRelativePath($absolutePath);
         $exists = OC_Filesystem::file_exists($path);
         $run = true;
         if (!$exists) {
             OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, array(OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
         }
         OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, array(OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run));
         if (!$run) {
             return false;
         }
         $target = OC_Filesystem::fopen($path, 'w');
         if ($target) {
             $count = $this->assemble($target);
             fclose($target);
             if (!$exists) {
                 OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_create, array(OC_Filesystem::signal_param_path => $path));
             }
             OC_Hook::emit(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array(OC_Filesystem::signal_param_path => $path));
             OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
             return $count > 0;
         } else {
             return false;
         }
     }
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:31,代码来源:filechunking.php

示例2: newFile

 /**
  * create a new file or folder
  *
  * @param dir  $dir
  * @param file $name
  * @param type $type
  */
 public static function newFile($dir, $name, $type)
 {
     if (OC_User::isLoggedIn()) {
         $file = $dir . '/' . $name;
         if ($type == 'dir') {
             return OC_Filesystem::mkdir($file);
         } elseif ($type == 'file') {
             $fileHandle = OC_Filesystem::fopen($file, 'w');
             if ($fileHandle) {
                 fclose($fileHandle);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:24,代码来源:files.php

示例3: get

 /**
  * Returns the data
  *
  * @return string
  */
 public function get()
 {
     return OC_Filesystem::fopen($this->path, 'r');
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:9,代码来源:file.php

示例4: 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

示例5: header

        header('WWW-Authenticate: Basic realm="ownCloud Server"');
        header('HTTP/1.0 401 Unauthorized');
        echo 'Valid credentials must be supplied';
        exit;
    } else {
        if (!OC_User::login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) {
            exit;
        }
    }
}
list($type, $file) = explode('/', substr($path_info, 1 + strlen($service) + 1), 2);
if ($type != 'oc_chunked') {
    OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
    die;
}
if (!OC_Filesystem::is_file($file)) {
    OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
    die;
}
switch ($_SERVER['REQUEST_METHOD']) {
    case 'PUT':
        $input = fopen("php://input", "r");
        $org_file = OC_Filesystem::fopen($file, 'rb');
        $info = array('name' => basename($file));
        $sync = new OC_FileChunking($info);
        $result = $sync->signature_split($org_file, $input);
        echo json_encode($result);
        break;
    default:
        OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
}
开发者ID:noci2012,项目名称:owncloud,代码行数:31,代码来源:filesync.php

示例6: fread

 * All rights reserved
 */
$filename = $_POST['filename'];
$json = false;
if (isset($_POST['json'])) {
    $json = (bool) $_POST["json"];
}
/*
 * max size of output file, to avoid reading a very big output and clogging the network
 */
$MAX_SIZE = 1024 * 512;
# "512k of memory should be enough for everyone"
$content = "";
if (OC_Filesystem::is_file($filename) && OC_Filesystem::is_readable($filename)) {
    if (OC_Filesystem::filesize($filename) > $MAX_SIZE) {
        $handle = OC_Filesystem::fopen($filename, "r");
        if ($handle) {
            $content = fread($handle, $MAX_SIZE);
            fclose($handle);
        }
    } else {
        $content = OC_Filesystem::file_get_contents($filename);
    }
} else {
    echo "ERROR: Cannot read " . $filename;
}
if ($json) {
    $json_obj = json_decode($content);
    foreach ($json_obj as $key => $value) {
        echo "{$key} : {$value}\n";
    }
开发者ID:v-iacovella,项目名称:NeuroBox,代码行数:31,代码来源:getoutput.php


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