Merge commit 'refs/merge-requests/4' of git://gitorious.org/owncloud/owncloud
This commit is contained in:
commit
01b7bf3b21
|
@ -1,43 +1,87 @@
|
|||
<?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();
|
||||
}
|
||||
|
||||
// Owner
|
||||
$CONFIG_FOOTEROWNERNAME = 'Frank Karlitschek';
|
||||
$CONFIG_FOOTEROWNEREMAIL = 'karlitschek@kde.org';
|
||||
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
|
||||
|
||||
|
||||
// ADMIN ACCOUNT
|
||||
$CONFIG_ADMINLOGIN = 'frank';
|
||||
$CONFIG_ADMINPASSWORD = '123';
|
||||
|
||||
|
||||
// DB Config
|
||||
$CONFIG_DBHOST = 'localhost';
|
||||
$CONFIG_DBNAME = 'owncloud';
|
||||
$CONFIG_DBUSER = 'owncloud';
|
||||
$CONFIG_DBPWD = 'owncloud12345';
|
||||
|
||||
// directories
|
||||
$CONFIG_DATADIRECTORY = '/www/testy';
|
||||
$CONFIG_DOCUMENTROOT = '/www/owncloud/htdocs';
|
||||
|
||||
|
||||
// force SSL
|
||||
$CONFIG_HTTPFORCESSL = false;
|
||||
|
||||
if(!isset($CONFIG_ADMINLOGIN)){
|
||||
if(!isset($_POST['CONFIG_FOOTEROWNERNAME'])){
|
||||
getConfig();
|
||||
}else{
|
||||
writeConfig($_POST);
|
||||
}
|
||||
}
|
||||
|
||||
// other
|
||||
$CONFIG_DATEFORMAT = 'j M Y G:i';
|
||||
$protocol=strtolower($_SERVER['SERVER_PROTOCOL']);
|
||||
$CONFIG_PROTOCOL=substr($protocol,0,strpos($protocol,"/"))."://";
|
||||
$CONFIG_WEBROOT=$CONFIG_PROTOCOL.$CONFIG_SITEROOT;
|
||||
|
||||
// plugins
|
||||
//$CONFIG_LOADPLUGINS = 'music test';
|
||||
$CONFIG_LOADPLUGINS = '';
|
||||
$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');
|
||||
|
||||
?>
|
||||
|
|
|
@ -57,7 +57,7 @@ class OC_USER {
|
|||
* check if the login button is pressed and logg the user in
|
||||
*
|
||||
*/
|
||||
public static function loginlistener(){
|
||||
public static function loginlisener(){
|
||||
global $CONFIG_ADMINLOGIN;
|
||||
global $CONFIG_ADMINPASSWORD;
|
||||
if(isset($_POST['loginbutton']) and isset($_POST['password']) and isset($_POST['login'])){
|
||||
|
@ -74,7 +74,7 @@ class OC_USER {
|
|||
* check if the logout button is pressed and logout the user
|
||||
*
|
||||
*/
|
||||
public static function logoutlistener(){
|
||||
public static function logoutlisener(){
|
||||
if(isset($_GET['logoutbutton'])){
|
||||
OC_LOG::event($_SESSION['username'],2,'');
|
||||
if(isset($_SESSION['username'])) unset($_SESSION['username']);
|
||||
|
@ -132,17 +132,18 @@ class OC_UTIL {
|
|||
*
|
||||
*/
|
||||
public static function shownavigation(){
|
||||
global $CONFIG_WEBROOT;
|
||||
echo('<table cellpadding="5" cellspacing="0" border="0"><tr>');
|
||||
echo('<td class="navigationitem1"><a href="/">'.$_SESSION['username'].'</a></td>');
|
||||
if($_SERVER['SCRIPT_NAME']=='/index.php') echo('<td class="navigationitemselected"><a href="/">Files</a></td>'); else echo('<td class="navigationitem"><a href="/">Files</a></td>');
|
||||
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>');
|
||||
|
||||
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="/log">Log</a></td>'); else echo('<td class="navigationitem"><a href="/log">Log</a></td>');
|
||||
if($_SERVER['SCRIPT_NAME']=='/settings/index.php') echo('<td class="navigationitemselected"><a href="/settings">Settings</a></td>'); else echo('<td class="navigationitem"><a href="/settings">Settings</a></td>');
|
||||
echo('<td class="navigationitem"><a href="/?logoutbutton=1">Logout</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>');
|
||||
echo('</tr></table>');
|
||||
}
|
||||
|
||||
|
@ -152,7 +153,7 @@ class OC_UTIL {
|
|||
*
|
||||
*/
|
||||
public static function showloginform(){
|
||||
require('templates/loginform.php');;
|
||||
require('templates/loginform.php');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,14 +191,14 @@ class OC_DB {
|
|||
$DBConnection = @new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPWD,$CONFIG_DBNAME);
|
||||
if (mysqli_connect_errno()) {
|
||||
@ob_end_clean();
|
||||
echo('<html><head></head><body class="error"><div class="center"><b>can not connect to database.</div></body></html>');
|
||||
echo('<html><head></head><body bgcolor="#F0F0F0"><br /><br /><center><b>can not connect to database.</center></body></html>');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$result = @$DBConnection->query($cmd);
|
||||
if (!$result) {
|
||||
$entry='<p>DB Error: "'.$DBConnection->error.'"</p>';
|
||||
$entry.='<p>Offending command was: '.$cmd.'</p>';
|
||||
$entry='DB Error: "'.$DBConnection->error.'"<br />';
|
||||
$entry.='Offending command was: '.$cmd.'<br />';
|
||||
echo($entry);
|
||||
}
|
||||
return $result;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<form method="post" enctype="multipart/form-data" action="/" >
|
||||
<form method="post" enctype="multipart/form-data" action="<?php echo $GLOBALS['CONFIG_WEBROOT'] ?>/" >
|
||||
<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>
|
||||
|
|
|
@ -32,14 +32,14 @@ if(isset($_GET['file'])) {
|
|||
|
||||
}else{
|
||||
|
||||
OC_USER::loginlistener();
|
||||
OC_USER::logoutlistener();
|
||||
OC_USER::loginlisener();
|
||||
OC_USER::logoutlisener();
|
||||
|
||||
OC_UTIL::showheader();
|
||||
|
||||
OC_FILES::showbrowser($CONFIG_DATADIRECTORY,$dir);
|
||||
|
||||
echo('<p class="hint">Hint: Mount it via webdav like this: <a href="webdav://'.$_SERVER["HTTP_HOST"].'/webdav/owncloud.php">webdav://'.$_SERVER["HTTP_HOST"].'/webdav/owncloud.php</a></p>');
|
||||
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>');
|
||||
|
||||
OC_UTIL::showfooter();
|
||||
|
||||
|
|
Loading…
Reference in New Issue