]> source.dussan.org Git - nextcloud-server.git/commitdiff
cleanup autoconfiguration wizard, add settings page, make it run from subdirectories...
authorroot <root@dev.(none)>
Tue, 16 Mar 2010 07:48:36 +0000 (08:48 +0100)
committerroot <root@dev.(none)>
Tue, 16 Mar 2010 07:48:36 +0000 (08:48 +0100)
14 files changed:
README [changed mode: 0644->0755]
config/config.php [changed mode: 0755->0644]
css/default.css [deleted file]
css/default.php [new file with mode: 0755]
inc/lib_base.php
inc/lib_files.php
inc/templates/configform.php [new file with mode: 0644]
inc/templates/footer.php
inc/templates/header.php
inc/templates/loginform.php
index.php
log/index.php
settings/index.php
webdav/owncloud.php

diff --git a/README b/README
old mode 100644 (file)
new mode 100755 (executable)
old mode 100755 (executable)
new mode 100644 (file)
index 8470ad3..4252781
@@ -1,87 +1,11 @@
-<?php
-
-function getConfig(){
-?>
-<form method="post" enctype="multipart/form-data" action="index.php" >
-<table cellpadding="5" cellspacing="5" border="0" class="loginform">
-<tr><td>owner name:</td><td><input type="text" name="CONFIG_FOOTEROWNERNAME" size="30" class="formstyle"></input></td></tr>
-<tr><td>owner email:</td><td><input type="text" name="CONFIG_FOOTEROWNEREMAIL" size="30" class="formstyle"></input></td></tr>
-<tr><td>admin name:</td><td><input type="text" name="CONFIG_ADMINLOGIN" size="30" class="formstyle"></input></td></tr>
-<tr><td>admin password:</td><td><input type="password" name="CONFIG_ADMINPASSWORD" size="30" class="formstyle"></input></td></tr>
-<tr><td>retype admin password:</td><td><input type="password" name="CONFIG_ADMINPASSWORD_RETYPE" size="30" class="formstyle"></input></td></tr>
-<tr><td>document root:</td><td><input type="text" name="CONFIG_DOCUMENTROOT" size="30" class="formstyle" value="<?php echo realpath(dirname(__FILE__).'/../'); ?>"></input></td></tr>
-<tr><td>data directory:</td><td><input type="text" name="CONFIG_DATADIRECTORY" size="30" class="formstyle" value="<?php echo realpath(dirname(__FILE__).'/../'); ?>/data/"></input></td></tr>
-<tr><td>site root:</td><td><input type="text" name="CONFIG_SITEROOT" size="30" class="formstyle" value="<?php echo $_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']); ?>"></input></td></tr>
-<tr><td>force ssl:</td><td><input type="checkbox" name="CONFIG_HTTPFORCESSL" size="30" class="formstyle" value='0'></input></td></tr>
-<tr><td>date format:</td><td><input type="text" name="CONFIG_DATEFORMAT" size="30" class="formstyle" value='j M Y G:i'></input></td></tr>
-<tr><td>database host:</td><td><input type="text" name="CONFIG_DBHOST" size="30" class="formstyle" value='localhost'></input></td></tr>
-<tr><td>database name:</td><td><input type="text" name="CONFIG_DBNAME" size="30" class="formstyle" value='owncloud'></input></td></tr>
-<tr><td>database user:</td><td><input type="text" name="CONFIG_DBUSER" size="30" class="formstyle" value='owncloud'></input></td></tr>
-<tr><td>database password:</td><td><input type="password" name="CONFIG_DBPWD" size="30" class="formstyle" value=''></input></td></tr>
-<tr><td>retype database password:</td><td><input type="password" name="CONFIG_DBPWD_RETYPE" size="30" class="formstyle" value=''></input></td></tr>
-<tr><td></td><td><input type="submit" name="savebutton" alt="save" value="save" class="formstyle" /></td></tr>
-</table></form>
-<?php
-       die();
-}
-
-function writeConfig($config){
-       $allowed=array('CONFIG_FOOTEROWNERNAME','CONFIG_FOOTEROWNEREMAIL','CONFIG_ADMINLOGIN','CONFIG_ADMINPASSWORD','CONFIG_DBHOST','CONFIG_DBNAME','CONFIG_DBUSER','CONFIG_DBPWD','CONFIG_DOCUMENTROOT','CONFIG_DATADIRECTORY','CONFIG_HTTPFORCESSL','CONFIG_DATEFORMAT','CONFIG_SITEROOT');
-       $requireRetype=array('CONFIG_ADMINPASSWORD','CONFIG_DBPWD');
-       foreach($requireRetype as $name){
-               if($config[$name]!=$config[$name.'_RETYPE']){
-                       echo "error: passwords don't match";
-                       getConfig();
-               }
-       }
-       $configString="//config\n";
-       foreach($allowed as $name){
-               if($config[$name]===''){
-                       echo "error: empty field not allowed";
-                       getConfig();
-               }
-               $GLOBALS[$name]=$config[$name];
-               if(is_string($config[$name])){
-                       $value="'{$config[$name]}'";
-               }else{
-                       $value=(integer)$config[$name];
-               }
-               $configString.="\$$name = $value;\n";
-       }
-       
-       $configFile=file_get_contents(__FILE__);
-       $configFile=str_replace('//config'.'_placeholder',$configString,$configFile);
-       file_put_contents(__FILE__,$configFile);
-}
-
-//config_placeholder
-
-
-
-
-
-
-
-if(!isset($CONFIG_ADMINLOGIN)){
-       if(!isset($_POST['CONFIG_FOOTEROWNERNAME'])){
-               getConfig();
-       }else{
-               writeConfig($_POST);
-       }
-}
-
-$protocol=strtolower($_SERVER['SERVER_PROTOCOL']);
-$CONFIG_PROTOCOL=substr($protocol,0,strpos($protocol,"/"))."://";
-$CONFIG_WEBROOT=$CONFIG_PROTOCOL.$CONFIG_SITEROOT;
-
-$CONFIG_LOADPLUGINS='';
-
-
-// set the right include path
-// donĀ“t change unless you know what you are doing
-set_include_path(get_include_path().PATH_SEPARATOR.$CONFIG_DOCUMENTROOT.PATH_SEPARATOR.$CONFIG_DOCUMENTROOT.'/inc');
-
-
-require_once('lib_base.php');
-
-?>
+<?php 
+$CONFIG_ADMINLOGIN='frank';
+$CONFIG_ADMINPASSWORD='123';
+$CONFIG_DATADIRECTORY='/www/testy';
+$CONFIG_HTTPFORCESSL=false;
+$CONFIG_DATEFORMAT='j M Y G:i';
+$CONFIG_DBHOST='localhost';
+$CONFIG_DBNAME='owncloud';
+$CONFIG_DBUSER='owncloud';
+$CONFIG_DBPASSWORD='owncloud123';
+?> 
\ No newline at end of file
diff --git a/css/default.css b/css/default.css
deleted file mode 100755 (executable)
index be4ffd0..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-body {background-color: #F9F9F9;}
-body.error {background-color: #F0F0F0;}
-body,th,td,ul,li,a,div,p,pre {color:#333333; font-family:Verdana,"Bitstream Vera Sans",Arial,Helvetica,Sans,"Bitstream Vera Serif"; font-size:9.0pt;}
-
-a img {
-  border:none;
-}
-
-h1 {
-  margin-bottom:1.5em;
-}
-
-.center {
-  text-align:center;
-}
-
-.center * {
-  margin-left:auto;
-  margin-right:auto;
-}
-
-div#nav {
-  margin-bottom:2em;
-}
-
-a#owncloud-logo {
-  margin-left:auto;
-  margin-right:auto;
-  display:block;
-  width:200px;
-  height:99px;
-  background: transparent url(/img/owncloud-logo-small.png) no-repeat scroll 0 0;
-}
-
-a#owncloud-logo span {
-  display:none;
-}
-
-.nametext a {color:#333333; font-size:8pt; font-weight:bold; text-decoration:none;}
-.highlighttext {color:#333333; font-size:9pt; font-weight:bold; text-decoration:none;}
-.datetext {color:#333333; font-size:7pt;}
-.sizetext {color:#333333; font-size:7pt;}
-.footer {color:#999999; text-align:center; font-size:9pt; margin-top:4em;}
-.hint {color:#AAAAAA; text-align:center; font-size:8pt; margin-top:4em; margin-bottom:2em;}
-.hint a{color:#AAAAAA; text-align:center; font-size:8pt;}
-
-.formstyle {
-  font-weight:normal;
-  font-size: 8.0pt;
-  color: #555555;
-  background-color: #FFFFFF;
-  border: 1px solid #DDDDDD;
-  padding:0px;
-  margin:0px;
-}
-
-.loginform {
-  background-color: #EEEEEE;
-}
-
-.browser {
-  background-color: #EEEEEE;
-}
-
-.browserline {
-  background-color: #EEEEEE;
-}
-
-.browserline:hover {
-  background-color: #DDDDDD;
-}
-
-
-.navigationitem1 {
-  background-color: #EEEEEE;
-  color:#555555; 
-  font-size:9pt; 
-  font-weight:bold;
-}
-
-.navigationitem1 a{
-  text-decoration:none;
-  padding-right:15px;
-  background: transparent url(/img/dots.png) no-repeat scroll center right;
-}
-
-.navigationitem1 img {
-  border:none;
-}
-
-.navigationitem1:hover {
-  background-color: #EEEEEE;
-}
-
-.navigationitem {
-  background-color: #EEEEEE;
-}
-
-.navigationitem:hover {
-  background-color: #DDDDDD;
-}
-
-.navigationselected td {
-  background-color: #DDDDDD;
-}
-
-.navigationitem a {
-  text-decoration:none;
-  color: #333333;
-  font-size: 8.0pt;
-}
-
-.navigationitemselected a {
-  text-decoration:none;
-  color: #333333;
-  font-size: 8.0pt;
-  font-weight:bold;
-}
-
-
-
-
diff --git a/css/default.php b/css/default.php
new file mode 100755 (executable)
index 0000000..7da6bb5
--- /dev/null
@@ -0,0 +1,128 @@
+<?php
+header('Content-Type: text/css');
+require_once('../inc/lib_base.php');
+?>
+body {background-color: #F9F9F9;}
+body.error {background-color: #F0F0F0;}
+body,th,td,ul,li,a,div,p,pre {color:#333333; font-family:Verdana,"Bitstream Vera Sans",Arial,Helvetica,Sans,"Bitstream Vera Serif"; font-size:9.0pt;}
+
+a img {
+  border:none;
+}
+
+h1 {
+  margin-bottom:1.5em;
+}
+
+.center {
+  text-align:center;
+}
+
+.center * {
+  margin-left:auto;
+  margin-right:auto;
+}
+
+div#nav {
+  margin-bottom:2em;
+}
+
+a#owncloud-logo {
+  margin-left:auto;
+  margin-right:auto;
+  display:block;
+  width:200px;
+  height:99px;
+  background: transparent url(<?php if(isset($WEBROOT)) echo($WEBROOT); ?>/img/owncloud-logo-small.png) no-repeat scroll 0 0;
+}
+
+a#owncloud-logo span {
+  display:none;
+}
+
+.nametext a {color:#333333; font-size:8pt; font-weight:bold; text-decoration:none;}
+.errortext {color:#CC3333; font-size:9pt; font-weight:bold; text-decoration:none;}
+.highlighttext {color:#333333; font-size:9pt; font-weight:bold; text-decoration:none;}
+.datetext {color:#333333; font-size:7pt;}
+.sizetext {color:#333333; font-size:7pt;}
+.footer {color:#999999; text-align:center; font-size:9pt; margin-top:4em;}
+.footer a {color:#999999; text-decoration:none;}
+.hint {color:#AAAAAA; text-align:center; font-size:8pt; margin-top:4em; margin-bottom:2em;}
+.hint a{color:#AAAAAA; text-align:center; font-size:8pt;}
+
+.formstyle {
+  font-weight:normal;
+  font-size: 8.0pt;
+  color: #555555;
+  background-color: #FFFFFF;
+  border: 1px solid #DDDDDD;
+  padding:0px;
+  margin:0px;
+}
+
+.loginform {
+  background-color: #EEEEEE;
+}
+
+.browser {
+  background-color: #EEEEEE;
+}
+
+.browserline {
+  background-color: #EEEEEE;
+}
+
+.browserline:hover {
+  background-color: #DDDDDD;
+}
+
+
+.navigationitem1 {
+  background-color: #EEEEEE;
+  color:#555555; 
+  font-size:9pt; 
+  font-weight:bold;
+}
+
+.navigationitem1 a{
+  text-decoration:none;
+  padding-right:15px;
+  background: transparent url(<?php if(isset($WEBROOT)) echo($WEBROOT); ?>/img/dots.png) no-repeat scroll center right;
+}
+
+.navigationitem1 img {
+  border:none;
+}
+
+.navigationitem1:hover {
+  background-color: #EEEEEE;
+}
+
+.navigationitem {
+  background-color: #EEEEEE;
+}
+
+.navigationitem:hover {
+  background-color: #DDDDDD;
+}
+
+.navigationselected td {
+  background-color: #DDDDDD;
+}
+
+.navigationitem a {
+  text-decoration:none;
+  color: #333333;
+  font-size: 8.0pt;
+}
+
+.navigationitemselected a {
+  text-decoration:none;
+  color: #333333;
+  font-size: 8.0pt;
+  font-weight:bold;
+}
+
+
+
+
index 227e616bcd1a3fb56468db6a92175c1d95146fe2..41f792d56b56dce08959c9f4de46bf3f1f33af73 100755 (executable)
 
 
 // set some stuff
+ob_start();
 error_reporting(E_ALL | E_STRICT);
 date_default_timezone_set('Europe/Berlin');
 ini_set('arg_separator.output','&amp;');
 ini_set('session.cookie_httponly','1;');
 session_start();
 
+// calculate the documentroot
+$DOCUMENTROOT=substr(__FILE__,0,-17);
+$SERVERROOT=$_SERVER['DOCUMENT_ROOT'];
+$count=strlen($SERVERROOT);
+$WEBROOT=substr($DOCUMENTROOT,$count);
+//echo($WEBROOT);
+
+// set the right include path
+set_include_path(get_include_path().PATH_SEPARATOR.$DOCUMENTROOT.PATH_SEPARATOR.$DOCUMENTROOT.'/inc'.PATH_SEPARATOR.$DOCUMENTROOT.'/config');
+
+// define default config values
+$CONFIG_ADMINLOGIN='';
+$CONFIG_ADMINPASSWORD='';
+$CONFIG_DATADIRECTORY='/var/data';
+$CONFIG_HTTPFORCESSL=false;
+$CONFIG_DATEFORMAT='j M Y G:i';
+$CONFIG_DBHOST='localhost';
+$CONFIG_DBNAME='owncloud';
+$CONFIG_DBUSER='';
+$CONFIG_DBPASSWORD='';
+
+// include the generated configfile
+@include_once('config.php');
+
 // redirect to https site if configured
-if($CONFIG_HTTPFORCESSL){
+if(isset($CONFIG_HTTPFORCESSL) and $CONFIG_HTTPFORCESSL){
   if(!isset($_SERVER['HTTPS']) or $_SERVER['HTTPS'] != 'on') { 
     $url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; 
     header("Location: $url"); 
@@ -43,10 +68,19 @@ require_once('lib_files.php');
 require_once('lib_log.php');
 
 // load plugins
+$CONFIG_LOADPLUGINS='';
 $plugins=explode(' ',$CONFIG_LOADPLUGINS);
 if(isset($plugins[0]['url'])) foreach($plugins as $plugin) require_once('plugins/'.$plugin.'/lib_'.$plugin.'.php');
 
 
+// check if the server is correctly configured for ownCloud
+OC_UTIL::checkserver();
+
+// listen for login or logout actions
+OC_USER::logoutlisener();
+$loginresult=OC_USER::loginlisener();
+
+
 /**
  * Class for usermanagement
  *
@@ -64,10 +98,12 @@ class OC_USER {
       if($_POST['login']==$CONFIG_ADMINLOGIN and $_POST['password']==$CONFIG_ADMINPASSWORD){
         $_SESSION['username']=$_POST['login'];
         OC_LOG::event($_SESSION['username'],1,'');
+        return('');
       }else{
-        echo('error');
+        return('error');
       } 
     }
+    return('');
   }
 
   /**
@@ -96,11 +132,26 @@ class OC_UTIL {
    */
   static private $NAVIGATION = array();
 
+
+  /**
+   * check if the current server configuration is suitable for ownCloud
+   *
+   */
+  public static function checkserver(){
+    global $DOCUMENTROOT;
+    $f=@fopen($DOCUMENTROOT.'/config/config.php','a+');
+    if(!$f) die('Error: Config file (config/config.php) is not writable for the webserver.');
+    @fclose($f);
+    
+  }
+
   /**
    * show the header of the web GUI
    *
    */
   public static function showheader(){
+    global $CONFIG_ADMINLOGIN;
+    global $WEBROOT;
     require('templates/header.php');;
   }
 
@@ -132,18 +183,18 @@ class OC_UTIL {
    *
    */
   public static function shownavigation(){
-    global $CONFIG_WEBROOT;
+    global $WEBROOT;
     echo('<table cellpadding="5" cellspacing="0" border="0"><tr>');
-    echo('<td class="navigationitem1"><a href="'.$CONFIG_WEBROOT.'/">'.$_SESSION['username'].'</a> <img src="/img/dots.png" border="0"></td>');
-    if($_SERVER['SCRIPT_NAME']=='/index.php') echo('<td class="navigationitemselected"><a href="'.$CONFIG_WEBROOT.'/">Files</a></td>'); else echo('<td class="navigationitem"><a href="'.$CONFIG_WEBROOT.'/">Files</a></td>');
+    echo('<td class="navigationitem1"><a href="'.$WEBROOT.'/">'.$_SESSION['username'].'</a></td>');
+    if($_SERVER['SCRIPT_NAME']=='/index.php') echo('<td class="navigationitemselected"><a href="'.$WEBROOT.'/">Files</a></td>'); else echo('<td class="navigationitem"><a href="'.$WEBROOT.'/">Files</a></td>');
 
     foreach(OC_UTIL::$NAVIGATION as $NAVI) {
       if($_SERVER['SCRIPT_NAME']==$NAVI['url']) echo('<td class="navigationitemselected"><a href="'.$NAVI['url'].'">'.$NAVI['name'].'</a></td>'); else echo('<td class="navigationitem"><a href="'.$NAVI['url'].'">'.$NAVI['name'].'</a></td>');
     }
 
-    if($_SERVER['SCRIPT_NAME']=='/log/index.php') echo('<td class="navigationitemselected"><a href="'.$CONFIG_WEBROOT.'/log">Log</a></td>'); else echo('<td class="navigationitem"><a href="'.$CONFIG_WEBROOT.'/log">Log</a></td>');
-    if($_SERVER['SCRIPT_NAME']=='/settings/index.php') echo('<td class="navigationitemselected"><a href="'.$CONFIG_WEBROOT.'/settings">Settings</a></td>'); else echo('<td class="navigationitem"><a href="'.$CONFIG_WEBROOT.'/settings">Settings</a></td>');
-    echo('<td class="navigationitem"><a href="'.$CONFIG_WEBROOT.'?logoutbutton=1">Logout</a></td>');
+    if($_SERVER['SCRIPT_NAME']=='/log/index.php') echo('<td class="navigationitemselected"><a href="'.$WEBROOT.'/log">Log</a></td>'); else echo('<td class="navigationitem"><a href="'.$WEBROOT.'/log">Log</a></td>');
+    if($_SERVER['SCRIPT_NAME']=='/settings/index.php') echo('<td class="navigationitemselected"><a href="'.$WEBROOT.'/settings">Settings</a></td>'); else echo('<td class="navigationitem"><a href="'.$WEBROOT.'/settings">Settings</a></td>');
+    echo('<td class="navigationitem"><a href="'.$WEBROOT.'?logoutbutton=1">Logout</a></td>');
     echo('</tr></table>');
   }
 
@@ -153,22 +204,94 @@ class OC_UTIL {
    *
    */
   public static function showloginform(){
+    global $loginresult;
     require('templates/loginform.php');
   }
 
+
   /**
    * show an icon for a filetype
    *
    */
   public static function showicon($filetype){
-    if($filetype=='dir'){ echo('<td><img src="/img/icons/folder.png" width="16" height="16"></td>');
+    global $WEBROOT;
+    if($filetype=='dir'){ echo('<td><img src="'.$WEBROOT.'/img/icons/folder.png" width="16" height="16"></td>');
     }elseif($filetype=='foo'){ echo('<td>foo</td>');
-    }else{ echo('<td><img src="/img/icons/other.png" width="16" height="16"></td>');
+    }else{ echo('<td><img src="'.$WEBROOT.'/img/icons/other.png" width="16" height="16"></td>');
     }
   }
 
+  /**
+   * show the configform
+   *
+   */
+  public static function showconfigform(){
+    global $CONFIG_ADMINLOGIN;
+    global $CONFIG_ADMINPASSWORD;
+    global $CONFIG_DATADIRECTORY;
+    global $CONFIG_HTTPFORCESSL;
+    global $CONFIG_DATEFORMAT;
+    global $CONFIG_DBHOST;
+    global $CONFIG_DBNAME;
+    global $CONFIG_DBUSER;
+    global $CONFIG_DBPASSWORD;
+    require('templates/configform.php');
+  }
+
+  /**
+   * lisen for configuration changes and write it to the file
+   *
+   */
+  public static function writeconfiglisener(){
+    global $DOCUMENTROOT;
+    global $WEBROOT;
+    if(isset($_POST['set_config'])){
+
+      //checkdata
+      $error='';
+
+      if(!isset($_POST['adminlogin'])        or empty($_POST['adminlogin']))        $error.='admin login not set<br />';
+      if(!isset($_POST['adminpassword'])     or empty($_POST['adminpassword']))     $error.='admin password not set<br />';
+      if(!isset($_POST['adminpassword2'])    or empty($_POST['adminpassword2']))    $error.='retype admin password not set<br />';
+      if(!isset($_POST['datadirectory'])     or empty($_POST['datadirectory']))     $error.='data directory not set<br />';
+      if(!isset($_POST['dateformat'])        or empty($_POST['dateformat']))        $error.='dteformat not set<br />';
+      if(!isset($_POST['dbhost'])            or empty($_POST['dbhost']))            $error.='database host not set<br />';
+      if(!isset($_POST['dbname'])            or empty($_POST['dbname']))            $error.='databasename not set<br />';
+      if(!isset($_POST['dbuser'])            or empty($_POST['dbuser']))            $error.='database user not set<br />';
+      if(!isset($_POST['dbpassword'])        or empty($_POST['dbpassword']))        $error.='database password not set<br />';
+      if(!isset($_POST['dbpassword2'])       or empty($_POST['dbpassword2']))       $error.='retype database password not set<br />';
+      if($_POST['dbpassword']<>$_POST['dbpassword2'] )                              $error.='database passwords are not the same<br />';
+      if($_POST['adminpassword']<>$_POST['adminpassword2'] )                        $error.='admin passwords are not the same<br />';
+
+
+      if(empty($error)) {
+        //storedata
+        $config='<?php '."\n";
+        $config.='$CONFIG_ADMINLOGIN=\''.$_POST['adminlogin']."';\n";
+        $config.='$CONFIG_ADMINPASSWORD=\''.$_POST['adminpassword']."';\n";
+        $config.='$CONFIG_DATADIRECTORY=\''.$_POST['datadirectory']."';\n";
+        if(isset($_POST['forcessl'])) $config.='$CONFIG_HTTPFORCESSL=true'.";\n"; else $config.='$CONFIG_HTTPFORCESSL=false'.";\n";
+        $config.='$CONFIG_DATEFORMAT=\''.$_POST['dateformat']."';\n";
+        $config.='$CONFIG_DBHOST=\''.$_POST['dbhost']."';\n";
+        $config.='$CONFIG_DBNAME=\''.$_POST['dbname']."';\n";
+        $config.='$CONFIG_DBUSER=\''.$_POST['dbuser']."';\n";
+        $config.='$CONFIG_DBPASSWORD=\''.$_POST['dbpassword']."';\n";
+        $config.='?> ';
+
+        $filename=$DOCUMENTROOT.'/config/config.php';
+        file_put_contents($filename,$config);
+        header("Location: ".$WEBROOT."/"); 
+
+      }
+      return($error);
+
+    }
+
+  }
+
 }
 
+
 /**
  * Class for database access
  *
@@ -186,12 +309,12 @@ class OC_DB {
     global $CONFIG_DBHOST;
     global $CONFIG_DBNAME;
     global $CONFIG_DBUSER;
-    global $CONFIG_DBPWD;
+    global $CONFIG_DBPASSWORD;
     if(!isset($DBConnection)) {
-      $DBConnection = @new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPWD,$CONFIG_DBNAME);
+      $DBConnection = @new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPASSWORD,$CONFIG_DBNAME);
       if (mysqli_connect_errno()) {
         @ob_end_clean();
-        echo('<html><head></head><body bgcolor="#F0F0F0"><br /><br /><center><b>can not connect to database.</center></body></html>');
+        echo('<b>can not connect to database.</center>');
         exit();
       }
     }
index ab0a5252982ddb29aa79062db43b0db96dfdb39f..8eb1fc9c12501f7b66cbd97ea130b5686343fc28 100755 (executable)
@@ -37,6 +37,7 @@ class OC_FILES {
    */
   public static function showbrowser($basedir,$dir){
     global $CONFIG_DATEFORMAT;
+    global $WEBROOT;
 
     $directory=$basedir.'/'.$dir;
 
@@ -49,11 +50,11 @@ class OC_FILES {
     // breadcrumb
     if(count($dirs)>1) {
       echo('<div class="center"><table cellpadding="2" cellspacing="0" border="0"><tr>');
-      echo('<td class="nametext"><a href="/">home</a></td>');
+      echo('<td class="nametext"><a href="'.$WEBROOT.'/">home</a></td>');
       $currentdir='';
       foreach($dirs as $d) {
         $currentdir.='/'.$d.'';
-        if($d<>'') echo('<td class="nametext"><a href="/?dir='.$currentdir.'"><img src="/img/arrow.png" />&nbsp;'.$d.'</a></td>');
+        if($d<>'') echo('<td class="nametext"><a href="'.$WEBROOT.'/?dir='.$currentdir.'"><img src="'.$WEBROOT.'/img/arrow.png" />&nbsp;'.$d.'</a></td>');
       }
       echo('</tr></table></div>');
     }
@@ -71,8 +72,8 @@ class OC_FILES {
             echo('<tr class="browserline">');
             OC_UTIL::showicon($filetype);
 
-            if($filetype=='dir') echo('<td class="nametext"><a href="/?dir='.$dir.'/'.$file.'">'.$file.'</a></td>');
-            if($filetype<>'dir') echo('<td class="nametext"><a href="/?dir='.$dir.'&file='.$file.'">'.$file.'</a></td>');
+            if($filetype=='dir') echo('<td class="nametext"><a href="'.$WEBROOT.'/?dir='.$dir.'/'.$file.'">'.$file.'</a></td>');
+            if($filetype<>'dir') echo('<td class="nametext"><a href="'.$WEBROOT.'/?dir='.$dir.'&file='.$file.'">'.$file.'</a></td>');
             if($filetype<>'dir') echo('<td class="sizetext">'.$stat['size'].' byte</td>'); else echo('<td></td>');
             echo('<td class="sizetext">'.date($CONFIG_DATEFORMAT,$stat['mtime']).'</td>');
             echo('</tr>');
diff --git a/inc/templates/configform.php b/inc/templates/configform.php
new file mode 100644 (file)
index 0000000..95043f9
--- /dev/null
@@ -0,0 +1,15 @@
+<form method="post" enctype="multipart/form-data">
+<table cellpadding="5" cellspacing="5" border="0" class="loginform">
+<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 password:</td><td><input type="password" name="adminpassword" size="30" class="formstyle" value="<?php echo($CONFIG_ADMINPASSWORD);?>"></input></td></tr>
+<tr><td>retype admin password:</td><td><input type="password" name="adminpassword2" size="30" class="formstyle" value="<?php echo($CONFIG_ADMINPASSWORD);?>"></input></td></tr>
+<tr><td>data directory:</td><td><input type="text" name="datadirectory" size="30" class="formstyle" value="<?php echo($CONFIG_DATADIRECTORY);?>"></input></td></tr>
+<tr><td>force ssl:</td><td><input type="checkbox" name="forcessl" size="30" class="formstyle" value='<?php echo($CONFIG_HTTPFORCESSL);?>'></input></td></tr>
+<tr><td>date format:</td><td><input type="text" name="dateformat" size="30" class="formstyle" value='<?php echo($CONFIG_DATEFORMAT);?>'></input></td></tr>
+<tr><td>database host:</td><td><input type="text" name="dbhost" size="30" class="formstyle" value='<?php echo($CONFIG_DBHOST);?>'></input></td></tr>
+<tr><td>database name:</td><td><input type="text" name="dbname" size="30" class="formstyle" value='<?php echo($CONFIG_DBNAME);?>'></input></td></tr>
+<tr><td>database user:</td><td><input type="text" name="dbuser" size="30" class="formstyle" value='<?php echo($CONFIG_DBUSER);?>'></input></td></tr>
+<tr><td>database password:</td><td><input type="password" name="dbpassword" size="30" class="formstyle" value='<?php echo($CONFIG_DBPASSWORD);?>'></input></td></tr>
+<tr><td>retype database password:</td><td><input type="password" name="dbpassword2" size="30" class="formstyle" value='<?php echo($CONFIG_DBPASSWORD);?>'></input></td></tr>
+<tr><td></td><td><input type="submit" name="set_config" alt="save" value="save" class="formstyle" /></td></tr>
+</table></form>
index 9771c797787a2692a70b942c3c8f34508cc923b3..5ce34a957910ea50510bd48c0b9754b468a5d78a 100755 (executable)
@@ -1,8 +1,6 @@
 <p class="footer">
 <?php
-  echo($CONFIG_FOOTEROWNERNAME);
-  echo(' - ');
-  echo($CONFIG_FOOTEROWNEREMAIL);
+  echo('<a href="http://ownCloud.org">ownCloud</a> - 1.0 beta 2');
 ?>
 </p>
 </body></html>
index 90a9b1c23f0b62448a1c41df6538a7fca517c1ba..cd9e2ead8b31fc1b30c354b94029554262a553e9 100755 (executable)
@@ -3,25 +3,37 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <title>ownCloud</title>
-<link rel="stylesheet" type="text/css" href="/css/default.css" />
+<link rel="stylesheet" type="text/css" href="<?php echo($WEBROOT); ?>/css/default.php" />
 </head>
 <body>
-<h1><a id="owncloud-logo" href="/"><span>OwnCloud</span></a></h1>
 <?php
+echo('<h1><a id="owncloud-logo" href="'.$WEBROOT.'/"><span>ownCloud</span></a></h1>');
 
-  if(!isset($_SESSION['username']) or $_SESSION['username']=='') {
 
+  // check if already configured. otherwise start configuration wizard
+  $error=OC_UTIL::writeconfiglisener();
+  if(empty($CONFIG_ADMINLOGIN)) {
+    echo('<div class="center">');
+    echo('<p class="errortext">'.$error.'</p>');
+    echo('<p class="highlighttext">First Run Wizard</p>');
+    OC_UTIL::showconfigform();
+    echo('</div>');
+    OC_UTIL::showfooter();
+    exit();
+  }
+
+
+  // show the loginform if not loggedin
+  if(!isset($_SESSION['username']) or $_SESSION['username']=='') {
     echo('<div class="center">');
     OC_UTIL::showloginform();
     echo('</div>');
     OC_UTIL::showfooter();
     exit();
   }else{
-
     echo('<div id="nav" class="center">');
     OC_UTIL::shownavigation();
     echo('</div>');
-
   }
 
 ?>
index d4543e2566943dbcd2cfd57f7d269e6a2d6e1ffd..9f5517431aef301603c26aa96ca713497d049925 100755 (executable)
@@ -1,4 +1,7 @@
-<form method="post" enctype="multipart/form-data" action="<?php echo $GLOBALS['CONFIG_WEBROOT'] ?>/" >
+<?php
+if(isset($loginresult) and $loginresult=='error') echo('<p class="errortext">login failed</p>');
+?>
+<form method="post" enctype="multipart/form-data">
 <table cellpadding="5" cellspacing="5" border="0" class="loginform">
 <tr><td>login:</td><td><input type="text" name="login" size="30" class="formstyle"></input></td></tr>
 <tr><td>password:</td><td><input type="password" name="password" size="30" class="formstyle"></input></td></tr>
index 75273f73cf9e169f60c5d7d972497fad43288d8b..b4a19dd0388cc4d0d16256666923e14b7050a403 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -21,8 +21,7 @@
 * 
 */
 
-
-require_once('config/config.php');
+require_once('inc/lib_base.php');
 
 if(isset($_GET['dir'])) $dir=$_GET['dir']; else $dir='';
 
@@ -32,14 +31,12 @@ if(isset($_GET['file'])) {
 
 }else{
 
-  OC_USER::loginlisener();
-  OC_USER::logoutlisener();
 
   OC_UTIL::showheader();
 
   OC_FILES::showbrowser($CONFIG_DATADIRECTORY,$dir);
 
-  echo('<br /><br /><p class="hint">Hint: Mount it via webdav like this: <a href="webdav://'.$CONFIG_SITEROOT.'/webdav/owncloud.php">webdav://'.$CONFIG_SITEROOT.'/webdav/owncloud.php</a></p>');
+  echo('<br /><br /><p class="hint">Hint: Mount it via webdav like this: <a href="webdav://'.$_SERVER["HTTP_HOST"].$WEBROOT.'/webdav/owncloud.php">webdav://'.$_SERVER["HTTP_HOST"].$WEBROOT.'/webdav/owncloud.php</a></p>');
 
   OC_UTIL::showfooter();
 
index ead048d2dbd75d360f7c65c95639dcc51e104cd3..3b10027f9cbfcfddc0539b695ce7c6d3821bf3fa 100755 (executable)
@@ -22,7 +22,7 @@
 */
 
 
-require_once('../config/config.php');
+require_once('../inc/lib_base.php');
 
 OC_UTIL::showheader();
 OC_LOG::show();
index 467e0ad96322350f2f999973a5863d4118286681..21b57216f2b616ff1322762b7ac56c3cdcff001a 100755 (executable)
 */
 
 
-require_once('../config/config.php');
+require_once('../inc/lib_base.php');
 
 OC_UTIL::showheader();
 
 echo('<div class="center">');
-echo('nothing here yet :-)');
+OC_UTIL::showconfigform();
 echo('</div>');
 
 
index 47dacae4db9379aa0e6db5219a2150ba30e10a42..33fc5f37c338567eacd9e73cad34f99ef72eda15 100755 (executable)
@@ -22,8 +22,7 @@
 */
 
 
-require_once('../config/config.php');
-require_once('lib_base.php');
+require_once('../inc/lib_base.php');
 require_once('HTTP/WebDAV/Server/Filesystem.php');
 
 
@@ -45,7 +44,7 @@ if(($user==$CONFIG_ADMINLOGIN) and ($passwd==$CONFIG_ADMINPASSWORD )){
   $server->db_host = $CONFIG_DBHOST;
   $server->db_name = $CONFIG_DBNAME;
   $server->db_user = $CONFIG_DBUSER;
-  $server->db_passwd = $CONFIG_DBPWD;
+  $server->db_passwd = $CONFIG_DBPASSWORD;
   $server->ServeRequest($CONFIG_DATADIRECTORY);
 
 }else{