phpwhois.patch

Patch for phpwhois against Rev. 204 - Marcel Koßin, 11/20/2009 12:35 am

Download (4.3 kB)

 
wi-unstable_mk/inc/config.php 2009-11-19 21:42:50.000000000 +0100
1
<?php        
2
/* This file is part of Glastopf Log v0.2
3
   ================================
4
   Copyright (c) 2008 Glastopf Project                   
5

  
6
  This program is free software; you can redistribute it and/or
7
  modify it under the terms of the GNU General Public License
8
  as published by the Free Software Foundation; either version 2
9
  of the License, or (at your option) any later version.
10
  
11
  This program is distributed in the hope that it will be useful,
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
  GNU General Public License for more details.
15
  
16
  You should have received a copy of the GNU General Public License
17
  along with this program; if not, write to the Free Software
18
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19
 
20
*/
21

  
22
/* WHOIS_METHOD
23
   ============
24
   system   - Use system() in order to invoke the whois shellcommand
25
   phpwhois - Use php to resolve whois information. This requires you to download
26
              and extract the latest version of phpwhois from:
27
              http://sourceforge.net/projects/phpwhois/files/phpwhois/
28
              1. create a folder named classes_3rdparty in the installation root of
29
                 of your glastopf webinterface
30
              2. extract phpwhois into this folder
31
              3. create a link called phpwhois to the new folder (e. g. 
32
                 ln -sf phpwhois-x.y.z phpwhois
33
              4. alter system into phpwhois below
34
*/
35

  
36
define('WHOIS_METHOD', 'system');      // Either 'system' or 'phpwhois' default is system
37

  
38
?>
wi-unstable_mk/log.php 2009-11-19 21:23:47.000000000 +0100
22 22

  
23 23
include ("inc/header.php");
24 24
include ("inc/connect.php");
25
include("inc/config.php");
25 26
?>
26 27
    <script type="text/javascript">tabdropdown.init("menu", 0)</script>
27 28
    <h2> Explanation</h2>
......
97 98
			<td align=center>Request</td>
98 99
			</tr>";
99 100
			while ($arr = mysql_fetch_array($res)) {
101
			    $lnk_whois = "whois.php?ip=" . $arr[ip];
102
			    if (WHOIS_METHOD != 'system') {
103
			       $lnk_whois = $lnk_whois . "&method=" . WHOIS_METHOD;
104
			    }
100 105
                            echo "<tr><td><a href=display.php?show=$arr[id]><center>$arr[id]</center></a></td>
101
                                 <td><a href=whois.php?ip=$arr[ip]>$arr[ip]</a></td>
106
                                 <td><a href=" . $lnk_whois . ">$arr[ip]</a></td>
102 107
                                  <td>".substr($arr['host'], 0, 32)."</td>
103 108
                                   <td>$arr[attime]</td>
104 109
                                    <td>".substr($arr['req'], 0, -1)."</td>
wi-unstable_mk/whois.php 2009-11-19 21:31:21.000000000 +0100
33 33
    <a href="search.php?ipquery=<?=htmlspecialchars($_GET["ip"])?>&start=0">Search for more attacks from IP</a>
34 34
    <h2>WHOIS Data for <i><?=htmlspecialchars($_GET["ip"])?></i>
35 35
    </h2>
36
    <font size=4>
37
    <pre>
38
<?php system("whois ".escapeshellcmd($_GET["ip"])); ?>
39
</pre>
40
</font>
41 36
<?php
42
include ("inc/footer.php");
43
?>
37
   if(isset($_GET["method"]) && $_GET["method"] == "phpwhois") {
38
      /* if configured use phpwhois classes */
39
      include_once('classes_3rdparty/phpwhois/whois.main.php'); 
40
      include_once('classes_3rdparty/phpwhois/whois.utils.php');
41

  
42
      echo '<font face="Courier New, Courier, mono" size="4">';
43
      $whois = new Whois();
44
      $result = $whois->Lookup($_GET["ip"]);
45

  
46
      $utils = new utils;
47

  
48
      echo utf8_encode($utils->showHTML($result));
49
      echo '</font>';
50
   } else {
51
      /* else invoke the whois system command */
52
      echo '<font size=4><pre>';
53
      system("whois ".escapeshellcmd($_GET["ip"]));
54
      echo '</pre><font>';
55
   }
56

  
57
   include ("inc/footer.php");
58
?>