1<?php
2/*  Clones detection script
3 *  Copyright (C) 2002 Jens 'DukePyrolator' Voss <DukePyrolator@wiredirc.net>
4 *
5 *  This program is free software; you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation; either version 2 of the License, or
8 *  (at your option) any later version.
9 *
10 *  This program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with this program; if not, write to the Free Software
17 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20/* ============================================================================
21 * clone-detecting-script www (powered by Thales)
22 *
23 *    File:      clones.php
24 *    Author:    Jens 'DukePyrolator' Voss | DukePyrolator@wiredirc.de
25 *    Version:   0.1
26 *    Input:     mySQL data from Thales tables
27 *    Output:    all clones on chan (a la mIRC)
28 *    Usage:     htp://.../clones.php?chan=mychan (without the leading '#')
29 *
30 * ===========================================================================
31 */
32
33
34
35$start = doubleval(time() + microtime());
36
37
38function safe_mysql_pconnect()
39{
40
41    $db_host = "localhost";
42    $db_user = "thales";
43    $db_pass = "mysecretpass";
44    $db_name = "thales";
45
46    $mysql_link = mysql_connect($db_host, $db_user, $db_pass) or die("Can't connect to mysql");
47    mysql_select_db($db_name);
48    return($mysql_link);
49}
50
51$mysql_link = safe_mysql_pconnect();
52
53
54$chan = "#$chan";
55echo $chan;
56echo "<br> <br>";
57
58
59$clones = mysql_query("SELECT nick, hostname
60                       FROM ison,chan,user
61		       WHERE channel=\"$chan\" and ison.chanid=chan.chanid and user.nickid=ison.nickid");
62
63echo mysql_error();
64
65
66$i = 1;
67while ($clones_f = mysql_fetch_row ($clones)) {
68      $u_nick[$i] = $clones_f[0];
69      $u_host[$i] = $clones_f[1];
70      $u_found[$i] = 0;
71      $i = $i + 1;
72};
73$groesse = $i + 1;
74
75
76for ($i=1;$i<$groesse;$i++) {
77       $found= 0;
78       for ($j=1;$j<$groesse;$j++) {
79         if (($u_host[$i] == $u_host[$j]) AND !($i == $j) AND ($u_found[$i]==0)){
80            if ($found == 0) {
81                 echo $u_nick[$i];
82	         $found=1;
83             }
84             echo "    ", $u_nick[$j];
85             $u_found[$j] = 1;
86         }
87       }
88       if ($found == 1) {
89           echo "<br>\n";
90	   $u_found[$i]=1;
91       }
92}
93
94
95
96echo "\n<br><br>\n";
97echo "  ", round(((time() + microtime())-$start),6), " Sek";
98
99
100mysql_close($mysql_link);
101?>
102