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


PHP OC::SERVERROOT方法代码示例

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


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

示例1: init

 public static function init()
 {
     // calculate the root directories
     OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4));
     // register autoloader
     $loaderStart = microtime(true);
     require_once __DIR__ . '/autoloader.php';
     self::$loader = new \OC\Autoloader([OC::$SERVERROOT . '/lib', OC::$SERVERROOT . '/core', OC::$SERVERROOT . '/settings', OC::$SERVERROOT . '/ocs', OC::$SERVERROOT . '/ocs-provider', OC::$SERVERROOT . '/3rdparty']);
     spl_autoload_register(array(self::$loader, 'load'));
     $loaderEnd = microtime(true);
     self::$CLI = php_sapi_name() == 'cli';
     try {
         self::initPaths();
         // setup 3rdparty autoloader
         $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php';
         if (!file_exists($vendorAutoLoad)) {
             throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".');
         }
         require_once $vendorAutoLoad;
     } catch (\RuntimeException $e) {
         OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
         // we can't use the template error page here, because this needs the
         // DI container which isn't available yet
         print $e->getMessage();
         exit;
     }
     foreach (OC::$APPSROOTS as $appRoot) {
         self::$loader->addValidRoot($appRoot['path']);
     }
     // setup the basic server
     self::$server = new \OC\Server(\OC::$WEBROOT);
     \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd);
     \OC::$server->getEventLogger()->start('boot', 'Initialize');
     // Don't display errors and log them
     error_reporting(E_ALL | E_STRICT);
     @ini_set('display_errors', 0);
     @ini_set('log_errors', 1);
     date_default_timezone_set('UTC');
     //try to configure php to enable big file uploads.
     //this doesn´t work always depending on the webserver and php configuration.
     //Let´s try to overwrite some defaults anyways
     //try to set the maximum execution time to 60min
     @set_time_limit(3600);
     @ini_set('max_execution_time', 3600);
     @ini_set('max_input_time', 3600);
     //try to set the maximum filesize to 10G
     @ini_set('upload_max_filesize', '10G');
     @ini_set('post_max_size', '10G');
     @ini_set('file_uploads', '50');
     self::setRequiredIniValues();
     self::handleAuthHeaders();
     self::registerAutoloaderCache();
     // initialize intl fallback is necessary
     \Patchwork\Utf8\Bootup::initIntl();
     OC_Util::isSetLocaleWorking();
     if (!defined('PHPUNIT_RUN')) {
         $logger = \OC::$server->getLogger();
         OC\Log\ErrorHandler::setLogger($logger);
         if (\OC::$server->getConfig()->getSystemValue('debug', false)) {
             OC\Log\ErrorHandler::register(true);
             set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
         } else {
             OC\Log\ErrorHandler::register();
         }
     }
     // register the stream wrappers
     stream_wrapper_register('fakedir', 'OC\\Files\\Stream\\Dir');
     stream_wrapper_register('static', 'OC\\Files\\Stream\\StaticStream');
     stream_wrapper_register('close', 'OC\\Files\\Stream\\Close');
     stream_wrapper_register('quota', 'OC\\Files\\Stream\\Quota');
     stream_wrapper_register('oc', 'OC\\Files\\Stream\\OC');
     \OC::$server->getEventLogger()->start('init_session', 'Initialize session');
     OC_App::loadApps(array('session'));
     if (!self::$CLI) {
         self::initSession();
     }
     \OC::$server->getEventLogger()->end('init_session');
     self::initTemplateEngine();
     self::checkConfig();
     self::checkInstalled();
     OC_Response::addSecurityHeaders();
     if (self::$server->getRequest()->getServerProtocol() === 'https') {
         ini_set('session.cookie_secure', true);
     }
     if (!defined('OC_CONSOLE')) {
         $errors = OC_Util::checkServer(\OC::$server->getConfig());
         if (count($errors) > 0) {
             if (self::$CLI) {
                 // Convert l10n string into regular string for usage in database
                 $staticErrors = [];
                 foreach ($errors as $error) {
                     echo $error['error'] . "\n";
                     echo $error['hint'] . "\n\n";
                     $staticErrors[] = ['error' => (string) $error['error'], 'hint' => (string) $error['hint']];
                 }
                 try {
                     \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors));
                 } catch (\Exception $e) {
                     echo 'Writing to database failed';
                 }
//.........这里部分代码省略.........
开发者ID:krsvital,项目名称:core,代码行数:101,代码来源:base.php

示例2: initPaths

 /**
  * @throws \RuntimeException when the 3rdparty directory is missing or
  * the app path list is empty or contains an invalid path
  */
 public static function initPaths()
 {
     // calculate the root directories
     OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4));
     // ensure we can find OC_Config
     set_include_path(OC::$SERVERROOT . '/lib' . PATH_SEPARATOR . get_include_path());
     if (defined('PHPUNIT_CONFIG_DIR')) {
         self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/';
     } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) {
         self::$configDir = OC::$SERVERROOT . '/tests/config/';
     } else {
         self::$configDir = OC::$SERVERROOT . '/config/';
     }
     OC_Config::$object = new \OC\Config(self::$configDir);
     OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT)));
     /**
      * FIXME: The following line is required because of a cyclic dependency
      *        on IRequest.
      */
     $params = ['server' => ['SCRIPT_NAME' => $_SERVER['SCRIPT_NAME'], 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME']]];
     $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig()));
     $scriptName = $fakeRequest->getScriptName();
     if (substr($scriptName, -1) == '/') {
         $scriptName .= 'index.php';
         //make sure suburi follows the same rules as scriptName
         if (substr(OC::$SUBURI, -9) != 'index.php') {
             if (substr(OC::$SUBURI, -1) != '/') {
                 OC::$SUBURI = OC::$SUBURI . '/';
             }
             OC::$SUBURI = OC::$SUBURI . 'index.php';
         }
     }
     if (OC::$CLI) {
         OC::$WEBROOT = OC_Config::getValue('overwritewebroot', '');
     } else {
         if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) {
             OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI));
             if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') {
                 OC::$WEBROOT = '/' . OC::$WEBROOT;
             }
         } else {
             // The scriptName is not ending with OC::$SUBURI
             // This most likely means that we are calling from CLI.
             // However some cron jobs still need to generate
             // a web URL, so we use overwritewebroot as a fallback.
             OC::$WEBROOT = OC_Config::getValue('overwritewebroot', '');
         }
     }
     // search the 3rdparty folder
     OC::$THIRDPARTYROOT = OC_Config::getValue('3rdpartyroot', null);
     OC::$THIRDPARTYWEBROOT = OC_Config::getValue('3rdpartyurl', null);
     if (empty(OC::$THIRDPARTYROOT) && empty(OC::$THIRDPARTYWEBROOT)) {
         if (file_exists(OC::$SERVERROOT . '/3rdparty')) {
             OC::$THIRDPARTYROOT = OC::$SERVERROOT;
             OC::$THIRDPARTYWEBROOT = OC::$WEBROOT;
         } elseif (file_exists(OC::$SERVERROOT . '/../3rdparty')) {
             OC::$THIRDPARTYWEBROOT = rtrim(dirname(OC::$WEBROOT), '/');
             OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/');
         }
     }
     if (empty(OC::$THIRDPARTYROOT) || !file_exists(OC::$THIRDPARTYROOT)) {
         throw new \RuntimeException('3rdparty directory not found! Please put the ownCloud 3rdparty' . ' folder in the ownCloud folder or the folder above.' . ' You can also configure the location in the config.php file.');
     }
     // search the apps folder
     $config_paths = OC_Config::getValue('apps_paths', array());
     if (!empty($config_paths)) {
         foreach ($config_paths as $paths) {
             if (isset($paths['url']) && isset($paths['path'])) {
                 $paths['url'] = rtrim($paths['url'], '/');
                 $paths['path'] = rtrim($paths['path'], '/');
                 OC::$APPSROOTS[] = $paths;
             }
         }
     } elseif (file_exists(OC::$SERVERROOT . '/apps')) {
         OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true);
     } elseif (file_exists(OC::$SERVERROOT . '/../apps')) {
         OC::$APPSROOTS[] = array('path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', 'url' => '/apps', 'writable' => true);
     }
     if (empty(OC::$APPSROOTS)) {
         throw new \RuntimeException('apps directory not found! Please put the ownCloud apps folder in the ownCloud folder' . ' or the folder above. You can also configure the location in the config.php file.');
     }
     $paths = array();
     foreach (OC::$APPSROOTS as $path) {
         $paths[] = $path['path'];
         if (!is_dir($path['path'])) {
             throw new \RuntimeException(sprintf('App directory "%s" not found! Please put the ownCloud apps folder in the' . ' ownCloud folder or the folder above. You can also configure the location in the' . ' config.php file.', $path['path']));
         }
     }
     // set the right include path
     set_include_path(OC::$SERVERROOT . '/lib/private' . PATH_SEPARATOR . OC::$SERVERROOT . '/config' . PATH_SEPARATOR . OC::$THIRDPARTYROOT . '/3rdparty' . PATH_SEPARATOR . implode(PATH_SEPARATOR, $paths) . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . OC::$SERVERROOT);
 }
开发者ID:andyboeh,项目名称:core,代码行数:95,代码来源:base.php

示例3: initPaths

 public static function initPaths()
 {
     // calculate the documentroot
     OC::$DOCUMENTROOT = realpath($_SERVER['DOCUMENT_ROOT']);
     OC::$SERVERROOT = str_replace("\\", '/', substr(__FILE__, 0, -13));
     OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT)));
     $scriptName = $_SERVER["SCRIPT_NAME"];
     if (substr($scriptName, -1) == '/') {
         $scriptName .= 'index.php';
         //make sure suburi follows the same rules as scriptName
         if (substr(OC::$SUBURI, -9) != 'index.php') {
             if (substr(OC::$SUBURI, -1) != '/') {
                 OC::$SUBURI = OC::$SUBURI . '/';
             }
             OC::$SUBURI = OC::$SUBURI . 'index.php';
         }
     }
     OC::$WEBROOT = substr($scriptName, 0, strlen($scriptName) - strlen(OC::$SUBURI));
     // try a new way to detect the WEBROOT which is simpler and also works with the app directory outside the owncloud folder. let´s see if this works for everybody
     //		OC::$WEBROOT=substr(OC::$SERVERROOT,strlen(OC::$DOCUMENTROOT));
     if (OC::$WEBROOT != '' and OC::$WEBROOT[0] !== '/') {
         OC::$WEBROOT = '/' . OC::$WEBROOT;
     }
     // ensure we can find OC_Config
     set_include_path(OC::$SERVERROOT . '/lib' . PATH_SEPARATOR . get_include_path());
     // search the 3rdparty folder
     if (OC_Config::getValue('3rdpartyroot', '') != '' and OC_Config::getValue('3rdpartyurl', '') != '') {
         OC::$THIRDPARTYROOT = OC_Config::getValue('3rdpartyroot', '');
         OC::$THIRDPARTYWEBROOT = OC_Config::getValue('3rdpartyurl', '');
     } elseif (file_exists(OC::$SERVERROOT . '/3rdparty')) {
         OC::$THIRDPARTYROOT = OC::$SERVERROOT;
         OC::$THIRDPARTYWEBROOT = OC::$WEBROOT;
     } elseif (file_exists(OC::$SERVERROOT . '/../3rdparty')) {
         OC::$THIRDPARTYWEBROOT = rtrim(dirname(OC::$WEBROOT), '/');
         OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/');
     } else {
         echo "3rdparty directory not found! Please put the ownCloud 3rdparty folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.";
         exit;
     }
     // search the apps folder
     if (OC_Config::getValue('appsroot', '') != '') {
         OC::$APPSROOT = OC_Config::getValue('appsroot', '');
         OC::$APPSWEBROOT = OC_Config::getValue('appsurl', '');
     } elseif (file_exists(OC::$SERVERROOT . '/apps')) {
         OC::$APPSROOT = OC::$SERVERROOT;
         OC::$APPSWEBROOT = OC::$WEBROOT;
     } elseif (file_exists(OC::$SERVERROOT . '/../apps')) {
         OC::$APPSROOT = rtrim(dirname(OC::$SERVERROOT), '/');
         OC::$APPSWEBROOT = rtrim(dirname(OC::$WEBROOT), '/');
     } else {
         echo "apps directory not found! Please put the ownCloud apps folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.";
         exit;
     }
     // set the right include path
     set_include_path(OC::$SERVERROOT . '/lib' . PATH_SEPARATOR . OC::$SERVERROOT . '/config' . PATH_SEPARATOR . OC::$THIRDPARTYROOT . '/3rdparty' . PATH_SEPARATOR . OC::$APPSROOT . PATH_SEPARATOR . OC::$APPSROOT . '/apps' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . OC::$SERVERROOT);
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:56,代码来源:base.php

示例4: initPaths

 public static function initPaths()
 {
     // calculate the root directories
     OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4));
     // ensure we can find OC_Config
     set_include_path(OC::$SERVERROOT . '/lib' . PATH_SEPARATOR . get_include_path());
     OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT)));
     $scriptName = OC_Request::scriptName();
     if (substr($scriptName, -1) == '/') {
         $scriptName .= 'index.php';
         //make sure suburi follows the same rules as scriptName
         if (substr(OC::$SUBURI, -9) != 'index.php') {
             if (substr(OC::$SUBURI, -1) != '/') {
                 OC::$SUBURI = OC::$SUBURI . '/';
             }
             OC::$SUBURI = OC::$SUBURI . 'index.php';
         }
     }
     OC::$WEBROOT = substr($scriptName, 0, strlen($scriptName) - strlen(OC::$SUBURI));
     if (OC::$WEBROOT != '' and OC::$WEBROOT[0] !== '/') {
         OC::$WEBROOT = '/' . OC::$WEBROOT;
     }
     // search the 3rdparty folder
     if (OC_Config::getValue('3rdpartyroot', '') != '' and OC_Config::getValue('3rdpartyurl', '') != '') {
         OC::$THIRDPARTYROOT = OC_Config::getValue('3rdpartyroot', '');
         OC::$THIRDPARTYWEBROOT = OC_Config::getValue('3rdpartyurl', '');
     } elseif (file_exists(OC::$SERVERROOT . '/3rdparty')) {
         OC::$THIRDPARTYROOT = OC::$SERVERROOT;
         OC::$THIRDPARTYWEBROOT = OC::$WEBROOT;
     } elseif (file_exists(OC::$SERVERROOT . '/../3rdparty')) {
         OC::$THIRDPARTYWEBROOT = rtrim(dirname(OC::$WEBROOT), '/');
         OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/');
     } else {
         echo '3rdparty directory not found! Please put the ownCloud 3rdparty' . ' folder in the ownCloud folder or the folder above.' . ' You can also configure the location in the config.php file.';
         exit;
     }
     // search the apps folder
     $config_paths = OC_Config::getValue('apps_paths', array());
     if (!empty($config_paths)) {
         foreach ($config_paths as $paths) {
             if (isset($paths['url']) && isset($paths['path'])) {
                 $paths['url'] = rtrim($paths['url'], '/');
                 $paths['path'] = rtrim($paths['path'], '/');
                 OC::$APPSROOTS[] = $paths;
             }
         }
     } elseif (file_exists(OC::$SERVERROOT . '/apps')) {
         OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true);
     } elseif (file_exists(OC::$SERVERROOT . '/../apps')) {
         OC::$APPSROOTS[] = array('path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', 'url' => '/apps', 'writable' => true);
     }
     if (empty(OC::$APPSROOTS)) {
         echo 'apps directory not found! Please put the ownCloud apps folder in the ownCloud folder' . ' or the folder above. You can also configure the location in the config.php file.';
         exit;
     }
     $paths = array();
     foreach (OC::$APPSROOTS as $path) {
         $paths[] = $path['path'];
     }
     // set the right include path
     set_include_path(OC::$SERVERROOT . '/lib' . PATH_SEPARATOR . OC::$SERVERROOT . '/config' . PATH_SEPARATOR . OC::$THIRDPARTYROOT . '/3rdparty' . PATH_SEPARATOR . implode($paths, PATH_SEPARATOR) . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . OC::$SERVERROOT);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:62,代码来源:base.php

示例5: init

 public static function init()
 {
     // register autoloader
     spl_autoload_register(array('OC', 'autoload'));
     // set some stuff
     //ob_start();
     error_reporting(E_ALL | E_STRICT);
     date_default_timezone_set('Europe/Berlin');
     ini_set('arg_separator.output', '&');
     // calculate the documentroot
     OC::$DOCUMENTROOT = realpath($_SERVER['DOCUMENT_ROOT']);
     OC::$SERVERROOT = str_replace("\\", '/', substr(__FILE__, 0, -13));
     OC::$SUBURI = substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT));
     $scriptName = $_SERVER["SCRIPT_NAME"];
     if (substr($scriptName, -1) == '/') {
         $scriptName .= 'index.php';
     }
     OC::$WEBROOT = substr($scriptName, 0, strlen($scriptName) - strlen(OC::$SUBURI));
     if (OC::$WEBROOT != '' and OC::$WEBROOT[0] !== '/') {
         OC::$WEBROOT = '/' . OC::$WEBROOT;
     }
     // set the right include path
     set_include_path(OC::$SERVERROOT . '/lib' . PATH_SEPARATOR . OC::$SERVERROOT . '/config' . PATH_SEPARATOR . OC::$SERVERROOT . '/3rdparty' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR . OC::$SERVERROOT);
     // redirect to https site if configured
     if (OC_Config::getValue("forcessl", false)) {
         ini_set("session.cookie_secure", "on");
         if (!isset($_SERVER['HTTPS']) or $_SERVER['HTTPS'] != 'on') {
             $url = "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
             header("Location: {$url}");
             exit;
         }
     }
     ini_set('session.cookie_httponly', '1;');
     session_start();
     // Add the stuff we need always
     OC_Util::addScript("jquery-1.6.4.min");
     OC_Util::addScript("jquery-ui-1.8.14.custom.min");
     OC_Util::addScript("jquery-showpassword");
     OC_Util::addScript("jquery.infieldlabel.min");
     OC_Util::addScript("jquery-tipsy");
     OC_Util::addScript("js");
     //OC_Util::addScript( "multiselect" );
     OC_Util::addScript('search', 'result');
     OC_Util::addStyle("styles");
     OC_Util::addStyle("multiselect");
     OC_Util::addStyle("jquery-ui-1.8.14.custom");
     OC_Util::addStyle("jquery-tipsy");
     $errors = OC_Util::checkServer();
     if (count($errors) > 0) {
         OC_Template::printGuestPage('', 'error', array('errors' => $errors));
         exit;
     }
     // TODO: we should get rid of this one, too
     // WARNING: to make everything even more confusing,
     //   DATADIRECTORY is a var that changes and DATADIRECTORY_ROOT
     //   stays the same, but is set by "datadirectory".
     //   Any questions?
     OC::$CONFIG_DATADIRECTORY = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     // User and Groups
     if (!OC_Config::getValue("installed", false)) {
         $_SESSION['user_id'] = '';
     }
     OC_User::useBackend(OC_Config::getValue("userbackend", "database"));
     OC_Group::setBackend(OC_Config::getValue("groupbackend", "database"));
     // Load Apps
     // This includes plugins for users and filesystems as well
     global $RUNTIME_NOAPPS;
     if (!$RUNTIME_NOAPPS) {
         OC_App::loadApps();
     }
     // Was in required file ... put it here
     OC_Filesystem::registerStorageType('local', 'OC_Filestorage_Local', array('datadir' => 'string'));
     // Set up file system unless forbidden
     global $RUNTIME_NOSETUPFS;
     if (!$RUNTIME_NOSETUPFS) {
         OC_Util::setupFS();
     }
     // Last part: connect some hooks
     OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Connector_Sabre_Principal', 'addPrincipal');
     OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Connector_Sabre_Principal', 'deletePrincipal');
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:81,代码来源:owncloud_lib_base.php


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