remove dependency on set_include_path because not all hosts support it

This commit is contained in:
Robin 2010-04-24 12:40:20 +02:00
parent 9be88c0080
commit d9e0d5deca
5 changed files with 125 additions and 18 deletions

View File

@ -40,7 +40,7 @@ if($WEBROOT{0}!=='/'){
} }
// set the right include path // set the right include path
set_include_path(get_include_path().PATH_SEPARATOR.$SERVERROOT.PATH_SEPARATOR.$SERVERROOT.'/inc'.PATH_SEPARATOR.$SERVERROOT.'/config'); // set_include_path(get_include_path().PATH_SEPARATOR.$SERVERROOT.PATH_SEPARATOR.$SERVERROOT.'/inc'.PATH_SEPARATOR.$SERVERROOT.'/config');
// define default config values // define default config values
$CONFIG_INSTALLED=false; $CONFIG_INSTALLED=false;
@ -51,7 +51,7 @@ $CONFIG_DBNAME='owncloud';
$CONFIG_DBTYPE='sqlite'; $CONFIG_DBTYPE='sqlite';
// include the generated configfile // include the generated configfile
@include_once('config.php'); @oc_include_once('config.php');
// redirect to https site if configured // redirect to https site if configured
if(isset($CONFIG_HTTPFORCESSL) and $CONFIG_HTTPFORCESSL){ if(isset($CONFIG_HTTPFORCESSL) and $CONFIG_HTTPFORCESSL){
@ -63,10 +63,10 @@ if(isset($CONFIG_HTTPFORCESSL) and $CONFIG_HTTPFORCESSL){
} }
// load core libs // load core libs
require_once('lib_files.php'); oc_require_once('lib_files.php');
require_once('lib_log.php'); oc_require_once('lib_log.php');
require_once('lib_config.php'); oc_require_once('lib_config.php');
require_once('lib_user.php'); oc_require_once('lib_user.php');
if(OC_USER::isLoggedIn()){ if(OC_USER::isLoggedIn()){
//jail the user in a seperate data folder //jail the user in a seperate data folder
@ -131,7 +131,7 @@ class OC_UTIL {
public static function showheader(){ public static function showheader(){
global $CONFIG_ADMINLOGIN; global $CONFIG_ADMINLOGIN;
global $WEBROOT; global $WEBROOT;
require('templates/header.php');; oc_require('templates/header.php');;
} }
/** /**
@ -141,7 +141,7 @@ class OC_UTIL {
public static function showfooter(){ public static function showfooter(){
global $CONFIG_FOOTEROWNERNAME; global $CONFIG_FOOTEROWNERNAME;
global $CONFIG_FOOTEROWNEREMAIL; global $CONFIG_FOOTEROWNEREMAIL;
require('templates/footer.php');; oc_require('templates/footer.php');;
} }
/** /**
@ -188,7 +188,7 @@ class OC_UTIL {
*/ */
public static function showloginform(){ public static function showloginform(){
global $loginresult; global $loginresult;
require('templates/loginform.php'); oc_require('templates/loginform.php');
} }
@ -452,4 +452,101 @@ class OC_DB {
} }
?> //custom require/include functions because not all hosts allow us to set the include path
function oc_require($file){
global $SERVERROOT;
global $DOCUMENTROOT;
global $WEBROOT;
global $CONFIG_DBNAME;
global $CONFIG_DBHOST;
global $CONFIG_DBUSER;
global $CONFIG_DBPASSWORD;
global $CONFIG_DBTYPE;
global $CONFIG_DATADIRECTORY;
global $CONFIG_HTTPFORCESSL;
global $CONFIG_DATEFORMAT;
global $CONFIG_INSTALLED;
if(is_file($file)){
require($file);
}elseif(is_file($SERVERROOT.'/'.$file)){
require($SERVERROOT.'/'.$file);
}elseif(is_file($SERVERROOT.'/inc/'.$file)){
require($SERVERROOT.'/inc/'.$file);
}elseif(is_file($SERVERROOT.'/config/'.$file)){
require($SERVERROOT.'/config/'.$file);
}
}
function oc_require_once($file){
global $SERVERROOT;
global $DOCUMENTROOT;
global $WEBROOT;
global $CONFIG_DBNAME;
global $CONFIG_DBHOST;
global $CONFIG_DBUSER;
global $CONFIG_DBPASSWORD;
global $CONFIG_DBTYPE;
global $CONFIG_DATADIRECTORY;
global $CONFIG_HTTPFORCESSL;
global $CONFIG_DATEFORMAT;
global $CONFIG_INSTALLED;
if(is_file($file)){
require_once($file);
}elseif(is_file($SERVERROOT.'/'.$file)){
require_once($SERVERROOT.'/'.$file);
}elseif(is_file($SERVERROOT.'/inc/'.$file)){
require_once($SERVERROOT.'/inc/'.$file);
}elseif(is_file($SERVERROOT.'/config/'.$file)){
require_once($SERVERROOT.'/config/'.$file);
}
}
function oc_include($file){
global $SERVERROOT;
global $DOCUMENTROOT;
global $WEBROOT;
global $CONFIG_DBNAME;
global $CONFIG_DBHOST;
global $CONFIG_DBUSER;
global $CONFIG_DBPASSWORD;
global $CONFIG_DBTYPE;
global $CONFIG_DATADIRECTORY;
global $CONFIG_HTTPFORCESSL;
global $CONFIG_DATEFORMAT;
global $CONFIG_INSTALLED;
if(is_file($file)){
include($file);
}elseif(is_file($SERVERROOT.'/'.$file)){
include($SERVERROOT.'/'.$file);
}elseif(is_file($SERVERROOT.'/inc/'.$file)){
include($SERVERROOT.'/inc/'.$file);
}elseif(is_file($SERVERROOT.'/config/'.$file)){
include($SERVERROOT.'/config/'.$file);
}
}
function oc_include_once($file){
global $SERVERROOT;
global $DOCUMENTROOT;
global $WEBROOT;
global $CONFIG_DBNAME;
global $CONFIG_DBHOST;
global $CONFIG_DBUSER;
global $CONFIG_DBPASSWORD;
global $CONFIG_DBTYPE;
global $CONFIG_DATADIRECTORY;
global $CONFIG_HTTPFORCESSL;
global $CONFIG_DATEFORMAT;
global $CONFIG_INSTALLED;
if(is_file($file)){
include_once($file);
}elseif(is_file($SERVERROOT.'/'.$file)){
include_once($SERVERROOT.'/'.$file);
}elseif(is_file($SERVERROOT.'/inc/'.$file)){
include_once($SERVERROOT.'/inc/'.$file);
}elseif(is_file($SERVERROOT.'/config/'.$file)){
include_once($SERVERROOT.'/config/'.$file);
}
}
?>

View File

@ -11,7 +11,7 @@ class OC_CONFIG{
global $CONFIG_HTTPFORCESSL; global $CONFIG_HTTPFORCESSL;
global $CONFIG_DATEFORMAT; global $CONFIG_DATEFORMAT;
global $CONFIG_DBNAME; global $CONFIG_DBNAME;
require('templates/configform.php'); oc_require('templates/configform.php');
} }
/** /**
@ -35,7 +35,7 @@ class OC_CONFIG{
} }
} }
if($allow){ if($allow){
require('templates/adminform.php'); oc_require('templates/adminform.php');
} }
} }

View File

@ -21,6 +21,12 @@
* *
*/ */
if(!$CONFIG_INSTALLED){
$_SESSION['user_id']=false;
$_SESSION['username']='';
$_SESSION['username_clean']='';
}
/** /**
* Class for usermanagement * Class for usermanagement
* *
@ -174,10 +180,14 @@ class OC_USER {
public static function ingroup($username,$groupname){ public static function ingroup($username,$groupname){
$userid=OC_USER::getuserid($username); $userid=OC_USER::getuserid($username);
$groupid=OC_USER::getgroupid($groupname); $groupid=OC_USER::getgroupid($groupname);
$query="SELECT user_group_id FROM `user_group` WHERE `group_id` = '$groupid ' AND `user_id` = '$userid 'LIMIT 1"; if($groupid>0 and $userid>0){
$result=OC_DB::select($query); $query="SELECT user_group_id FROM `user_group` WHERE `group_id` = '$groupid ' AND `user_id` = '$userid 'LIMIT 1";
if(isset($result[0]) && isset($result[0]['user_group_id'])){ $result=OC_DB::select($query);
return true; if(isset($result[0]) && isset($result[0]['user_group_id'])){
return true;
}else{
return false;
}
}else{ }else{
return false; return false;
} }

View File

@ -49,7 +49,7 @@ function dbtypechange(){
<?php <?php
} }
if($FIRSTRUN){?> if($FIRSTRUN){?>
<tr><td>admin login:</td><td><input type="text" name="adminlogin" size="30" class="formstyle" value="<?php echo($CONFIG_ADMINLOGIN);?>"></input></td></tr> <tr><td>admin login:</td><td><input type="text" name="adminlogin" size="30" class="formstyle" value=""></input></td></tr>
<tr><td>admin password:</td><td><input type="password" name="adminpassword" size="30" class="formstyle"></input></td><td>(leave empty to keep current password)</td></tr> <tr><td>admin password:</td><td><input type="password" name="adminpassword" size="30" class="formstyle"></input></td><td>(leave empty to keep current password)</td></tr>
<tr><td>retype admin password:</td><td><input type="password" name="adminpassword2" size="30" class="formstyle"></input></td></tr> <tr><td>retype admin password:</td><td><input type="password" name="adminpassword2" size="30" class="formstyle"></input></td></tr>
<?php <?php

View File

@ -23,7 +23,7 @@
require_once('../inc/lib_base.php'); require_once('../inc/lib_base.php');
require_once('HTTP/WebDAV/Server/Filesystem.php'); oc_require_once('HTTP/WebDAV/Server/Filesystem.php');
ini_set('default_charset', 'UTF-8'); ini_set('default_charset', 'UTF-8');