Removed global vars are DOCUMENTROOT, SERVERROOT, SUBURI, WEBROOT and CONFIG_DATADIRECTORYtags/v3.0
@@ -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)) { |
@@ -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 | |||
// }}} | |||
} | |||
?> | |||
?> |
@@ -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 | |||
} | |||
?> | |||
?> |
@@ -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()); |
@@ -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()); |
@@ -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; | |||
} | |||
?> | |||
?> |
@@ -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{ | |||
} | |||
} | |||
?> | |||
?> |
@@ -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']){ |
@@ -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)); |
@@ -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(); |
@@ -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'; | |||
?> | |||
?> |
@@ -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 { | |||
?> | |||
?> |
@@ -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> |
@@ -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): ?> |
@@ -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')); |
@@ -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()); |
@@ -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 | |||
// }}} | |||
} | |||
?> | |||
?> |
@@ -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 | |||
} | |||
} | |||
?> | |||
?> |
@@ -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); |
@@ -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 )){ |
@@ -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').")"))); |
@@ -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){ |
@@ -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 | |||
} | |||
} |
@@ -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"; | |||
} | |||
} | |||
@@ -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 ){ |
@@ -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; |
@@ -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); | |||
} | |||
} | |||
@@ -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', ''); | |||
} | |||
} | |||
@@ -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" ); | |||
} | |||
} | |||
@@ -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(); | |||
@@ -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(); | |||
} | |||