parent
af37f5c138
commit
9f11875e39
@ -2,7 +2,7 @@
|
|||||||
# Version 2.5
|
# Version 2.5
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `lychee_albums` (
|
CREATE TABLE IF NOT EXISTS `?` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`title` varchar(50) NOT NULL,
|
`title` varchar(50) NOT NULL,
|
||||||
`description` varchar(1000) DEFAULT '',
|
`description` varchar(1000) DEFAULT '',
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Version 2.5
|
# Version 2.5
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `lychee_log` (
|
CREATE TABLE IF NOT EXISTS `?` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`time` int(11) NOT NULL,
|
`time` int(11) NOT NULL,
|
||||||
`type` varchar(11) NOT NULL,
|
`type` varchar(11) NOT NULL,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Version 2.5
|
# Version 2.5
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `lychee_photos` (
|
CREATE TABLE IF NOT EXISTS `?` (
|
||||||
`id` bigint(14) NOT NULL,
|
`id` bigint(14) NOT NULL,
|
||||||
`title` varchar(50) NOT NULL,
|
`title` varchar(50) NOT NULL,
|
||||||
`description` varchar(1000) DEFAULT '',
|
`description` varchar(1000) DEFAULT '',
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Version 2.5
|
# Version 2.5
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
INSERT INTO `lychee_settings` (`key`, `value`)
|
INSERT INTO `?` (`key`, `value`)
|
||||||
VALUES
|
VALUES
|
||||||
('version',''),
|
('version',''),
|
||||||
('username',''),
|
('username',''),
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Version 2.5
|
# Version 2.5
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `lychee_settings` (
|
CREATE TABLE IF NOT EXISTS `?` (
|
||||||
`key` varchar(50) NOT NULL DEFAULT '',
|
`key` varchar(50) NOT NULL DEFAULT '',
|
||||||
`value` varchar(200) DEFAULT ''
|
`value` varchar(200) DEFAULT ''
|
||||||
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
@ -29,7 +29,8 @@ class Database extends Module {
|
|||||||
if (!Database::createDatabase($database, $name)) exit('Error: Could not create database!');
|
if (!Database::createDatabase($database, $name)) exit('Error: Could not create database!');
|
||||||
|
|
||||||
# Check tables
|
# Check tables
|
||||||
if (!$database->query('SELECT * FROM lychee_photos, lychee_albums, lychee_settings, lychee_log LIMIT 0;'))
|
$query = Database::prepare($database, 'SELECT * FROM ?, ?, ?, ? LIMIT 0', [LYCHEE_TABLE_PHOTOS, LYCHEE_TABLE_ALBUMS, LYCHEE_TABLE_SETTINGS, LYCHEE_TABLE_LOG]);
|
||||||
|
if (!$database->query($query))
|
||||||
if (!Database::createTables($database)) exit('Error: Could not create tables!');
|
if (!Database::createTables($database)) exit('Error: Could not create tables!');
|
||||||
|
|
||||||
return $database;
|
return $database;
|
||||||
@ -140,30 +141,36 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
|||||||
Module::dependencies(isset($database));
|
Module::dependencies(isset($database));
|
||||||
|
|
||||||
# Create log
|
# Create log
|
||||||
if (!$database->query('SELECT * FROM lychee_log LIMIT 0;')) {
|
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', [LYCHEE_TABLE_LOG]);
|
||||||
|
if (!$database->query($exist)) {
|
||||||
|
|
||||||
# Read file
|
# Read file
|
||||||
$file = __DIR__ . '/../database/log_table.sql';
|
$file = __DIR__ . '/../database/log_table.sql';
|
||||||
$query = @file_get_contents($file);
|
$query = @file_get_contents($file);
|
||||||
|
|
||||||
# Create table
|
|
||||||
if (!isset($query)||$query===false) return false;
|
if (!isset($query)||$query===false) return false;
|
||||||
|
|
||||||
|
# Create table
|
||||||
|
$query = Database::prepare($database, $query, [LYCHEE_TABLE_LOG]);
|
||||||
if (!$database->query($query)) return false;
|
if (!$database->query($query)) return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create settings
|
# Create settings
|
||||||
if (!$database->query('SELECT * FROM lychee_settings LIMIT 0;')) {
|
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', [LYCHEE_TABLE_SETTINGS]);
|
||||||
|
if (!$database->query($exist)) {
|
||||||
|
|
||||||
# Read file
|
# Read file
|
||||||
$file = __DIR__ . '/../database/settings_table.sql';
|
$file = __DIR__ . '/../database/settings_table.sql';
|
||||||
$query = @file_get_contents($file);
|
$query = @file_get_contents($file);
|
||||||
|
|
||||||
# Create table
|
|
||||||
if (!isset($query)||$query===false) {
|
if (!isset($query)||$query===false) {
|
||||||
Log::error($database, __METHOD__, __LINE__, 'Could not load query for lychee_settings');
|
Log::error($database, __METHOD__, __LINE__, 'Could not load query for lychee_settings');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create table
|
||||||
|
$query = Database::prepare($database, $query, [LYCHEE_TABLE_SETTINGS]);
|
||||||
if (!$database->query($query)) {
|
if (!$database->query($query)) {
|
||||||
Log::error($database, __METHOD__, __LINE__, $database->error);
|
Log::error($database, __METHOD__, __LINE__, $database->error);
|
||||||
return false;
|
return false;
|
||||||
@ -173,11 +180,13 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
|||||||
$file = __DIR__ . '/../database/settings_content.sql';
|
$file = __DIR__ . '/../database/settings_content.sql';
|
||||||
$query = @file_get_contents($file);
|
$query = @file_get_contents($file);
|
||||||
|
|
||||||
# Add content
|
|
||||||
if (!isset($query)||$query===false) {
|
if (!isset($query)||$query===false) {
|
||||||
Log::error($database, __METHOD__, __LINE__, 'Could not load content-query for lychee_settings');
|
Log::error($database, __METHOD__, __LINE__, 'Could not load content-query for lychee_settings');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add content
|
||||||
|
$query = Database::prepare($database, $query, [LYCHEE_TABLE_SETTINGS]);
|
||||||
if (!$database->query($query)) {
|
if (!$database->query($query)) {
|
||||||
Log::error($database, __METHOD__, __LINE__, $database->error);
|
Log::error($database, __METHOD__, __LINE__, $database->error);
|
||||||
return false;
|
return false;
|
||||||
@ -186,17 +195,20 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Create albums
|
# Create albums
|
||||||
if (!$database->query('SELECT * FROM lychee_albums LIMIT 0;')) {
|
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', [LYCHEE_TABLE_ALBUMS]);
|
||||||
|
if (!$database->query($exist)) {
|
||||||
|
|
||||||
# Read file
|
# Read file
|
||||||
$file = __DIR__ . '/../database/albums_table.sql';
|
$file = __DIR__ . '/../database/albums_table.sql';
|
||||||
$query = @file_get_contents($file);
|
$query = @file_get_contents($file);
|
||||||
|
|
||||||
# Create table
|
|
||||||
if (!isset($query)||$query===false) {
|
if (!isset($query)||$query===false) {
|
||||||
Log::error($database, __METHOD__, __LINE__, 'Could not load query for lychee_albums');
|
Log::error($database, __METHOD__, __LINE__, 'Could not load query for lychee_albums');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create table
|
||||||
|
$query = Database::prepare($database, $query, [LYCHEE_TABLE_ALBUMS]);
|
||||||
if (!$database->query($query)) {
|
if (!$database->query($query)) {
|
||||||
Log::error($database, __METHOD__, __LINE__, $database->error);
|
Log::error($database, __METHOD__, __LINE__, $database->error);
|
||||||
return false;
|
return false;
|
||||||
@ -205,17 +217,20 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Create photos
|
# Create photos
|
||||||
if (!$database->query('SELECT * FROM lychee_photos LIMIT 0;')) {
|
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', [LYCHEE_TABLE_PHOTOS]);
|
||||||
|
if (!$database->query($exist)) {
|
||||||
|
|
||||||
# Read file
|
# Read file
|
||||||
$file = __DIR__ . '/../database/photos_table.sql';
|
$file = __DIR__ . '/../database/photos_table.sql';
|
||||||
$query = @file_get_contents($file);
|
$query = @file_get_contents($file);
|
||||||
|
|
||||||
# Create table
|
|
||||||
if (!isset($query)||$query===false) {
|
if (!isset($query)||$query===false) {
|
||||||
Log::error($database, __METHOD__, __LINE__, 'Could not load query for lychee_photos');
|
Log::error($database, __METHOD__, __LINE__, 'Could not load query for lychee_photos');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create table
|
||||||
|
$query = Database::prepare($database, $query, [LYCHEE_TABLE_PHOTOS]);
|
||||||
if (!$database->query($query)) {
|
if (!$database->query($query)) {
|
||||||
Log::error($database, __METHOD__, __LINE__, $database->error);
|
Log::error($database, __METHOD__, __LINE__, $database->error);
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user