Further simplification.
このコミットが含まれているのは:
コミット
ed347b7392
15
index.php
15
index.php
|
@ -4,8 +4,7 @@
|
||||||
define("PDIR", "/home/".YOMAMA."/dev");
|
define("PDIR", "/home/".YOMAMA."/dev");
|
||||||
|
|
||||||
// Prevent accessing stuff you're not supposed to access.
|
// Prevent accessing stuff you're not supposed to access.
|
||||||
$path = (isset($_GET["path"]) ? $_GET["path"] : "");
|
$path = htmlentities((isset($_GET["path"]) ? $_GET["path"] : ""));
|
||||||
$path = htmlentities($path);
|
|
||||||
if ($path == "/") $path = "";
|
if ($path == "/") $path = "";
|
||||||
foreach (explode("/", $path) as $e) { if ($e == "." || $e == ".." || $e == ".git") die("fuck off."); }
|
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"));
|
$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.
|
// Get the Git info and whether it's a Git repo at all.
|
||||||
$isgit = false;
|
|
||||||
$cgp = PDIR;
|
$cgp = PDIR;
|
||||||
$proot = "";
|
$proot = "";
|
||||||
foreach (explode("/", $path) as $cg) {
|
foreach (explode("/", $path) as $cg) {
|
||||||
$cgp .= $cg."/";
|
$cgp .= $cg."/";
|
||||||
if (file_exists($cgp.".git")) {
|
if (file_exists($cgp.".git")) $proot = $cgp;
|
||||||
$proot = $cgp;
|
|
||||||
$isgit = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
unset($cgp);
|
unset($cgp);
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
function git_branch (string $fp) : string {
|
function git_branch (string $fp) : string {
|
||||||
$res = str_replace("ref: ", "", file_get_contents($fp.".git/HEAD"));
|
$res = explode("/", str_replace("ref: ", "", file_get_contents($fp.".git/HEAD")));
|
||||||
$res = explode("/", $res);
|
|
||||||
return trim($res[array_key_last($res)]);
|
return trim($res[array_key_last($res)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +60,7 @@
|
||||||
?>
|
?>
|
||||||
</h1>
|
</h1>
|
||||||
<?php
|
<?php
|
||||||
if ($isgit) echo "<h2>Branch: ".git_branch($proot)."</h2>";
|
if ($proot != "") echo "<h2>Branch: ".git_branch($proot)."</h2>";
|
||||||
unset($isgit);
|
|
||||||
unset($proot);
|
unset($proot);
|
||||||
if (!is_dir(PDIR.$path)) {
|
if (!is_dir(PDIR.$path)) {
|
||||||
echo "<pre>".cat($path)."</pre>";
|
echo "<pre>".cat($path)."</pre>";
|
||||||
|
|
読み込み中…
新しいイシューから参照