summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-04-16 18:26:13 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-04-16 18:27:58 +0200
commitf0e59b9043292a5abfb0b0d21763a0cd7306dad7 (patch)
tree34498f379ef00ef2afce3fe23c4d29dde9680b70
parent964a55033adba52d3004ec90a82cdb5d521a7a97 (diff)
downloadnextcloud-server-f0e59b9043292a5abfb0b0d21763a0cd7306dad7.tar.gz
nextcloud-server-f0e59b9043292a5abfb0b0d21763a0cd7306dad7.zip
better display for server configuration errors
-rw-r--r--css/styles.css15
-rw-r--r--lib/base.php26
-rw-r--r--templates/error.php6
3 files changed, 38 insertions, 9 deletions
diff --git a/css/styles.css b/css/styles.css
index 4fc5a39b8c0..d6e5ea8fcc0 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -633,3 +633,18 @@ p.actions a.delete
border: 1px solid #CCC;
text-align: right;
}
+
+li.error{
+ list-style:none;
+ width: 640px;
+ margin: 4em auto;
+ padding: 1em 1em 1em 4em;
+ background-color: #FEE;
+ background-image: url(../img/task-attention.png);
+ background-position: 0.8em 0.8em;
+ background-repeat: no-repeat;
+ border: 1px solid #CCC;
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
+ border-radius: 10px;
+} \ No newline at end of file
diff --git a/lib/base.php b/lib/base.php
index 712ea54d706..dbeba1dd1f9 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -222,7 +222,7 @@ class OC_UTIL {
/**
* check if the current server configuration is suitable for ownCloud
- * @return array with error messages
+ * @return array arrays with error messages and hints
*/
public static function checkServer(){
global $SERVERROOT;
@@ -235,11 +235,23 @@ class OC_UTIL {
//check for database drivers
if(!is_callable('sqlite_open') and !is_callable('mysql_connect')){
- $errors[]='No database drivers (sqlite or mysql) installed.<br/>';
+ $errors[]=array('error'=>'No database drivers (sqlite or mysql) installed.<br/>','hint'=>'');//TODO: sane hint
}
$CONFIG_DBTYPE = OC_CONFIG::getValue( "dbtype", "sqlite" );
$CONFIG_DBNAME = OC_CONFIG::getValue( "dbname", "owncloud" );
-
+
+ //try to get the username the httpd server runs on, used in hints
+ $stat=stat($_SERVER['DOCUMENT_ROOT']);
+ if(is_callable('posix_getpwuid')){
+ $serverUser=posix_getpwuid($stat['uid']);
+ $serverUser='\''.$serverUser['name'].'\'';
+ }else{
+ $serverUser='\'www-data\' for ubuntu/debian';//TODO: try to detect the distro and give a guess based on that
+ }
+
+ //common hint for all file permissons error messages
+ $permissionsHint="Permissions can usually be fixed by setting the owner of the directory to the user the web server runs as ($serverUser)";
+
//check for correct file permissions
if(!stristr(PHP_OS, 'WIN')){
if($CONFIG_DBTYPE=='sqlite'){
@@ -251,7 +263,7 @@ class OC_UTIL {
clearstatcache();
$prems=substr(decoct(fileperms($file)),-3);
if(substr($prems,2,1)!='0'){
- $errors[]='SQLite database file ('.$file.') is readable from the web<br/>';
+ $errors[]=array('error'=>'SQLite database file ('.$file.') is readable from the web<br/>','hint'=>$permissionsHint);
}
}
}
@@ -262,7 +274,7 @@ class OC_UTIL {
clearstatcache();
$prems=substr(decoct(fileperms($CONFIG_DATADIRECTORY_ROOT)),-3);
if(substr($prems,2,1)!='0'){
- $errors[]='Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable from the web<br/>';
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable from the web<br/>','hint'=>$permissionsHint);
}
}
if( OC_CONFIG::getValue( "enablebackup", false )){
@@ -272,7 +284,7 @@ class OC_UTIL {
clearstatcache();
$prems=substr(decoct(fileperms($CONFIG_BACKUPDIRECTORY)),-3);
if(substr($prems,2,1)!='0'){
- $errors[]='Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable from the web<br/>';
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable from the web<br/>','hint'=>$permissionsHint);
}
}
}
@@ -280,7 +292,7 @@ class OC_UTIL {
//TODO: premisions checks for windows hosts
}
if(!is_writable($CONFIG_DATADIRECTORY_ROOT)){
- $errors[]='Data directory ('.$CONFIG_BACKUPDIRECTORY.') not writable by ownCloud<br/>';
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') not writable by ownCloud<br/>','hint'=>$permissionsHint);
}
//TODO: check for php modules
diff --git a/templates/error.php b/templates/error.php
index e8f56d63bd1..5b71c1ef751 100644
--- a/templates/error.php
+++ b/templates/error.php
@@ -5,10 +5,12 @@
?>
<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>
+ <li class='error'>
+ <?php echo $error['error'] ?><br/>
+ <p class='hint'><?php echo $error['hint'] ?></p>
+ </li>
<?php endforeach ?>
</ul>
</div>