show server configuration errors on seperate page

remotes/origin/stable
Robin Appelman 13 years ago
parent b5f913a3fc
commit 1495ec0f31

@ -24,7 +24,12 @@
require_once( 'lib/base.php' ); require_once( 'lib/base.php' );
require_once( 'appconfig.php' ); require_once( 'appconfig.php' );
require_once( 'template.php' ); require_once( 'template.php' );
if( OC_USER::isLoggedIn()){
// check if the server is correctly configured for ownCloud
$errors=OC_UTIL::checkServer();
if(count($errors)>0){
OC_TEMPLATE::printGuestPage( "", "error", array( "errors" => $errors ));
}elseif( OC_USER::isLoggedIn()){
if( $_GET["logout"] ){ if( $_GET["logout"] ){
OC_USER::logout(); OC_USER::logout();
header( "Location: $WEBROOT"); header( "Location: $WEBROOT");
@ -34,8 +39,7 @@ if( OC_USER::isLoggedIn()){
header( "Location: ".OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" )); header( "Location: ".OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" ));
exit(); exit();
} }
} }else{
else{
if( OC_USER::login( $_POST["user"], $_POST["password"] )){ if( OC_USER::login( $_POST["user"], $_POST["password"] )){
header( "Location: ".OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" )); header( "Location: ".OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" ));
exit(); exit();

@ -89,13 +89,17 @@ require_once('connect.php');
require_once('remotestorage.php'); require_once('remotestorage.php');
require_once('plugin.php'); require_once('plugin.php');
OC_PLUGIN::loadPlugins( "" ); $error=(count(OC_UTIL::checkServer())>0);
if(!$error){
OC_PLUGIN::loadPlugins( "" );
}
OC_USER::setBackend( OC_CONFIG::getValue( "userbackend", "database" )); OC_USER::setBackend( OC_CONFIG::getValue( "userbackend", "database" ));
OC_GROUP::setBackend( OC_CONFIG::getValue( "groupbackend", "database" )); OC_GROUP::setBackend( OC_CONFIG::getValue( "groupbackend", "database" ));
// Set up file system unless forbidden // Set up file system unless forbidden
if( !$RUNTIME_NOSETUPFS ){ if(!$error and !$RUNTIME_NOSETUPFS ){
OC_UTIL::setupFS(); OC_UTIL::setupFS();
} }
@ -108,12 +112,10 @@ OC_UTIL::addStyle( "jquery-ui-1.8.10.custom" );
OC_UTIL::addStyle( "styles" ); OC_UTIL::addStyle( "styles" );
// Load Apps // Load Apps
if( !$RUNTIME_NOAPPS ){ if(!$error and !$RUNTIME_NOAPPS ){
OC_APP::loadApps(); OC_APP::loadApps();
} }
// check if the server is correctly configured for ownCloud
OC_UTIL::checkserver();
/** /**
* Class for utility functions * Class for utility functions
* *
@ -221,7 +223,7 @@ class OC_UTIL {
/** /**
* check if the current server configuration is suitable for ownCloud * check if the current server configuration is suitable for ownCloud
* * @return array with error messages
*/ */
public static function checkServer(){ public static function checkServer(){
global $SERVERROOT; global $SERVERROOT;
@ -230,12 +232,16 @@ class OC_UTIL {
$CONFIG_DATADIRECTORY_ROOT = OC_CONFIG::getValue( "datadirectory", "$SERVERROOT/data" );; $CONFIG_DATADIRECTORY_ROOT = OC_CONFIG::getValue( "datadirectory", "$SERVERROOT/data" );;
$CONFIG_BACKUPDIRECTORY = OC_CONFIG::getValue( "backupdirectory", "$SERVERROOT/backup" ); $CONFIG_BACKUPDIRECTORY = OC_CONFIG::getValue( "backupdirectory", "$SERVERROOT/backup" );
$CONFIG_INSTALLED = OC_CONFIG::getValue( "installed", false ); $CONFIG_INSTALLED = OC_CONFIG::getValue( "installed", false );
$error=''; $errors=array();
//check for database drivers
if(!is_callable('sqlite_open') and !is_callable('mysql_connect')){ if(!is_callable('sqlite_open') and !is_callable('mysql_connect')){
$error.='No database drivers (sqlite or mysql) installed.<br/>'; $errors[]='No database drivers (sqlite or mysql) installed.<br/>';
} }
$CONFIG_DBTYPE = OC_CONFIG::getValue( "dbtype", "sqlite" ); $CONFIG_DBTYPE = OC_CONFIG::getValue( "dbtype", "sqlite" );
$CONFIG_DBNAME = OC_CONFIG::getValue( "dbname", "owncloud" ); $CONFIG_DBNAME = OC_CONFIG::getValue( "dbname", "owncloud" );
//check for correct file permissions
if(!stristr(PHP_OS, 'WIN')){ if(!stristr(PHP_OS, 'WIN')){
if($CONFIG_DBTYPE=='sqlite'){ if($CONFIG_DBTYPE=='sqlite'){
$file=$SERVERROOT.'/'.$CONFIG_DBNAME; $file=$SERVERROOT.'/'.$CONFIG_DBNAME;
@ -246,7 +252,7 @@ class OC_UTIL {
clearstatcache(); clearstatcache();
$prems=substr(decoct(fileperms($file)),-3); $prems=substr(decoct(fileperms($file)),-3);
if(substr($prems,2,1)!='0'){ if(substr($prems,2,1)!='0'){
$error.='SQLite database file ('.$file.') is readable from the web<br/>'; $errors[]='SQLite database file ('.$file.') is readable from the web<br/>';
} }
} }
} }
@ -257,7 +263,7 @@ class OC_UTIL {
clearstatcache(); clearstatcache();
$prems=substr(decoct(fileperms($CONFIG_DATADIRECTORY_ROOT)),-3); $prems=substr(decoct(fileperms($CONFIG_DATADIRECTORY_ROOT)),-3);
if(substr($prems,2,1)!='0'){ if(substr($prems,2,1)!='0'){
$error.='Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable from the web<br/>'; $errors[]='Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable from the web<br/>';
} }
} }
if( OC_CONFIG::getValue( "enablebackup", false )){ if( OC_CONFIG::getValue( "enablebackup", false )){
@ -267,16 +273,20 @@ class OC_UTIL {
clearstatcache(); clearstatcache();
$prems=substr(decoct(fileperms($CONFIG_BACKUPDIRECTORY)),-3); $prems=substr(decoct(fileperms($CONFIG_BACKUPDIRECTORY)),-3);
if(substr($prems,2,1)!='0'){ if(substr($prems,2,1)!='0'){
$error.='Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable from the web<br/>'; $errors[]='Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable from the web<br/>';
} }
} }
} }
}else{ }else{
//TODO: premisions checks for windows hosts //TODO: premisions checks for windows hosts
} }
if($error){ if(!is_writable($CONFIG_DATADIRECTORY_ROOT)){
die($error); $errors[]='Data directory ('.$CONFIG_BACKUPDIRECTORY.') not writable by ownCloud<br/>';
} }
//TODO: check for php modules
return $errors;
} }
} }

@ -0,0 +1,15 @@
<?php
/*
* Template for error page
*/
?>
<div id="login">
<img src="<?php echo image_path("", "owncloud-logo-medium-white.png"); ?>" alt="ownCloud" />
<br/><br/><br/><br/>
<ul>
<?php foreach($_["errors"] as $error):?>
<li><?php echo $error ?></li>
<?php endforeach ?>
</ul>
</div>
Loading…
Cancel
Save