]> jfr.im git - irc/thales.git/blob - contrib/whois/dowhois.php
Initial revision
[irc/thales.git] / contrib / whois / dowhois.php
1 <?
2 /* ============================================================================
3 # /whois emulation for www (powered by Thales)
4 # (note: this is just an example script, add/modify as you wish)
5 #
6 # File: dowhois.php
7 # Author: Partizanu | partizanu@netchat.ro
8 # Version: 0.1
9 # Input: mySQL data from Thales tables
10 # Output: whois info (a la mIRC)
11 #
12 #
13 # Make sure to:
14 # 1) Change $mysqluser and $mysqlpassword
15 # 2) set permision and flush privileges in mysql so that script can connect
16 # 3) place the html and the php files in the same dir (or change paths in source)
17 # 4) IMPORTANT!!!: this script takes $nickname from the POST of the html file
18 # This variable may be "dirty" (eg. bad javascript code, SQL inject etc)
19 # Use whatever function makes you confortable to add security to this code (eg. strip_tags,addslashes,htmlspecialchars,quotemeta etc.)
20 # The (main) reason why this script doesn't use em is because I (the author) don't want to get mail-bombed with "Your security sux, they hacked my site coz of your stupid script" so do your "security" thing :)
21 # 5) change isok variable from 1 to 0 so I can know that you read this :)
22 # 6) have fun
23 # ============================================================================*/
24
25 $mysqluser = "php";
26 $mysqlpassword = "phprulez";
27 $isok=1;
28
29
30
31 //===Don't change anything below this unless you know what you'r doing (yeah, right)
32
33 $link = mysql_connect ("localhost", $mysqluser, $mysqlpassword) or die ("Can't connect");
34 mysql_select_db("thales");
35
36
37
38 $q = mysql_query("select * from user where nick=\"$nickname\" ");
39 if (mysql_num_rows($q) < 1)
40 {
41 mysql_close($link);
42 die($nickname ." No such nick/channel");
43 }
44
45 if ($isok==1) die("Read instructions from head of php file!");
46 while ($row = mysql_fetch_array($q))
47 {
48 $id = $row["nickid"];
49 $rname = $row["realname"];
50 $hostname = $row["hostname"];
51 $username = $row["username"];
52 $connecttime = $row["connecttime"];
53 $servid = $row["servid"];
54 $away = $row["away"];
55 if ($away == "Y") $awaymsg = $row["awaymsg"];
56 $isircop = $row["mode_lo"];
57 $issadmin = $row["mode_la"]; //bahamut only?
58 $isreg = $row["mode_lr"]; //bahamut only? depends of type of services?
59 }
60
61 $q_servers = mysql_query ("select server,comment from server where servid=$servid");
62 $r = mysql_fetch_row($q_servers);
63 $server = $r[0];
64 $scomm = $r[1];
65
66 $chid = Array();
67 $chname = Array();
68 $channels = NULL;
69 $q_channs = mysql_query ("select channel from ison,chan,user where nick = \"$nickname\" and (ison.chanid=chan.chanid and user.nickid=ison.nickid)");
70 while ($r = mysql_fetch_array ($q_channs))
71 {
72 $tmp = $r["channel"];
73 $q_mode = mysql_query("select mode_ls,mode_lp,chanid from chan where channel=\"$tmp\" ");
74 $q_mode_r = mysql_fetch_row($q_mode);
75 if ($q_mode_r[0] == "N" && $q_mode_r[1] == "N")
76 {
77 $q_getop=mysql_query("select mode_lo,mode_lv from ison where chanid=$q_mode_r[2] and nickid=$id");
78 $chmode = mysql_fetch_row($q_getop);
79 if ($chmode[0]=="Y") $channels = $channels . " @" . $tmp;
80 elseif ($chmode[1]=="Y") $channels = $channels . " +" . $tmp;
81 else $channels = $channels . " " . $tmp;
82 }
83 }
84 mysql_close($link);
85
86
87 echo "<table width=\"550\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">";
88 echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$nickname is ".$username."@".$hostname." * ".$rname."</font></td></tr>";
89 echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$nickname is connected since $connecttime</font></td></tr>";
90
91 if (!is_null($channels)) echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$nickname on $channels</font></td></tr>";
92 echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$nickname using $server $scomm</font></td></tr>";
93 if ($isreg == "Y") echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$nickname has identified for this nick</font></td></tr>";
94 if ($away == "N") echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$nickname is not away</font></td></tr>";
95 else echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$nickname is away: $awaymsg</font></td></tr>";
96 if ($isircop == "Y") echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$nickname is an IRC Operator</font></td></tr>";
97 if ($issadmin == "Y") echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$nickname is a Service Administrator</font></td></tr>";
98 echo "<tr><td align=\"center\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><hr></font></td></tr>";
99 echo "<tr><td align=\"center\"><font face=\"Arial, Helvetica, sans-serif\" size=\"-2\">Whois by <a href=\"mailto:partizanu@netchat.ro\">Partizanu</a></font></td></tr>";
100 echo "<tr><td align=\"center\"><font face=\"Arial, Helvetica, sans-serif\" size=\"-2\">Unleash &#147;<a href=\"http://www.lucas-nussbaum.net/thales/\">Thales</a>&#148; power!</font></td></tr>";
101 echo "</table>";
102 ?>