X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=b3b560a0963f0be40495966d4a6a5030bb8eee73;hb=f29bd23ea8ed2ae82771ee2c78f7fe82e2b123ed;hp=33cdafc19908c7bab72d7d1e5e13881a689018bd;hpb=09a0be73bffdb7a7725e87cc73396765524ce210;p=friendica.git diff --git a/boot.php b/boot.php index 33cdafc199..b3b560a096 100644 --- a/boot.php +++ b/boot.php @@ -1,6 +1,6 @@ user['email'] ?? '', $adminlist); } -function explode_querystring($query) -{ - $arg_st = strpos($query, '?'); - if ($arg_st !== false) { - $base = substr($query, 0, $arg_st); - $arg_st += 1; - } else { - $base = ''; - $arg_st = 0; - } - - $args = explode('&', substr($query, $arg_st)); - foreach ($args as $k => $arg) { - /// @TODO really compare type-safe here? - if ($arg === '') { - unset($args[$k]); - } - } - $args = array_values($args); - - if (!$base) { - $base = $args[0]; - unset($args[0]); - $args = array_values($args); - } - - return [ - 'base' => $base, - 'args' => $args, - ]; -} - /** * Returns the complete URL of the current page, e.g.: http(s)://something.com/network * @@ -499,93 +444,6 @@ function get_temppath() return ''; } -function get_cachefile($file, $writemode = true) -{ - $cache = get_itemcachepath(); - - if ((!$cache) || (!is_dir($cache))) { - return ""; - } - - $subfolder = $cache . "/" . substr($file, 0, 2); - - $cachepath = $subfolder . "/" . $file; - - if ($writemode) { - if (!is_dir($subfolder)) { - mkdir($subfolder); - chmod($subfolder, 0777); - } - } - - return $cachepath; -} - -function clear_cache($basepath = "", $path = "") -{ - if ($path == "") { - $basepath = get_itemcachepath(); - $path = $basepath; - } - - if (($path == "") || (!is_dir($path))) { - return; - } - - if (substr(realpath($path), 0, strlen($basepath)) != $basepath) { - return; - } - - $cachetime = (int) DI::config()->get('system', 'itemcache_duration'); - if ($cachetime == 0) { - $cachetime = 86400; - } - - if (is_writable($path)) { - if ($dh = opendir($path)) { - while (($file = readdir($dh)) !== false) { - $fullpath = $path . "/" . $file; - if ((filetype($fullpath) == "dir") && ($file != ".") && ($file != "..")) { - clear_cache($basepath, $fullpath); - } - if ((filetype($fullpath) == "file") && (filectime($fullpath) < (time() - $cachetime))) { - unlink($fullpath); - } - } - closedir($dh); - } - } -} - -function get_itemcachepath() -{ - // Checking, if the cache is deactivated - $cachetime = (int) DI::config()->get('system', 'itemcache_duration'); - if ($cachetime < 0) { - return ""; - } - - $itemcache = DI::config()->get('system', 'itemcache'); - if (($itemcache != "") && System::isDirectoryUsable($itemcache)) { - return BasePath::getRealPath($itemcache); - } - - $temppath = get_temppath(); - - if ($temppath != "") { - $itemcache = $temppath . "/itemcache"; - if (!file_exists($itemcache) && !is_dir($itemcache)) { - mkdir($itemcache); - } - - if (System::isDirectoryUsable($itemcache)) { - DI::config()->set("system", "itemcache", $itemcache); - return $itemcache; - } - } - return ""; -} - /** * Returns the path where spool files are stored *