-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlink.php
34 lines (30 loc) · 1.06 KB
/
link.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
<?php
if(isset($_GET['id'])) {
require 'includes/php/url-shortener.php';
require 'includes/php/tracker.php';
$shortUrlCode = $_GET['id'];
if(shortUrlExist($db, $shortUrlCode)) {
$request = getShortUrl($db, $shortUrlCode);
$data = $request->fetch();
$request->closeCursor();
if(trackerExistById($db, $data['tracker_id'])) {
$ip = $_SERVER['REMOTE_ADDR'];
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if(addTrackerLog($db, $ip, $userAgent, $data['tracker_id'])) {
header('Location: ' . htmlspecialchars($data['url']));
exit();
} else {
header('Location: 404.php');
}
} else {
header('Location: 404.php');
exit();
}
} else {
header('Location: 404.php');
exit();
}
} else {
header('Location: 404.php');
exit();
}