Exemple #1
0
  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 
  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  POSSIBILITY OF SUCH DAMAGE.

  This code cannot simply be copied and put under the GNU Public License or 
    any other GPL-like (LGPL, GPL2) License.
*/
require_once 'config.php';
require_once 'header.php';
require_once 'networkchk.php';
$ip = $_SERVER['REMOTE_ADDR'];
$config = get_config_by_network($ip, $config_list);
$vserver_id = $config["VSERVER_ID"];
$forward_uri = $config['NAS_LOGIN_PROTO'] . "://" . $config['NAS_LOGIN_HOST'];
$forward_uri .= !empty($config['NAS_LOGIN_PORT']) ? ":" . $config['NAS_LOGIN_PORT'] : "";
$forward_uri .= "/login.php?sss=" . time();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>RahuNAS Authentication</title>
<style>
body {
  font-family: sans-serif;
Exemple #2
0
  This code cannot simply be copied and put under the GNU Public License or 
    any other GPL-like (LGPL, GPL2) License.
*/
include_once 'config.php';
require_once 'rahu_xmlrpc.class.php';
require_once 'networkchk.php';
define(CACHE_TIME, 120);
if (!defined(STDIN)) {
    define("STDIN", fopen("php://stdin", "r"));
}
$user_list = array();
while (!feof(STDIN)) {
    $arg = trim(fgets(STDIN));
    $srcip = rawurldecode($arg);
    $config = get_config_by_network(trim($srcip), $config_list);
    $vserver_id = $config["VSERVER_ID"];
    // Check cache
    if (!empty($user_list[$vserver_id][$srcip]['username']) && time() - $user_list[$vserver_id][$srcip]['timestamp'] < CACHE_TIME) {
        fwrite(STDOUT, "OK user="******"\n");
        continue;
    }
    $xmlrpc = new rahu_xmlrpc_client();
    $xmlrpc->host = $config["RAHUNAS_HOST"];
    $xmlrpc->port = $config["RAHUNAS_PORT"];
    try {
        $retinfo = $xmlrpc->do_getsessioninfo($vserver_id, $srcip);
        if (is_array($retinfo) && !empty($retinfo['session_id'])) {
            $user_list[$vserver_id][$srcip]['username'] = $retinfo['username'];
            $user_list[$vserver_id][$srcip]['timestamp'] = time();
            fwrite(STDOUT, "OK user="******"\n");