79 lines
1.8 KiB
PHP
79 lines
1.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
include_once("./include/cfg-petar.php");
|
||
|
|
include_once("./include/layout.php");
|
||
|
|
include_once("./include/users.php");
|
||
|
|
include_once("./include/db.php");
|
||
|
|
include_once("./include/cfg-radius.php");
|
||
|
|
|
||
|
|
echo makemyheader();
|
||
|
|
echo maketop();
|
||
|
|
|
||
|
|
?>
|
||
|
|
|
||
|
|
<table align="center" width=95% border=0 cellspacing=10 cellpadding=0 bordercolor=black>
|
||
|
|
<tr align=left valign=top>
|
||
|
|
<td width=15%> <? echo $menu; ?>
|
||
|
|
<td width=85%>
|
||
|
|
|
||
|
|
<table width=85% border=1 align=center cellpadding=3>
|
||
|
|
<tr bgcolor=navy align=center>
|
||
|
|
<td colspan=1><font color=yellow><b>Sync DB >> Radius</b></td>
|
||
|
|
|
||
|
|
<?php
|
||
|
|
|
||
|
|
echo "<tr><td>";
|
||
|
|
|
||
|
|
$query = sqlite_query($dbhandle, "SELECT login, pwd, ip, netmask, opt1 FROM radiususer order by inet_aton(ip)");
|
||
|
|
$numrecords = sqlite_num_rows($query);
|
||
|
|
|
||
|
|
|
||
|
|
if (is_file($radius_user_file)){
|
||
|
|
|
||
|
|
echo "<strong>radius user file</strong><br>".
|
||
|
|
"Backup of old: $radius_user_file <br>";
|
||
|
|
copy($radius_user_file, $radius_user_file.".old");
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
$handle = fopen("$radius_user_file", "w");
|
||
|
|
|
||
|
|
while ($entry = sqlite_fetch_array($query, SQLITE_ASSOC)) {
|
||
|
|
|
||
|
|
$record = $entry['login']."\tUser-Password == \"".$entry['pwd']."\"\n".
|
||
|
|
"\tService-Type = Framed-User,\n".
|
||
|
|
"\tFramed-Protocol = PPP,\n".
|
||
|
|
"\tFramed-IP-Address = ".$entry['ip'].",\n".
|
||
|
|
"\tFramed-IP-Netmask = ".$entry['netmask'].",\n";
|
||
|
|
|
||
|
|
if ( $entry['opt1'] == "voip_user"){
|
||
|
|
$record .= "\tCisco-avpair = \"ip:sub-policy-Out=voip_user\",\n";
|
||
|
|
}
|
||
|
|
|
||
|
|
$record .= "\n";
|
||
|
|
|
||
|
|
fwrite($handle, $record);
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
fclose($handle);
|
||
|
|
|
||
|
|
echo "Records succesfully written: ".$numrecords;
|
||
|
|
|
||
|
|
|
||
|
|
echo "<p>".
|
||
|
|
"<strong>radius-sync backend</strong><br>";
|
||
|
|
|
||
|
|
passthru("/usr/local/bin/sudo ".$radius_sync_prg, $retval);
|
||
|
|
|
||
|
|
if ($retval != "0"){
|
||
|
|
echo "Execution exited with status code:".$retval;
|
||
|
|
} else {
|
||
|
|
echo "Execution finished succesfully: $retval";
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|
||
|
|
|
||
|
|
</table>
|
||
|
|
</td> </table>
|