commit 3802c0c99be352da985965842cb00acf8a38f0dd Author: octt <6083316-octospacc@users.noreply.gitlab.com> Date: Fri May 23 12:43:35 2025 +0200 v0.1, 14/01 diff --git a/Proxatore.php b/Proxatore.php new file mode 100644 index 0000000..497bab2 --- /dev/null +++ b/Proxatore.php @@ -0,0 +1,215 @@ + ['t.me', 'telegram.me'], + 'reddit' => ['reddit.com', 'old.reddit.com'], + 'instagram' => ['instagram.com'], + 'facebook' => ['facebook.com'], + 'tiktok' => ['tiktok.com'], + 'twitter' => ['twitter.com'], + 'x' => ['x.com'], +]; + +function fetchContent($url) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Content Proxy)'); + $html = curl_exec($ch); + curl_close($ch); + return $html ?: null; +} + +function parseMetaTags($html) { + $doc = new DOMDocument(); + @$doc->loadHTML($html); + $metaTags = []; + foreach ($doc->getElementsByTagName('meta') as $meta) { + if ($meta->hasAttribute('property')) { + $metaTags[$meta->getAttribute('property')] = $meta->getAttribute('content'); + } + } + return $metaTags; +} + +function loadHistory() { + $history = []; + if (file_exists(HISTORY_FILE)) { + $lines = file(HISTORY_FILE, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + foreach ($lines as $line) { + $history[] = json_decode($line, true); + } + } + return $history; +} + +function saveHistory($entry) { + $history = loadHistory(); + $history = array_filter($history, function ($item) use ($entry) { + return $item['platform'] !== $entry['platform'] || $item['relativeurl'] !== $entry['relativeurl']; + }); + $history[] = $entry; + $lines = array_map(fn($item) => json_encode($item, JSON_UNESCAPED_SLASHES), $history); + file_put_contents(HISTORY_FILE, implode(PHP_EOL, $lines) . PHP_EOL, LOCK_EX); +} + +function searchHistory($keyword) { + $results = []; + $history = loadHistory(); + foreach ($history as $entry) { + if (stripos(json_encode($entry, JSON_UNESCAPED_SLASHES), $keyword) !== false) { + $results[] = $entry; + } + } + return $results; +} + +$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); +$immediateResult = null; + +if (isset($_GET['search']) && $_GET['search'] !== '') { + $searchResults = searchHistory($_GET['search']); +} else { + $segments = explode('/', trim($path, '/')); + array_shift($segments); + + $upstream = $segments[0] ?? null; + $relativeUrl = implode('/', array_slice($segments, 1)); + + if (isset($platforms[$upstream])) { + $platform = $upstream; + $domain = $platforms[$upstream][0]; + $upstreamUrl = "https://$domain/$relativeUrl"; + } else { + foreach ($platforms as $platform => $domains) { + if (in_array($upstream, $domains) || in_array(implode('www.', array_slice(explode('www.', $upstream), 1)), $domains)) { + $upstreamUrl = "https://$upstream/$relativeUrl"; + break; + } + } + } + + if ($relativeUrl && ($html = fetchContent("$upstreamUrl/$relativeUrl"))) { + $metaTags = parseMetaTags($html); + + $immediateResult = [ + 'platform' => $platform, + 'relativeurl' => $relativeUrl, + 'datetime' => date('Y-m-d H:i:s'), + 'request_time' => time(), + 'mediaurls' => [$metaTags['og:image'] ?? null], + 'title' => $metaTags['og:title'] ?? 'No title', + 'author' => $metaTags['og:site_name'] ?? 'Unknown', + 'description' => $metaTags['og:description'] ?? 'No description', + ]; + + saveHistory($immediateResult); + } +} +?> + + + + + + + Content Proxy + + + + + "> + + + +
+

Content Proxy

+ + +
+ Media +
+
+ Platform: |
+
+ View Original +
+
+ + + + +
+ Media +
+
+ Platform: |
+
+ View Original +
+
+ + +
+ + +