Further simplification.
このコミットが含まれているのは:
コミット
ed347b7392
15
index.php
15
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 @@
|
|||
?>
|
||||
</h1>
|
||||
<?php
|
||||
if ($isgit) echo "<h2>Branch: ".git_branch($proot)."</h2>";
|
||||
unset($isgit);
|
||||
if ($proot != "") echo "<h2>Branch: ".git_branch($proot)."</h2>";
|
||||
unset($proot);
|
||||
if (!is_dir(PDIR.$path)) {
|
||||
echo "<pre>".cat($path)."</pre>";
|
||||
|
|
読み込み中…
新しいイシューから参照