Adjust weblogin config and beautify php code
authorNeutron Soutmun <neo.neutron@gmail.com>
Thu, 27 Nov 2008 09:30:09 +0000 (16:30 +0700)
committerNeutron Soutmun <neo.neutron@gmail.com>
Thu, 27 Nov 2008 09:30:09 +0000 (16:30 +0700)
2008-11-27  Neutron Soutmun <neo.neutron@gmail.com>

* weblogin/config.php:
  - Adjust the weblogin config value to satisfy the default settings of
    RahuNAS.
  - Set rahunas theme to be default theme.
* weblogin/{indedx,login,logout}.php,
  weblogin/{rahu_radius.class,rahu_xmlrpc.class,xmlrpc_service}.php:
  - Convert tab to 2 spaces (Beautify code for text editor compatibility).

ChangeLog
weblogin/config.php
weblogin/index.php
weblogin/login.php
weblogin/logout.php
weblogin/rahu_radius.class.php
weblogin/rahu_xmlrpc.class.php
weblogin/xmlrpc_service.php

index bb22c7a..26ff717 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2008-11-27  Neutron Soutmun <neo.neutron@gmail.com>
 
+       * weblogin/config.php: 
+         - Adjust the weblogin config value to satisfy the default settings of 
+           RahuNAS.
+         - Set rahunas theme to be default theme.
+       * weblogin/{indedx,login,logout}.php,
+         weblogin/{rahu_radius.class,rahu_xmlrpc.class,xmlrpc_service}.php:
+         - Convert tab to 2 spaces (Beautify code for text editor compatibility).
+
+2008-11-27  Neutron Soutmun <neo.neutron@gmail.com>
+
        * -example/rahunas.{default,init,conf}, -example/{firewall,bandwidth}.sh
          +example/rahunas.{default,init,conf}.in, 
          +example/{firewall,bandwidth}.sh.in:
index 4f6db86..1f157a4 100644 (file)
@@ -1,20 +1,20 @@
 <?php
 $config = array(
   "RADIUS_HOST" => "localhost",
-       "RADIUS_SECRET" => "testing123",
-  "RADIUS_ENCRYPT" => "PAP",
-       "RADIUS_AUTH_PORT" => 0,
-       "RADIUS_ACCT_PORT" => 0,
-       "RAHUNAS_HOST" => "localhost",
-       "RAHUNAS_PORT" => "8123",
-       "NAS_IDENTIFIER" => "RahuNAS-01",
-       "NAS_IP_ADDRESS" => "10.55.95.251",
-       "NAS_LOGIN_HOST" => "10.55.95.251",
+  "RADIUS_SECRET" => "testing123",
+  "RADIUS_ENCRYPT" => "CHAP_MD5",
+  "RADIUS_AUTH_PORT" => 0,
+  "RADIUS_ACCT_PORT" => 0,
+  "RAHUNAS_HOST" => "localhost",
+  "RAHUNAS_PORT" => "8123",
+  "NAS_IDENTIFIER" => "RahuNAS-01",
+  "NAS_IP_ADDRESS" => "172.30.0.1",
+  "NAS_LOGIN_HOST" => "172.30.0.1",
   "NAS_LOGIN_PORT" => "8443",
-       "NAS_LOGIN_PROTO" => "https",
-       "NAS_PORT" => 1,
+  "NAS_LOGIN_PROTO" => "https",
+  "NAS_PORT" => 1,
   "NAS_LOGIN_TITLE" => "RahuNAS Network",
-       "DEFAULT_REDIRECT_URL" => "http://www.kku.ac.th",
-  "UAM_TEMPLATE" => "kkuwifi"
+  "DEFAULT_REDIRECT_URL" => "http://www.kku.ac.th",
+  "UAM_TEMPLATE" => "rahunas"
 );
 ?>
index dcd4cd8..5a91669 100644 (file)
@@ -22,7 +22,7 @@ a {
 
 a:hover {
   font-weight: bolder;
-       color: #FF0000;
+  color: #FF0000;
 }
 </style>
 </head>
index 67c613f..25ab41c 100644 (file)
@@ -9,42 +9,42 @@ require_once 'header.php';
 
 if (!empty($_POST['user']) && !empty($_POST['passwd'])) {
   $ip = $_SERVER['REMOTE_ADDR'];
-       $forward = false;
+  $forward = false;
   $LogoutURL  = $config['NAS_LOGIN_PROTO'] . "://" . $config['NAS_LOGIN_HOST'];
   $LogoutURL .= !empty($config['NAS_LOGIN_PORT']) ? ":" . $config['NAS_LOGIN_PORT'] : "";
-       $LogoutURL .= "/logout.php";
+  $LogoutURL .= "/logout.php";
 
   $RequestURL = empty($_GET['request_url']) ? 
-                        $config['DEFAULT_REDIRECT_URL']
-                      : urldecode($_GET['request_url']);
-       $_SESSION['request_url'] = $RequestURL;
+                   $config['DEFAULT_REDIRECT_URL']
+                 : urldecode($_GET['request_url']);
+  $_SESSION['request_url'] = $RequestURL;
   $message = "";
   $rauth = new rahu_radius_auth ($_POST['user'], $_POST['passwd'], $config['RADIUS_ENCRYPT']);
   $rauth->host = $config["RADIUS_HOST"];
-       $rauth->port = $config["RADIUS_AUTH_PORT"];
-       $rauth->secret = $config["RADIUS_SECRET"];
-       $rauth->start();
+  $rauth->port = $config["RADIUS_AUTH_PORT"];
+  $rauth->secret = $config["RADIUS_SECRET"];
+  $rauth->start();
 
-       if ($rauth->isError()) {
-         $message = "ไม่สามารถเชื่อมต่อ กับเครื่องตรวจสอบสิทธิ์ได้";
-       } else if ($rauth->isAccept()) {
-         $message = "ผู้ใช้ ผ่านการตรวจสอบสิทธิ์ รอสักครู่ ";
-         $forward = true;
-               $racct = new rahu_radius_acct ($_POST['user']);
+  if ($rauth->isError()) {
+    $message = "ไม่สามารถเชื่อมต่อ กับเครื่องตรวจสอบสิทธิ์ได้";
+  } else if ($rauth->isAccept()) {
+    $message = "ผู้ใช้ ผ่านการตรวจสอบสิทธิ์ รอสักครู่ ";
+    $forward = true;
+    $racct = new rahu_radius_acct ($_POST['user']);
     $racct->host = $config["RADIUS_HOST"];
-         $racct->port = $config["RADIUS_ACCT_PORT"];
-         $racct->secret = $config["RADIUS_SECRET"];
-               $racct->nas_identifier = $config["NAS_IDENTIFIER"];
+    $racct->port = $config["RADIUS_ACCT_PORT"];
+    $racct->secret = $config["RADIUS_SECRET"];
+    $racct->nas_identifier = $config["NAS_IDENTIFIER"];
     $racct->nas_ip_address = $config["NAS_IP_ADDRESS"];
     $racct->nas_port = $config["NAS_PORT"];
     $racct->framed_ip_address  = $_SERVER['REMOTE_ADDR'];
     $racct->calling_station_id = returnMacAddress();
-               $racct->gen_session_id();
+    $racct->gen_session_id();
 
-               // Verify if the user already login
-               $xmlrpc = new rahu_xmlrpc_client();
-               $xmlrpc->host = $config["RAHUNAS_HOST"];
-               $xmlrpc->port = $config["RAHUNAS_PORT"];
+    // Verify if the user already login
+    $xmlrpc = new rahu_xmlrpc_client();
+    $xmlrpc->host = $config["RAHUNAS_HOST"];
+    $xmlrpc->port = $config["RAHUNAS_PORT"];
 
     try {
       $prepareData = array (
@@ -55,32 +55,32 @@ if (!empty($_POST['user']) && !empty($_POST['passwd'])) {
         "Session-Timeout" => $rauth->attributes['session_timeout'],
         "Bandwidth-Max-Down" => $rauth->attributes['WISPr-Bandwidth-Max-Down'],
         "Bandwidth-Max-Up" => $rauth->attributes['WISPr-Bandwidth-Max-Up']);
-               $result = $xmlrpc->do_startsession($prepareData);
-               if (strstr($result,"Client already login")) {
+      $result = $xmlrpc->do_startsession($prepareData);
+      if (strstr($result,"Client already login")) {
         $message = "ผู้ใช้นี้ ได้ใช้สิทธิ์เข้าใช้งานแล้ว";
-           $forward = false;
-               } else if (strstr($result, "Greeting")) {
+        $forward = false;
+      } else if (strstr($result, "Greeting")) {
         $racct->acctStart();
-               } else if (strstr($result, "Invalid IP Address")) {
+      } else if (strstr($result, "Invalid IP Address")) {
         $message = "หมายเลข IP Address ประจำเครื่อง ไม่ถูกต้อง";
-           $forward = false;
-               }
+        $forward = false;
+      }
     } catch (XML_RPC2_FaultException $e) {
       $message = "ผิดพลาด! ไม่สามารถเชื่อมต่อเครื่องแม่ข่ายได้";
-         $forward = false;
+      $forward = false;
     } catch (Exception $e) {
       $message = "ผิดพลาด! ไม่สามารถเชื่อมต่อเครื่องแม่ข่ายได้";
-         $forward = false;
+      $forward = false;
     }
-       } else {
+  } else {
     if ($rauth->isLoggedIn()) {
-           $message = "ไม่สามารถเข้าระบบได้ มีการเข้าระบบซ้ำ";
+      $message = "ไม่สามารถเข้าระบบได้ มีการเข้าระบบซ้ำ";
     } else if ($rauth->isTimeout()) {
-           $message = "ไม่สามารถเข้าระบบได้ หมดเวลาการใช้งาน";
+      $message = "ไม่สามารถเข้าระบบได้ หมดเวลาการใช้งาน";
     } else {
-           $message = "ไม่พบผู้ใช้นี้ หรือรหัสผ่านผิด";
+      $message = "ไม่พบผู้ใช้นี้ หรือรหัสผ่านผิด";
     }
-       }
+  }
 }
 
 if ($forward) {
@@ -140,7 +140,7 @@ $loginscript = "<script>" .
                "if (ns4)" .
                "  msg=document.message;\n" .
                "else if (ns6)" .
-                    "  msg=document.getElementById('message').style;\n" .
+               "  msg=document.getElementById('message').style;\n" .
                "else if (ie4)" .
                "  msg=document.all.message.style;\n\n" .
                "var wt=(document.all);\n" .  
index 8b78073..002a785 100644 (file)
@@ -36,7 +36,7 @@ if (is_array($retinfo)) {
   $ip =& $retinfo["ip"];
   $username =& $retinfo["username"];
   $session_id =& $retinfo["session_id"];
-       $session_start =& $retinfo["session_start"];
+  $session_start =& $retinfo["session_start"];
   $mac_address =& $retinfo["mac_address"];
   $isinfo = true;
 } else {
@@ -45,16 +45,16 @@ if (is_array($retinfo)) {
 
 if (!empty($_POST['do_logout'])) {
   if ($isinfo) {
-         $result = $xmlrpc->do_stopsession($ip, returnMacAddress());
-         if ($result === true) {
+    $result = $xmlrpc->do_stopsession($ip, returnMacAddress());
+    if ($result === true) {
       $valid = false;
-                 $message = "ทำการ 'Logout' สำเร็จ";
+      $message = "ทำการ 'Logout' สำเร็จ";
       $isstopacct = true;
-       } else {
+    } else {
       $valid = false;
-                 $message = "ไม่สามารถ 'เลิกใช้งาน' ได้ในขณะนี้ กรุณาลองใหม่อีกครั้ง";
-                 $show_info = true;
-         }
+      $message = "ไม่สามารถ 'เลิกใช้งาน' ได้ในขณะนี้ กรุณาลองใหม่อีกครั้ง";
+      $show_info = true;
+    }
   }
 
   if ($isstopacct) {
@@ -78,15 +78,15 @@ if (!empty($_POST['do_logout'])) {
 }
 
 if ($show_info) {
-       $result = $xmlrpc->do_getsessioninfo($ip);
-       if (is_array($result)) {
-         if (!empty($result['session_id'])) {
+  $result = $xmlrpc->do_getsessioninfo($ip);
+  if (is_array($result)) {
+    if (!empty($result['session_id'])) {
       $valid = true;
-                       $info = $result;
-               } else {
+      $info = $result;
+    } else {
       $message = "คุณยังไม่ได้เข้าใช้งานในระบบ";
-               }
-       }
+    }
+  }
 }
 ?>
 
@@ -95,34 +95,34 @@ if ($show_info) {
 $valid_text = !$valid ? "" : "" . 
 "  <table id='bg'>" .
 "  <tr>" .
-"        <td align='right'><b>Username:</b></td>" .
-"        <td>". $info['username']."</td>" .
-"      </tr>" .
+"   <td align='right'><b>Username:</b></td>" .
+"   <td>". $info['username']."</td>" .
+" </tr>" .
 "  <tr>" .
-"        <td align='right'><b>Session Start:</b></td>" .
-"              <td>". date('j F Y H:i', $info['session_start']) . "</td>" .
-"      </tr>" .
+"   <td align='right'><b>Session Start:</b></td>" .
+"   <td>". date('j F Y H:i', $info['session_start']) . "</td>" .
+" </tr>" .
 "  <tr>" .
-"        <td align='right'><b>Session Time:</b></td>" .
-"              <td>" . (time() - $info['session_start']) . " seconds</td>" .
-"      </tr>" .
+"   <td align='right'><b>Session Time:</b></td>" .
+"   <td>" . (time() - $info['session_start']) . " seconds</td>" .
+" </tr>" .
 "" .
 "  <tr>" .
-"        <td align='right'><b>User expired:</b></td>" .
-"              <td>". ($info['session_timeout'] == 0 ? "Never" : date('j F Y H:i', $info['session_timeout'])) . "</td>" .
-"      </tr>" .
+"   <td align='right'><b>User expired:</b></td>" .
+"   <td>". ($info['session_timeout'] == 0 ? "Never" : date('j F Y H:i', $info['session_timeout'])) . "</td>" .
+" </tr>" .
 "" .
 "  <tr>" .
-"        <td align='right'><b>Request URL:</b></td>" .
-"              <td><a href='$request_url' target='_new'>$request_url_text</a></td>" .
-"      </tr>" .
+"   <td align='right'><b>Request URL:</b></td>" .
+"   <td><a href='$request_url' target='_new'>$request_url_text</a></td>" .
+" </tr>" .
 "</table>".
 "<table>".
 " <tr>" .
-"        <td>&nbsp;<input type='hidden' name='do_logout' value='yes'></td>" .
-"        <td><input type='button' value='Go! Go! Go!' id='rh_goto_button' onClick='window.open(\"".$request_url."\");'></td>" .
-"        <td><input type='submit' value='Logout' id='rh_logout_button'></td>" .
-"      </tr>" .
+"   <td>&nbsp;<input type='hidden' name='do_logout' value='yes'></td>" .
+"   <td><input type='button' value='Go! Go! Go!' id='rh_goto_button' onClick='window.open(\"".$request_url."\");'></td>" .
+"   <td><input type='submit' value='Logout' id='rh_logout_button'></td>" .
+" </tr>" .
 "</table>";
 $request_uri = $_SERVER['REQUEST_URI'];
 $loginbox = "<style>" .
@@ -167,7 +167,7 @@ $loginscript = "<script>" .
                "if (ns4)" .
                "  msg=document.message;\n" .
                "else if (ns6)" .
-                    "  msg=document.getElementById('message').style;\n" .
+               "  msg=document.getElementById('message').style;\n" .
                "else if (ie4)" .
                "  msg=document.all.message.style;\n\n" .
                "var wt=(document.all);\n" .  
index 87aa49e..d71ade8 100644 (file)
@@ -5,33 +5,33 @@ require_once 'rahu_dictionary.php';
 
 class rahu_radius_auth {
   var $type;
-       var $username;
-       var $password;
-       var $host;
-       var $port;
-       var $secret;
-       var $result;
-       var $error;
-       var $attributes;
-       var $rawAttributes;
-       var $rawVendorAttributes;
+  var $username;
+  var $password;
+  var $host;
+  var $port;
+  var $secret;
+  var $result;
+  var $error;
+  var $attributes;
+  var $rawAttributes;
+  var $rawVendorAttributes;
   var $LoggedIn;
   var $Timeout;
 
   function rahu_radius_auth($username, $password, $type = 'CHAP_MD5') {
-         $this->type = $type;
+    $this->type = $type;
     $this->username = $username;
     $this->password = $password;
-               $this->error = 0;
+    $this->error = 0;
     $this->LoggedIn = false;
-       }
+  }
 
-       function start() {
+  function start() {
     global $vendors;
 
-         $type =& $this->type;
-               $username =& $this->username;
-               $password =& $this->password;
+    $type =& $this->type;
+    $username =& $this->username;
+    $password =& $this->password;
 
     $classname = 'Auth_RADIUS_' . $type;
     $rauth = new $classname ($username, $password);
@@ -43,48 +43,48 @@ class rahu_radius_auth {
     
     switch ($type) {
       case 'CHAP_MD5':
-       case 'MSCHAPv1':
-         $classname = $type == 'MSCHAPv1' ? 'Crypt_CHAP_MSv1' : 'Crypt_CHAP_MD5';
-               $crpt = new $classname;
-               $crpt->password = $password;
-               $rauth->challenge = $crpt->challenge;
-               $rauth->chapid = $crpt->chapid;
-               $rauth->response = $crpt->challengeResponse ();
-               $rauth->flags = 1;
-               break;
+      case 'MSCHAPv1':
+        $classname = $type == 'MSCHAPv1' ? 'Crypt_CHAP_MSv1' : 'Crypt_CHAP_MD5';
+        $crpt = new $classname;
+        $crpt->password = $password;
+        $rauth->challenge = $crpt->challenge;
+        $rauth->chapid = $crpt->chapid;
+        $rauth->response = $crpt->challengeResponse ();
+        $rauth->flags = 1;
+        break;
     
-       case 'MSCHAPv2':
-         $crpt = new Crypt_CHAP_MSv2;
-               $crpt->username = $username;
-               $crpt->password = $password;
-               $rauth->challenge = $crpt->authChallenge;
-               $rauth->peerChallenge = $crpt->peerChallenge;
-               $rauth->chapid = $crpt->chapid;
-               $rauth->response = $crpt->challengeResponse;
-               break;
+      case 'MSCHAPv2':
+        $crpt = new Crypt_CHAP_MSv2;
+        $crpt->username = $username;
+        $crpt->password = $password;
+        $rauth->challenge = $crpt->authChallenge;
+        $rauth->peerChallenge = $crpt->peerChallenge;
+        $rauth->chapid = $crpt->chapid;
+        $rauth->response = $crpt->challengeResponse;
+        break;
     
       default:
-         $rauth->password = $password;
-               break;
+        $rauth->password = $password;
+        break;
     }
     
     
     if (!$rauth->start ()) {
-                 $this->error = 1;
-                       return -1;
+      $this->error = 1;
+      return -1;
     }
     
     $this->result = $rauth->send ();
     if (PEAR::isError ($this->result)) {
-                 $this->error = 1;
-                       return -1;
+      $this->error = 1;
+      return -1;
     }    
 
     // get attributes, even if auth failed
     if ($rauth->getAttributes ()) {
-                 $this->attributes = $rauth->attributes;
-                       $this->rawAttributes = $rauth->rawAttributes;
-                       $this->rawVendorAttributes = $rauth->rawVendorAttributes;
+      $this->attributes = $rauth->attributes;
+      $this->rawAttributes = $rauth->rawAttributes;
+      $this->rawVendorAttributes = $rauth->rawVendorAttributes;
 
       // Extract the vendor attributes
       foreach ($this->rawVendorAttributes as $ven_id=>$data) {
@@ -105,18 +105,18 @@ class rahu_radius_auth {
     }
     
     $rauth->close ();
-       }
+  }
 
-       function isError() {
+  function isError() {
     return $this->error == 1;
-       }
+  }
 
-       function isAccept() {
-         if ($this->error)
-                 return false;
+  function isAccept() {
+    if ($this->error)
+      return false;
 
     return $this->result === true;
-       }
+  }
 
   function isLoggedIn() {
     return $this->LoggedIn;
@@ -129,98 +129,98 @@ class rahu_radius_auth {
 
 class rahu_radius_acct {
   var $username;
-       var $host;
-       var $port;
-       var $secret;
+  var $host;
+  var $port;
+  var $secret;
   var $framed_ip_address;
   var $calling_station_id;
   var $terminate_cause;
-       var $nas_identifier;
-       var $nas_ip_address;
-       var $nas_port;
-       var $session_id;
-       var $session_start;
-       var $result;
-       var $error;
-
-       function rahu_radius_acct ($username) {
+  var $nas_identifier;
+  var $nas_ip_address;
+  var $nas_port;
+  var $session_id;
+  var $session_start;
+  var $result;
+  var $error;
+
+  function rahu_radius_acct ($username) {
     $this->username = $username;
-               $this->error = 0;
-       }
-
-       function gen_session_id() {
-       $randno1 = rand(0,65535);
-       $randno2 = rand(0,65535);
-       $randno3 = rand(0,65535);
-       $randno4 = rand(0,65535);
+    $this->error = 0;
+  }
+
+  function gen_session_id() {
+    $randno1 = rand(0,65535);
+    $randno2 = rand(0,65535);
+    $randno3 = rand(0,65535);
+    $randno4 = rand(0,65535);
     $randno = sprintf("%s%s%s%s", dechex($randno1), dechex($randno2),
-                                                                                                                                       dechex($randno3), dechex($randno4));
-       $this->session_id = $randno;
-                                                                  
-               return $this->session_id;
-       }
+                                    dechex($randno3), dechex($randno4));
+    $this->session_id = $randno;
+                                                     
+    return $this->session_id;
+  }
 
-       function get_session_time() {
+  function get_session_time() {
     return time() - $this->session_start;
-       }
+  }
 
-       function acct($accttype, $param=NULL) {
-         $classname = "Auth_RADIUS_Acct_" .$accttype;
+  function acct($accttype, $param=NULL) {
+    $classname = "Auth_RADIUS_Acct_" .$accttype;
     $racct = new $classname;
     $racct->addServer($this->host, $this->port, $this->secret);
     $racct->username = $this->username;
     $racct->authentic = RADIUS_AUTH_LOCAL;
     $racct->session_id = empty($this->session_id) ? $this->gen_session_id() :
-                                                               $this->session_id;
-               $racct->session_time = $this->get_session_time();
+                                                    $this->session_id;
+    $racct->session_time = $this->get_session_time();
     $racct->useStandardAttributes = 0;
   
     $status = $racct->start();
     if(PEAR::isError($status)) {
-                 $this->error = 1;
-                       return -1;
+      $this->error = 1;
+      return -1;
     }
 
-               $racct->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET);
-               $racct->putAttribute(RADIUS_USER_NAME, $this->username);
-               $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, 
+    $racct->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET);
+    $racct->putAttribute(RADIUS_USER_NAME, $this->username);
+    $racct->putAttribute(RADIUS_FRAMED_IP_ADDRESS, 
                              ip2long($this->framed_ip_address));
     $racct->putAttribute(RADIUS_CALLING_STATION_ID, $this->calling_station_id);
-               $racct->putAttribute(RADIUS_NAS_IDENTIFIER, $this->nas_identifier);
-               $racct->putAttribute(RADIUS_NAS_IP_ADDRESS, ip2long($this->nas_ip_address));
-               $racct->putAttribute(RADIUS_NAS_PORT, $this->nas_port);
+    $racct->putAttribute(RADIUS_NAS_IDENTIFIER, $this->nas_identifier);
+    $racct->putAttribute(RADIUS_NAS_IP_ADDRESS, ip2long($this->nas_ip_address));
+    $racct->putAttribute(RADIUS_NAS_PORT, $this->nas_port);
 
-               switch($accttype) {
+    switch($accttype) {
       case "Start":
-                         break;
-                 case "Stop":
-                         $racct->putAttribute(RADIUS_ACCT_TERMINATE_CAUSE, 
-                                                    $this->terminate_cause);
-                         break;
-                 case "Update":
-               }
+        break;
+      case "Stop":
+        $racct->putAttribute(RADIUS_ACCT_TERMINATE_CAUSE, 
+                             $this->terminate_cause);
+        break;
+      case "Update":
+    }
     
     $this->result = $racct->send();
     if(PEAR::isError($this->result)) {
-                 $this->error = 1;
-                       return -1;
+      $this->error = 1;
+      return -1;
     }
-       
+    
     $racct->close();
-               return $this->result;
-       }
+    return $this->result;
+  }
 
-       function acctStart() {
+  function acctStart() {
     return $this->acct("Start"); 
-       }
+  }
 
-       function acctUpdate() {
+  function acctUpdate() {
     return $this->acct("Update");
-       }
+  }
 
-       function acctStop() {
-         return $this->acct("Stop");
-       }
+  function acctStop() {
+    return $this->acct("Stop");
+  }
 }
 
 ?>
index 6572e22..6d57ad3 100644 (file)
@@ -4,66 +4,66 @@ require_once 'XML/RPC2/Value.php';
 
 class rahu_xmlrpc_client {
   var $host;
-       var $port;
-       var $options;
+  var $port;
+  var $options;
 
-       function rahu_xmlrpc_client() {
+  function rahu_xmlrpc_client() {
     $this->options = array('prefix' => '',
                            'debug' => false,
                            'encoding' => 'utf-8');
-       }
-       
-       function getClient() {
+  }
+  
+  function getClient() {
     return XML_RPC2_Client::create("http://$this->host:$this->port", 
                                    $this->options); 
 
-       }
+  }
 
-       function do_startsession($data) {
+  function do_startsession($data) {
     $client = $this->getClient(); 
-               $params = implode("|", $data);
+    $params = implode("|", $data);
     $params .= "|";
     $result = $client->startsession($params);
-               return $result;
-       }
+    return $result;
+  }
 
-       function do_stopsession($ip, $mac) {
+  function do_stopsession($ip, $mac) {
     $client = $this->getClient(); 
-               $params = sprintf("%s|%s", $ip, $mac);
+    $params = sprintf("%s|%s", $ip, $mac);
     $result = $client->stopsession($params);
-               if (strstr($result, "was removed"))
-                 return true;
-               else
-                 return false;
-       }
+    if (strstr($result, "was removed"))
+      return true;
+    else
+      return false;
+  }
 
-       function do_getsessioninfo($ip) {
+  function do_getsessioninfo($ip) {
     $client = $this->getClient(); 
-               $params = sprintf("%s", $ip);
+    $params = sprintf("%s", $ip);
     $result = $client->getsessioninfo($ip);
-               $ret = explode("|", $result);
+    $ret = explode("|", $result);
 
-               /* $ret[0] - ip
-                  $ret[1] - username
-                        $ret[2] - session_id
-                        $ret[3] - session_start
+    /* $ret[0] - ip
+       $ret[1] - username
+       $ret[2] - session_id
+       $ret[3] - session_start
        $ret[4] - mac_address
        $ret[5] - session_timeout */
-               $ip = $ret[0];
-               $username = $ret[1];
-               $session_id = $ret[2];
-               $session_start = $ret[3];
-               $mac_address = $ret[4];
+    $ip = $ret[0];
+    $username = $ret[1];
+    $session_id = $ret[2];
+    $session_start = $ret[3];
+    $mac_address = $ret[4];
     $session_timeout = $ret[5];
 
-         $result = array("ip"=>$ip, 
-                               "username"=>$username, 
-                                                                               "session_id"=>$session_id,
-                                                                               "session_start"=>$session_start,
+    $result = array("ip"=>$ip, 
+                    "username"=>$username, 
+                    "session_id"=>$session_id,
+                    "session_start"=>$session_start,
                     "mac_address"=>$mac_address,
                     "session_timeout"=>$session_timeout);
-               return $result;
-       }
+    return $result;
+  }
 }
 
 ?>
index 0745906..7ce7717 100644 (file)
@@ -11,7 +11,7 @@ function do_stopacct($method_name, $params, $app_data)
   $ip =& $GLOBALS["ip"];
   $username =& $GLOBALS["username"];
   $session_id =& $GLOBALS["session_id"];
-       $session_start =& $GLOBALS["session_start"];
+  $session_start =& $GLOBALS["session_start"];
   $mac_address =& $GLOBALS["mac_address"];
   $cause =& $GLOBALS["cause"];
 
@@ -23,22 +23,22 @@ function do_stopacct($method_name, $params, $app_data)
   // parsing[5] - cause  
  
   //return $params[0];
-       $parsing = explode("|", $params[0]);
+  $parsing = explode("|", $params[0]);
   $ip = $parsing[0];
-       $username   = $parsing[1];
-       $session_id = $parsing[2];
-       $session_start = intval($parsing[3]);
-       $mac_address = $parsing[4];
+  $username   = $parsing[1];
+  $session_id = $parsing[2];
+  $session_start = intval($parsing[3]);
+  $mac_address = $parsing[4];
   $cause = intval($parsing[5]);
 
-       if (!empty($username) && !empty($session_id)) {
-         $GLOBALS["task"] = "do_stopacct";
+  if (!empty($username) && !empty($session_id)) {
+    $GLOBALS["task"] = "do_stopacct";
   } else {
-         $GLOBALS["task"] = "";
-       }
+    $GLOBALS["task"] = "";
+  }
 
 //  return "Recieve: IP=$ip, Username=$username, Session-ID=$session_id, Session-Start=$session_start, MAC=$mac_address";
-       return "[RESULT]";
+  return "[RESULT]";
 }
 
 $xmlrpc_server = xmlrpc_server_create();
@@ -53,7 +53,7 @@ if ($GLOBALS["task"] == "do_stopacct") {
   $ip =& $GLOBALS["ip"];
   $username =& $GLOBALS["username"];
   $session_id =& $GLOBALS["session_id"];
-       $session_start =& $GLOBALS["session_start"];
+  $session_start =& $GLOBALS["session_start"];
   $mac_address =& $GLOBALS["mac_address"];
   $cause =& $GLOBALS["cause"];
 
@@ -71,9 +71,9 @@ if ($GLOBALS["task"] == "do_stopacct") {
   $racct->session_start = $session_start;
   if ($racct->acctStop() === true) {
     $response = str_replace ("[RESULT]", "OK", $response);
-       } else {
+  } else {
     $response = str_replace ("[RESULT]", "FAIL", $response);
-       }
+  }
 }
 
 print $response;