-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.php
37 lines (32 loc) · 1.12 KB
/
routes.php
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
<?php
include_once 'server/connect.php';
function checkRoom($short) {
global $dbPrefix, $pdo;
try {
$stmt = $pdo->prepare('SELECT * FROM ' . $dbPrefix . 'rooms WHERE `shortagenturl`= ? or `shortvisitorurl`= ? or `shortagenturl_broadcast`= ? or `shortvisitorurl_broadcast`= ?');
$stmt->execute([$short, $short, $short, $short]);
$row = $stmt->fetch();
if ($row) {
if ($row['shortagenturl'] == $short) {
return $row['agenturl'];
}
if ($row['shortvisitorurl'] == $short) {
return $row['visitorurl'];
}
if ($row['shortagenturl_broadcast'] == $short) {
return $row['agenturl_broadcast'];
}
if ($row['shortvisitorurl_broadcast'] == $short) {
return $row['visitorurl_broadcast'];
}
} else {
return false;
}
} catch (Exception $e) {
return false;
}
}
$redirect = (checkRoom($_GET['short'])) ? checkRoom($_GET['short']) : '/';
Header('HTTP/1.1 301 Moved Permanently');
Header('Location: ' . $redirect);
die();