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


PHP Files::buildNotExistingFileName方法代码示例

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


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

示例1: createShare

 /**
  * create a new share
  *
  * @param array $params
  * @return \OC_OCS_Result
  */
 public function createShare($params)
 {
     if (!$this->isS2SEnabled(true)) {
         return new \OC_OCS_Result(null, 503, 'Server does not support server-to-server sharing');
     }
     $remote = isset($_POST['remote']) ? $_POST['remote'] : null;
     $token = isset($_POST['token']) ? $_POST['token'] : null;
     $name = isset($_POST['name']) ? $_POST['name'] : null;
     $owner = isset($_POST['owner']) ? $_POST['owner'] : null;
     $shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
     $remoteId = isset($_POST['remoteId']) ? (int) $_POST['remoteId'] : null;
     if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
         if (!\OCP\Util::isValidFileName($name)) {
             return new \OC_OCS_Result(null, 400, 'The mountpoint name contains invalid characters.');
         }
         if (!\OCP\User::userExists($shareWith)) {
             return new \OC_OCS_Result(null, 400, 'User does not exists');
         }
         \OC_Util::setupFS($shareWith);
         $externalManager = new \OCA\Files_Sharing\External\Manager(\OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getUserSession(), \OC::$server->getHTTPHelper());
         $name = \OCP\Files::buildNotExistingFileName('/', $name);
         try {
             $externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId);
             $user = $owner . '@' . $this->cleanupRemote($remote);
             \OC::$server->getActivityManager()->publishActivity('files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user), '', array(), '', '', $shareWith, \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_LOW);
             return new \OC_OCS_Result();
         } catch (\Exception $e) {
             \OCP\Util::writeLog('files_sharing', 'server can not add remote share, ' . $e->getMessage(), \OCP\Util::ERROR);
             return new \OC_OCS_Result(null, 500, 'internal server error, was not able to add share from ' . $remote);
         }
     }
     return new \OC_OCS_Result(null, 400, 'server can not add remote share, missing parameter');
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:39,代码来源:server2server.php

示例2: acceptShare

    /**
     * accept server-to-server share
     *
     * @param int $id
     * @return bool True if the share could be accepted, false otherwise
     */
    public function acceptShare($id)
    {
        $share = $this->getShare($id);
        if ($share) {
            $mountPoint = Files::buildNotExistingFileName('/', $share['name']);
            $mountPoint = Filesystem::normalizePath('/' . $mountPoint);
            $hash = md5($mountPoint);
            $acceptShare = $this->connection->prepare('
				UPDATE `*PREFIX*share_external`
				SET `accepted` = ?,
					`mountpoint` = ?,
					`mountpoint_hash` = ?
				WHERE `id` = ? AND `user` = ?');
            $acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid));
            $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
            //FIXME $this->scrapNotification($share['remote_id']);
            return true;
        }
        return false;
    }
开发者ID:slapia,项目名称:core,代码行数:26,代码来源:manager.php

示例3: doCompile

 /**
  * Compile Latex File
  *
  * @NoAdminRequired
  *
  * @param string $path
  * @param string $filename
  * @param string $compiler
  * @return DataResponse
  */
 public function doCompile($path, $filename, $compiler)
 {
     $success = 'success';
     $error = 'error';
     try {
         set_time_limit(0);
         //scanning can take ages
         // If they've set the compiler to something other than an allowable option....
         if (!($compiler === 'xelatex' || $compiler === 'pdflatex' || $compiler === 'latex')) {
             $compiler = 'latex';
         }
         // The real directory file
         $workdir = dirname(\OC\Files\Filesystem::getLocalFile(stripslashes($path) . $filename));
         $info = pathinfo($filename);
         $fileext = '.' . $info['extension'];
         $projectname = trim(basename($filename, $fileext));
         $pdffile = $projectname . '.pdf';
         $dvifile = $projectname . '.dvi';
         $psfile = $projectname . '.ps';
         $tocfile = $projectname . '.toc';
         $logfile = $projectname . '.log';
         $bibfile = $projectname;
         // Bibtex File is without extension
         // As we will write pdf/ps file(s) in the $path, we need to known if it's writable
         if (!\OC\Files\Filesystem::isCreatable(stripslashes($path))) {
             return new JSONResponse(array('data' => array('message' => 'As you don\'t have write permission in the owner directory, it\'s not possible to create output latex files.', 'output' => '')), Http::STATUS_BAD_REQUEST);
         }
         // Command to jump into directory
         $cd_command = "cd " . str_replace(' ', '\\ ', trim($workdir));
         // PDFLatex command preparation
         if ($compiler == 'xelatex' || $compiler == 'pdflatex') {
             $latex_command = $compiler . ' ' . $filename;
             $bibtex_command = 'bibtex ' . $bibfile;
         } else {
             $latex_command = "latex -output-directory={$outpath}  {$filename} ; cd {$outpath}; dvips  {$dvifile} ; ps2pdf {$psfile}";
         }
         $output = "<b>========BEGIN COMPILE========</b>\n{$psfile} \n";
         $output .= $cd_command . "\n";
         $output .= getcwd() . "\n";
         // First Compile
         $output .= shell_exec($cd_command . " && pwd");
         $return = shell_exec($cd_command . " && " . $latex_command);
         $output .= getcwd() . "\n";
         // For BibTeX
         if ($compiler == 'pdflatex') {
             // Second compile step with bibtex
             $return .= shell_exec($cd_command . " && " . $bibtex_command);
             // compile again after bibtex
             $return .= shell_exec($cd_command . " && " . $latex_command);
         }
         $logfile = $workdir . '/' . $logfile;
         $log = file_get_contents($logfile);
         while (preg_match('/Return to get cross-references right/', $log) || preg_match('/No file ' . $tocfile . '/', $log)) {
             $return .= shell_exec($cd_command . " && " . $this->latex_command);
             $log = file_get_contents($logfile);
         }
         // ! at begining of a line indicate an error!
         $errors = preg_grep("/^!/", explode("\n", $log));
         if (empty($errors) === false) {
             $log_array = explode("\n", $log);
             $error = "\n";
             foreach ($errors as $line => $msg) {
                 for ($i = $line; $i <= $line + 5; $i++) {
                     $error .= $log_array[$i] . "\n";
                 }
             }
             return new JSONResponse(array('data' => array('message' => $this->l->t('Compile failed with errors') . ' - <br/>', 'output' => nl2br($output . " % " . $latex_command . "\n" . $error)), 'status' => $error), Http::STATUS_OK);
         }
         // No PDF File !?
         if (!file_exists($workdir . '/' . $pdffile)) {
             return new JSONResponse(array('data' => array('message' => $this->l->t('Compile failed with errors') . ':<br/>', 'output' => nl2br($output . " % " . $latex_command . "\n" . file_get_contents($outpath . '/' . $logfile))), 'status' => $error), Http::STATUS_OK);
         }
         $output .= $return;
         $output .= "\n========END COMPILE==========\n";
         $oc_workdir = stripslashes(\OC\Files\Filesystem::getLocalPath($workdir));
         $target = \OCP\Files::buildNotExistingFileName($oc_workdir, $pdffile);
         $target = \OC\Files\Filesystem::normalizePath($target);
         $meta = \OC\Files\Filesystem::getFileInfo($target);
         if ($compiler === 'latex') {
             $target = \OCP\Files::buildNotExistingFileName($oc_workdir, $psfile);
             $target = \OC\Files\Filesystem::normalizePath($target);
             $meta = \OC\Files\Filesystem::getFileInfo($target);
         }
         return new JSONResponse(array('data' => array('output' => nl2br($output), 'path' => $path, 'pdffile' => $pdffile, 'psfile' => $psfile, 'logfile' => $logfile), 'status' => $success), Http::STATUS_OK);
     } catch (\Exception $e) {
         return new DataResponse(['message' => $e], Http::STATUS_BAD_REQUEST);
     }
 }
开发者ID:Aypac,项目名称:files_latexeditor,代码行数:98,代码来源:compilecontroller.php

示例4: upload

 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  * @SSOCORS
  */
 public function upload($dir = '/')
 {
     \OC::$server->getSession()->close();
     // Firefox and Konqueror tries to download application/json for me.  --Arthur
     \OCP\JSON::setContentTypeHeader('text/plain');
     // If a directory token is sent along check if public upload is permitted.
     // If not, check the login.
     // If no token is sent along, rely on login only
     $allowedPermissions = \OCP\Constants::PERMISSION_ALL;
     $errorCode = null;
     if (\OC\Files\Filesystem::file_exists($dir) === false) {
         return new DataResponse(array('data' => array_merge(array('message' => 'Invalid directory.')), 'status' => 'error'));
     }
     // get array with current storage stats (e.g. max file size)
     $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
     $files = $this->request->getUploadedFile('files');
     if (!isset($files)) {
         return new DataResponse(array('data' => array_merge(array('message' => 'No file was uploaded. Unknown error'), $storageStats), 'status' => 'error'));
     }
     foreach ($files['error'] as $error) {
         if ($error != 0) {
             $errors = array(UPLOAD_ERR_OK => 'There is no error, the file uploaded with success', UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini: ' . ini_get('upload_max_filesize'), UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder', UPLOAD_ERR_CANT_WRITE => 'Failed to write to disk');
             $errorMessage = $errors[$error];
             \OC::$server->getLogger()->alert("Upload error: {$error} - {$errorMessage}", array('app' => 'files'));
             return new DataResponse(array('data' => array_merge(array('message' => $errorMessage), $storageStats), 'status' => 'error'));
         }
     }
     $error = false;
     $maxUploadFileSize = $storageStats['uploadMaxFilesize'];
     $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
     $totalSize = 0;
     foreach ($files['size'] as $size) {
         $totalSize += $size;
     }
     if ($maxUploadFileSize >= 0 and $totalSize > $maxUploadFileSize) {
         return new DataResponse(array('data' => array('message' => 'Not enough storage available', 'uploadMaxFilesize' => $maxUploadFileSize, '   maxHumanFilesize' => $maxHumanFileSize), 'status' => 'error'));
     }
     $result = array();
     $fileCount = count($files['name']);
     for ($i = 0; $i < $fileCount; $i++) {
         // target directory for when uploading folders
         $relativePath = '';
         $target = \OC\Files\Filesystem::normalizePath($dir . $relativePath . '/' . $files['name'][$i]);
         // relative dir to return to the client
         if (isset($publicDirectory)) {
             // path relative to the public root
             $returnedDir = $publicDirectory . $relativePath;
         } else {
             // full path
             $returnedDir = $dir . $relativePath;
         }
         $returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir);
         $exists = \OC\Files\Filesystem::file_exists($target);
         if ($exists) {
             $target = \OCP\Files::buildNotExistingFileName($dir . $relativePath, $files['name'][$i]);
         }
         try {
             if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
                 // updated max file size after upload
                 $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
                 $meta = \OC\Files\Filesystem::getFileInfo($target);
                 if ($meta === false) {
                     $error = 'The target folder has been moved or deleted.';
                     $errorCode = 'targetnotfound';
                 } else {
                     $data = \OCA\Files\Helper::formatFileInfo($meta);
                     $data['originalname'] = $files['name'][$i];
                     $data['uploadMaxFilesize'] = $maxUploadFileSize;
                     $data['maxHumanFilesize'] = $maxHumanFileSize;
                     $data['permissions'] = $meta['permissions'] & $allowedPermissions;
                     $data['directory'] = $returnedDir;
                     $result[] = $data;
                 }
             } else {
                 $error = 'Upload failed. Could not find uploaded file';
             }
         } catch (Exception $ex) {
             $error = $ex->getMessage();
         }
     }
     if ($error === false) {
         $result = \OCP\JSON::encode($result);
         return new DataResponse(array('data' => $result, 'status' => 'success'));
     } else {
         return new DataResponse(array('data' => array_merge(array('message' => $error, 'code' => $errorCode), $storageStats), 'status' => 'error'));
     }
 }
开发者ID:inwinstack,项目名称:owncloud-singlesignon,代码行数:92,代码来源:collaborationapicontroller.php


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