move to sqlite merged
This commit is contained in:
parent
ba9c95621b
commit
78a1792c04
8 changed files with 105 additions and 265 deletions
28
docs/INSTALL
28
docs/INSTALL
|
@ -1,34 +1,18 @@
|
|||
== PREREQUISITS ==
|
||||
php5
|
||||
currently mysql, should optionally be sqlite
|
||||
sqlite
|
||||
|
||||
== SETUP ==
|
||||
Set up your paths in:
|
||||
config/config.php
|
||||
|
||||
Your data will be in:
|
||||
$CONFIG_DATADIRECTORY = '/www/testy';
|
||||
Apache needs to have write permissions to this directory.
|
||||
|
||||
And the ownCloud path is:
|
||||
$CONFIG_DOCUMENTROOT = '/www/owncloud/htdocs';
|
||||
The ownCloud checkout should be in the root of "htdocs".
|
||||
|
||||
Both are absolute paths, so if your server is in /var/www, you need to add the /var
|
||||
Place owncloud in a subdirectory of your web server. Go to that directory with
|
||||
a web browser and the first run wizard should take it from there.
|
||||
|
||||
|
||||
== Database ==
|
||||
The database should by default be sqlite. No configuration there.
|
||||
The database is sqlite. If you are having trouble make sure that the line
|
||||
|
||||
But until then you need some setup with mysql:
|
||||
extension=sqlite.so
|
||||
|
||||
Create a table "owncloud":
|
||||
mysqladmin create owncloud -u root -p
|
||||
|
||||
Dump the default database schema:
|
||||
mysql owncloud -u root -p < owncloud.sql
|
||||
|
||||
TODO: you also need to create a mysql user that is configured in config/config.php
|
||||
appears in your php.ini
|
||||
|
||||
|
||||
Please help improving this documentation!
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
|
||||
- remove dependency on mysql. replace with sqlite to make it easier to install
|
||||
|
||||
- simplify installation
|
||||
|
||||
- write installation documentation
|
||||
|
||||
- better ajax web gui
|
||||
|
|
|
@ -1,39 +1,27 @@
|
|||
CREATE TABLE 'locks' (
|
||||
'token' VARCHAR(255) NOT NULL DEFAULT '',
|
||||
'path' varchar(200) NOT NULL DEFAULT '',
|
||||
'expires' int(11) NOT NULL DEFAULT '0',
|
||||
'owner' varchar(200) DEFAULT NULL,
|
||||
'recursive' int(11) DEFAULT '0',
|
||||
'writelock' int(11) DEFAULT '0',
|
||||
'exclusivelock' int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY ('token'),
|
||||
UNIQUE ('token')
|
||||
);
|
||||
|
||||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `locks` (
|
||||
`token` varchar(255) NOT NULL DEFAULT '',
|
||||
`path` varchar(200) NOT NULL DEFAULT '',
|
||||
`expires` int(11) NOT NULL DEFAULT '0',
|
||||
`owner` varchar(200) DEFAULT NULL,
|
||||
`recursive` int(11) DEFAULT '0',
|
||||
`writelock` int(11) DEFAULT '0',
|
||||
`exclusivelock` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`token`),
|
||||
UNIQUE KEY `token` (`token`),
|
||||
KEY `path` (`path`),
|
||||
KEY `path_2` (`path`),
|
||||
KEY `path_3` (`path`,`token`),
|
||||
KEY `expires` (`expires`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `log` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`timestamp` int(11) NOT NULL,
|
||||
`user` varchar(250) NOT NULL,
|
||||
`type` int(11) NOT NULL,
|
||||
`message` varchar(250) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `properties` (
|
||||
`path` varchar(255) NOT NULL DEFAULT '',
|
||||
`name` varchar(120) NOT NULL DEFAULT '',
|
||||
`ns` varchar(120) NOT NULL DEFAULT 'DAV:',
|
||||
`value` text,
|
||||
PRIMARY KEY (`path`,`name`,`ns`),
|
||||
KEY `path` (`path`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
CREATE TABLE 'log' (
|
||||
'timestamp' int(11) NOT NULL,
|
||||
'user' varchar(250) NOT NULL,
|
||||
'type' int(11) NOT NULL,
|
||||
'message' varchar(250) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE 'properties' (
|
||||
'path' varchar(255) NOT NULL DEFAULT '',
|
||||
'name' varchar(120) NOT NULL DEFAULT '',
|
||||
'ns' varchar(120) NOT NULL DEFAULT 'DAV:',
|
||||
'value' text,
|
||||
PRIMARY KEY ('path','name','ns')
|
||||
);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
|
||||
require_once "lib_base.php";
|
||||
require_once "HTTP/WebDAV/Server.php";
|
||||
require_once "System.php";
|
||||
|
||||
|
@ -20,38 +21,6 @@
|
|||
*/
|
||||
var $base = "";
|
||||
|
||||
/**
|
||||
* MySQL Host where property and locking information is stored
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
var $db_host = "localhost";
|
||||
|
||||
/**
|
||||
* MySQL database for property/locking information storage
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
var $db_name = "webdav";
|
||||
|
||||
/**
|
||||
* MySQL user for property/locking db access
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
var $db_user = "root";
|
||||
|
||||
/**
|
||||
* MySQL password for property/locking db access
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
var $db_passwd = "";
|
||||
|
||||
/**
|
||||
* Serve a webdav request
|
||||
*
|
||||
|
@ -79,11 +48,6 @@
|
|||
$this->base = $_SERVER['DOCUMENT_ROOT'];
|
||||
}
|
||||
|
||||
// establish connection to property/locking db
|
||||
mysql_connect($this->db_host, $this->db_user, $this->db_passwd) or die(mysql_error());
|
||||
mysql_select_db($this->db_name) or die(mysql_error());
|
||||
// TODO throw on connection problems
|
||||
|
||||
// let the base class do all the work
|
||||
parent::ServeRequest();
|
||||
}
|
||||
|
@ -192,11 +156,11 @@
|
|||
|
||||
// get additional properties from database
|
||||
$query = "SELECT ns, name, value FROM properties WHERE path = '$path'";
|
||||
$res = mysql_query($query);
|
||||
while ($row = mysql_fetch_assoc($res)) {
|
||||
$res = OC_DB::query($query);
|
||||
while ($row = OC_DB::fetch_assoc($res)) {
|
||||
$info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]);
|
||||
}
|
||||
mysql_free_result($res);
|
||||
OC_DB::free_result($res);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
@ -478,13 +442,13 @@
|
|||
|
||||
if (is_dir($path)) {
|
||||
$query = "DELETE FROM properties WHERE path LIKE '".$this->_slashify($options["path"])."%'";
|
||||
mysql_query($query);
|
||||
OC_DB::query($query);
|
||||
System::rm("-rf $path");
|
||||
} else {
|
||||
unlink ($path);
|
||||
}
|
||||
$query = "DELETE FROM properties WHERE path = '$options[path]'";
|
||||
mysql_query($query);
|
||||
OC_DB::query($query);
|
||||
|
||||
return "204 No Content";
|
||||
}
|
||||
|
@ -568,13 +532,13 @@
|
|||
$query = "UPDATE properties
|
||||
SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
|
||||
WHERE path LIKE '".$this->_slashify($options["path"])."%'";
|
||||
mysql_query($query);
|
||||
OC_DB::query($query);
|
||||
}
|
||||
|
||||
$query = "UPDATE properties
|
||||
SET path = '".$destpath."'
|
||||
WHERE path = '".$options["path"]."'";
|
||||
mysql_query($query);
|
||||
OC_DB::query($query);
|
||||
} else {
|
||||
if (is_dir($source)) {
|
||||
$files = System::find($source);
|
||||
|
@ -644,7 +608,7 @@
|
|||
} else {
|
||||
$query = "DELETE FROM properties WHERE path = '$options[path]' AND name = '$prop[name]' AND ns = '$prop[ns]'";
|
||||
}
|
||||
mysql_query($query);
|
||||
OC_DB::query($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -662,9 +626,9 @@
|
|||
{
|
||||
if (isset($options["update"])) { // Lock Update
|
||||
$query = "UPDATE locks SET expires = ".(time()+300);
|
||||
mysql_query($query);
|
||||
OC_DB::query($query);
|
||||
|
||||
if (mysql_affected_rows()) {
|
||||
if (OC_DB::affected_rows()) {
|
||||
$options["timeout"] = 300; // 5min hardcoded
|
||||
return true;
|
||||
} else {
|
||||
|
@ -681,9 +645,9 @@
|
|||
, expires = '$options[timeout]'
|
||||
, exclusivelock = " .($options['scope'] === "exclusive" ? "1" : "0")
|
||||
;
|
||||
mysql_query($query);
|
||||
OC_DB::query($query);
|
||||
|
||||
return mysql_affected_rows() ? "200 OK" : "409 Conflict";
|
||||
return OC_DB::affected_rows() ? "200 OK" : "409 Conflict";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -697,9 +661,9 @@
|
|||
$query = "DELETE FROM locks
|
||||
WHERE path = '$options[path]'
|
||||
AND token = '$options[token]'";
|
||||
mysql_query($query);
|
||||
OC_DB::query($query);
|
||||
|
||||
return mysql_affected_rows() ? "204 No Content" : "409 Conflict";
|
||||
return OC_DB::affected_rows() ? "204 No Content" : "409 Conflict";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -716,11 +680,11 @@
|
|||
FROM locks
|
||||
WHERE path = '$path'
|
||||
";
|
||||
$res = mysql_query($query);
|
||||
$res = OC_DB::query($query);
|
||||
|
||||
if ($res) {
|
||||
$row = mysql_fetch_array($res);
|
||||
mysql_free_result($res);
|
||||
$row = OC_DB::fetch_assoc($res);
|
||||
OC_DB::free_result($res);
|
||||
|
||||
if ($row) {
|
||||
$result = array( "type" => "write",
|
||||
|
|
|
@ -45,10 +45,7 @@ $CONFIG_ADMINPASSWORD='';
|
|||
$CONFIG_DATADIRECTORY=$SERVERROOT.$WEBROOT.'/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');
|
||||
|
@ -111,9 +108,9 @@ class OC_USER {
|
|||
*
|
||||
*/
|
||||
public static function logoutlisener(){
|
||||
if(isset($_GET['logoutbutton'])){
|
||||
if(isset($_GET['logoutbutton']) && isset($_SESSION['username'])){
|
||||
OC_LOG::event($_SESSION['username'],2,'');
|
||||
if(isset($_SESSION['username'])) unset($_SESSION['username']);
|
||||
unset($_SESSION['username']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,14 +235,12 @@ class OC_DB {
|
|||
* @return result-set
|
||||
*/
|
||||
static function query($cmd) {
|
||||
global $DOCUMENTROOT;
|
||||
global $DBConnection;
|
||||
global $CONFIG_DBHOST;
|
||||
global $CONFIG_DBNAME;
|
||||
global $CONFIG_DBUSER;
|
||||
global $CONFIG_DBPASSWORD;
|
||||
if(!isset($DBConnection)) {
|
||||
$DBConnection = @new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPASSWORD,$CONFIG_DBNAME);
|
||||
if (mysqli_connect_errno()) {
|
||||
$DBConnection = @new SQLiteDatabase($DOCUMENTROOT.'/'.$CONFIG_DBNAME);
|
||||
if (!$DBConnection) {
|
||||
@ob_end_clean();
|
||||
echo('<b>can not connect to database.</center>');
|
||||
exit();
|
||||
|
@ -253,12 +248,12 @@ class OC_DB {
|
|||
}
|
||||
$result = @$DBConnection->query($cmd);
|
||||
if (!$result) {
|
||||
$entry='DB Error: "'.$DBConnection->error.'"<br />';
|
||||
$entry='DB Error: "'.sqlite_error_string($DBConnection->lastError()).'"<br />';
|
||||
$entry.='Offending command was: '.$cmd.'<br />';
|
||||
echo($entry);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* executes multiply queries on the database
|
||||
|
@ -267,22 +262,20 @@ class OC_DB {
|
|||
* @return result-set
|
||||
*/
|
||||
static function multiquery($cmd) {
|
||||
global $DOCUMENTROOT;
|
||||
global $DBConnection;
|
||||
global $CONFIG_DBHOST;
|
||||
global $CONFIG_DBNAME;
|
||||
global $CONFIG_DBUSER;
|
||||
global $CONFIG_DBPASSWORD;
|
||||
if(!isset($DBConnection)) {
|
||||
$DBConnection = @new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPASSWORD,$CONFIG_DBNAME);
|
||||
if (mysqli_connect_errno()) {
|
||||
$DBConnection = @new SQLiteDatabase($DOCUMENTROOT.'/'.$CONFIG_DBNAME);
|
||||
if (!$DBConnection) {
|
||||
@ob_end_clean();
|
||||
echo('<b>can not connect to database.</center>');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$result = @$DBConnection->multi_query($cmd);
|
||||
$result = @$DBConnection->queryExec($cmd);
|
||||
if (!$result) {
|
||||
$entry='DB Error: "'.$DBConnection->error.'"<br />';
|
||||
$entry='DB Error: "'.sqlite_error_string($DBConnection->lastError()).'"<br />';
|
||||
$entry.='Offending command was: '.$cmd.'<br />';
|
||||
echo($entry);
|
||||
}
|
||||
|
@ -312,7 +305,7 @@ class OC_DB {
|
|||
*/
|
||||
static function insertid() {
|
||||
global $DBConnection;
|
||||
return(mysqli_insert_id($DBConnection));
|
||||
return $DBConnectio->lastInsertRowid();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -323,7 +316,7 @@ class OC_DB {
|
|||
*/
|
||||
static function numrows($result) {
|
||||
if(!isset($result) or ($result == false)) return 0;
|
||||
$num= mysqli_num_rows($result);
|
||||
$num= $result->numRows();
|
||||
return($num);
|
||||
}
|
||||
|
||||
|
@ -335,7 +328,7 @@ class OC_DB {
|
|||
static function affected_rows() {
|
||||
global $DBConnection;
|
||||
if(!isset($DBConnection) or ($DBConnection==false)) return 0;
|
||||
$num= mysqli_affected_rows($DBConnection);
|
||||
$num= $DBConnection->changes();
|
||||
return($num);
|
||||
}
|
||||
|
||||
|
@ -348,16 +341,10 @@ class OC_DB {
|
|||
* @return unknown
|
||||
*/
|
||||
static function result($result, $i, $field) {
|
||||
//return @mysqli_result($result, $i, $field);
|
||||
|
||||
mysqli_data_seek($result,$i);
|
||||
if (is_string($field))
|
||||
$tmp=mysqli_fetch_array($result,MYSQLI_BOTH);
|
||||
else
|
||||
$tmp=mysqli_fetch_array($result,MYSQLI_NUM);
|
||||
$result->seek($ii);
|
||||
$tmp=$result->fetch();
|
||||
$tmp=$tmp[$field];
|
||||
return($tmp);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -367,7 +354,7 @@ class OC_DB {
|
|||
* @return data
|
||||
*/
|
||||
static function fetch_assoc($result) {
|
||||
return mysqli_fetch_assoc($result);
|
||||
return $result->fetch(SQLITE_ASSOC);
|
||||
}
|
||||
|
||||
|
||||
|
@ -378,7 +365,8 @@ class OC_DB {
|
|||
* @return bool
|
||||
*/
|
||||
static function free_result($result) {
|
||||
return @mysqli_free_result($result);
|
||||
$result = null; //No native way to do this
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
123
inc/lib_config.php
Normal file → Executable file
123
inc/lib_config.php
Normal file → Executable file
|
@ -10,10 +10,7 @@ class OC_CONFIG{
|
|||
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');
|
||||
}
|
||||
|
||||
|
@ -24,17 +21,12 @@ class OC_CONFIG{
|
|||
public static function writeconfiglisener(){
|
||||
global $DOCUMENTROOT;
|
||||
global $WEBROOT;
|
||||
global $CONFIG_DBHOST;
|
||||
global $CONFIG_DBNAME;
|
||||
global $CONFIG_DBUSER;
|
||||
global $CONFIG_DBPASSWORD;
|
||||
global $CONFIG_ADMINLOGIN;
|
||||
global $CONFIG_ADMINPASSWORD;
|
||||
if(isset($_POST['set_config'])){
|
||||
|
||||
//checkdata
|
||||
$error='';
|
||||
$FIRSTRUN=empty($CONFIG_ADMINLOGIN);
|
||||
$FIRSTRUN=isset($CONFIG_ADMINLOGIN);
|
||||
if(!$FIRSTRUN){
|
||||
if($_POST['currentpassword']!=$CONFIG_ADMINPASSWORD){
|
||||
$error.='wrong password';
|
||||
|
@ -46,27 +38,15 @@ class OC_CONFIG{
|
|||
if(!isset($_POST['adminpassword2']) or empty($_POST['adminpassword2']) and $FIRSTRUN) $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(!isset($_POST['adminpassword']) or empty($_POST['adminpassword']) and !$FIRSTRUN){
|
||||
$_POST['adminpassword']=$CONFIG_ADMINPASSWORD;
|
||||
}
|
||||
|
||||
if(empty($error)) {
|
||||
//create/fill database
|
||||
$CONFIG_DBHOST=$_POST['dbhost'];
|
||||
$CONFIG_DBNAME=$_POST['dbname'];
|
||||
$CONFIG_DBUSER=$_POST['dbuser'];
|
||||
$CONFIG_DBPASSWORD=$_POST['dbpassword'];
|
||||
if(isset($_POST['createdatabase'])){
|
||||
self::createdatabase($_POST['dbadminuser'],$_POST['dbadminpwd']);
|
||||
}
|
||||
if(isset($_POST['filldb'])){
|
||||
self::filldatabase();
|
||||
}
|
||||
|
@ -78,11 +58,8 @@ class OC_CONFIG{
|
|||
$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.='?>';
|
||||
$config.='?> ';
|
||||
|
||||
$filename=$DOCUMENTROOT.'/config/config.php';
|
||||
file_put_contents($filename,$config);
|
||||
|
@ -96,81 +73,43 @@ class OC_CONFIG{
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the database and user
|
||||
* @param string adminUser
|
||||
* @param string adminPwd
|
||||
*
|
||||
*/
|
||||
private static function createdatabase($adminUser,$adminPwd){
|
||||
global $CONFIG_DBHOST;
|
||||
global $CONFIG_DBNAME;
|
||||
global $CONFIG_DBUSER;
|
||||
global $CONFIG_DBPWD;
|
||||
//we cant user OC_BD functions here because we need to connect as the administrative user.
|
||||
$connection = @new mysqli($CONFIG_DBHOST, $adminUser, $adminPwd);
|
||||
if (mysqli_connect_errno()) {
|
||||
@ob_end_clean();
|
||||
echo('<html><head></head><body bgcolor="#F0F0F0"><br /><br /><center><b>can not connect to database as administrative user.</center></body></html>');
|
||||
exit();
|
||||
}
|
||||
$query="CREATE USER '{$_POST['dbuser']}' IDENTIFIED BY '{$_POST['dbpassword']}';
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS `{$_POST['dbname']}` ;
|
||||
|
||||
GRANT ALL PRIVILEGES ON `{$_POST['dbname']}` . * TO '{$_POST['dbuser']}';";
|
||||
$result = @$connection->multi_query($query);
|
||||
if (!$result) {
|
||||
$entry='DB Error: "'.$connection->error.'"<br />';
|
||||
$entry.='Offending command was: '.$query.'<br />';
|
||||
echo($entry);
|
||||
}
|
||||
$connection->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the database with the initial tables
|
||||
*
|
||||
* Note: while the AUTO_INCREMENT function is not supported by SQLite
|
||||
* the same effect can be achieved by accessing the SQLite pseudo-column
|
||||
* "rowid"
|
||||
*/
|
||||
private static function filldatabase(){
|
||||
$query="SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";
|
||||
$query="CREATE TABLE 'locks' (
|
||||
'token' VARCHAR(255) NOT NULL DEFAULT '',
|
||||
'path' varchar(200) NOT NULL DEFAULT '',
|
||||
'expires' int(11) NOT NULL DEFAULT '0',
|
||||
'owner' varchar(200) DEFAULT NULL,
|
||||
'recursive' int(11) DEFAULT '0',
|
||||
'writelock' int(11) DEFAULT '0',
|
||||
'exclusivelock' int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY ('token'),
|
||||
UNIQUE ('token')
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `locks` (
|
||||
`token` varchar(255) NOT NULL DEFAULT '',
|
||||
`path` varchar(200) NOT NULL DEFAULT '',
|
||||
`expires` int(11) NOT NULL DEFAULT '0',
|
||||
`owner` varchar(200) DEFAULT NULL,
|
||||
`recursive` int(11) DEFAULT '0',
|
||||
`writelock` int(11) DEFAULT '0',
|
||||
`exclusivelock` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`token`),
|
||||
UNIQUE KEY `token` (`token`),
|
||||
KEY `path` (`path`),
|
||||
KEY `path_2` (`path`),
|
||||
KEY `path_3` (`path`,`token`),
|
||||
KEY `expires` (`expires`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `log` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`timestamp` int(11) NOT NULL,
|
||||
`user` varchar(250) NOT NULL,
|
||||
`type` int(11) NOT NULL,
|
||||
`message` varchar(250) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;
|
||||
CREATE TABLE 'log' (
|
||||
'timestamp' int(11) NOT NULL,
|
||||
'user' varchar(250) NOT NULL,
|
||||
'type' int(11) NOT NULL,
|
||||
'message' varchar(250) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `properties` (
|
||||
`path` varchar(255) NOT NULL DEFAULT '',
|
||||
`name` varchar(120) NOT NULL DEFAULT '',
|
||||
`ns` varchar(120) NOT NULL DEFAULT 'DAV:',
|
||||
`value` text,
|
||||
PRIMARY KEY (`path`,`name`,`ns`),
|
||||
KEY `path` (`path`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
";
|
||||
CREATE TABLE 'properties' (
|
||||
'path' varchar(255) NOT NULL DEFAULT '',
|
||||
'name' varchar(120) NOT NULL DEFAULT '',
|
||||
'ns' varchar(120) NOT NULL DEFAULT 'DAV:',
|
||||
'value' text,
|
||||
PRIMARY KEY ('path','name','ns')
|
||||
);";
|
||||
OC_DB::multiquery($query);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
<?php
|
||||
global $FIRSTRUN;
|
||||
if(!isset($createDB)) $createDB=true;
|
||||
if(!isset($fillDB)) $fillDB=true;
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function showDBAdmin(){
|
||||
var show=document.getElementById('dbCreate').checked;
|
||||
document.getElementById('dbAdminUser').style.display=(show)?'table-row':'none';
|
||||
document.getElementById('dbAdminPwd').style.display=(show)?'table-row':'none';
|
||||
}
|
||||
</script>
|
||||
<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<table cellpadding="5" cellspacing="5" border="0" class="loginform">
|
||||
<?php
|
||||
if(!$FIRSTRUN){?>
|
||||
|
@ -19,20 +12,12 @@ document.getElementById('dbAdminPwd').style.display=(show)?'table-row':'none';
|
|||
}
|
||||
?>
|
||||
<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"></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 pass
|
||||
<tr><td>retype admin password:</td><td><input type="password" name="adminpassword2" size="30" class="formstyle"></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>data directory:</td><td><input type="text" name="datadirectory" size="30" class="formstyle" value="<?php echo($CONFIG_DATADIRECTORY);?>"></input><
|
||||
<tr><td>force ssl:</td><td><input type="checkbox" name="forcessl" size="30" class="formstyle" value='<?php echo($CONFIG_HTTPFORCESSL);?>'></input></td></t
|
||||
<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>create database and user:</td><td><input id='dbCreate' type="checkbox" name="createdatabase" size="30" class="formstyle" value='1' <?php if($FIRSTRUN) echo 'checked'; ?> onchange='showDBAdmin()'></input></td></tr>
|
||||
<tr id='dbAdminUser'><td>database administrative user:</td><td><input type="text" name="dbadminuser" size="30" class="formstyle" value='root'></input></td></tr>
|
||||
<tr id='dbAdminPwd'><td>database administrative password:</td><td><input type="password" name="dbadminpwd" size="30" class="formstyle" value=''></input></td></tr>
|
||||
<tr><td>automaticly fill initial database:</td><td><input type="checkbox" name="filldb" size="30" class="formstyle" value='1' <?php if($FIRSTRUN) echo 'checked'; ?>></input></td></tr>
|
||||
<tr><td>automaticly fill initial database:</td><td><input type="checkbox" name="filldb" size="30" class="formstyle" value='1' <?php if($FIRSTRUN) echo 'ch
|
||||
<tr><td></td><td><input type="submit" name="set_config" alt="save" value="save" class="formstyle" /></td></tr>
|
||||
</table></form>
|
||||
<script type="text/javascript">showDBAdmin()</script>
|
||||
|
|
|
@ -41,10 +41,7 @@ $passwd=$_SERVER['PHP_AUTH_PW'];
|
|||
if(($user==$CONFIG_ADMINLOGIN) and ($passwd==$CONFIG_ADMINPASSWORD )){
|
||||
|
||||
$server = new HTTP_WebDAV_Server_Filesystem();
|
||||
$server->db_host = $CONFIG_DBHOST;
|
||||
$server->db_name = $CONFIG_DBNAME;
|
||||
$server->db_user = $CONFIG_DBUSER;
|
||||
$server->db_passwd = $CONFIG_DBPASSWORD;
|
||||
$server->ServeRequest($CONFIG_DATADIRECTORY);
|
||||
|
||||
}else{
|
||||
|
|
Loading…
Reference in a new issue