mirror of
https://gitlab.com/octospacc/Proxatore.git
synced 2025-06-05 17:19:18 +02:00
v0.8, 17/01
This commit is contained in:
@@ -54,6 +54,7 @@ const EMBEDS_SUFFIXES = [
|
|||||||
'telegram' => '?embed=1&mode=tme',
|
'telegram' => '?embed=1&mode=tme',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
define('SCRIPT_NAME', /* $_SERVER['SCRIPT_NAME'] . */ '/');
|
||||||
define('HISTORY_FILE', './' . $_SERVER['SCRIPT_NAME'] . '.history.jsonl');
|
define('HISTORY_FILE', './' . $_SERVER['SCRIPT_NAME'] . '.history.jsonl');
|
||||||
|
|
||||||
function lstrip($str, $sub) {
|
function lstrip($str, $sub) {
|
||||||
@@ -64,8 +65,15 @@ function urlLast($url) {
|
|||||||
return end(explode('/', trim(parse_url($url, PHP_URL_PATH), '/')));
|
return end(explode('/', trim(parse_url($url, PHP_URL_PATH), '/')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseAbsoluteUrl($str) {
|
||||||
|
$strlow = strtolower($str);
|
||||||
|
if (str_starts_with($strlow, 'http://') || str_starts_with($strlow, 'https://')) {
|
||||||
|
return implode('://', array_slice(explode('://', $str), 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function redirectTo($internalUrl) {
|
function redirectTo($internalUrl) {
|
||||||
header('Location: ' . $_SERVER['SCRIPT_NAME'] . '/' . $internalUrl);
|
header('Location: ' . SCRIPT_NAME . $internalUrl);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,14 +170,25 @@ function searchHistory($keyword) {
|
|||||||
$path = $_SERVER['REQUEST_URI'];//parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
$path = $_SERVER['REQUEST_URI'];//parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||||
$immediateResult = null;
|
$immediateResult = null;
|
||||||
|
|
||||||
if (isset($_GET['search']) && ($search = $_GET['search']) !== '') {
|
if (isset($_GET['proxatore-search']) && ($search = $_GET['proxatore-search']) !== '') {
|
||||||
if (str_starts_with(strtolower($search), 'https://')) {
|
//if (str_starts_with(strtolower($search), 'https://')) {
|
||||||
redirectTo(lstrip($search, 'https://'));
|
// redirectTo(lstrip($search, 'https://'));
|
||||||
|
if ($url = parseAbsoluteUrl($search)) {
|
||||||
|
redirectTo($url);
|
||||||
|
} else {
|
||||||
|
$searchResults = searchHistory($search);
|
||||||
}
|
}
|
||||||
$searchResults = searchHistory($search);
|
|
||||||
} else {
|
} else {
|
||||||
$segments = explode('/', trim($path, '/'));
|
$path = trim($path, '/');
|
||||||
array_shift($segments);
|
if ($url = parseAbsoluteUrl($path)) {
|
||||||
|
//$path = $url;
|
||||||
|
redirectTo($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$segments = explode('/', $path);
|
||||||
|
if (SCRIPT_NAME !== '/') {
|
||||||
|
array_shift($segments);
|
||||||
|
}
|
||||||
|
|
||||||
$platform = null;
|
$platform = null;
|
||||||
$upstream = $segments[0] ?? null;
|
$upstream = $segments[0] ?? null;
|
||||||
@@ -472,9 +491,9 @@ video:not(video[src=""]) + img {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1><a href="<?php echo $_SERVER['SCRIPT_NAME']; ?>"><?php echo APPNAME; ?></a></h1>
|
<h1><a href="<?= SCRIPT_NAME ?>"><?php echo APPNAME; ?></a></h1>
|
||||||
<form class="search-bar" method="get" action="<?php echo htmlspecialchars($_SERVER['SCRIPT_NAME'] . '/') ?>">
|
<form class="search-bar" method="get" action="<?= SCRIPT_NAME ?>">
|
||||||
<input type="text" required="required" name="search" placeholder="Search or Input URL" value="<?= htmlspecialchars($_GET['search'] ?: makeCanonicalUrl($immediateResult) ?: '') ?>">
|
<input type="text" required="required" name="proxatore-search" placeholder="Search or Input URL" value="<?= htmlspecialchars($_GET['proxatore-search'] ?: makeCanonicalUrl($immediateResult) ?: '') ?>">
|
||||||
<button type="submit">Go 💣️</button>
|
<button type="submit">Go 💣️</button>
|
||||||
</form>
|
</form>
|
||||||
<?php if (!isset($searchResults)) {
|
<?php if (!isset($searchResults)) {
|
||||||
@@ -510,7 +529,7 @@ video:not(video[src=""]) + img {
|
|||||||
<p style="white-space: preserve-breaks; border-left: 2px solid black; padding: 1em; word-break: break-word;"><?= /*htmlspecialchars*/($item['description']) ?></p>
|
<p style="white-space: preserve-breaks; border-left: 2px solid black; padding: 1em; word-break: break-word;"><?= /*htmlspecialchars*/($item['description']) ?></p>
|
||||||
<p>
|
<p>
|
||||||
<a class="button block" href="<?= htmlspecialchars(makeCanonicalUrl($item)) ?>" target="_blank" rel="noopener nofollow">Original on <code><?= htmlspecialchars(PLATFORMS[$item['platform']][0] ?: $item['platform']) ?>/<?= htmlspecialchars($item['relativeurl']) ?></code></a>
|
<a class="button block" href="<?= htmlspecialchars(makeCanonicalUrl($item)) ?>" target="_blank" rel="noopener nofollow">Original on <code><?= htmlspecialchars(PLATFORMS[$item['platform']][0] ?: $item['platform']) ?>/<?= htmlspecialchars($item['relativeurl']) ?></code></a>
|
||||||
<a class="button block" href="<?= htmlspecialchars($_SERVER['SCRIPT_NAME'] . '/' . $item['platform'] . '/' . $item['relativeurl']) ?>"><?= APPNAME ?> Permalink</a>
|
<a class="button block" href="<?= htmlspecialchars(SCRIPT_NAME . $item['platform'] . '/' . $item['relativeurl']) ?>"><?= APPNAME ?> Permalink</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user