. * * Version 0.1 * Author: Daniel Larraz */ include_once $API_core.'conf_file.php'; include_once $base_plugin.'php/paths.php'; include_once $base_plugin.'php/display_certs.php'; include_once $base_plugin.'php/display_users.php'; include_once $base_plugin.'php/display_servers.php'; include_once $base_plugin.'php/display_clients.php'; include_once $base_plugin.'php/certs.php'; function make_radius () /* ------------------------------------------------------------------------ */ { global $paths; global $section; global $plugin; global $url_plugin; $list ='
FreeRADIUS Manager
'; $list .= make_certificates_panel (); $list .= '
'; $list .= make_radius_config_panel (); $list .='
'; return $list; } /* ------------------------------------------------------------------------ */ function get_auth_servers() /* ------------------------------------------------------------------------ */ { global $paths; $auth_servers = load_conf_file ($paths['auth_servers']); if ( empty($auth_servers) ) { $auth_servers = array ( 'vs0' => array ('port' => '18120', 'wpa_eap' => array('tls','ttls','peap')), 'vs1' => array ('port' => '18121', 'wpa_eap' => array('tls','ttls','peap')) ); save_conf_file ($paths['auth_servers'], $auth_servers); } return $auth_servers; } /* ------------------------------------------------------------------------ */ function get_acct_servers() /* ------------------------------------------------------------------------ */ { global $paths; $acct_servers = load_conf_file ($paths['acct_servers']); if ( empty($acct_servers) ) { $acct_servers = array ( 'default' => array ('port' => '18130', 'pass' => '123456') ); save_conf_file ($paths['acct_servers'], $acct_servers); } return $acct_servers; } /* ------------------------------------------------------------------------ */ function make_radius_config_panel () /* ------------------------------------------------------------------------ */ { global $paths; if ( !file_exists($paths['radius_conf_dir']) ) { exec ("sudo mkdir -p ".$paths['radius_conf_dir']); } $auth_servers = get_auth_servers(); $list = make_auth_servers_panel ($auth_servers); $acct_servers = get_acct_servers(); $list .= make_acct_servers_panel ($acct_servers); $list .= make_clients_panel ($auth_servers); $list .= make_users_panel (); $list .= '
'; return $list; } /* ------------------------------------------------------------------------ */ function exists_cert ($filepath) /* ------------------------------------------------------------------------ */ { exec ("sudo ls ".$filepath, $return); return ( $return[0] == $filepath ); } /* ------------------------------------------------------------------------ */ function make_certificates_panel () /* ------------------------------------------------------------------------ */ { global $paths; $list ='
FreeRADIUS certificates
CA certificate
Server certificate
Server key
The private key has a password.
You have to input it so that Apache can use it.
Password:
Confirm password:
$avs_data) { $list .= ''; $list .= make_auth_server_info_row($avs_name, $avs_data, $url_plugin); $list .= '
'; } $list .= '
'; $list .= make_auth_server_form_panel (); $list .= '
'; return $list; } /* ------------------------------------------------------------------------ */ function make_auth_server_form_panel () /* ------------------------------------------------------------------------ */ { $list = '
New virtual auth server
Name:
Port:
TLS TTLS PEAP
'; return $list; } /* ------------------------------------------------------------------------ */ function make_acct_servers_panel ($acct_servers) /* ------------------------------------------------------------------------ */ { global $paths; $list = '
Virtual Acct Server
Name Port
'; foreach ($acct_servers as $acvs_name => $acvs_data) { $list .= ''; $list .= make_acct_server_info_row($acvs_name, $acvs_data); $list .= '
'; } $list .= '
'; $list .= '
'; return $list; } /* ------------------------------------------------------------------------ */ function make_clients_panel ($auth_servers) /* ------------------------------------------------------------------------ */ { global $paths; $list = '
Clients
'; $list .= '
Name Address/es Virtual Auth Servers
'; $clients = load_conf_file ($paths['clients']); if ( empty($clients) ) { $clients = array ( 'localhost' => array ('addr' => '127.0.0.1', 'pass' => '123456', 'auth_servers' => array('vs0', 'vs1')) ); save_conf_file ($paths['clients'], $clients); } $list .= ''."\n"; foreach ($clients as $client_name => $client_data) { $list .= ''; $list .= make_client_info_row($client_name, $client_data); $list .= '
'; $list .= "'."\n"; } $list .= '
'; $list .= make_client_form_panel ($auth_servers); $list .= '
'; return $list; } /* ------------------------------------------------------------------------ */ function make_client_form_panel ($auth_servers) /* ------------------------------------------------------------------------ */ { $list = '
New client
Name:
Available virtual auth servers Selected virtual auth servers

Address/es:
Password:
Confirm password:
'; return $list; } /* ------------------------------------------------------------------------ */ function create_login_time_data($username, $info) /* ------------------------------------------------------------------------ */ { $list = ''; $dweek_str = array ( 'Al' => 'All', 'Wk' => 'Monday-Friday', 'Mo' => 'Monday', 'Tu' => 'Tuesday', 'We' => 'Wednesday', 'Th' => 'Thursday', 'Fr' => 'Friday', 'Sa' => 'Saturday', 'Su' => 'Sunday' ); $login_time = $info; $slot = strtok ($login_time, ","); while ($slot !== false) { $dweek = substr($slot, 0, 2); $hour_start = substr($slot, 2, 2); $min_start = substr($slot, 4, 2); $hour_end = substr($slot, 7, 2); $min_end = substr($slot, 9, 2); $logtime = ''.$dweek_str[$dweek].', '.$hour_start.':'. $min_start.'-'.$hour_end.':'.$min_end; $list .= "user_logtime['".$username."'].push('$logtime');\n"; $slot = strtok (","); } return $list; } /* ------------------------------------------------------------------------ */ function make_users_panel () /* ------------------------------------------------------------------------ */ { global $paths; $list = '
Users
'; $list .= '
Name Session timeout Login time On-Line
'; $users = load_conf_file ($paths['users']); exec ('sudo radwho -r', $radwho); $online = array(); foreach ($radwho as $line) { $online[] = strtok($line, ','); } $list .= ''."\n"; foreach ($users as $username => $user_data) { $list .= '
'; $list .= ''; $list .= make_user_info_row($username, $user_data, in_array($username, $online)); $list .= '
'; $list .= "'."\n"; } $list .= '
'; $list .= make_user_form_panel (); $list .= '
'; return $list; } /* ------------------------------------------------------------------------ */ function make_user_form_panel () /* ------------------------------------------------------------------------ */ { $list = '
New user
Username:
Password:
Confirm password:
Session timeout: seconds
Login time:
Add time slot
'; return $list; } /* ------------------------------------------------------------------------ */ ?>