diff --git a/index.php b/index.php index eb6f1f8..aa65717 100644 --- a/index.php +++ b/index.php @@ -4,8 +4,7 @@ define("PDIR", "/home/".YOMAMA."/dev"); // Prevent accessing stuff you're not supposed to access. - $path = (isset($_GET["path"]) ? $_GET["path"] : ""); - $path = htmlentities($path); + $path = htmlentities((isset($_GET["path"]) ? $_GET["path"] : "")); if ($path == "/") $path = ""; foreach (explode("/", $path) as $e) { if ($e == "." || $e == ".." || $e == ".git") die("fuck off."); } @@ -13,22 +12,17 @@ $url = (str_contains($_SERVER['HTTP_HOST'], ".i2p") ? "http://ryocafe.i2p" : (str_contains($_SERVER["HTTP_HOST"], ".onion") ? "http://asc7ewkcvat2wsoi5yuwkej5ukyrqqnpnzpj4u34r2jxnoxhnbx6yqad.onion" : "https://ryocafe.site")); // Get the Git info and whether it's a Git repo at all. - $isgit = false; $cgp = PDIR; $proot = ""; foreach (explode("/", $path) as $cg) { $cgp .= $cg."/"; - if (file_exists($cgp.".git")) { - $proot = $cgp; - $isgit = true; - } + if (file_exists($cgp.".git")) $proot = $cgp; } unset($cgp); // Functions function git_branch (string $fp) : string { - $res = str_replace("ref: ", "", file_get_contents($fp.".git/HEAD")); - $res = explode("/", $res); + $res = explode("/", str_replace("ref: ", "", file_get_contents($fp.".git/HEAD"))); return trim($res[array_key_last($res)]); } @@ -66,8 +60,7 @@ ?> Branch: ".git_branch($proot).""; - unset($isgit); + if ($proot != "") echo "

Branch: ".git_branch($proot)."

"; unset($proot); if (!is_dir(PDIR.$path)) { echo "
".cat($path)."
";