diff options
Diffstat (limited to 'include/common.php')
-rw-r--r-- | include/common.php | 34 |
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; + } |