forked from tectronics/ChristianFlatshare
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclicks.php
More file actions
43 lines (33 loc) · 985 Bytes
/
clicks.php
File metadata and controls
43 lines (33 loc) · 985 Bytes
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
// Autoloader
require_once 'web/global.php';
connectToDB();
if (isset($_GET['lets_have_a_look_at'])) {
$banner_id = trim($_GET['lets_have_a_look_at']);
} else {
header("Location: index.php");
exit;
}
// Load the information of the banner from teh database
$query = "SELECT * FROM cf_banners WHERE banner_id = '".$banner_id."'";
$result = mysqli_query($GLOBALS['mysql_conn'], $query);
if (!$result) {
header("Location: index.php");
exit;
} else if (mysqli_num_rows($result) == 0) {
header("Location: index.php");
exit;
} else {
$banner = mysqli_fetch_assoc($result);
// Capture statistics
$query = "
INSERT INTO cf_banners_clicks SET
banner_id = '".$banner_id."',
IP = '".$_SERVER['REMOTE_ADDR']."',
time = now();
";
$result = mysqli_query($GLOBALS['mysql_conn'], $query);
// Redirect to the appropriate link
header("Location: ".$banner['link']);
}
?>