Auth_RADIUS
[ class tree: Auth_RADIUS ] [ index: Auth_RADIUS ] [ all elements ]

Source for file radius-acct.php

Documentation is available at radius-acct.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. /*
  4. Copyright (c) 2003, Michael Bretterklieber <michael@bretterklieber.com>
  5. All rights reserved.
  6.  
  7. Redistribution and use in source and binary forms, with or without 
  8. modification, are permitted provided that the following conditions 
  9. are met:
  10.  
  11. 1. Redistributions of source code must retain the above copyright 
  12.    notice, this list of conditions and the following disclaimer.
  13. 2. Redistributions in binary form must reproduce the above copyright 
  14.    notice, this list of conditions and the following disclaimer in the
  15.    documentation and/or other materials provided with the distribution.
  16. 3. The names of the authors may not be used to endorse or promote products 
  17.    derived from this software without specific prior written permission.
  18.  
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
  20. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
  21. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  22. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
  23. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
  24. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
  25. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
  26. OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
  27. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
  28. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29.  
  30. This code cannot simply be copied and put under the GNU Public License or 
  31. any other GPL-like (LGPL, GPL2) License.
  32.  
  33.     $Id$
  34. */
  35.  
  36. if ($argv[1== 'pearcvs'{
  37.     ini_set('include_path''..:../..:' ini_get('include_path'));
  38.     require_once 'RADIUS.php';
  39.     require_once 'Crypt_CHAP/CHAP.php';
  40. else {
  41.     require_once 'Auth/RADIUS.php';
  42.     require_once 'Crypt/CHAP.php';
  43. }
  44. $username 'sepp';
  45.  
  46. $starttime time();
  47.  
  48. $racct = new Auth_RADIUS_Acct_Start;
  49. $racct->addServer('127.0.0.1'0'testing123');
  50. $racct->username = $username;
  51. // RADIUS_AUTH_RADIUS => authenticated via Radius
  52. // RADIUS_AUTH_LOCAL => authenicated local
  53. // RADIUS_AUTH_REMOTE => authenticated remote
  54. $racct->authentic = RADIUS_AUTH_LOCAL;
  55. $status $racct->start();
  56. if(PEAR::isError($status)) {
  57.     printf("Radius start: %s<br>\n"$status->getMessage());
  58.     exit;
  59. }
  60. // you can put any additional attributes here
  61. // $racct->putAttribute(RADIUS_ACCT_INPUT_PACKETS, 45236);
  62. $racct->putAttribute(RADIUS_ACCT_OUTPUT_PACKETSpow(2,32)-1);
  63. $result $racct->send();
  64. if (PEAR::isError($result)) {
  65.     printf("Radius send failed: %s<br>\n"$result->getMessage());
  66.     exit;
  67. else if ($result === true{
  68.     printf("Radius Acounting succeeded<br>\n");
  69. else {
  70.     printf("Radius Acounting rejected<br>\n");
  71. }
  72.  
  73. $racct->close();
  74.  
  75. // Wait a bit, that we can put the session-time
  76. sleep(2);
  77.  
  78. // send an accounting update
  79. $racct = new Auth_RADIUS_Acct_Update;
  80. $racct->addServer('localhost'0'testing123');
  81. $racct->username = $username;
  82. $racct->session_time = time($starttime;
  83. $status $racct->start();
  84. if(PEAR::isError($status)) {
  85.     printf("Radius start: %s<br>\n"$status->getMessage());
  86.     exit;
  87. }
  88. $result $racct->send();
  89. if (PEAR::isError($result)) {
  90.     printf("Radius send failed: %s<br>\n"$result->getMessage());
  91.     exit;
  92. else if ($result === true{
  93.     printf("Radius Acounting succeeded<br>\n");
  94. else {
  95.     printf("Radius Acounting rejected<br>\n");
  96. }
  97.  
  98. // Wait a bit, that we can put the session-time
  99. sleep(2);
  100.  
  101. // send the stop
  102. $racct = new Auth_RADIUS_Acct_Stop;
  103. $racct->addServer('localhost'0'testing123');
  104. $racct->username = $username;
  105. $racct->session_time = time($starttime;
  106. $status $racct->start();
  107. if(PEAR::isError($status)) {
  108.     printf("Radius start: %s<br>\n"$status->getMessage());
  109.     exit;
  110. }
  111. // you can put any additional attributes here
  112. // $racct->putAttribute(RADIUS_ACCT_TERMINATE_CAUSE, RADIUS_TERM_SESSION_TIMEOUT);
  113. $result $racct->send();
  114. if (PEAR::isError($result)) {
  115.     printf("Radius send failed: %s<br>\n"$result->getMessage());
  116.     exit;
  117. else if ($result === true{
  118.     printf("Radius Acounting succeeded<br>\n");
  119. else {
  120.     printf("Radius Acounting rejected<br>\n");
  121. }
  122.  
  123. $racct->close();
  124.  
  125. ?>

Documentation generated on Mon, 11 Mar 2019 16:01:19 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.