public function __construct()
{
- $dbFile = dirname(__FILE__, 2) . '/data/profiles.sqlite3';
+ $dbFile = static::getDbFilePath();
$this->db = new PDO(
'sqlite:' . $dbFile,
'', '',
$this->createTablesIfNeeded();
}
+ public static function getDbFilePath()
+ {
+ return dirname(__FILE__, 2) . '/data/profiles.sqlite3';
+ }
+
public function getProfileByHardwareId(string $hwId): ?Profile
{
$stmt = $this->db->prepare('SELECT * FROM gamesticks WHERE hwId = :id');
--- /dev/null
+<?php
+/**
+ * Check if everything is fine
+ */
+header('HTTP/1.0 500 Internal Server Error');
+
+function error($msg)
+{
+ header('HTTP/1.0 500 Internal Server Error');
+ header('Content-Type: text/plain');
+ echo 'Error: ' . $msg . "\n";
+ exit(1);
+}
+
+$configFile = __DIR__ . '/../config.php';
+if (!file_exists($configFile)) {
+ error('config.php missing. Copy config.php.dist to config.php');
+}
+
+require_once $configFile;
+require_once __DIR__ . '/../src/ProfileDb.php';
+
+$dbFile = ProfileDb::getDbFilePath();
+if (!file_exists($dbFile)) {
+ $dbFileDir = dirname($dbFile);
+ if (!is_writable($dbFileDir)) {
+ error('Database file directory is not writable: ' . $dbFileDir);
+ }
+}
+
+if (isset($GLOBALS['popuplarTxtFile'])
+ && strlen($GLOBALS['popuplarTxtFile'])
+ && !file_exists($GLOBALS['popuplarTxtFile'])
+) {
+ error('Popular games file does not exist: ' . $GLOBALS['popuplarTxtFile']);
+}
+
+if (isset($GLOBALS['featuredFile'])
+ && strlen($GLOBALS['featuredFile'])
+ && !file_exists($GLOBALS['featuredFile'])
+) {
+ error('Featured games file does not exist: ' . $GLOBALS['featuredFile']);
+}
+
+$cacheDir = __DIR__ . '/../cache/';
+$appsCacheFile = $cacheDir . 'connect-apps.min.json';
+$featuredAgesCacheFile = $cacheDir . 'connect-featured-ages.min.json';
+
+if (!file_exists($appsCacheFile)) {
+ error('Apps cache file does not exist. Run bin/generate-apps-cache.php');
+}
+if (!file_exists($featuredAgesCacheFile)) {
+ error('Featured ages cache file does not exist. Run bin/generate-apps-cache.php');
+}
+
+
+//FIXME: api tests
+
+header('HTTP/1.0 200 OK');
+header('Content-Type: text/plain');
+echo "Everything looks fine\n";
+?>