summaryrefslogtreecommitdiff
path: root/common.php
blob: 367ae553334c83c2ed5bf8a731f0df7d5f194dde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

function sanity_check() {

	if (!is_writable(SCRATCH_DB)) {
		die(SCRATCH_DB . " is not writable");
	}

	if (!is_writable(dirname(SCRATCH_DB))) {
		die(dirname(SCRATCH_DB) . " directory is not writable");
	}

	try {
		$dbh = new PDO("sqlite:" . SCRATCH_DB);

		$res = $dbh->query("SELECT id FROM epube_users LIMIT 1");

		if (!$res) {
			die("Test query failed, is schema installed? (sqlite3 " . SCRATCH_DB . "< schema.sql)");
		}

	} catch (Exception $e) {
		die($e);
	}

}