added custom error messages (fixed existing implementation)
[iauth.git] / iauth-wgn.php
1 <?php
2 $fakelocalip = true;
3 $fakemibbitip = true;
4 $mibbit_ips = array("207.192.75.252", "64.62.228.82", "78.129.202.38", "109.169.29.95");
5 $fakewebircip = true;
6 $public=true;  //Force one of the settings below (reject connection if nothing is matching)
7 $not_public['staff.webgamesnet.net']=true; // servername in lower chars  (exceptions from $public)
8 $passwd="*"; // global password to log in normaly without any special modes like below  (you can set this to false)
9
10
11 $user="secret_user";
12 $users[$user]['modes']="+SDHnIk";
13 $ip="10.".rand(1,255).".".rand(1,255).".".rand(1,255);
14 $users[$user]['host']=$ip.".fake";
15 $users[$user]['ip']=$ip;
16 $users[$user]['ident']="spoof";
17
18 $user="another_user";
19 $users[$user]['access']=true;
20
21
22
23
24 $pass = $public;
25 if($not_public[strtolower(ARG_SERVER)]) $pass=false;
26 if($passwd && ARG_PASS == $passwd) $pass = true;
27 $ip=null;
28 $host=null;
29 $ident=null;
30 $extra=null;
31 if($fakemibbitip && array_search(ARG_REMOTEIP, $mibbit_ips)) {
32     //Mibbit user!
33     //we should have a hey ip in the ident
34     if(strlen(ARG_USERNAME) == 8) {
35         $ip=hexdec(substr(ARG_USERNAME,0,2)).".".hexdec(substr(ARG_USERNAME,2,2)).".".hexdec(substr(ARG_USERNAME,4,2)).".".hexdec(substr(ARG_USERNAME,6,2));
36         $host="c".strtoupper(ARG_USERNAME).".spoof.mibbit.WebGamesNet";
37         $ident="Mibbit";
38         $modes = "+W";
39     }
40 } else if($fakewebircip && (ARG_REMOTEIP == "127.0.0.1" || ARG_REMOTEIP == "::1") && preg_match("/(.*)\/(.*) - WEBIRC/i",ARG_REALNAME)) {
41     //Webirc user!
42     $split = explode(" ",ARG_REALNAME);
43     $split = explode("/",$split[0]);
44     $ipsplit = explode(".",$split[1]);
45     $host = "c".strtoupper(dechex($ipsplit[0]).dechex($ipsplit[1]).dechex($ipsplit[2]).dechex($ipsplit[3])).".spoof.webirc.WebGamesNet";
46     $ip = $split[1];
47     $ident = "webirc";
48     $modes = "+W";
49 } else if($fakelocalip && (ARG_REMOTEIP == "127.0.0.1" || ARG_REMOTEIP == "::1")) {
50     $md5=md5(ARG_USERNAME." ".ARG_SERVER);
51     $ip="10.".hexdec(substr($md5,0,2)).".".hexdec(substr($md5,2,2)).".".hexdec(substr($md5,4,2));
52     $host="c".strtoupper(substr($md5,0,6)).".localIP";
53 }
54 if(ARG_ACCOUNT == "") {
55     if(!$pass) iauth_reject("You are not allowed to use this server.");
56 } else {
57     if(array_key_exists(strtolower(ARG_ACCOUNT), $users)) {
58         $user = $users[strtolower(ARG_ACCOUNT)];
59         $ident = (array_key_exists('ident', $user) ? $user['ident'] : $ident);
60         $host = (array_key_exists('host', $user) ? $user['host'] : $host);
61         $ip = (array_key_exists('ip', $user) ? $user['ip'] : $ip);
62         $modes = (array_key_exists('modes', $user) ? $user['modes'] : null);
63         iauth_return(null, $ident, $host, $ip, $modes);
64     } else if(!$pass) {
65         iauth_reject("You are not allowed to use this server.");
66     }
67 }
68 iauth_return(null, $ident, $host, $ip, $modes);
69
70 ?>