Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Visscher <bart@thisnet.nl>2011-09-18 21:37:54 +0400
committerBart Visscher <bart@thisnet.nl>2011-09-18 21:37:54 +0400
commit82c7598861db175617694891bb9f21b426426225 (patch)
treefce8fb4717b4cc2a5dc6da8835bdb51b5fb40054
parentd5656716f69caa6a1eb98706994ffcb9a08553a7 (diff)
Remove global vars and use the OC static version.
Removed global vars are DOCUMENTROOT, SERVERROOT, SUBURI, WEBROOT and CONFIG_DATADIRECTORY
-rw-r--r--3rdparty/MDB2.php5
-rw-r--r--3rdparty/MDB2/Driver/Manager/sqlite.php5
-rw-r--r--3rdparty/MDB2/Driver/sqlite.php5
-rw-r--r--apps/calendar/caldav.php2
-rw-r--r--apps/contacts/carddav.php2
-rw-r--r--apps/media/ajax/api.php3
-rw-r--r--apps/media/lib_ampache.php3
-rw-r--r--apps/media/server/xml.server.php1
-rw-r--r--apps/unhosted/compat.php2
-rw-r--r--apps/user_openid/appinfo/app.php3
-rw-r--r--apps/user_openid/user.php3
-rw-r--r--apps/user_openid/user_openid.php5
-rw-r--r--core/templates/layout.guest.php2
-rw-r--r--core/templates/layout.user.php2
-rw-r--r--files/webdav.php2
-rw-r--r--index.php8
-rw-r--r--lib/MDB2/Driver/Manager/sqlite3.php5
-rw-r--r--lib/MDB2/Driver/sqlite3.php5
-rw-r--r--lib/app.php7
-rw-r--r--lib/base.php27
-rw-r--r--lib/config.php11
-rw-r--r--lib/db.php3
-rw-r--r--lib/files.php11
-rw-r--r--lib/helper.php40
-rw-r--r--lib/installer.php11
-rw-r--r--lib/l10n.php15
-rw-r--r--lib/remote/cloud.php8
-rw-r--r--lib/setup.php14
-rw-r--r--lib/template.php34
-rw-r--r--lib/util.php23
-rw-r--r--search/index.php2
31 files changed, 103 insertions, 166 deletions
diff --git a/3rdparty/MDB2.php b/3rdparty/MDB2.php
index fbc7107914e..aa7ec6ba093 100644
--- a/3rdparty/MDB2.php
+++ b/3rdparty/MDB2.php
@@ -969,11 +969,10 @@ class MDB2
static function fileExists($file)
{
// safe_mode does notwork with is_readable()
- global $SERVERROOT;
if (!@ini_get('safe_mode')) {
$dirs = explode(PATH_SEPARATOR, ini_get('include_path'));
- array_unshift($dirs,$SERVERROOT);
- array_unshift($dirs,$SERVERROOT. DIRECTORY_SEPARATOR .'inc');
+ array_unshift($dirs,OC::$SERVERROOT);
+ array_unshift($dirs,OC::$SERVERROOT. DIRECTORY_SEPARATOR .'inc');
// print_r($dirs);die();
foreach ($dirs as $dir) {
if (is_readable($dir . DIRECTORY_SEPARATOR . $file)) {
diff --git a/3rdparty/MDB2/Driver/Manager/sqlite.php b/3rdparty/MDB2/Driver/Manager/sqlite.php
index 64019669645..650910174e7 100644
--- a/3rdparty/MDB2/Driver/Manager/sqlite.php
+++ b/3rdparty/MDB2/Driver/Manager/sqlite.php
@@ -71,8 +71,7 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
*/
function createDatabase($name, $options = array())
{
- global $SERVERROOT;
- $datadir=OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );
+ $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
$db =$this->getDBInstance();
if (PEAR::isError($db)) {
return $db;
@@ -1362,4 +1361,4 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
// }}}
}
-?> \ No newline at end of file
+?>
diff --git a/3rdparty/MDB2/Driver/sqlite.php b/3rdparty/MDB2/Driver/sqlite.php
index 63db241b863..5d2ad27d016 100644
--- a/3rdparty/MDB2/Driver/sqlite.php
+++ b/3rdparty/MDB2/Driver/sqlite.php
@@ -347,8 +347,7 @@ class MDB2_Driver_sqlite extends MDB2_Driver_Common
**/
function connect()
{
- global $SERVERROOT;
- $datadir=OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );
+ $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
$database_file = $this->_getDatabaseFile($this->database_name);
if (is_resource($this->connection)) {
//if (count(array_diff($this->connected_dsn, $this->dsn)) == 0
@@ -1086,4 +1085,4 @@ class MDB2_Statement_sqlite extends MDB2_Statement_Common
}
-?> \ No newline at end of file
+?>
diff --git a/apps/calendar/caldav.php b/apps/calendar/caldav.php
index 49fc9633365..15259ad4461 100644
--- a/apps/calendar/caldav.php
+++ b/apps/calendar/caldav.php
@@ -38,7 +38,7 @@ $nodes = array(
// Fire up server
$server = new Sabre_DAV_Server($nodes);
-$server->setBaseUri($WEBROOT.'/apps/calendar/caldav.php');
+$server->setBaseUri(OC::$WEBROOT.'/apps/calendar/caldav.php');
// Add plugins
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
$server->addPlugin(new Sabre_CalDAV_Plugin());
diff --git a/apps/contacts/carddav.php b/apps/contacts/carddav.php
index 77b3c105deb..4bc215453c4 100644
--- a/apps/contacts/carddav.php
+++ b/apps/contacts/carddav.php
@@ -38,7 +38,7 @@ $nodes = array(
// Fire up server
$server = new Sabre_DAV_Server($nodes);
-$server->setBaseUri($WEBROOT.'/apps/contacts/carddav.php');
+$server->setBaseUri(OC::$WEBROOT.'/apps/contacts/carddav.php');
// Add plugins
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
$server->addPlugin(new Sabre_CardDAV_Plugin());
diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php
index 3b4932728da..31ff33bf03a 100644
--- a/apps/media/ajax/api.php
+++ b/apps/media/ajax/api.php
@@ -41,7 +41,6 @@ if(!isset($_POST['action']) and isset($_GET['action'])){
foreach($arguments as &$argument){
$argument=stripslashes($argument);
}
-global $CONFIG_DATADIRECTORY;
@ob_clean();
if(!isset($arguments['artist'])){
$arguments['artist']=0;
@@ -155,4 +154,4 @@ function findMusic($path='/'){
return $music;
}
-?> \ No newline at end of file
+?>
diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php
index b3bd7b16189..dc88e35a697 100644
--- a/apps/media/lib_ampache.php
+++ b/apps/media/lib_ampache.php
@@ -157,7 +157,6 @@ class OC_MEDIA_AMPACHE{
}
private static function printSong($song,$artistName=false,$albumName=false){
- global $WEBROOT;
if(!$artistName){
$artistName=OC_MEDIA_COLLECTION::getArtistName($song['song_artist']);
}
@@ -363,4 +362,4 @@ class OC_MEDIA_AMPACHE{
}
}
-?> \ No newline at end of file
+?>
diff --git a/apps/media/server/xml.server.php b/apps/media/server/xml.server.php
index 516ab740072..e61fadf234c 100644
--- a/apps/media/server/xml.server.php
+++ b/apps/media/server/xml.server.php
@@ -35,7 +35,6 @@ foreach($arguments as &$argument){
$argument=stripslashes($argument);
}
ob_clean();
-global $CONFIG_DATADIRECTORY;
if(isset($arguments['action'])){
error_log($arguments['action']);
switch($arguments['action']){
diff --git a/apps/unhosted/compat.php b/apps/unhosted/compat.php
index 5034d04de31..00d6a7c2eeb 100644
--- a/apps/unhosted/compat.php
+++ b/apps/unhosted/compat.php
@@ -67,7 +67,7 @@ if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'unhosted'
$server = new Sabre_DAV_Server($publicDir);
// Path to our script
- $server->setBaseUri("$WEBROOT/apps/unhosted/compat.php/$ownCloudUser");
+ $server->setBaseUri(OC::$WEBROOT."/apps/unhosted/compat.php/$ownCloudUser");
// Auth backend
$authBackend = new OC_Connector_Sabre_Auth_ro_oauth(OC_UnhostedWeb::getValidTokens($ownCloudUser, $userName.'@'.$userHost, $dataScope));
diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php
index e8e9fd2296b..578f8f4dade 100644
--- a/apps/user_openid/appinfo/app.php
+++ b/apps/user_openid/appinfo/app.php
@@ -32,13 +32,12 @@ if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){
$openid_validation_result = $openid->ValidateWithServer();
if ($openid_validation_result == true){ // OK HERE KEY IS VALID
error_log('auth sucessfull');
- global $WEBROOT;
$identity=$openid->GetIdentity();
error_log("auth as $identity");
$user=OC_USER_OPENID::findUserForIdentity($identity);
if($user){
$_SESSION['user_id']=$user;
- header("Location: $WEBROOT");
+ header("Location: ".OC::$WEBROOT);
}
}else if($openid->IsError() == true){ // ON THE WAY, WE GOT SOME ERROR
$error = $openid->GetError();
diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php
index 52fa1047344..60e12ed88e0 100644
--- a/apps/user_openid/user.php
+++ b/apps/user_openid/user.php
@@ -42,10 +42,9 @@ if(!OC_User::userExists($USERNAME)){
error_log($USERNAME.' doesn\'t exist');
$USERNAME='';
}
-global $WEBROOT;
$IDENTITY=OC_Helper::linkTo( "user_openid", "user.php", null, true ).'/'.$USERNAME;
require_once 'phpmyid.php';
-?> \ No newline at end of file
+?>
diff --git a/apps/user_openid/user_openid.php b/apps/user_openid/user_openid.php
index d9af94dcafa..df050e908de 100644
--- a/apps/user_openid/user_openid.php
+++ b/apps/user_openid/user_openid.php
@@ -36,13 +36,12 @@ class OC_USER_OPENID extends OC_User_Backend {
* Check if the password is correct without logging in the user
*/
public function checkPassword( $uid, $password ){
- global $WEBROOT;
// Get identity from user and redirect browser to OpenID Server
$openid = new SimpleOpenID;
$openid->SetIdentity($uid);
$openid->SetTrustRoot('http://' . $_SERVER["HTTP_HOST"]);
if ($openid->GetOpenIDServer()){
- $openid->SetApprovedURL('http://' . $_SERVER["HTTP_HOST"] . $WEBROOT); // Send Response from OpenID server to this script
+ $openid->SetApprovedURL('http://' . $_SERVER["HTTP_HOST"] . OC::$WEBROOT); // Send Response from OpenID server to this script
$openid->Redirect(); // This will redirect user to OpenID Server
exit;
}else{
@@ -67,4 +66,4 @@ class OC_USER_OPENID extends OC_User_Backend {
-?> \ No newline at end of file
+?>
diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php
index 6f40619f5f5..7e05fce0ecf 100644
--- a/core/templates/layout.guest.php
+++ b/core/templates/layout.guest.php
@@ -8,7 +8,7 @@
<link rel="stylesheet" href="<?php echo $cssfile; ?>" type="text/css" media="screen" />
<?php endforeach; ?>
<script type="text/javascript">
- var oc_webroot = '<?php global $WEBROOT; echo $WEBROOT; ?>';
+ var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
</script>
<?php foreach($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index 90b19259292..f793275f2ca 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -8,7 +8,7 @@
<link rel="stylesheet" href="<?php echo $cssfile; ?>" type="text/css" media="screen" />
<?php endforeach; ?>
<script type="text/javascript">
- var oc_webroot = '<?php global $WEBROOT; echo $WEBROOT; ?>';
+ var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
var oc_current_user = '<?php echo OC_User::getUser() ?>';
</script>
<?php foreach($_['jsfiles'] as $jsfile): ?>
diff --git a/files/webdav.php b/files/webdav.php
index b1d242b2cc9..dd06074b780 100644
--- a/files/webdav.php
+++ b/files/webdav.php
@@ -37,7 +37,7 @@ $publicDir = new OC_Connector_Sabre_Directory('');
// Fire up server
$server = new Sabre_DAV_Server($publicDir);
-$server->setBaseUri($WEBROOT.'/files/webdav.php');
+$server->setBaseUri(OC::$WEBROOT.'/files/webdav.php');
// Load plugins
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
diff --git a/index.php b/index.php
index 5255e8fadbe..249ce41d51e 100644
--- a/index.php
+++ b/index.php
@@ -50,11 +50,11 @@ if($_SERVER['REQUEST_METHOD']=='PROPFIND'){//handle webdav
elseif(OC_User::isLoggedIn()) {
if(isset($_GET["logout"]) and ($_GET["logout"])) {
OC_User::logout();
- header("Location: ".$WEBROOT.'/');
+ header("Location: ".OC::$WEBROOT.'/');
exit();
}
else {
- header("Location: ".$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
+ header("Location: ".OC::$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
exit();
}
}
@@ -67,7 +67,7 @@ elseif(isset($_COOKIE["oc_remember_login"]) && $_COOKIE["oc_remember_login"]) {
if(OC_User::userExists($_COOKIE['oc_username']) &&
OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") == $_COOKIE['oc_token']) {
OC_User::setUserId($_COOKIE['oc_username']);
- header("Location: ". $WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
+ header("Location: ". OC::$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
}
else {
OC_Template::printGuestPage("", "login", array("error" => true));
@@ -78,7 +78,7 @@ elseif(isset($_COOKIE["oc_remember_login"]) && $_COOKIE["oc_remember_login"]) {
elseif(isset($_POST["user"]) && isset($_POST['password'])) {
OC_App::loadApps();
if(OC_User::login($_POST["user"], $_POST["password"])) {
- header("Location: ".$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
+ header("Location: ".OC::$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
if(!empty($_POST["remember_login"])){
error_log("Setting remember login to cookie");
$token = md5($_POST["user"].time());
diff --git a/lib/MDB2/Driver/Manager/sqlite3.php b/lib/MDB2/Driver/Manager/sqlite3.php
index 4e420b5d0b2..eabbb72b3c2 100644
--- a/lib/MDB2/Driver/Manager/sqlite3.php
+++ b/lib/MDB2/Driver/Manager/sqlite3.php
@@ -69,8 +69,7 @@ class MDB2_Driver_Manager_sqlite3 extends MDB2_Driver_Manager_Common
*/
function createDatabase($name, $options = array())
{
- global $SERVERROOT;
- $datadir=OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );
+ $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
$db =$this->getDBInstance();
if (PEAR::isError($db)) {
return $db;
@@ -1361,4 +1360,4 @@ class MDB2_Driver_Manager_sqlite3 extends MDB2_Driver_Manager_Common
// }}}
}
-?> \ No newline at end of file
+?>
diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php
index ccf6bb53688..a41aeed4850 100644
--- a/lib/MDB2/Driver/sqlite3.php
+++ b/lib/MDB2/Driver/sqlite3.php
@@ -351,8 +351,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common
if($this->connection instanceof SQLite3){
return MDB2_OK;
}
- global $SERVERROOT;
- $datadir=OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );
+ $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
$database_file = $this->_getDatabaseFile($this->database_name);
if (is_resource($this->connection)) {
//if (count(array_diff($this->connected_dsn, $this->dsn)) == 0
@@ -1358,4 +1357,4 @@ class MDB2_Statement_sqlite3 extends MDB2_Statement_Common
}
}
-?> \ No newline at end of file
+?>
diff --git a/lib/app.php b/lib/app.php
index 61ea081c6ff..cd4a7293e49 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -44,8 +44,6 @@ class OC_App{
* exists.
*/
public static function loadApps(){
- global $SERVERROOT;
-
// Did we allready load everything?
if( self::$init ){
return true;
@@ -60,7 +58,7 @@ class OC_App{
$apps = OC_Appconfig::getApps();
foreach( $apps as $app ){
if( self::isEnabled( $app )){
- if(is_file($SERVERROOT.'/apps/'.$app.'/appinfo/app.php')){
+ if(is_file(OC::$SERVERROOT.'/apps/'.$app.'/appinfo/app.php')){
require( 'apps/'.$app.'/appinfo/app.php' );
}
}
@@ -285,8 +283,7 @@ class OC_App{
* @return string
*/
public static function getCurrentApp(){
- global $WEBROOT;
- $script=substr($_SERVER["SCRIPT_NAME"],strlen($WEBROOT)+1);
+ $script=substr($_SERVER["SCRIPT_NAME"],strlen(OC::$WEBROOT)+1);
$topFolder=substr($script,0,strpos($script,'/'));
if($topFolder=='apps'){
$length=strlen($topFolder);
diff --git a/lib/base.php b/lib/base.php
index dc3ed4129cd..7344601ba45 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -81,30 +81,21 @@ ini_set('session.cookie_httponly','1;');
session_start();
// calculate the documentroot
-$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
-$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13));
-$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen($SERVERROOT));
+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';
}
-$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen($SUBURI));
+OC::$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen(OC::$SUBURI));
-OC::$SERVERROOT=$SERVERROOT;
-OC::$WEBROOT=$WEBROOT;
-
-if($WEBROOT!='' and $WEBROOT[0]!=='/'){
- $WEBROOT='/'.$WEBROOT;
+if(OC::$WEBROOT!='' and OC::$WEBROOT[0]!=='/'){
+ OC::$WEBROOT='/'.OC::$WEBROOT;
}
-// We are going to use OC::* instead of globels soon
-OC::$WEBROOT = $WEBROOT;
-OC::$SERVERROOT = $SERVERROOT;
-OC::$DOCUMENTROOT = $DOCUMENTROOT;
-OC::$SUBURI = $SUBURI;
-
// set the right include path
-set_include_path($SERVERROOT.'/lib'.PATH_SEPARATOR.$SERVERROOT.'/config'.PATH_SEPARATOR.$SERVERROOT.'/3rdparty'.PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.$SERVERROOT);
+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);
//Some libs we really depend on
require_once('Sabre/autoload.php');
@@ -119,9 +110,9 @@ if( !isset( $RUNTIME_NOAPPS )){
// TODO: we should get rid of this one, too
// WARNING: to make everything even more confusing, DATADIRECTORY is a var that
-// changes and DATATIRECTORY_ROOT stays the same, but is set by
+// changes and DATADIRECTORY_ROOT stays the same, but is set by
// "datadirectory". Any questions?
-$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );
+OC::$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
// redirect to https site if configured
if( OC_Config::getValue( "forcessl", false )){
diff --git a/lib/config.php b/lib/config.php
index dafb37edd33..67df5e94c6d 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -131,14 +131,12 @@ class OC_Config{
return true;
}
- global $SERVERROOT;
-
- if( !file_exists( "$SERVERROOT/config/config.php" )){
+ if( !file_exists( OC::$SERVERROOT."/config/config.php" )){
return false;
}
// Include the file, save the data from $CONFIG
- include( "$SERVERROOT/config/config.php" );
+ include( OC::$SERVERROOT."/config/config.php" );
if( isset( $CONFIG ) && is_array( $CONFIG )){
self::$cache = $CONFIG;
}
@@ -158,9 +156,6 @@ class OC_Config{
* Known flaws: Strings are not escaped properly
*/
public static function writeData(){
- // We need the serverroot path
- global $SERVERROOT;
-
// Create a php file ...
$content = "<?php\n\$CONFIG = array(\n";
@@ -177,7 +172,7 @@ class OC_Config{
$content .= ");\n?>\n";
// Write the file
- $result=@file_put_contents( "$SERVERROOT/config/config.php", $content );
+ $result=@file_put_contents( OC::$SERVERROOT."/config/config.php", $content );
if(!$result) {
$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 setting the owner of 'config' to the user that the web server uses (".exec('whoami').")")));
diff --git a/lib/db.php b/lib/db.php
index 414525ae207..0b7065eec8b 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -43,8 +43,7 @@ class OC_DB {
$CONFIG_DBUSER = OC_Config::getValue( "dbuser", "" );;
$CONFIG_DBPASSWORD = OC_Config::getValue( "dbpassword", "" );;
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );;
- global $SERVERROOT;
- $datadir=OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );
+ $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
// do nothing if the connection already has been established
if(!self::$DBConnection){
diff --git a/lib/files.php b/lib/files.php
index f1789d9c7ac..84dc9fd1c53 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -33,9 +33,8 @@ class OC_Files {
* @param dir $directory
*/
public static function getDirectoryContent($directory){
- global $CONFIG_DATADIRECTORY;
- if(strpos($directory,$CONFIG_DATADIRECTORY)===0){
- $directory=substr($directory,strlen($CONFIG_DATADIRECTORY));
+ if(strpos($directory,OC::$CONFIG_DATADIRECTORY)===0){
+ $directory=substr($directory,strlen(OC::$CONFIG_DATADIRECTORY));
}
$filesfound=true;
$content=array();
@@ -279,16 +278,14 @@ class OC_Files {
* @param int size filesisze in bytes
*/
static function setUploadLimit($size){
- global $SERVERROOT;
- global $WEBROOT;
$size=OC_Helper::humanFileSize($size);
$size=substr($size,0,-1);//strip the B
$size=str_replace(' ','',$size); //remove the space between the size and the postfix
- $content = "ErrorDocument 404 /$WEBROOT/core/templates/404.php\n";//custom 404 error page
+ $content = "ErrorDocument 404 /".OC::$WEBROOT."/core/templates/404.php\n";//custom 404 error page
$content.= "php_value upload_max_filesize $size\n";//upload limit
$content.= "php_value post_max_size $size\n";
$content.= "SetEnv htaccessWorking true\n";
$content.= "Options -Indexes\n";
- @file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
+ @file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
}
}
diff --git a/lib/helper.php b/lib/helper.php
index d9b47280ff7..1661f38e8ab 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -35,25 +35,22 @@ class OC_Helper {
* Returns a url to the given app and file.
*/
public static function linkTo( $app, $file, $redirect_url=NULL, $absolute=false ){
- global $WEBROOT;
- global $SERVERROOT;
-
if( $app != '' ){
$app .= '/';
// Check if the app is in the app folder
- if( file_exists( $SERVERROOT . '/apps/'. $app.$file )){
- $urlLinkTo = $WEBROOT . '/apps/' . $app . $file;
+ if( file_exists( OC::$SERVERROOT . '/apps/'. $app.$file )){
+ $urlLinkTo = OC::$WEBROOT . '/apps/' . $app . $file;
}
else{
- $urlLinkTo = $WEBROOT . '/' . $app . $file;
+ $urlLinkTo = OC::$WEBROOT . '/' . $app . $file;
}
}
else{
- if( file_exists( $SERVERROOT . '/core/'. $file )){
- $urlLinkTo = $WEBROOT . '/core/'.$file;
+ if( file_exists( OC::$SERVERROOT . '/core/'. $file )){
+ $urlLinkTo = OC::$WEBROOT . '/core/'.$file;
}
else{
- $urlLinkTo = $WEBROOT . '/'.$file;
+ $urlLinkTo = OC::$WEBROOT . '/'.$file;
}
}
@@ -79,18 +76,15 @@ class OC_Helper {
* Returns the path to the image.
*/
public static function imagePath( $app, $image ){
- global $SERVERROOT;
- global $WEBROOT;
-
// Check if the app is in the app folder
- if( file_exists( "$SERVERROOT/apps/$app/img/$image" )){
- return "$WEBROOT/apps/$app/img/$image";
+ if( file_exists( OC::$SERVERROOT."/apps/$app/img/$image" )){
+ return OC::$WEBROOT."/apps/$app/img/$image";
}
elseif( !empty( $app )){
- return "$WEBROOT/$app/img/$image";
+ return OC::$WEBROOT."/$app/img/$image";
}
else{
- return "$WEBROOT/core/img/$image";
+ return OC::$WEBROOT."/core/img/$image";
}
}
@@ -102,27 +96,25 @@ class OC_Helper {
* Returns the path to the image of this file type.
*/
public static function mimetypeIcon( $mimetype ){
- global $SERVERROOT;
- global $WEBROOT;
// Replace slash with a minus
$mimetype = str_replace( "/", "-", $mimetype );
// Is it a dir?
if( $mimetype == "dir" ){
- return "$WEBROOT/core/img/places/folder.svg";
+ return OC::$WEBROOT."/core/img/places/folder.svg";
}
// Icon exists?
- if( file_exists( "$SERVERROOT/core/img/filetypes/$mimetype.svg" )){
- return "$WEBROOT/core/img/filetypes/$mimetype.svg";
+ if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.svg" )){
+ return OC::$WEBROOT."/core/img/filetypes/$mimetype.svg";
}
//try only the first part of the filetype
$mimetype=substr($mimetype,0,strpos($mimetype,'-'));
- if( file_exists( "$SERVERROOT/core/img/filetypes/$mimetype.svg" )){
- return "$WEBROOT/core/img/filetypes/$mimetype.svg";
+ if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.svg" )){
+ return OC::$WEBROOT."/core/img/filetypes/$mimetype.svg";
}
else{
- return "$WEBROOT/core/img/filetypes/file.svg";
+ return OC::$WEBROOT."/core/img/filetypes/file.svg";
}
}
diff --git a/lib/installer.php b/lib/installer.php
index e6810a267db..83c575032ec 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -55,8 +55,6 @@ class OC_Installer{
* needed to get the app working.
*/
public static function installApp( $data = array()){
- global $SERVERROOT;
-
if(!isset($data['source'])){
error_log("No source specified when installing app");
return false;
@@ -105,7 +103,7 @@ class OC_Installer{
return false;
}
$info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml');
- $basedir=$SERVERROOT.'/apps/'.$info['id'];
+ $basedir=OC::$SERVERROOT.'/apps/'.$info['id'];
//check if an app with the same id is already installed
if(self::isInstalled( $info['id'] )){
@@ -246,11 +244,10 @@ class OC_Installer{
* If $enabled is false, apps are installed as disabled.
*/
public static function installShippedApps( $enabled ){
- global $SERVERROOT;
- $dir = opendir( "$SERVERROOT/apps" );
+ $dir = opendir( OC::$SERVERROOT."/apps" );
while( false !== ( $filename = readdir( $dir ))){
- if( substr( $filename, 0, 1 ) != '.' and is_dir("$SERVERROOT/apps/$filename") ){
- if( file_exists( "$SERVERROOT/apps/$filename/appinfo/app.php" )){
+ if( substr( $filename, 0, 1 ) != '.' and is_dir(OC::$SERVERROOT."/apps/$filename") ){
+ if( file_exists( OC::$SERVERROOT."/apps/$filename/appinfo/app.php" )){
if(!OC_Installer::isInstalled($filename)){
OC_Installer::installShippedApp($filename);
if( $enabled ){
diff --git a/lib/l10n.php b/lib/l10n.php
index c0c32185996..54331d44ae4 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -57,7 +57,6 @@ class OC_L10N{
* language.
*/
public function __construct($app, $lang = null){
- global $SERVERROOT;
// Find the right language
if(is_null($lang)){
$lang = self::findLanguage($app);
@@ -81,9 +80,9 @@ class OC_L10N{
}
}
- if(file_exists($SERVERROOT.'/core/l10n/l10n-'.$lang.'.php')){
+ if(file_exists(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php')){
// Include the file, save the data from $CONFIG
- include($SERVERROOT.'/core/l10n/l10n-'.$lang.'.php');
+ include(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php');
if(isset($LOCALIZATIONS) && is_array($LOCALIZATIONS)){
$this->localizations = array_merge($this->localizations, $LOCALIZATIONS);
}
@@ -224,17 +223,15 @@ class OC_L10N{
* @returns directory
*/
protected static function findI18nDir($app){
- global $SERVERROOT;
-
// find the i18n dir
- $i18ndir = $SERVERROOT.'/core/l10n/';
+ $i18ndir = OC::$SERVERROOT.'/core/l10n/';
if($app != ''){
// Check if the app is in the app folder
- if(file_exists($SERVERROOT.'/apps/'.$app.'/l10n/')){
- $i18ndir = $SERVERROOT.'/apps/'.$app.'/l10n/';
+ if(file_exists(OC::$SERVERROOT.'/apps/'.$app.'/l10n/')){
+ $i18ndir = OC::$SERVERROOT.'/apps/'.$app.'/l10n/';
}
else{
- $i18ndir = $SERVERROOT.'/'.$app.'/l10n/';
+ $i18ndir = OC::$SERVERROOT.'/'.$app.'/l10n/';
}
}
return $i18ndir;
diff --git a/lib/remote/cloud.php b/lib/remote/cloud.php
index 2d3dee47b1c..75d60155d06 100644
--- a/lib/remote/cloud.php
+++ b/lib/remote/cloud.php
@@ -184,7 +184,6 @@ class OC_REMOTE_CLOUD{
}
public function sendFile($sourceDir,$sourceFile,$targetDir,$targetFile){
- global $WEBROOT;
$source=$sourceDir.'/'.$sourceFile;
$tmp=OC_Filesystem::toTmpFile($source);
return $this->sendTmpFile($tmp,$targetDir,$targetFile);
@@ -192,15 +191,14 @@ class OC_REMOTE_CLOUD{
public function sendTmpFile($tmp,$targetDir,$targetFile){
$token=sha1(uniqid().$tmp);
- global $WEBROOT;
$file=sys_get_temp_dir().'/'.'remoteCloudFile'.$token;
rename($tmp,$file);
if( OC_Config::getValue( "forcessl", false ) or isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') {
- $url = "https://". $_SERVER['SERVER_NAME'] . $WEBROOT;
+ $url = "https://". $_SERVER['SERVER_NAME'] . OC::$WEBROOT;
}else{
- $url = "http://". $_SERVER['SERVER_NAME'] . $WEBROOT;
+ $url = "http://". $_SERVER['SERVER_NAME'] . OC::$WEBROOT;
}
return $this->apiCall('pull',array('dir'=>$targetDir,'file'=>$targetFile,'token'=>$token,'source'=>$url),true);
}
}
- \ No newline at end of file
+
diff --git a/lib/setup.php b/lib/setup.php
index ebdf3ef823e..7183eb624a8 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -3,7 +3,7 @@
$hasSQLite = (is_callable('sqlite_open') or class_exists('SQLite3'));
$hasMySQL = is_callable('mysql_connect');
$hasPostgreSQL = is_callable('pg_connect');
-$datadir = OC_Config::getValue('datadirectory', $SERVERROOT.'/data');
+$datadir = OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data');
$opts = array(
'hasSQLite' => $hasSQLite,
'hasMySQL' => $hasMySQL,
@@ -23,7 +23,7 @@ if(isset($_POST['install']) AND $_POST['install']=='true') {
OC_Template::printGuestPage("", "installation", $options);
}
else {
- header("Location: ".$WEBROOT.'/');
+ header("Location: ".OC::$WEBROOT.'/');
exit();
}
}
@@ -270,21 +270,19 @@ class OC_Setup {
* create .htaccess files for apache hosts
*/
private static function createHtaccess() {
- $SERVERROOT=OC::$SERVERROOT;
- $WEBROOT=OC::$WEBROOT;
- $content = "ErrorDocument 404 $WEBROOT/core/templates/404.php\n";//custom 404 error page
+ $content = "ErrorDocument 404 ".OC::$WEBROOT."/core/templates/404.php\n";//custom 404 error page
$content.= "<IfModule mod_php5.c>\n";
$content.= "php_value upload_max_filesize 512M\n";//upload limit
$content.= "php_value post_max_size 512M\n";
$content.= "SetEnv htaccessWorking true\n";
$content.= "</IfModule>\n";
$content.= "Options -Indexes\n";
- @file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
+ @file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
$content = "deny from all\n";
$content.= "IndexIgnore *";
- file_put_contents(OC_Config::getValue('datadirectory', $SERVERROOT.'/data').'/.htaccess', $content);
- file_put_contents(OC_Config::getValue('datadirectory', $SERVERROOT.'/data').'/index.html', '');
+ file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content);
+ file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/index.html', '');
}
}
diff --git a/lib/template.php b/lib/template.php
index adedd4f901a..a293e63b437 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -124,18 +124,15 @@ class OC_Template{
* "admin".
*/
public function __construct( $app, $name, $renderas = "" ){
- // Global vars we need
- global $SERVERROOT;
-
// Get the right template folder
- $template = "$SERVERROOT/core/templates/";
+ $template = OC::$SERVERROOT."/core/templates/";
if( $app != "" ){
// Check if the app is in the app folder
- if( file_exists( "$SERVERROOT/apps/$app/templates/" )){
- $template = "$SERVERROOT/apps/$app/templates/";
+ if( file_exists( OC::$SERVERROOT."/apps/$app/templates/" )){
+ $template = OC::$SERVERROOT."/apps/$app/templates/";
}
else{
- $template = "$SERVERROOT/$app/templates/";
+ $template = OC::$SERVERROOT."/$app/templates/";
}
}
@@ -222,9 +219,6 @@ class OC_Template{
* will produce a full page.
*/
public function fetchPage(){
- // global Data we need
- global $WEBROOT;
- global $SERVERROOT;
$data = $this->_fetch();
if( $this->renderas ){
@@ -247,25 +241,25 @@ class OC_Template{
// Add the css and js files
foreach(OC_Util::$scripts as $script){
- if(is_file("$SERVERROOT/apps/$script.js" )){
- $page->append( "jsfiles", "$WEBROOT/apps/$script.js" );
+ if(is_file(OC::$SERVERROOT."/apps/$script.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/apps/$script.js" );
}
- elseif(is_file("$SERVERROOT/$script.js" )){
- $page->append( "jsfiles", "$WEBROOT/$script.js" );
+ elseif(is_file(OC::$SERVERROOT."/$script.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/$script.js" );
}
else{
- $page->append( "jsfiles", "$WEBROOT/core/$script.js" );
+ $page->append( "jsfiles", OC::$WEBROOT."/core/$script.js" );
}
}
foreach(OC_Util::$styles as $style){
- if(is_file("$SERVERROOT/apps/$style.css" )){
- $page->append( "cssfiles", "$WEBROOT/apps/$style.css" );
+ if(is_file(OC::$SERVERROOT."/apps/$style.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/apps/$style.css" );
}
- elseif(is_file("$SERVERROOT/$style.css" )){
- $page->append( "cssfiles", "$WEBROOT/$style.css" );
+ elseif(is_file(OC::$SERVERROOT."/$style.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/$style.css" );
}
else{
- $page->append( "cssfiles", "$WEBROOT/core/$style.css" );
+ $page->append( "cssfiles", OC::$WEBROOT."/core/$style.css" );
}
}
diff --git a/lib/util.php b/lib/util.php
index f4ca879a9bc..e6c4eb83b33 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -16,19 +16,15 @@ class OC_Util {
return false;
}
- // Global Variables
- global $SERVERROOT;
- global $CONFIG_DATADIRECTORY;
-
- $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );
- $CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", "$SERVERROOT/backup" );
+ $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
+ $CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", OC::$SERVERROOT."/backup" );
// 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 setting the owner of '$SERVERROOT' to the user that the web server uses (".exec('whoami').")")));
+ $tmpl->assign('errors',array(1=>array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY_ROOT.")",'hint'=>"You can usually fix this by setting the owner of '".OC::$SERVERROOT."' to the user that the web server uses (".exec('whoami').")")));
$tmpl->printPage();
exit;
}
@@ -57,9 +53,9 @@ class OC_Util {
$sharedStorage = OC_Filesystem::createStorage('shared',array('datadir'=>'/'.OC_User::getUser().'/files/Shared'));
OC_Filesystem::mount($sharedStorage,'/'.OC_User::getUser().'/files/Shared/');
- $CONFIG_DATADIRECTORY = "$CONFIG_DATADIRECTORY_ROOT/$user/$root";
- if( !is_dir( $CONFIG_DATADIRECTORY )){
- mkdir( $CONFIG_DATADIRECTORY, 0755, true );
+ OC::$CONFIG_DATADIRECTORY = $CONFIG_DATADIRECTORY_ROOT."/$user/$root";
+ if( !is_dir( OC::$CONFIG_DATADIRECTORY )){
+ mkdir( OC::$CONFIG_DATADIRECTORY, 0755, true );
}
// TODO: find a cool way for doing this
@@ -193,11 +189,8 @@ class OC_Util {
* @return array arrays with error messages and hints
*/
public static function checkServer(){
- global $SERVERROOT;
- global $CONFIG_DATADIRECTORY;
-
- $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );
- $CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", "$SERVERROOT/backup" );
+ $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
+ $CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", OC::$SERVERROOT."/backup" );
$CONFIG_INSTALLED = OC_Config::getValue( "installed", false );
$errors=array();
diff --git a/search/index.php b/search/index.php
index 7369a6d81ce..c781c31f549 100644
--- a/search/index.php
+++ b/search/index.php
@@ -38,7 +38,7 @@ $query=(isset($_POST['query']))?$_POST['query']:'';
if($query){
$results=OC_Search::search($query);
}else{
- header("Location: ".$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
+ header("Location: ".OC::$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
exit();
}