Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!
Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.

Użytkownik


Ostatnio się trochę męczyłem aby połączyć frreradiusa z LMS'em i PPPoE.
Opis uruchomienia jest na http://www.netkod.pl/pppoe/ z tą różnicą, że jest to opis do ver. 1.6 LMS'a.
Ja pozmieniałem troche, żeby dane do bazy radiusa były zapisywane z LMS. Każde dodanie hosta, jego edycja powoduje odpowiednie wpisy w bazie radiusa. Dzieki temu możemy obserwowaś statystyki, itp., w dialup adminie.
glowne zmiany robimy w modulach LMS. do edycji bierzemy plik ../lms/lib/LMS.class.php.
dodajemy wpisy w sekcjiach:
function NodeUpdate($nodedata)
{
$this->SetTS('usergroup');
$this->DB->Execute('UPDATE usergroup SET GroupName=(?) WHERE UserName=?', array($nodedata['group'], $nodedata['name']));
$this->SetTS('radcheck');
$this->DB->Execute('UPDATE radcheck SET Value=(?) WHERE UserName=?', array($nodedata['passwd'], $nodedata['name']));
$this->SetTS('radreply');
$this->DB->Execute('UPDATE radreply SET name=LOWER(?), Value=(?) WHERE UserName=?', array($nodedata['ipaddr'], $nodedata['name']));
$this->SetTS('nodes');
return $this->DB->Execute('UPDATE nodes SET name=LOWER(?), ipaddr_pub=inet_aton(?), ipaddr=inet_aton(?), mac=UPPER(?),passwd=?, netdev=?, moddate=?NOW?, modid=?, access=?, warning=?, ownerid=?, info=? WHERE id=?', array($nodedata['name'], $nodedata['ipaddr_pub'], $nodedata['ipaddr'], $nodedata['mac'], $nodedata['passwd'], $nodedata['netdev'], $this->AUTH->id, $nodedata['access'], $nodedata['warning'], $nodedata['ownerid'], $nodedata['info'], $nodedata['id']));
}
function DeleteNode($id,$name)
{
if (isset($name)) {
$this->SetTS('radcheck');
$this->DB->Execute('DELETE from radcheck WHERE UserName=?', array($name));
$this->SetTS('usergroup');
$this->DB->Execute('DELETE from usergroup WHERE UserName=?', array($name));
$this->SetTS('radreply');
$this->DB->Execute('DELETE from radreply WHERE UserName=?', array($name));
}
$this->SetTS('nodes');
return $this->DB->Execute('DELETE FROM nodes WHERE id=?', array($id));
}
function NodeAdd($nodedata)
{
$this->SetTS('nodes');
if($this->DB->Execute('INSERT INTO nodes (name, mac, ipaddr, ipaddr_pub, ownerid, passwd, creatorid, creation date, access, warning, info, netdev) VALUES (?, ?, inet_aton(?),inet_aton(?), ?, ?, ?, ?NOW?, ?, ?, ?, ?)', array(strtolower($nodedata['name']), strtoupper($nodedata['mac']), $nodedata['ipaddr'], $nodedata['ipaddr_pub'], $nodedata['ownerid'],
$nodedata['passwd'],
$this->AUTH->id,
$nodedata['access'],
$nodedata['warning'],
$nodedata['info'],
$nodedata['netdev']))) {
$this->SetTS('radcheck');
$this->DB->Execute('INSERT INTO radcheck (Attribute, Value, UserName, op) VALUES ( ?, ?, ?, ?)', array('User-Password', $nodedata['passwd'], $nodedata['name'], '=='));
$this->SetTS('radreply');
$this->DB->Execute('INSERT INTO radreply (Attribute, Value, UserName, op) VALUES ( ?, ?, ?, ?)', array('Framed-IP-Address', $nodedata['ipaddr'], $nodedata['name'], '==') );
$this->DB->Execute('INSERT INTO radreply (Attribute, Value, UserName, op) VALUES ( ?, ?, ?, ?)', array('Framed-Protocol', 'PPP', $nodedata['name'], '==') );
$this->DB->Execute('INSERT INTO radreply (Attribute, Value, UserName, op) VALUES ( ?, ?, ?, ?)', array('Framed-IP-Netmask', '255.255.255.255', $nodedata['name'], '==') );
$this->DB->Execute('INSERT INTO radreply (Attribute, Value, UserName, op) VALUES ( ?, ?, ?, ?)', array('Framed-MTU', '1492', $nodedata['name'], '==') );
$this->DB->Execute('INSERT INTO radreply (Attribute, Value, UserName, op) VALUES ( ?, ?, ?, ?)', array('Port-Limit', '1', $nodedata['name'], '==') );
$this->SetTS('usergroup');
$this->DB->Execute('INSERT INTO usergroup (UserName, GroupName) VALUES ( ?, ?)', array ( $nodedata['name'], $nodedata['group'] ) );
return $this->DB->GetOne('SELECT MAX(id) FROM nodes');
} else
return FALSE;
}
tabele radiusa wrzycamy do bazy LMS'a.
edytujemy jeszcze ../lms/templates/nodeeditbox.html, zebyśmy nie mogli zmienić nazwy hosta. niestety z tym sobie nie poradzilem. jeśli zmieni się nazwe hosta z panelu edycji, nie zostanie dokonana zmiana w tabelach radiusa ze wzgledu na inne id w tabeli nodes, radreply i radcheck, wiec trzeba bylo porownywac po nazwie.
<!--// $Id: nodeeditbox.html,v 1.61 2005/10/19 13:34:48 lukas Exp $ //-->
<FORM NAME="editnode" METHOD="POST" ACTION="?m=nodeedit&id={$nodeinfo.id}">
<INPUT type="submit" class="hiddenbtn">
<INPUT TYPE="hidden" NAME="nodeedit[id]" VALUE="{$nodeinfo.id}">
<INPUT TYPE="hidden" NAME="nodeedit[name]" VALUE="{$nodeinfo.name}">
<TABLE WIDTH="100%" CELLPADDING="3">
<TR CLASS="DARK">
<TD WIDTH="1%" CLASS="FLEFTU">
<IMG SRC="img/node.gif" ALT="">
</TD>
<TD WIDTH="99%" CLASS="FRIGHTU" COLSPAN="2">
<B>{$nodeinfo.name} ({$nodeinfo.id|string_format:"%04d"})</B>
</TD>
</TR>
może ktoś zrobił to w inny sposób.
sposób mój można zastosować do każdej wersji LMS.
może komuś się to przyda
pzdr
Offline