-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.php
More file actions
68 lines (56 loc) · 2.19 KB
/
example.php
File metadata and controls
68 lines (56 loc) · 2.19 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
<?php
require_once dirname(__FILE__).'/classes/traffix.php';
$traffix = new traffix;
$DOMAIN = $_SERVER['HTTP_HOST'];
?>
<html lang="en">
<head>
<title>Traffix Quick Example</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/style.php">
<script type="text/javascript" src="js/javascript.php"></script>
</head>
<body>
<?php
echo "<b>Request</b>:<br>";
echo "IP Address: ".$traffix->ip;
echo "<br>Reverse DNS: ".$traffix->rDNS;
echo "<br>Made at: ".date('r',$traffix->request_time);
echo "<br>Pages Per Minute Access Speed: ".$traffix->pages_per_minute();
echo "<br><br>";
// Log the traffic, a new entry for each visitor is made daily.
$traffix->log();
// Trafic Headers.
echo "<b>Request Headers:</b><br>";
$info = $traffix->info();
foreach( $info['request_headers'] as $header=>$value )
echo "[$header] = $value<br>";
// Assert a refer, for example if your processing a form submission
// and want to check if the form is comming from your site.
echo "<br><b>Assert Referrer:</b><br>";
if( $traffix->assert_referer($DOMAIN) )
echo "<span style='color:green;font-weight:bold;'>Traffic has a referrer matching $DOMAIN.</span><br>";
else
echo "<span style='color:red;font-weight:bold;'>Traffic refferer does not match $DOMAIN</span><br>";
// Assert a request method, for example if your form processes via POST you can check
// to make sure the request matches
echo "<br><b>Assert Request Method: POST</b><br>";
if( $traffix->assert_request_method("POST") )
echo "<span style='color:green;font-weight:bold;'>Request made with POST</span><br>";
else
echo "<span style='color:red;font-weight:bold;'>Request made with GET</span><br>";
// Check if the browser matches the common request header pattern.
echo "<br><b>Browser Request Header Pattern</b><br>";
if( $traffix->check_browser_pattern() )
echo "<span style='color:green;font-weight:bold;'>Request Header Pattern is okay</span><br>";
else
echo "<span style='color:red;font-weight:bold;'>Something is wrong with the Request Header Pattern</span><br>";
?>
<br>
<a href="example.php">Visit this page with a local link.</a>
<br>
<script type="text/javascript">
did_this_page_load();
</script>
</body>
</html>