about summary refs log tree commit diff stats
path: root/include/common.php
diff options
context:
space:
mode:
authorAndrew Dolgov <noreply@fakecake.org>2021-03-05 21:14:35 +0300
committerAndrew Dolgov <noreply@fakecake.org>2021-03-05 21:14:35 +0300
commit2b8b845abe7c13ecbb266613910484310cffe8e1 (patch)
tree90bd2e93737c2aad17cfb09496cc57cf3f9968cd /include/common.php
parentb2341679d53b227fc90fba34c3a7e6453e3cad6e (diff)
downloadthe-epube-2b8b845abe7c13ecbb266613910484310cffe8e1.tar.gz
the-epube-2b8b845abe7c13ecbb266613910484310cffe8e1.tar.xz
* use ORM for trivial queries
 * environment-based configuration
 * useradm.php -> update.php with new options
 * support for schema migrations
 * various fixes
Diffstat (limited to 'include/common.php')
-rw-r--r--include/common.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/common.php b/include/common.php
new file mode 100644
index 0000000..8f57b91
--- /dev/null
+++ b/include/common.php
@@ -0,0 +1,34 @@
+<?php
+	ini_set('display_errors', "false");
+	ini_set('display_startup_errors', "false");
+
+	// config.php is optional
+	if (stream_resolve_include_path("config.php"))
+		require_once "config.php";
+
+	require_once "autoload.php";
+
+	/** its a dummy :( */
+	function T_sprintf(...$args) {
+		return sprintf(...$args);
+	}
+
+	function sql_bool_to_bool($s) {
+		return $s && ($s !== "f" && $s !== "false"); //no-op for PDO, backwards compat for legacy layer
+	}
+
+	function bool_to_sql_bool($s) {
+		return $s ? 1 : 0;
+	}
+
+	function read_stdin() {
+		$fp = fopen("php://stdin", "r");
+
+		if ($fp) {
+			$line = trim(fgets($fp));
+			fclose($fp);
+			return $line;
+		}
+
+		return null;
+	}