Browse Source

Improved error handling for table creation

Tobias Reich 11 years ago
parent
commit
fbf8309e44
1 changed files with 8 additions and 4 deletions
  1. 8 4
      php/modules/Database.php

+ 8 - 4
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;
 
 		}