-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseg.php
More file actions
43 lines (34 loc) · 1.11 KB
/
seg.php
File metadata and controls
43 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
// seg.php - router for /seg/... segment proxy
require_once __DIR__ . '/helpers.php';
// Path: /seg/{u}/{pass_or_token}/{id}
$uri = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH) ?: '';
$parts = array_values(array_filter(explode('/', $uri)));
if (count($parts) < 4 || strtolower($parts[0]) !== 'seg') {
http_response_code(404);
exit('Not Found');
}
$u = rawurldecode((string)$parts[1]);
$cred = rawurldecode((string)$parts[2]);
// Basic hardening: prevent path breaking/null bytes
if (strpos($u, '/') !== false || strpos($cred, '/') !== false || strpos($u, "