diff --git a/php/database/log_table.sql b/php/database/log_table.sql new file mode 100644 index 0000000..953de9a --- /dev/null +++ b/php/database/log_table.sql @@ -0,0 +1,13 @@ +# Dump of table lychee_log +# Version 2.5 +# ------------------------------------------------------------ + +CREATE TABLE IF NOT EXISTS `lychee_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `time` int(11) NOT NULL, + `type` varchar(11) NOT NULL, + `function` varchar(100) NOT NULL, + `line` int(11) NOT NULL, + `text` TEXT DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; \ No newline at end of file diff --git a/php/modules/Database.php b/php/modules/Database.php index bfb9808..3ef3e51 100755 --- a/php/modules/Database.php +++ b/php/modules/Database.php @@ -29,7 +29,7 @@ class Database extends Module { if (!Database::createDatabase($database, $name)) exit('Error: Could not create database!'); # Check tables - if (!$database->query('SELECT * FROM lychee_photos, lychee_albums, lychee_settings LIMIT 0;')) + if (!$database->query('SELECT * FROM lychee_photos, lychee_albums, lychee_settings, lychee_log LIMIT 0;')) if (!Database::createTables($database)) exit('Error: Could not create tables!'); return $database; @@ -119,6 +119,19 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!'); # Check dependencies Module::dependencies(isset($database)); + # Create log + if (!$database->query('SELECT * FROM lychee_log LIMIT 0;')) { + + # Read file + $file = __DIR__ . '/../database/log_table.sql'; + $query = @file_get_contents($file); + + # Create table + if (!isset($query)||$query===false) return false; + if (!$database->query($query)) return false; + + } + # Create settings if (!$database->query('SELECT * FROM lychee_settings LIMIT 0;')) { diff --git a/php/modules/Log.php b/php/modules/Log.php new file mode 100644 index 0000000..2630b10 --- /dev/null +++ b/php/modules/Log.php @@ -0,0 +1,37 @@ +query($query); + + if (!$result) return false; + return $database->insert_id; + + } + +} + +?> \ No newline at end of file