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);
 }