Просмотр исходного кода

Fix - Undefined index dbLocation (#1093)

causefx 7 лет назад
Родитель
Сommit
faee053834
1 измененных файлов с 13 добавлено и 9 удалено
  1. 13 9
      api/functions/api-functions.php

+ 13 - 9
api/functions/api-functions.php

@@ -1164,14 +1164,18 @@ function revokeToken($array)
 
 function getSchema()
 {
-	try {
-		$connect = new Dibi\Connection([
-			'driver' => 'sqlite3',
-			'database' => $GLOBALS['dbLocation'] . $GLOBALS['dbName'],
-		]);
-		$result = $connect->fetchAll(' SELECT name, sql FROM sqlite_master WHERE type=\'table\' ORDER BY name');
-		return $result;
-	} catch (Dibi\Exception $e) {
-		return false;
+	if (file_exists('config' . DIRECTORY_SEPARATOR . 'config.php')) {
+		try {
+			$connect = new Dibi\Connection([
+				'driver' => 'sqlite3',
+				'database' => $GLOBALS['dbLocation'] . $GLOBALS['dbName'],
+			]);
+			$result = $connect->fetchAll(' SELECT name, sql FROM sqlite_master WHERE type=\'table\' ORDER BY name');
+			return $result;
+		} catch (Dibi\Exception $e) {
+			return false;
+		}
+	} else {
+		return 'DB not set yet...';
 	}
 }