-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofileInfo-common.php
More file actions
90 lines (79 loc) · 1.88 KB
/
profileInfo-common.php
File metadata and controls
90 lines (79 loc) · 1.88 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
if (validProfile() AND validUserAgent()) {
// connect to the database
if (TryOpenDB()) {
writeProfileToDB();
}
}
returnAppcast();
exit();
function writeProfileToDB() {
global $debug, $DbLink, $DbError, $appcastKeys;
if ($debug) {
print "<html><head><title>debug</title></head><body>\n";
}
// Record the report
$report_date = strftime("%Y-%m-%d %H:%M:%S");
$remote_addr = $_SERVER['REMOTE_ADDR'];
$queryString = "INSERT INTO profileReport (IP_ADDR, REPORT_DATE) VALUES (?,?)";
if ($debug) {
print "$remote_addr<br />";
print "$report_date<br />";
}
$stmt = $DbLink->prepare($queryString);
$stmt->bind_param("ss", $remote_addr, $report_date);
$sqlResult = $stmt->execute();
$stmt->close();
if (!$sqlResult) {
$DbError = $DbLink->error;
abortAndExit();
}
$record_id = $DbLink->insert_id;
// parse the data report
$queryString = "INSERT INTO reportRecord (REPORT_KEY, REPORT_VALUE, REPORT_ID) VALUES (?,?,?)";
$stmt = $DbLink->prepare($queryString);
while (list($key, $value) = each($_GET)) {
// Date,
if (array_key_exists($key, $appcastKeys) && $appcastKeys[$key] == 1) {
if ($debug) {
print "$key: $value<br />\n";
}
$stmt->bind_param("ssi", $key, $value, $record_id);
$sqlResult = $stmt->execute();
if (!$sqlResult) {
$DbError = $DbLink->error;
abortAndExit();
}
}
}
$stmt->close();
CloseDB();
if ($debug) {
print "</body>\n";
exit();
}
}
function returnAppcast() {
global $appcastURL;
header("content-type: application/xhtml+xml");
$xml = simplexml_load_file($appcastURL);
echo $xml->asXML();
}
function validProfile() {
if (array_key_exists('appName', $_GET)) {
return TRUE;
} else {
return FALSE;
}
}
function validUserAgent() {
$ua = $_SERVER['HTTP_USER_AGENT'];
$blockedAgents[] = "/^Bodega\//";
foreach ($blockedAgents as $agent) {
if (preg_match($agent,$ua) > 0) {
return FALSE;
}
}
return TRUE;
}
?>