From fbf8309e44e90cfef2666911a14117af4919c848 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sat, 19 Apr 2014 16:57:36 +0200 Subject: [PATCH] Improved error handling for table creation --- php/modules/Database.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/php/modules/Database.php b/php/modules/Database.php index f51d5ea..0a5e94c 100755 --- a/php/modules/Database.php +++ b/php/modules/Database.php @@ -119,16 +119,18 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!'); # Read file $file = __DIR__ . '/../database/settings_table.sql'; - $query = file_get_contents($file); + $query = @file_get_contents($file); # Create table + if (!isset($query)||$query===false) return false; if (!$database->query($query)) return false; # Read file $file = __DIR__ . '/../database/settings_content.sql'; - $query = file_get_contents($file); + $query = @file_get_contents($file); # Add content + if (!isset($query)||$query===false) return false; if (!$database->query($query)) return false; } @@ -138,9 +140,10 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!'); # Read file $file = __DIR__ . '/../database/albums_table.sql'; - $query = file_get_contents($file); + $query = @file_get_contents($file); # Create table + if (!isset($query)||$query===false) return false; if (!$database->query($query)) return false; } @@ -150,9 +153,10 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!'); # Read file $file = __DIR__ . '/../database/photos_table.sql'; - $query = file_get_contents($file); + $query = @file_get_contents($file); # Create table + if (!isset($query)||$query===false) return false; if (!$database->query($query)) return false; }