+
+ public static function checkVar($var, $default = '')
+ {
+ return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default);
+ }
+
+ public static function getDomain($url)
+ {
+ return parse_url($url, PHP_URL_HOST);
+ }
+
+ public static function getReadingTime($text) {
+ $word = str_word_count(strip_tags($text));
+ $minutes = floor($word / 200);
+ $seconds = floor($word % 200 / (200 / 60));
+ $time = array('minutes' => $minutes, 'seconds' => $seconds);
+
+ return $minutes;
+ }
+
+ public static function getDocLanguage($userlanguage) {
+ $lang = explode('.', $userlanguage);
+ return str_replace('_', '-', $lang[0]);
+ }
+
+ public static function status($status_code)
+ {
+ if (strpos(php_sapi_name(), 'apache') !== false) {
+
+ header('HTTP/1.0 '.$status_code);
+ }
+ else {
+
+ header('Status: '.$status_code);
+ }
+ }
+
+ public static function download_db() {
+ header('Content-Disposition: attachment; filename="poche.sqlite.gz"');
+ self::status(200);
+
+ header('Content-Transfer-Encoding: binary');
+ header('Content-Type: application/octet-stream');
+ echo gzencode(file_get_contents(STORAGE_SQLITE));
+
+ exit;
+ }
+}