-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrorreporter.php
executable file
·102 lines (68 loc) · 2.29 KB
/
errorreporter.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
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
91
92
93
94
95
96
97
98
99
100
101
102
<?php
session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
header("Location: /dashboard/login");
}
?>
/* object literal wrapper to avoid namespace conflicts */
var ErrorTracking = {};
var org = '<?php echo $_SESSION["orgID"]; ?>';
/* URL of your server-side error recording script */
ErrorTracking.errorReportingURL = "http://104.131.195.41:9091/seterrors.php";
ErrorTracking.encodeValue = function(val)
{
var encodedVal;
if (!encodeURIComponent)
{
encodedVal = escape(val);
/* fix the omissions */
encodedVal = encodedVal.replace(/@/g, '%40');
encodedVal = encodedVal.replace(/\//g, '%2F');
encodedVal = encodedVal.replace(/\+/g, '%2B');
}
else
{
encodedVal = encodeURIComponent(val);
/* fix the omissions */
encodedVal = encodedVal.replace(/~/g, '%7E');
encodedVal = encodedVal.replace(/!/g, '%21');
encodedVal = encodedVal.replace(/\(/g, '%28');
encodedVal = encodedVal.replace(/\)/g, '%29');
encodedVal = encodedVal.replace(/'/g, '%27');
}
/* clean up the spaces and return */
return encodedVal.replace(/\%20/g,'+');
}
ErrorTracking.reportJSError = function (errorMessage,url,lineNumber)
{
function sendRequest(url,payload)
{
var img = new Image();
img.src = url+"?"+payload;
}
/* form payload string with error data */
var payload = "url=" + ErrorTracking.encodeValue(url);
payload += "&message=" + ErrorTracking.encodeValue(errorMessage);
payload += "&line=" + ErrorTracking.encodeValue(lineNumber);
payload += "&orgID=" + org;
/* submit error message */
sendRequest(ErrorTracking.errorReportingURL,payload);
alert("JavaScript Error Encountered. \nSite Administrators have been notified.");
return true;
}
ErrorTracking.registerErrorHandler = function ()
{
if (window.onerror)
{
var oldError = window.onerror;
var newErrorHandler = function (errorMessage, url, lineNumber){
ErrorTracking.reportJSError(errorMessage,url,lineNumber);
oldError(errorMessage,url,lineNumber);
}
window.onerror = newErrorHandler;
}
else
window.onerror = ErrorTracking.reportJSError;
}
/* bind the error handler */
ErrorTracking.registerErrorHandler();