Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
a061dd33
Commit
a061dd33
authored
14 years ago
by
Frank Karlitschek
Browse files
Options
Downloads
Plain Diff
Merge commit 'refs/merge-requests/17' of
git://gitorious.org/owncloud/owncloud
parents
6889c9b4
8f92dc8e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inc/lib_base.php
+3
-0
3 additions, 0 deletions
inc/lib_base.php
inc/lib_config.php
+89
-4
89 additions, 4 deletions
inc/lib_config.php
with
92 additions
and
4 deletions
inc/lib_base.php
+
3
−
0
View file @
a061dd33
...
...
@@ -291,6 +291,9 @@ class OC_DB {
global
$DBConnection
;
global
$CONFIG_DBNAME
;
global
$CONFIG_DBTYPE
;
global
$CONFIG_DBHOST
;
global
$CONFIG_DBUSER
;
global
$CONFIG_DBPASSWORD
;
if
(
!
isset
(
$DBConnection
))
{
if
(
$CONFIG_DBTYPE
==
'sqlite'
){
$DBConnection
=
@
new
SQLiteDatabase
(
$DOCUMENTROOT
.
'/'
.
$CONFIG_DBNAME
);
...
...
This diff is collapsed.
Click to expand it.
inc/lib_config.php
+
89
−
4
View file @
a061dd33
...
...
@@ -22,12 +22,16 @@ class OC_CONFIG{
global
$DOCUMENTROOT
;
global
$SERVERROOT
;
global
$WEBROOT
;
global
$CONFIG_DBHOST
;
global
$CONFIG_DBNAME
;
global
$CONFIG_DBUSER
;
global
$CONFIG_DBPASSWORD
;
global
$CONFIG_DBTYPE
;
if
(
isset
(
$_POST
[
'set_config'
])){
//checkdata
$error
=
''
;
$FIRSTRUN
=
isset
(
$CONFIG_ADMINLOGIN
);
$FIRSTRUN
=
!
isset
(
$CONFIG_ADMINLOGIN
);
if
(
!
$FIRSTRUN
){
if
(
$_POST
[
'currentpassword'
]
!=
$CONFIG_ADMINPASSWORD
){
$error
.
=
'wrong password'
;
...
...
@@ -54,9 +58,18 @@ class OC_CONFIG{
}
if
(
empty
(
$error
))
{
//create/fill database
$CONFIG_DBTYPE
=
$dbtype
;
$CONFIG_DBNAME
=
$_POST
[
'dbname'
];
if
(
$dbtype
==
'mysql'
){
$CONFIG_DBHOST
=
$_POST
[
'dbhost'
];
$CONFIG_DBUSER
=
$_POST
[
'dbuser'
];
$CONFIG_DBPASSWORD
=
$_POST
[
'dbpassword'
];
}
if
(
isset
(
$_POST
[
'createdatabase'
])
and
$CONFIG_DBTYPE
==
'mysql'
){
self
::
createdatabase
(
$_POST
[
'dbadminuser'
],
$_POST
[
'dbadminpwd'
]);
}
if
(
isset
(
$_POST
[
'filldb'
])){
//
self::filldatabase();
self
::
filldatabase
();
}
//storedata
...
...
@@ -77,7 +90,6 @@ class OC_CONFIG{
$filename
=
$SERVERROOT
.
'/config/config.php'
;
file_put_contents
(
$filename
,
$config
);
header
(
"Location: "
.
$WEBROOT
.
"/"
);
}
...
...
@@ -94,7 +106,9 @@ class OC_CONFIG{
* "rowid"
*/
private
static
function
filldatabase
(){
$query
=
"CREATE TABLE 'locks' (
global
$CONFIG_DBTYPE
;
if
(
$CONFIG_DBTYPE
==
'sqlite'
){
$query
=
"CREATE TABLE 'locks' (
'token' VARCHAR(255) NOT NULL DEFAULT '',
'path' varchar(200) NOT NULL DEFAULT '',
'expires' int(11) NOT NULL DEFAULT '0',
...
...
@@ -121,8 +135,79 @@ CREATE TABLE 'properties' (
'value' text,
PRIMARY KEY ('path','name','ns')
);"
;
}
elseif
(
$CONFIG_DBTYPE
==
'mysql'
){
$query
=
"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;
"
;
}
OC_DB
::
multiquery
(
$query
);
}
/**
* 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
();
}
}
?>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment