-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
50 lines (43 loc) · 1.31 KB
/
index.php
File metadata and controls
50 lines (43 loc) · 1.31 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
44
45
46
47
48
49
50
<?php
// index.php - front controller / router for Railway
declare(strict_types=1);
$path = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH);
// Serve photos directly: /photos/filename.jpg
if (strpos($path, '/photos/') === 0) {
$file = __DIR__ . $path; // e.g. /app/photos/9109...jpg
if (is_file($file)) {
// Very simple content-type detection
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
switch ($ext) {
case 'jpg':
case 'jpeg':
header('Content-Type: image/jpeg');
break;
case 'png':
header('Content-Type: image/png');
break;
default:
header('Content-Type: application/octet-stream');
}
readfile($file);
} else {
http_response_code(404);
header('Content-Type: text/plain; charset=utf-8');
echo "Photo not found\n";
}
exit;
}
// Simple router for our PHP endpoints
switch ($path) {
case '/login.php':
require __DIR__ . '/login.php';
exit;
case '/phone_lookup.php':
require __DIR__ . '/phone_lookup.php';
exit;
case '/':
default:
header('Content-Type: text/plain; charset=utf-8');
echo "Telegram lookup service is running\n";
exit;
}