-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransfer.php
52 lines (29 loc) · 1.38 KB
/
transfer.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
// error_reporting(E_ALL);
// ini_set('display_errors', 1);
//Database Connection
$link = mysqli_connect("localhost","root","root","zizim") or die("Error " . mysqli_error($link));
// IP Address
$ip = $_SERVER['REMOTE_ADDR'];
$query = $_GET['q'];
if ((substr($query, -1) != "$")){
// If the query isn't to view the tracking details of a URL
$url_check_query = "SELECT * FROM `url` WHERE `alias`='$query' OR `shortcut`='$query' LIMIT 1" or die("Error in the consult.." . mysqli_error($link));
$url_check_results = mysqli_query($link, $url_check_query);
if (mysqli_num_rows($url_check_results) > 0){
$URL_Info = mysqli_fetch_array($url_check_results);
$referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "N/A";
$add_tracking_query = "INSERT INTO `track` (`urlID`, `referrer`, `ip`) VALUES ('".$URL_Info['ID']."', '$referrer', '$ip')" or die("Error adding tracking: " . mysqli_error($link));
$add_tracking = mysqli_query($link, $add_tracking_query);
// DEBUG
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . $URL_Info['url'] );
} else {
// If there are no matches, redirect to index.php. Show an appropriate error message.
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: index.php?error=No+Matches" );
}
} else if ((substr($query, -1)) == "$"){
// include('stats.php');
}
?>