_env.php.example to _env.php and check the settings inside!"); } require_once __DIR__ . '/_env.php'; $prod = defined('STDIN'); define('DEBUG', !$prod); $root = DEBUG ? json_encode(ESP_IP) : 'location.host'; define('JS_WEB_ROOT', $root); define('LOCALE', isset($_GET['locale']) ? $_GET['locale'] : 'en'); $_messages = require(__DIR__ . '/lang/' . LOCALE . '.php'); $_pages = require(__DIR__ . '/_pages.php'); define('APP_NAME', 'ESPTerm'); /** URL (dev or production) */ function url($name, $relative = false) { global $_pages; if ($relative) return $_pages[$name]->path; if (DEBUG) return "/index.php?page=$name"; else return $_pages[$name]->path; } /** URL label for a button */ function label($name) { global $_pages; return $_pages[$name]->label; } function e($s) { return htmlspecialchars($s, ENT_HTML5 | ENT_QUOTES); } function tr($key) { global $_messages; return isset($_messages[$key]) ? $_messages[$key] : ('??' . $key . '??'); } /** Like eval, but allows */ function include_str($code) { $tmp = tmpfile(); $tmpf = stream_get_meta_data($tmp); $tmpf = $tmpf ['uri']; fwrite($tmp, $code); $ret = include($tmpf); fclose($tmp); return $ret; }