Repository navigation
Expand file tree
/
Copy pathtracker.js
More file actions
297 lines (281 loc) · 8.88 KB
/
Copy pathtracker.js
File metadata and controls
297 lines (281 loc) · 8.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
var searchdata;
var fd;
$(document).ready(function(){
$("#GULclear").click(function(e){
e.preventDefault();
$("#GULout").html("");
});
$(".GUL_gen").live( "click", function(e) {
e.preventDefault();
$("#GULloading").show();
GULinitiate({ "target": $(this).attr("value") }, $(this).attr("value"));
});
$('#GULform').submit(function(e) {
e.preventDefault();
$("#GULloading").show();
GULinitiate($("#GULform").serialize(), $("#GULtarget").val());
$("#GULtarget").val("");
$('#GULscroll').scrollTop($('#GULscroll'));
});
function GULinitiate(formdata, target) {
$.post("tracker.php", formdata, function(result){
$("#GULloading").hide();
GULProcessOutput(result);
}, "json");
}
function GULgeolocate(ip, target) {
var location;
$.getJSON("http://freegeoip.net/json/"+ ip +"?callback=?", function(json) {
location = "<a href='http://maps.google.com/maps?q="+ json.city +" "+ json.region_name +" "+ json.country_code +"' target='_blank'>"+ json.city +", "+ json.region_name +" ("+ json.country_code +")</a>";
$("#GULgeo_"+target).html("This player's most recent IP address maps to approximately: "+ location +"<br />\n");
});
}
function GULProcessOutput(result) {
var report = "";
if ( result.success ) {
if ( result.wildcard )
report = "No exact results for your search term, only partial match was <b>"+ result.target +"</b><br />\n";
report += "<h3>Report for "+ result.target +"</h3>\n<p>";
report += "<span id='GULgeo_"+ result.target +"'></span>";
for ( ip in result.body ) {
report += "• Connected from <a "+
"href='http://dnstools.com/?count=2&lookup=on&wwwhois=on&arin=on&checkp=on&portNum=80&ping=on&all=on&target="+
ip +"&submit=Go!'>"+ ip +"</a> most recently at "+ result['body'][ip]['time'];
report += ".<br />\n";
if ( result['body'][ip]['total'] > 0 ) {
report += "<span class='assoc_acct'>";
for (var i = 0; i < result['body'][ip]['matches'].length; i++) {
report += "» This IP is also associated with the account <a href='#newreport' class='GUL_gen' value='"+
result['body'][ip]['matches'][i] +"'>"+ result['body'][ip]['matches'][i] +"</a><br />\n";
}
report += "</span>";
}
}
report += "</p>";
$("#GULout").prepend(report);
GULgeolocate(result.lastip, result.target);
searchdata = result.map;
if ( fd != null ) {
fd.loadJSON(searchdata);
fd.computeIncremental({
iter: 60,
property: 'end',
onComplete: function(){
fd.animate({
modes: ['linear'],
transition: $jit.Trans.Elastic.easeOut,
duration: 2500
});
}
});
}
else {
$("#playerweb").show();
init();
}
}
else {
report = "<h3 style='color:red;'>"+ result.head +"</h3><br />\n";
report += result.body +"<br /><hr>\n";
$("#GULout").prepend(report);
}
//console.log(result);
}
function GULfetchdata(target){
$('#GULscroll').scrollTop($('#GULscroll'));
var targetIP = $('#GULlatestIP-' + target).text();
$.getJSON("http://freegeoip.net/json/"+ targetIP +"?callback=?",
function(json) {
$('#GULgeo-'+ target).html("<a href='http://maps.google.com/maps?q="+ json.city +" "+ json.region_name +" "+ json.country_code +"' target='_blank'>»"+ json.city +", "+ json.region_name +" ("+ json.country_code +")</a>");
});
}
});
function selectCode(a)
{
// Get ID of code block
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
// Not IE
if (window.getSelection)
{
var s = window.getSelection();
// Safari
if (s.setBaseAndExtent)
{
s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
}
// Firefox and Opera
else
{
// workaround for bug # 42885
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
{
e.innerHTML = e.innerHTML + ' ';
}
var r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
}
// Some older browsers
else if (document.getSelection)
{
var s = document.getSelection();
var r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
// IE
else if (document.selection)
{
var r = document.body.createTextRange();
r.moveToElementText(e);
r.select();
}
}
var labelType, useGradients, nativeTextSupport, animate;
(function() {
var ua = navigator.userAgent,
iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i),
typeOfCanvas = typeof HTMLCanvasElement,
nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'),
textSupport = nativeCanvasSupport
&& (typeof document.createElement('canvas').getContext('2d').fillText == 'function');
//I'm setting this based on the fact that ExCanvas provides text support for IE
//and that as of today iPhone/iPad current text support is lame
labelType = (!nativeCanvasSupport || (textSupport && !iStuff))? 'Native' : 'HTML';
nativeTextSupport = labelType == 'Native';
useGradients = nativeCanvasSupport;
animate = !(iStuff || !nativeCanvasSupport);
})();
var Log = {
elem: false,
write: function(text){
if (!this.elem)
this.elem = document.getElementById('log');
this.elem.innerHTML = text;
this.elem.style.left = (500 - this.elem.offsetWidth / 2) + 'px';
}
};
function init(){
// init ForceDirected
fd = new $jit.ForceDirected({
//id of the visualization container
injectInto: 'playerweb',
//Enable zooming and panning
//by scrolling and DnD
Navigation: {
enable: true,
//Enable panning events only if we're dragging the empty
//canvas (and not a node).
panning: 'avoid nodes',
zooming: 50 //zoom speed. higher is more sensible
},
// Change node and edge styles such as
// color and width.
// These properties are also set per node
// with dollar prefixed data-properties in the
// JSON structure.
Node: {
overridable: true
},
Edge: {
overridable: true,
color: '#23A4FF',
lineWidth: 0.4
},
//Native canvas text styling
Label: {
type: labelType, //Native or HTML
size: 10,
style: 'bold'
},
//Add Tips
Tips: {
enable: true,
onShow: function(tip, node) {
//count connections
var count = 0;
node.eachAdjacency(function() { count++; });
//display node info in tooltip
tip.innerHTML = "<div class=\"tip-title\">" + node.name + "</div>"
+ "<div class=\"tip-text\"><b>connections:</b> " + count + "</div>";
}
},
// Add node events
Events: {
enable: true,
type: 'Native',
//Change cursor style when hovering a node
onMouseEnter: function() {
fd.canvas.getElement().style.cursor = 'move';
},
onMouseLeave: function() {
fd.canvas.getElement().style.cursor = '';
},
//Update node positions when dragged
onDragMove: function(node, eventInfo, e) {
var pos = eventInfo.getPos();
node.pos.setc(pos.x, pos.y);
fd.plot();
},
//Implement the same handler for touchscreens
onTouchMove: function(node, eventInfo, e) {
$jit.util.event.stop(e); //stop default touchmove event
this.onDragMove(node, eventInfo, e);
},
/*/Add also a click handler to nodes
onClick: function(node) {
if(!node) return;
// Build the right column relations list.
// This is done by traversing the clicked node connections.
var html = "<h4>" + node.name + "</h4><b> connections:</b><ul><li>",
list = [];
node.eachAdjacency(function(adj){
list.push(adj.nodeTo.name);
});
//append connections information
$jit.id('inner-details').innerHTML = html + list.join("</li><li>") + "</li></ul>";
}*/
},
//Number of iterations for the FD algorithm
iterations: 200,
//Edge length
levelDistance: 130,
// Add text to the labels. This method is only triggered
// on label creation and only for DOM labels (not native canvas ones).
onCreateLabel: function(domElement, node){
domElement.innerHTML = node.name;
var style = domElement.style;
style.fontSize = "0.9em";
style.color = "#111";
},
// Change node styles when DOM labels are placed
// or moved.
onPlaceLabel: function(domElement, node){
var style = domElement.style;
var left = parseInt(style.left);
var top = parseInt(style.top);
var w = domElement.offsetWidth;
style.left = (left - w / 2) + 'px';
style.top = (top + 10) + 'px';
style.display = '';
}
});
// load JSON data.
fd.loadJSON(searchdata);
// compute positions incrementally and animate.
fd.computeIncremental({
iter: 60,
property: 'end',
onComplete: function(){
fd.animate({
modes: ['linear'],
transition: $jit.Trans.Elastic.easeOut,
duration: 2500
});
}
});
// end
}