Initial add of defaria.com
[clearscm.git] / defaria.com / php / report_breakin.php
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2    "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6   <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
7   <link rel="stylesheet" type="text/css" media="screen" href="/css/Plain.css">
8   <title>Your violation has been reported</title>
9 <?php
10 $ip     = $_SERVER  ["REMOTE_ADDR"];
11 $page   = $_REQUEST ["page"];
12 $date   = date ("m/d/Y @ h:i A");
13
14 function GetEmails ($ip) {
15   $whois_list = array (
16     "",
17     "whois.arin.net",
18     "whois.nsiregistry.net",
19     "whois.opensrs.net",
20     "whois.networksolutions.com"
21   );
22
23   $email_address = array ();
24
25   foreach ($whois_list as $whois_server) {
26     $lines = "";
27
28     if ($whois_server == "") {
29       $lines = `whois $ip`;
30     } else {
31       $lines = `whois -h $whois_server $ip`;
32     } // if
33
34     preg_match_all ("/\s(\S+\@\S[\.\S]+)/", $lines, $matches, PREG_PATTERN_ORDER);
35
36     foreach ($matches [1] as $match) {
37       $email_address [$match] = $match;
38     } // foreach
39
40     $count = count ($email_address);
41     if (count ($email_address) > 0) {
42       break;
43     } // if
44   } // foreach
45
46   return $email_address;
47 } // GetEmails
48
49 function LogViolation ($ip, $email_address, $page) {
50   global $date;
51   $filename = "/web/violation.log";
52
53   $fh = fopen ($filename, "a");
54
55   $msg = "";
56
57   if ($email_address == "<unknown>") {
58     $msg = "$date $ip attempted to access $page - No email address found to report violation to\n";
59   } else {
60     $msg = "$date $ip attempted to access $page - violation reported to $email_address\n";
61   } // if
62
63   fwrite ($fh, $msg);
64
65   fclose ($fh);
66 } // LogViolation
67
68 function SendViolation ($ip, $email_address) {
69   $domain  = "DeFaria.com";
70   $contact = "Andrew@DeFaria.com";
71   $subject = "Illegal attempts to break into $domain from your domain ($ip)";
72   $message = "
73 <html>
74 <head>
75   <title>$subject</title>
76 </head>
77 <body>
78   <h3>$subject</h3>
79
80   <p>On $date somebody from your domain with an IP Address of $ip has been
81   attempting to break into my domain, <a
82   href=\"http://$domain\">$domain</a>. Breaking into somebody else's
83   computer is <font color=\"red\"><b>illegal</b></font> and <font
84   color=\"red\"><b>criminal prosecution can result</b></font>. As a
85   responsible ISP it is in your best interests to investigate such
86   activity and to shutdown any such illegal activity as it is a
87   <u>violation of law</u> and most likely a violation of your user
88   level agreement. It is expected that you will investigate this and
89   send the result and/or disposition of your investigation back to <a
90   href=\"mailto:$contact\">$contact</a>. <font color=\"red\"><b>If you
91   fail to do so then criminal prosecution may result!</b></font>
92 </body>
93 </html>
94 ";
95   // To send HTML mail, the Content-type header must be set
96   $extra_headers  = "MIME-Version: 1.0\n";
97   $extra_headers .= "Content-type: text/html; charset=iso-8859-1\n";
98
99   // Additional headers
100   $extra_headers .= "From: Andrew DeFaria <$contact>\n";
101   //$extra_headers .= "Cc: $contact\n";
102
103   if (mail ($email_address, $subject, $message, $extra_headers)) {
104     print "Sent violation report to $email_address<br>";
105   } else {
106     print "Error sending violation report to $email_address</br>";
107   } // if
108 } // function
109 ?>
110 </head>
111
112 <body>
113
114 <div class="heading">
115   <h1 class="centered">Your violation has been reported!</h1>
116 </div>
117
118 <div id="content">
119   <p>You have purposely and illegal probed my site to arrive at this page. As a
120   result your IP address <?php echo $ip;?> has been logged and a 
121   report was sent to your ISP.</p>
122
123 <?php
124 $email_addresses = GetEmails ($ip);
125
126 if (count ($email_addresses) == 0) {
127   LogViolation ($ip, "<unknown>", $page);
128 } else {
129   foreach ($email_addresses as $email_address) {
130     SendViolation ($ip, $email_address);
131     LogViolation ($ip, $email_address, $page);
132   } // foreach
133 } // if
134 ?>
135
136 </div>
137
138 </body>
139 </html>