added custom error messages (fixed existing implementation)
[iauth.git] / iauth.php
index 267e871ad5fea0125176be4b91be806e4b26290e..c89f0557f24c188451fdffc8ad1c183c3bbecdcb 100644 (file)
--- a/iauth.php
+++ b/iauth.php
@@ -1,6 +1,7 @@
 #!/usr/bin/php
 <?php
-/* Written by David Herrmann.
+/* Written by David Herrmann,
+ *  improved by Philipp Kreil.
  * Dedicated to the Public Domain.
  */
 /* PHP IAuth verifier.
@@ -68,7 +69,8 @@
  *     echo "+wogsfr 131071 fake.host.net account:124653295"
  * The last parameter "mode" can have as many spaces as you want.
  */
-
+error_reporting(0);
 /* These constants are defined to access $argv more easily. */
 define("ARG_REMOTEIP", $argv[1]);
 define("ARG_REMOTEPORT", $argv[2]);
@@ -100,12 +102,13 @@ function iauth_return($class = NULL, $ident = NULL, $host = NULL, $ip = NULL, $m
     if($host === NULL || strlen($host) == 0) $host = "$";
     if($ip === NULL || strlen($ip) == 0) $ip = "$";
     if($mode === NULL || strlen($mode) == 0) $mode = "$";
-    echo "$class $ident $host $ip $mode";
+    echo "$class $ident $host $ip $mode %";
     exit(0);
 }
 
 /* This rejects the client. */
-function iauth_reject() {
+function iauth_reject($reason = NULL) {
+    if($reason != NULL && strlen($reason) != 0) echo"error ".$reason." %";
     exit(0);
 }
 
@@ -130,6 +133,9 @@ function iauth_reject() {
 /* iauth_reject(); */
 
 /* our real implementation */
+if (is_readable('iauth-wgn.php')) {
+    require('iauth-wgn.php');
+}
 iauth_return();
 
 ?>