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


PHP OC_Template::printPage方法代码示例

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


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

示例1: setupFS

 public static function setupFS($user = "", $root = "files")
 {
     // configure the initial filesystem based on the configuration
     if (self::$fsSetup) {
         //setting up the filesystem twice can only lead to trouble
         return false;
     }
     $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     $CONFIG_BACKUPDIRECTORY = OC_Config::getValue("backupdirectory", OC::$SERVERROOT . "/backup");
     // Check if config folder is writable.
     if (!is_writable(OC::$SERVERROOT . "/config/")) {
         $tmpl = new OC_Template('', 'error', 'guest');
         $tmpl->assign('errors', array(1 => array('error' => "Can't write into config directory 'config'", 'hint' => "You can usually fix this by giving the webserver user write access to the config directory in owncloud")));
         $tmpl->printPage();
         exit;
     }
     // Check if apps folder is writable.
     if (!is_writable(OC::$SERVERROOT . "/apps/")) {
         $tmpl = new OC_Template('', 'error', 'guest');
         $tmpl->assign('errors', array(1 => array('error' => "Can't write into apps directory 'apps'", 'hint' => "You can usually fix this by giving the webserver user write access to the config directory in owncloud")));
         $tmpl->printPage();
         exit;
     }
     // Create root dir.
     if (!is_dir($CONFIG_DATADIRECTORY_ROOT)) {
         $success = @mkdir($CONFIG_DATADIRECTORY_ROOT);
         if (!$success) {
             $tmpl = new OC_Template('', 'error', 'guest');
             $tmpl->assign('errors', array(1 => array('error' => "Can't create data directory (" . $CONFIG_DATADIRECTORY_ROOT . ")", 'hint' => "You can usually fix this by giving the webserver write access to the ownCloud directory '" . OC::$SERVERROOT . "' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' ")));
             $tmpl->printPage();
             exit;
         }
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     //first set up the local "root" storage
     if (!self::$rootMounted) {
         OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $CONFIG_DATADIRECTORY_ROOT), '/');
         self::$rootMounted = true;
     }
     if ($user != "") {
         //if we aren't logged in, there is no use to set up the filesystem
         OC::$CONFIG_DATADIRECTORY = $CONFIG_DATADIRECTORY_ROOT . "/{$user}/{$root}";
         if (!is_dir(OC::$CONFIG_DATADIRECTORY)) {
             mkdir(OC::$CONFIG_DATADIRECTORY, 0755, true);
         }
         //jail the user into his "home" directory
         OC_Filesystem::init('/' . $user . '/' . $root);
         $quotaProxy = new OC_FileProxy_Quota();
         OC_FileProxy::register($quotaProxy);
         self::$fsSetup = true;
     }
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:55,代码来源:util.php

示例2: dopre

 public function dopre()
 {
     $user = OC_User::getUser();
     if (!$user) {
         return false;
     }
     if (!OC_User::isEnabled($user) && OC_User::userExists($user)) {
         header('HTTP/1.1 401 Unauthorized');
         header('Status: 401 Unauthorized');
         $template = new \OC_Template('user_permission', 'userdisable', 'guest');
         $template->printPage();
         die;
     }
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:14,代码来源:userpermissionprefilter.php

示例3: explode

    }
    $subadmins = false;
}
// load preset quotas
$quotaPreset = $config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
$quotaPreset = explode(',', $quotaPreset);
foreach ($quotaPreset as &$preset) {
    $preset = trim($preset);
}
$quotaPreset = array_diff($quotaPreset, array('default', 'none'));
$defaultQuota = $config->getAppValue('files', 'default_quota', 'none');
$defaultQuotaIsUserDefined = array_search($defaultQuota, $quotaPreset) === false && array_search($defaultQuota, array('none', 'default')) === false;
$tmpl = new OC_Template("settings", "users/main", "user");
$tmpl->assign('groups', $groups);
$tmpl->assign('sortGroups', $sortGroupsBy);
$tmpl->assign('adminGroup', $adminGroup);
$tmpl->assign('isAdmin', (int) $isAdmin);
$tmpl->assign('subadmins', $subadmins);
$tmpl->assign('numofgroups', count($groups) + count($adminGroup));
$tmpl->assign('quota_preset', $quotaPreset);
$tmpl->assign('default_quota', $defaultQuota);
$tmpl->assign('defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
$tmpl->assign('recoveryAdminEnabled', $recoveryAdminEnabled);
$tmpl->assign('enableAvatars', \OC::$server->getConfig()->getSystemValue('enable_avatars', true));
$tmpl->assign('show_storage_location', $config->getAppValue('core', 'umgmt_show_storage_location', 'false'));
$tmpl->assign('show_last_login', $config->getAppValue('core', 'umgmt_show_last_login', 'false'));
$tmpl->assign('show_email', $config->getAppValue('core', 'umgmt_show_email', 'false'));
$tmpl->assign('show_backend', $config->getAppValue('core', 'umgmt_show_backend', 'false'));
$tmpl->assign('send_email', $config->getAppValue('core', 'umgmt_send_email', 'false'));
$tmpl->printPage();
开发者ID:nem0xff,项目名称:core,代码行数:30,代码来源:users.php

示例4: get

 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $files ; separated list of files to download
  * @param boolean $only_header ; boolean to only send header of the request
  */
 public static function get($dir, $files, $only_header = false)
 {
     $xsendfile = false;
     if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
         $xsendfile = true;
     }
     if (is_array($files) && count($files) === 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         $get_type = GET_TYPE::ZIP_FILES;
         $basename = basename($dir);
         if ($basename) {
             $name = $basename . '.zip';
         } else {
             $name = 'download.zip';
         }
         $filename = $dir . '/' . $name;
     } else {
         $filename = $dir . '/' . $files;
         if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
             $get_type = GET_TYPE::ZIP_DIR;
             // downloading root ?
             if ($files === '') {
                 $name = 'download.zip';
             } else {
                 $name = $files . '.zip';
             }
         } else {
             $get_type = GET_TYPE::FILE;
             $name = $files;
         }
     }
     if ($get_type === GET_TYPE::FILE) {
         $zip = false;
         if ($xsendfile && OC_App::isEnabled('files_encryption')) {
             $xsendfile = false;
         }
     } else {
         $zip = new ZipStreamer(false);
     }
     OC_Util::obEnd();
     if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name, $zip);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->assign('file', $name);
         $tmpl->printPage();
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($only_header) {
         return;
     }
     if ($zip) {
         $executionTime = intval(ini_get('max_execution_time'));
         set_time_limit(0);
         if ($get_type === GET_TYPE::ZIP_FILES) {
             foreach ($files as $file) {
                 $file = $dir . '/' . $file;
                 if (\OC\Files\Filesystem::is_file($file)) {
                     $fh = \OC\Files\Filesystem::fopen($file, 'r');
                     $zip->addFileFromStream($fh, basename($file));
                     fclose($fh);
                 } elseif (\OC\Files\Filesystem::is_dir($file)) {
                     self::zipAddDir($file, $zip);
                 }
             }
         } elseif ($get_type === GET_TYPE::ZIP_DIR) {
             $file = $dir . '/' . $files;
             self::zipAddDir($file, $zip);
         }
         $zip->finalize();
         set_time_limit($executionTime);
     } else {
         if ($xsendfile) {
             $view = \OC\Files\Filesystem::getView();
             /** @var $storage \OC\Files\Storage\Storage */
             list($storage) = $view->resolvePath($filename);
             if ($storage->isLocal()) {
                 self::addSendfileHeader($filename);
             } else {
                 \OC\Files\Filesystem::readfile($filename);
             }
         } else {
             \OC\Files\Filesystem::readfile($filename);
         }
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:98,代码来源:files.php

示例5: printExceptionErrorPage

 /**
  * print error page using Exception details
  * @param Exception $exception
  */
 public static function printExceptionErrorPage($exception)
 {
     try {
         $request = \OC::$server->getRequest();
         $content = new \OC_Template('', 'exception', 'error', false);
         $content->assign('errorClass', get_class($exception));
         $content->assign('errorMsg', $exception->getMessage());
         $content->assign('errorCode', $exception->getCode());
         $content->assign('file', $exception->getFile());
         $content->assign('line', $exception->getLine());
         $content->assign('trace', $exception->getTraceAsString());
         $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
         $content->assign('remoteAddr', $request->getRemoteAddress());
         $content->assign('requestID', $request->getId());
         $content->printPage();
     } catch (\Exception $e) {
         $logger = \OC::$server->getLogger();
         $logger->logException($exception, ['app' => 'core']);
         $logger->logException($e, ['app' => 'core']);
         header(self::getHttpProtocol() . ' 500 Internal Server Error');
         header('Content-Type: text/plain; charset=utf-8');
         print "Internal Server Error\n\n";
         print "The server encountered an internal error and was unable to complete your request.\n";
         print "Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n";
         print "More details can be found in the server log.\n";
     }
     die;
 }
开发者ID:DanielTosello,项目名称:owncloud,代码行数:32,代码来源:template.php

示例6: printUpgradePage

 /**
  * Prints the upgrade page
  */
 private static function printUpgradePage()
 {
     $systemConfig = \OC::$server->getSystemConfig();
     $oldTheme = $systemConfig->getValue('theme');
     $systemConfig->setValue('theme', '');
     \OCP\Util::addScript('config');
     // needed for web root
     \OCP\Util::addScript('update');
     // check whether this is a core update or apps update
     $installedVersion = $systemConfig->getValue('version', '0.0.0');
     $currentVersion = implode('.', OC_Util::getVersion());
     $appManager = \OC::$server->getAppManager();
     $tmpl = new OC_Template('', 'update.admin', 'guest');
     $tmpl->assign('version', OC_Util::getVersionString());
     // if not a core upgrade, then it's apps upgrade
     if (version_compare($currentVersion, $installedVersion, '=')) {
         $tmpl->assign('isAppsOnlyUpgrade', true);
     } else {
         $tmpl->assign('isAppsOnlyUpgrade', false);
     }
     // get third party apps
     $ocVersion = OC_Util::getVersion();
     $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
     $tmpl->assign('incompatibleAppsList', $appManager->getIncompatibleApps($ocVersion));
     $tmpl->assign('productName', 'ownCloud');
     // for now
     $tmpl->assign('oldTheme', $oldTheme);
     $tmpl->printPage();
 }
开发者ID:krsvital,项目名称:core,代码行数:32,代码来源:base.php

示例7: printExceptionErrorPage

 /**
  * print error page using Exception details
  * @param Exception $exception
  */
 public static function printExceptionErrorPage(Exception $exception)
 {
     $request = \OC::$server->getRequest();
     $content = new \OC_Template('', 'exception', 'error', false);
     $content->assign('errorClass', get_class($exception));
     $content->assign('errorMsg', $exception->getMessage());
     $content->assign('errorCode', $exception->getCode());
     $content->assign('file', $exception->getFile());
     $content->assign('line', $exception->getLine());
     $content->assign('trace', $exception->getTraceAsString());
     $content->assign('debugMode', defined('DEBUG') && DEBUG === true);
     $content->assign('remoteAddr', $request->getRemoteAddress());
     $content->assign('requestID', $request->getId());
     $content->printPage();
     die;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:20,代码来源:template.php

示例8: initSession

 public static function initSession()
 {
     // prevents javascript from accessing php session cookies
     ini_set('session.cookie_httponly', '1;');
     // set the session name to the instance id - which is unique
     session_name(OC_Util::getInstanceId());
     // if session cant be started break with http 500 error
     if (session_start() === false) {
         OC_Log::write('core', 'Session could not be initialized', OC_Log::ERROR);
         header('HTTP/1.1 500 Internal Server Error');
         OC_Util::addStyle("styles");
         $error = 'Session could not be initialized. Please contact your ';
         $error .= 'system administrator';
         $tmpl = new OC_Template('', 'error', 'guest');
         $tmpl->assign('errors', array(1 => array('error' => $error)));
         $tmpl->printPage();
         exit;
     }
     $sessionLifeTime = self::getSessionLifeTime();
     // regenerate session id periodically to avoid session fixation
     if (!isset($_SESSION['SID_CREATED'])) {
         $_SESSION['SID_CREATED'] = time();
     } else {
         if (time() - $_SESSION['SID_CREATED'] > $sessionLifeTime / 2) {
             session_regenerate_id(true);
             $_SESSION['SID_CREATED'] = time();
         }
     }
     // session timeout
     if (isset($_SESSION['LAST_ACTIVITY']) && time() - $_SESSION['LAST_ACTIVITY'] > $sessionLifeTime) {
         if (isset($_COOKIE[session_name()])) {
             setcookie(session_name(), '', time() - 42000, '/');
         }
         session_unset();
         session_destroy();
         session_start();
     }
     $_SESSION['LAST_ACTIVITY'] = time();
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:39,代码来源:base.php

示例9: checkUpgrade

 public static function checkUpgrade($showTemplate = true)
 {
     if (self::needUpgrade()) {
         if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
             OC_Config::setValue('theme', '');
             $minimizerCSS = new OC_Minimizer_CSS();
             $minimizerCSS->clearCache();
             $minimizerJS = new OC_Minimizer_JS();
             $minimizerJS->clearCache();
             OC_Util::addScript('config');
             // needed for web root
             OC_Util::addScript('update');
             $tmpl = new OC_Template('', 'update.admin', 'guest');
             $tmpl->assign('version', OC_Util::getVersionString());
             $tmpl->printPage();
             exit;
         } else {
             return true;
         }
     }
     return false;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:22,代码来源:base.php

示例10: get

 /**
  * return the content of a file or return a zip file containing multiple files
  *
  * @param string $dir
  * @param string $files ; separated list of files to download
  * @param boolean $onlyHeader ; boolean to only send header of the request
  */
 public static function get($dir, $files, $onlyHeader = false)
 {
     $view = \OC\Files\Filesystem::getView();
     if (is_array($files) && count($files) === 1) {
         $files = $files[0];
     }
     if (is_array($files)) {
         $getType = self::ZIP_FILES;
         $basename = basename($dir);
         if ($basename) {
             $name = $basename;
         } else {
             $name = 'download';
         }
         $filename = $dir . '/' . $name;
     } else {
         $filename = $dir . '/' . $files;
         if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
             $getType = self::ZIP_DIR;
             // downloading root ?
             if ($files === '') {
                 $name = 'download';
             } else {
                 $name = $files;
             }
         } else {
             $getType = self::FILE;
             $name = $files;
         }
     }
     if ($getType === self::FILE) {
         $streamer = false;
     } else {
         $streamer = new Streamer();
     }
     OC_Util::obEnd();
     try {
         if ($getType === self::FILE) {
             $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
         }
         if ($streamer) {
             $streamer->sendHeaders($name);
         } elseif (\OC\Files\Filesystem::isReadable($filename)) {
             self::sendHeaders($filename, $name);
         } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
             header("HTTP/1.0 404 Not Found");
             $tmpl = new OC_Template('', '404', 'guest');
             $tmpl->printPage();
             exit;
         } else {
             header("HTTP/1.0 403 Forbidden");
             die('403 Forbidden');
         }
         if ($onlyHeader) {
             return;
         }
         if ($streamer) {
             $executionTime = intval(ini_get('max_execution_time'));
             set_time_limit(0);
             if ($getType === self::ZIP_FILES) {
                 foreach ($files as $file) {
                     $file = $dir . '/' . $file;
                     if (\OC\Files\Filesystem::is_file($file)) {
                         $fileSize = \OC\Files\Filesystem::filesize($file);
                         $fh = \OC\Files\Filesystem::fopen($file, 'r');
                         $streamer->addFileFromStream($fh, basename($file), $fileSize);
                         fclose($fh);
                     } elseif (\OC\Files\Filesystem::is_dir($file)) {
                         $streamer->addDirRecursive($file);
                     }
                 }
             } elseif ($getType === self::ZIP_DIR) {
                 $file = $dir . '/' . $files;
                 $streamer->addDirRecursive($file);
             }
             $streamer->finalize();
             set_time_limit($executionTime);
         } else {
             \OC\Files\Filesystem::readfile($filename);
         }
         if ($getType === self::FILE) {
             $view->unlockFile($filename, ILockingProvider::LOCK_SHARED);
         }
     } catch (\OCP\Lock\LockedException $ex) {
         $l = \OC::$server->getL10N('core');
         $hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
         \OC_Template::printErrorPage($l->t('File is currently busy, please try again later'), $hint);
     } catch (\Exception $ex) {
         $l = \OC::$server->getL10N('core');
         $hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
         \OC_Template::printErrorPage($l->t('Can\'t read file'), $hint);
     }
 }
开发者ID:hyb148,项目名称:core,代码行数:100,代码来源:files.php

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

示例12: no_mode

/**
 * The default information screen
 * @global array $profile
 */
function no_mode()
{
    global $USERNAME, $profile;
    $tmpl = new OC_Template('user_openid', 'nomode', 'guest');
    if (substr($profile['req_url'], -1, 1) !== '/') {
        //the identity should always end with a /
        $profile['req_url'] .= '/';
    }
    $tmpl->addHeader('link', array('rel' => 'openid.server', 'href' => $profile['req_url']));
    $tmpl->addHeader('link', array('rel' => 'openid.delegate', 'href' => $profile['idp_url']));
    $tmpl->assign('user', $USERNAME);
    $tmpl->printPage();
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:17,代码来源:owncloud_apps_user_openid_phpmyid.php

示例13: getSingleFile

 /**
  * @param View $view
  * @param string $name
  * @param string $dir
  * @param array $params ; 'head' boolean to only send header of the request ; 'range' http range header
  */
 private static function getSingleFile($view, $dir, $name, $params)
 {
     $filename = $dir . '/' . $name;
     OC_Util::obEnd();
     $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
     $rangeArray = array();
     if (isset($params['range']) && substr($params['range'], 0, 6) === 'bytes=') {
         $rangeArray = self::parseHttpRangeHeader(substr($params['range'], 6), \OC\Files\Filesystem::filesize($filename));
     }
     if (\OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name, $rangeArray);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if (isset($params['head']) && $params['head']) {
         return;
     }
     if (!empty($rangeArray)) {
         try {
             if (count($rangeArray) == 1) {
                 $view->readfilePart($filename, $rangeArray[0]['from'], $rangeArray[0]['to']);
             } else {
                 // check if file is seekable (if not throw UnseekableException)
                 // we have to check it before body contents
                 $view->readfilePart($filename, $rangeArray[0]['size'], $rangeArray[0]['size']);
                 $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
                 foreach ($rangeArray as $range) {
                     echo "\r\n--" . self::getBoundary() . "\r\n" . "Content-type: " . $type . "\r\n" . "Content-range: bytes " . $range['from'] . "-" . $range['to'] . "/" . $range['size'] . "\r\n\r\n";
                     $view->readfilePart($filename, $range['from'], $range['to']);
                 }
                 echo "\r\n--" . self::getBoundary() . "--\r\n";
             }
         } catch (\OCP\Files\UnseekableException $ex) {
             // file is unseekable
             header_remove('Accept-Ranges');
             header_remove('Content-Range');
             header("HTTP/1.1 200 OK");
             self::sendHeaders($filename, $name, array());
             $view->readfile($filename);
         }
     } else {
         $view->readfile($filename);
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:56,代码来源:files.php

示例14: writeData

 /**
  * @brief Writes the config file
  * @return bool
  *
  * Saves the config to the config file.
  *
  */
 public static function writeData()
 {
     // Create a php file ...
     $defaults = new OC_Defaults();
     $content = "<?php\n\$CONFIG = ";
     $content .= var_export(self::$cache, true);
     $content .= ";\n";
     $filename = OC::$SERVERROOT . "/config/config.php";
     // Write the file
     $result = @file_put_contents($filename, $content);
     if (!$result) {
         $tmpl = new OC_Template('', 'error', 'guest');
         $tmpl->assign('errors', array(1 => array('error' => "Can't write into config directory 'config'", 'hint' => 'This can usually be fixed by ' . '<a href="' . $defaults->getDocBaseUrl() . '/server/5.0/admin_manual/installation/installation_source.html#set-the-directory-permissions" target="_blank">giving the webserver write access to the config directory</a>.')));
         $tmpl->printPage();
         exit;
     }
     // Prevent others not to read the config
     @chmod($filename, 0640);
     OC_Util::clearOpcodeCache();
     return true;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:28,代码来源:config.php

示例15: getSingleFile

 /**
  * @param View $view
  * @param string $name
  */
 private static function getSingleFile($view, $dir, $name, $onlyHeader)
 {
     $filename = $dir . '/' . $name;
     OC_Util::obEnd();
     $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
     if (\OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($onlyHeader) {
         return;
     }
     $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
     $pos = strpos(strtolower($type), "video");
     if ($pos != -1) {
         $view->streamVideoFile($filename);
     } else {
         $view->readfile($filename);
     }
 }
开发者ID:hassanhawilo,项目名称:core,代码行数:31,代码来源:files.php


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