From cvs w lms.org.pl Sun May 2 14:28:12 2010 From: cvs w lms.org.pl (LMS CVS) Date: Sun, 2 May 2010 14:28:12 +0200 (CEST) Subject: [lms-commits] CVS update of lms/sample (radius-sql.conf) Message-ID: <20100502122812.D74FE3027B29@hydra.altec.pl> Date: Sunday, May 2, 2010 @ 14:28:12 Author: alec Path: /cvsroot/lms/sample Modified: radius-sql.conf - formatting Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/sample/radius-sql.conf.diff?&r1=1.1&r2=1.2 Index: lms/sample/radius-sql.conf diff -u lms/sample/radius-sql.conf:1.1 lms/sample/radius-sql.conf:1.2 --- lms/sample/radius-sql.conf:1.1 Sun Apr 5 11:21:43 2009 +++ lms/sample/radius-sql.conf Sun May 2 14:28:12 2010 @@ -9,7 +9,7 @@ # If you are using Oracle, please use 'oracle.conf', instead. # If you are using MS-SQL, please use 'mssql.conf', instead. # -# $Id: radius-sql.conf,v 1.1 2009/04/05 09:21:43 alec Exp $ +# $Id: radius-sql.conf,v 1.2 2010/05/02 12:28:12 alec Exp $ # sql { @@ -29,24 +29,81 @@ #safe-characters = "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /" sql_user_name = "%{User-Name}" - accounting_onoff_query = "UPDATE ${acct_table1} SET AcctStopTime='%S', AcctSessionTime=unix_timestamp('%S') - unix_timestamp(AcctStartTime), AcctTerminateCause='%{Acct-Terminate-Cause}', AcctStopDelay = '%{Acct-Delay-Time}' WHERE AcctSessionTime=0 AND AcctStopTime=0 AND NASIPAddress= '%{NAS-IP-Address}' AND AcctStartTime <= '%S'" + accounting_onoff_query = "UPDATE ${acct_table1} \ + SET AcctStopTime='%S', \ + AcctSessionTime=unix_timestamp('%S') - unix_timestamp(AcctStartTime), \ + AcctTerminateCause='%{Acct-Terminate-Cause}', \ + AcctStopDelay = '%{Acct-Delay-Time}' \ + WHERE AcctSessionTime=0 \ + AND AcctStopTime=0 \ + AND NASIPAddress= '%{NAS-IP-Address}' AND AcctStartTime <= '%S'" + accounting_update_query = "UPDATE ${acct_table1} \ - SET FramedIPAddress = '%{Framed-IP-Address}', \ - AcctSessionTime = '%{Acct-Session-Time}', \ - AcctInputOctets = '%{Acct-Input-Octets}', \ - AcctOutputOctets = '%{Acct-Output-Octets}' \ - WHERE AcctSessionId = '%{Acct-Session-Id}' \ - AND UserName = '%{SQL-User-Name}' \ - AND NASIPAddress= '%{NAS-IP-Address}'" - accounting_update_query_alt = "INSERT into ${acct_table1} (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPortId, NASPortType, AcctStartTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay) values('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', DATE_SUB('%S',INTERVAL (%{Acct-Session-Time:-0} + %{Acct-Delay-Time:-0}) SECOND), '%{Acct-Session-Time}', '%{Acct-Authentic}', '', '%{Acct-Input-Octets}', '%{Acct-Output-Octets}', '%{Called-Station-Id}', '%{Calling-Station-Id}', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '0')" - accounting_start_query = "INSERT into ${acct_table1} (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPortId, NASPortType, AcctStartTime, AcctStopTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, ConnectInfo_stop, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, AcctTerminateCause, ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay, AcctStopDelay) values('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', '%S', '0', '0', '%{Acct-Authentic}', '%{Connect-Info}', '', '0', '0', '%{Called-Station-Id}', '%{Calling-Station-Id}', '', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '%{Acct-Delay-Time}', '0')" - accounting_start_query_alt = "UPDATE ${acct_table1} SET AcctStartTime = '%S', AcctStartDelay = '%{Acct-Delay-Time}', ConnectInfo_start = '%{Connect-Info}' WHERE AcctSessionId = '%{Acct-Session-Id}' AND UserName = '%{SQL-User-Name}' AND NASIPAddress = '%{NAS-IP-Address}'" - accounting_stop_query = "UPDATE ${acct_table2} SET AcctStopTime = '%S', AcctSessionTime = '%{Acct-Session-Time}', AcctInputOctets = '%{Acct-Input-Octets}', AcctOutputOctets = '%{Acct-Output-Octets}', AcctTerminateCause = '%{Acct-Terminate-Cause}', AcctStopDelay = '%{Acct-Delay-Time}', ConnectInfo_stop = '%{Connect-Info}' WHERE AcctSessionId = '%{Acct-Session-Id}' AND UserName = '%{SQL-User-Name}' AND NASIPAddress = '%{NAS-IP-Address}'" - accounting_stop_query_alt = "INSERT into ${acct_table2} (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPortId, NASPortType, AcctStartTime, AcctStopTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, ConnectInfo_stop, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, AcctTerminateCause, ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay, AcctStopDelay) values('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', DATE_SUB('%S', INTERVAL (%{Acct-Session-Time:-0} + %{Acct-Delay-Time:-0}) SECOND), '%S', '%{Acct-Session-Time}', '%{Acct-Authentic}', '', '%{Connect-Info}', '%{Acct-Input-Octets}', '%{Acct-Output-Octets}', '%{Called-Station-Id}', '%{Calling-Station-Id}', '%{Acct-Terminate-Cause}', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '0', '%{Acct-Delay-Time}')" + SET FramedIPAddress = '%{Framed-IP-Address}', \ + AcctSessionTime = '%{Acct-Session-Time}', \ + AcctInputOctets = '%{Acct-Input-Octets}', \ + AcctOutputOctets = '%{Acct-Output-Octets}' \ + WHERE AcctSessionId = '%{Acct-Session-Id}' \ + AND UserName = '%{SQL-User-Name}' \ + AND NASIPAddress= '%{NAS-IP-Address}'" + + accounting_update_query_alt = "INSERT into ${acct_table1} \ + (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPortId, \ + NASPortType, AcctStartTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, \ + AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, \ + ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay) \ + VALUES ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', \ + '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', \ + DATE_SUB('%S',INTERVAL (%{Acct-Session-Time:-0} + %{Acct-Delay-Time:-0}) SECOND), \ + '%{Acct-Session-Time}', '%{Acct-Authentic}', '', '%{Acct-Input-Octets}', \ + '%{Acct-Output-Octets}', '%{Called-Station-Id}', '%{Calling-Station-Id}', \ + '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '0')" + + accounting_start_query = "INSERT into ${acct_table1} \ + (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPortId, \ + NASPortType, AcctStartTime, AcctStopTime, AcctSessionTime, AcctAuthentic, \ + ConnectInfo_start, ConnectInfo_stop, AcctInputOctets, AcctOutputOctets, \ + CalledStationId, CallingStationId, AcctTerminateCause, ServiceType, \ + FramedProtocol, FramedIPAddress, AcctStartDelay, AcctStopDelay) \ + VALUES ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', \ + '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', \ + '%S', '0', '0', '%{Acct-Authentic}', '%{Connect-Info}', '', '0', '0', \ + '%{Called-Station-Id}', '%{Calling-Station-Id}', '', '%{Service-Type}', \ + '%{Framed-Protocol}', '%{Framed-IP-Address}', '%{Acct-Delay-Time}', '0')" + + accounting_start_query_alt = "UPDATE ${acct_table1} \ + SET AcctStartTime = '%S', AcctStartDelay = '%{Acct-Delay-Time}', \ + ConnectInfo_start = '%{Connect-Info}' \ + WHERE AcctSessionId = '%{Acct-Session-Id}' AND UserName = '%{SQL-User-Name}' \ + AND NASIPAddress = '%{NAS-IP-Address}'" + + accounting_stop_query = "UPDATE ${acct_table2} \ + SET AcctStopTime = '%S', AcctSessionTime = '%{Acct-Session-Time}', \ + AcctInputOctets = '%{Acct-Input-Octets}', AcctOutputOctets = '%{Acct-Output-Octets}', \ + AcctTerminateCause = '%{Acct-Terminate-Cause}', AcctStopDelay = '%{Acct-Delay-Time}', \ + ConnectInfo_stop = '%{Connect-Info}' \ + WHERE AcctSessionId = '%{Acct-Session-Id}' AND UserName = '%{SQL-User-Name}' \ + AND NASIPAddress = '%{NAS-IP-Address}'" + + accounting_stop_query_alt = "INSERT into ${acct_table2} \ + (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, \ + NASPortId, NASPortType, AcctStartTime, AcctStopTime, AcctSessionTime, \ + AcctAuthentic, ConnectInfo_start, ConnectInfo_stop, AcctInputOctets, \ + AcctOutputOctets, CalledStationId, CallingStationId, AcctTerminateCause, \ + ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay, AcctStopDelay) \ + VALUES ('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', \ + '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', \ + DATE_SUB('%S', INTERVAL (%{Acct-Session-Time:-0} + %{Acct-Delay-Time:-0}) SECOND), \ + '%S', '%{Acct-Session-Time}', '%{Acct-Authentic}', '', '%{Connect-Info}', \ + '%{Acct-Input-Octets}', '%{Acct-Output-Octets}', '%{Called-Station-Id}', \ + '%{Calling-Station-Id}', '%{Acct-Terminate-Cause}', '%{Service-Type}', \ + '%{Framed-Protocol}', '%{Framed-IP-Address}', '0', '%{Acct-Delay-Time}')" # Uncomment simul_count_query to enable simultaneous use checking # simul_count_query = "SELECT COUNT(*) FROM ${acct_table1} WHERE UserName='%{SQL-User-Name}' AND AcctStopTime = 0" - simul_verify_query = "SELECT RadAcctId, AcctSessionId, UserName, NASIPAddress, NASPortId, FramedIPAddress, CallingStationId, FramedProtocol FROM ${acct_table1} WHERE UserName='%{SQL-User-Name}' AND AcctStopTime = 0" + simul_verify_query = "SELECT RadAcctId, AcctSessionId, UserName, \ + NASIPAddress, NASPortId, FramedIPAddress, CallingStationId, FramedProtocol \ + FROM ${acct_table1} WHERE UserName='%{SQL-User-Name}' AND AcctStopTime = 0" # Set to 'yes' to read radius clients from the database ('nas' table) #readclients = yes @@ -68,70 +125,109 @@ authreply_table = "radreply" nas_table = "nas" readclients = no - authorize_check_query = "SELECT id, lower(name) as UserName , 'User-Password' as Attribute , passwd as Value, '==' as op FROM nodes WHERE name = '%{User-Name}'\ - UNION\ - SELECT id, lower(name) as UserName , 'Simultaneous-Use' as Attribute, '1' as Value, ':=' as op FROM nodes WHERE name = '%{User-Name}'\ - UNION\ - SELECT 0 AS id, '%{User-Name}' AS UserName, 'Max-Octets' AS Attribute,\ - CONCAT(ROUND(COALESCE(x.dlimit, y.dlimit))) AS Value, ':=' AS op\ - FROM (SELECT n.id, MIN(n.name) AS name, SUM(t.dlimit/o.cnt) AS dlimit\ - FROM nodeassignments na\ - JOIN assignments a ON (na.assignmentid = a.id)\ - JOIN tariffs t ON (a.tariffid = t.id)\ - JOIN nodes n ON (na.nodeid = n.id)\ - JOIN (SELECT assignmentid, COUNT(*) AS cnt\ - FROM nodeassignments GROUP BY assignmentid) o ON (o.assignmentid = na.assignmentid)\ - WHERE (a.datefrom <= unix_timestamp() OR a.datefrom = 0) AND (a.dateto > unix_timestamp() OR a.dateto = 0) AND a.suspended = 0 AND n.name = '%{User-Name}'\ - GROUP BY n.id\ - ) x\ - RIGHT JOIN (SELECT\ - SUM(t.dlimit)/o.cnt AS dlimit\ - FROM assignments a\ - JOIN tariffs t ON (a.tariffid = t.id)\ - JOIN nodes n ON (a.customerid = n.ownerid)\ - JOIN (SELECT COUNT(*) AS cnt, ownerid FROM nodes\ - WHERE NOT EXISTS(SELECT 1 FROM nodeassignments, assignments a WHERE assignmentid = a.id AND nodeid = nodes.id AND a.suspended = 0 AND (a.dateto > unix_timestamp() OR a.dateto = 0))\ - GROUP BY ownerid) o ON (o.ownerid = n.ownerid)\ - WHERE (a.datefrom <= unix_timestamp() OR a.datefrom = 0) AND (a.dateto > unix_timestamp() OR a.dateto = 0) AND a.suspended = 0 AND t.dlimit != '0'\ - AND NOT EXISTS (SELECT 1 FROM nodeassignments WHERE assignmentid = a.id) AND n.name = '%{User-Name}'\ - GROUP BY n.id\ - ) y ON (1=1);" - - authorize_reply_query = "SELECT id, lower(name) as UserName , 'Framed-IP-Address' as Attribute, inet_ntoa(ipaddr) as Value, '==' as op FROM nodes WHERE name = '%{User-Name}'\ - UNION\ - SELECT 0 AS id, '%{User-Name}' AS UserName, 'Mikrotik-Rate-Limit' AS Attribute,\ - CONCAT(ROUND(COALESCE(x.upceil, y.upceil, z.upceil)),'k','/', ROUND(COALESCE(x.downceil, y.downceil, z.downceil)),'k') AS Value, '==' AS op\ - FROM (SELECT n.id, MIN(n.name) AS name, SUM(t.downceil/o.cnt) AS downceil, SUM(t.upceil/o.cnt) AS upceil\ - FROM nodeassignments na\ - JOIN assignments a ON (na.assignmentid = a.id)\ - JOIN tariffs t ON (a.tariffid = t.id)\ - JOIN nodes n ON (na.nodeid = n.id)\ - JOIN (SELECT assignmentid, COUNT(*) AS cnt\ - FROM nodeassignments GROUP BY assignmentid) o ON (o.assignmentid = na.assignmentid)\ - WHERE (a.datefrom <= unix_timestamp() OR a.datefrom = 0) AND (a.dateto > unix_timestamp() OR a.dateto = 0) AND a.suspended = 0 AND n.name = '%{User-Name}'\ - GROUP BY n.id\ - ) x\ - RIGHT JOIN (SELECT\ - SUM(t.downceil)/o.cnt AS downceil,\ - SUM(t.upceil)/o.cnt AS upceil\ - FROM assignments a\ - JOIN tariffs t ON (a.tariffid = t.id)\ - JOIN nodes n ON (a.customerid = n.ownerid)\ - JOIN (SELECT COUNT(*) AS cnt, ownerid FROM nodes \ - WHERE NOT EXISTS(SELECT 1 FROM nodeassignments, assignments a WHERE assignmentid = a.id AND nodeid = nodes.id AND a.suspended = 0 AND (a.dateto > unix_timestamp() OR a.dateto = 0))\ - GROUP BY ownerid) o ON (o.ownerid = n.ownerid)\ - WHERE (a.datefrom <= unix_timestamp() OR a.datefrom = 0) AND (a.dateto > unix_timestamp() OR a.dateto = 0) AND a.suspended = 0\ - AND NOT EXISTS (SELECT 1 FROM nodeassignments WHERE assignmentid = a.id) AND n.name = '%{User-Name}'\ - GROUP BY n.id\ - ) y ON (1=1)\ - RIGHT JOIN (SELECT n.id, n.name, 64 AS downceil, 64 AS upceil\ - FROM nodes n WHERE n.name = '%{User-Name}'\ - ) z ON (1=1)\ - UNION\ - SELECT id, UserName, Attribute, Value, op \ - FROM ${authreply_table} \ - WHERE Username = '%{SQL-User-Name}' \ - ORDER BY id;" + authorize_check_query = "SELECT \ + id, lower(name) as UserName , 'User-Password' as Attribute , passwd as Value, '==' as op \ + FROM nodes \ + WHERE name = '%{User-Name}'\ + UNION \ + SELECT id, lower(name) as UserName , 'Simultaneous-Use' as Attribute, '1' as Value, ':=' as op \ + FROM nodes \ + WHERE name = '%{User-Name}'\ + UNION \ + SELECT 0 AS id, '%{User-Name}' AS UserName, 'Max-Octets' AS Attribute, \ + CONCAT(ROUND(COALESCE(x.dlimit, y.dlimit))) AS Value, ':=' AS op \ + FROM (\ + SELECT n.id, MIN(n.name) AS name, SUM(t.dlimit/o.cnt) AS dlimit \ + FROM nodeassignments na \ + JOIN assignments a ON (na.assignmentid = a.id) \ + JOIN tariffs t ON (a.tariffid = t.id)\ + JOIN nodes n ON (na.nodeid = n.id)\ + JOIN (\ + SELECT assignmentid, COUNT(*) AS cnt\ + FROM nodeassignments \ + GROUP BY assignmentid \ + ) o ON (o.assignmentid = na.assignmentid)\ + WHERE (a.datefrom <= unix_timestamp() OR a.datefrom = 0) \ + AND (a.dateto > unix_timestamp() OR a.dateto = 0) \ + AND a.suspended = 0 AND n.name = '%{User-Name}'\ + GROUP BY n.id\ + ) x\ + RIGHT JOIN ( \ + SELECT SUM(t.dlimit)/o.cnt AS dlimit\ + FROM assignments a\ + JOIN tariffs t ON (a.tariffid = t.id)\ + JOIN nodes n ON (a.customerid = n.ownerid)\ + JOIN ( \ + SELECT COUNT(*) AS cnt, ownerid \ + FROM nodes\ + WHERE NOT EXISTS (\ + SELECT 1 FROM nodeassignments, assignments a \ + WHERE assignmentid = a.id AND nodeid = nodes.id \ + AND a.suspended = 0 AND (a.dateto > unix_timestamp() OR a.dateto = 0))\ + GROUP BY ownerid\ + ) o ON (o.ownerid = n.ownerid)\ + WHERE (a.datefrom <= unix_timestamp() OR a.datefrom = 0) \ + AND (a.dateto > unix_timestamp() OR a.dateto = 0) \ + AND a.suspended = 0 AND t.dlimit != '0'\ + AND NOT EXISTS (\ + SELECT 1 FROM nodeassignments \ + WHERE assignmentid = a.id)\ + AND n.name = '%{User-Name}'\ + GROUP BY n.id\ + ) y ON (1=1);" + + authorize_reply_query = "SELECT \ + id, lower(name) as UserName , 'Framed-IP-Address' as Attribute, inet_ntoa(ipaddr) as Value, '==' as op \ + FROM nodes \ + WHERE name = '%{User-Name}'\ + UNION\ + SELECT 0 AS id, '%{User-Name}' AS UserName, 'Mikrotik-Rate-Limit' AS Attribute,\ + CONCAT(ROUND(COALESCE(x.upceil, y.upceil, z.upceil)),'k','/', ROUND(COALESCE(x.downceil, y.downceil, z.downceil)),'k') AS Value, '==' AS op\ + FROM (\ + SELECT n.id, MIN(n.name) AS name, SUM(t.downceil/o.cnt) AS downceil, SUM(t.upceil/o.cnt) AS upceil\ + FROM nodeassignments na\ + JOIN assignments a ON (na.assignmentid = a.id)\ + JOIN tariffs t ON (a.tariffid = t.id)\ + JOIN nodes n ON (na.nodeid = n.id)\ + JOIN (\ + SELECT assignmentid, COUNT(*) AS cnt\ + FROM nodeassignments \ + ROUP BY assignmentid\ + ) o ON (o.assignmentid = na.assignmentid)\ + WHERE (a.datefrom <= unix_timestamp() OR a.datefrom = 0) \ + AND (a.dateto > unix_timestamp() OR a.dateto = 0) \ + AND a.suspended = 0 AND n.name = '%{User-Name}'\ + GROUP BY n.id\ + ) x\ + RIGHT JOIN (\ + SELECT SUM(t.downceil)/o.cnt AS downceil,\ + SUM(t.upceil)/o.cnt AS upceil\ + FROM assignments a\ + JOIN tariffs t ON (a.tariffid = t.id)\ + JOIN nodes n ON (a.customerid = n.ownerid)\ + JOIN (\ + SELECT COUNT(*) AS cnt, ownerid FROM nodes \ + WHERE NOT EXISTS (\ + SELECT 1 FROM nodeassignments, assignments a \ + WHERE assignmentid = a.id AND nodeid = nodes.id \ + AND a.suspended = 0 AND (a.dateto > unix_timestamp() OR a.dateto = 0))\ + GROUP BY ownerid \ + ) o ON (o.ownerid = n.ownerid)\ + WHERE (a.datefrom <= unix_timestamp() OR a.datefrom = 0) \ + AND (a.dateto > unix_timestamp() OR a.dateto = 0) AND a.suspended = 0\ + AND NOT EXISTS (SELECT 1 FROM nodeassignments WHERE assignmentid = a.id) \ + AND n.name = '%{User-Name}'\ + GROUP BY n.id\ + ) y ON (1=1)\ + RIGHT JOIN (\ + SELECT n.id, n.name, 64 AS downceil, 64 AS upceil\ + FROM nodes n WHERE n.name = '%{User-Name}'\ + ) z ON (1=1)\ + UNION\ + SELECT id, UserName, Attribute, Value, op \ + FROM ${authreply_table} \ + WHERE Username = '%{SQL-User-Name}' \ + ORDER BY id;" } sql sql_mac { @@ -147,7 +243,9 @@ connect_failure_retry_delay = 60 sql_user_name = "%{User-Name}" sql_set_password = "" - authorize_check_query = "SELECT id, upper(mac) as UserName , 'User-Password' as Attribute, '' as Value, '==' as op FROM nodes WHERE upper(mac) = '%{SQL-User-Name}' and access=1 ORDER by id" + authorize_check_query = "SELECT id, upper(mac) as UserName , 'User-Password' as Attribute, '' as Value, '==' as op \ + FROM nodes \ + WHERE upper(mac) = '%{SQL-User-Name}' and access=1 ORDER by id" } sql sql_last_online { From cvs w lms.org.pl Tue May 4 09:23:42 2010 From: cvs w lms.org.pl (LMS CVS) Date: Tue, 4 May 2010 09:23:42 +0200 (CEST) Subject: [lms-commits] CVS update of lms/modules (trafficdbcompact.php) Message-ID: <20100504072342.D88A23027B2B@hydra.altec.pl> Date: Tuesday, May 4, 2010 @ 09:23:42 Author: alec Path: /cvsroot/lms/modules Modified: trafficdbcompact.php - BTS#0000832: fixed stats compacting Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/modules/trafficdbcompact.php.diff?&r1=1.32&r2=1.33 Index: lms/modules/trafficdbcompact.php diff -u lms/modules/trafficdbcompact.php:1.32 lms/modules/trafficdbcompact.php:1.33 --- lms/modules/trafficdbcompact.php:1.32 Thu Mar 11 14:07:49 2010 +++ lms/modules/trafficdbcompact.php Tue May 4 09:23:42 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: trafficdbcompact.php,v 1.32 2010/03/11 13:07:49 alec Exp $ + * $Id: trafficdbcompact.php,v 1.33 2010/05/04 07:23:42 alec Exp $ */ $layout['pagetitle'] = trans('Network Statistics Compacting'); @@ -79,7 +79,6 @@ $maxtime = $period; $timeoffset = date('Z'); $dtdivider = 'FLOOR((dt+'.$timeoffset.')/'.$step.')'; - $data = $DB->GetAll('SELECT SUM(download) AS download, SUM(upload) AS upload, COUNT(dt) AS count, MIN(dt) AS mintime, MAX(dt) AS maxtime @@ -92,13 +91,13 @@ $DB->Execute('DELETE FROM stats WHERE nodeid = ? AND dt >= ? AND dt <= ?', array($node['id'], $mintime, $maxtime)); - + foreach($data as $record) { $deleted += $record['count']; if($record['download'] || $record['upload']) $inserted += $DB->Execute('INSERT INTO stats - (nodeid, dt, download, upload) + (nodeid, dt, upload, download) VALUES (?, ?, ?, ?)', array($node['id'], $record['maxtime'], $record['upload'], $record['download'])); From cvs w lms.org.pl Tue May 4 09:23:42 2010 From: cvs w lms.org.pl (LMS CVS) Date: Tue, 4 May 2010 09:23:42 +0200 (CEST) Subject: [lms-commits] CVS update of lms/doc (ChangeLog) Message-ID: <20100504072342.C2F413027B29@hydra.altec.pl> Date: Tuesday, May 4, 2010 @ 09:23:42 Author: alec Path: /cvsroot/lms/doc Modified: ChangeLog - BTS#0000832: fixed stats compacting Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/doc/ChangeLog.diff?&r1=1.1492&r2=1.1493 Index: lms/doc/ChangeLog diff -u lms/doc/ChangeLog:1.1492 lms/doc/ChangeLog:1.1493 --- lms/doc/ChangeLog:1.1492 Fri Apr 23 15:37:00 2010 +++ lms/doc/ChangeLog Tue May 4 09:23:42 2010 @@ -1,8 +1,9 @@ -$Id: ChangeLog,v 1.1492 2010/04/23 13:37:00 alec Exp $ +$Id: ChangeLog,v 1.1493 2010/05/04 07:23:42 alec Exp $ version ? (????-??-??) - fixed SQL queries in postfix configuration manual (alec) + - BTS#0000832: fixed stats compacting (alec) version 1.11.10 Kri (2010-04-19) From cvs w lms.org.pl Thu May 6 22:24:57 2010 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 6 May 2010 22:24:57 +0200 (CEST) Subject: [lms-commits] CVS update of lms/bin (lms-makedhcpconf) Message-ID: <20100506202457.0F8EA3027B29@hydra.altec.pl> Date: Thursday, May 6, 2010 @ 22:24:56 Author: chilek Path: /cvsroot/lms/bin Modified: lms-makedhcpconf - we can bind many macs to one node (chilan) Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/bin/lms-makedhcpconf.diff?&r1=1.62&r2=1.63 Index: lms/bin/lms-makedhcpconf diff -u lms/bin/lms-makedhcpconf:1.62 lms/bin/lms-makedhcpconf:1.63 --- lms/bin/lms-makedhcpconf:1.62 Thu Mar 11 14:07:28 2010 +++ lms/bin/lms-makedhcpconf Thu May 6 22:24:56 2010 @@ -20,7 +20,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # -# $Id: lms-makedhcpconf,v 1.62 2010/03/11 13:07:28 alec Exp $ +# $Id: lms-makedhcpconf,v 1.63 2010/05/06 20:24:56 chilek Exp $ use strict; use DBI; @@ -147,14 +147,17 @@ my $dbtype = $ini->val('database', 'type') || 'mysql'; my $dbase; +my $macgroupconcat; if($dbtype =~ /mysql/) { $dbase = DBI->connect("DBI:mysql:database=$dbname;host=$dbhost","$dbuser","$dbpasswd", { RaiseError => 1 }); + $macgroupconcat = "GROUP_CONCAT(mac SEPARATOR ',')"; } elsif($dbtype eq "postgres") { $dbase = DBI->connect("DBI:Pg:dbname=$dbname;host=$dbhost","$dbuser","$dbpasswd", { RaiseError => 1 }); + $macgroupconcat = "array_to_string(array_agg(mac), ',')"; } else { @@ -334,7 +337,9 @@ print DHCPDCONF "\n"; - my $dbq2 = $dbase->prepare("SELECT id, name, ipaddr, mac, ownerid FROM nodes ORDER BY ipaddr"); + my $dbq2 = $dbase->prepare("SELECT id, name, ipaddr, m.mac AS mac, ownerid FROM nodes + LEFT JOIN (SELECT nodeid, $macgroupconcat AS mac FROM macs GROUP BY nodeid) m ON nodes.id = m.nodeid + ORDER BY ipaddr"); $dbq2->execute(); while (my $row2 = $dbq2->fetchrow_hashref()) { @@ -360,26 +365,32 @@ my $ngateway = $ini->val("dhcp:$ipaddr",'gateway') || ''; my $ndns = $ini->val("dhcp:$ipaddr",'dns') || ''; my $nwins = $ini->val("dhcp:$ipaddr",'wins') || ''; - print DHCPDCONF "\t\thost $row2->{'name'} { # ID: $row2->{'id'}\n"; - print DHCPDCONF "\t\t\thardware ethernet $row2->{'mac'};\n"; - print DHCPDCONF "\t\t\tfixed-address $row2->{'ipaddr'};\n"; - if($ndomain) + my @macs = split ',', $row2->{'mac'}; + my $idx = 0; + foreach my $mac (@macs) { - print DHCPDCONF "\t\t\toption domain-name \"$ndomain\";\n"; + print DHCPDCONF "\t\thost $row2->{'name'}".($idx>0 ? "-$idx" : "")." { # ID: $row2->{'id'}\n"; + print DHCPDCONF "\t\t\thardware ethernet $mac;\n"; + print DHCPDCONF "\t\t\tfixed-address $row2->{'ipaddr'};\n"; + if($ndomain) + { + print DHCPDCONF "\t\t\toption domain-name \"$ndomain\";\n"; + } + if($ngateway) + { + print DHCPDCONF "\t\t\toption routers $ngateway;\n"; + } + if($ndns) + { + print DHCPDCONF "\t\t\toption domain-name-servers $ndns;\n"; + } + if($nwins) + { + print DHCPDCONF "\t\t\toption netbios-name-servers $nwins;\n"; + } + print DHCPDCONF "\t\t}\n"; + $idx++; } - if($ngateway) - { - print DHCPDCONF "\t\t\toption routers $ngateway;\n"; - } - if($ndns) - { - print DHCPDCONF "\t\t\toption domain-name-servers $ndns;\n"; - } - if($nwins) - { - print DHCPDCONF "\t\t\toption netbios-name-servers $nwins;\n"; - } - print DHCPDCONF "\t\t}\n"; } } } From cvs w lms.org.pl Thu May 6 22:24:57 2010 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 6 May 2010 22:24:57 +0200 (CEST) Subject: [lms-commits] CVS update of lms/daemon/modules/dhcp (dhcp.c) Message-ID: <20100506202457.29A083027B2B@hydra.altec.pl> Date: Thursday, May 6, 2010 @ 22:24:57 Author: chilek Path: /cvsroot/lms/daemon/modules/dhcp Modified: dhcp.c - we can bind many macs to one node (chilan) Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/daemon/modules/dhcp/dhcp.c.diff?&r1=1.38&r2=1.39 Index: lms/daemon/modules/dhcp/dhcp.c diff -u lms/daemon/modules/dhcp/dhcp.c:1.38 lms/daemon/modules/dhcp/dhcp.c:1.39 --- lms/daemon/modules/dhcp/dhcp.c:1.38 Thu Mar 11 14:07:31 2010 +++ lms/daemon/modules/dhcp/dhcp.c Thu May 6 22:24:57 2010 @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: dhcp.c,v 1.38 2010/03/11 13:07:31 alec Exp $ + * $Id: dhcp.c,v 1.39 2010/05/06 20:24:57 chilek Exp $ */ #include @@ -94,7 +94,15 @@ fh = fopen(dhcp->file, "w"); if(fh) { - res = g->db_query(g->conn, "SELECT name, mac, ipaddr, ipaddr_pub, ownerid FROM nodes ORDER BY ipaddr"); + res = g->db_query(g->conn, "SELECT name, m.mac AS mac, ipaddr, ipaddr_pub, ownerid FROM nodes " + "LEFT JOIN (SELECT nodeid, " +#ifdef USE_PGSQL + "array_to_string(array_agg(mac), ',') " +#else + "GROUP_CONCAT(mac SEPARATOR ',') " +#endif + "AS mac FROM macs GROUP BY nodeid) m ON (nodes.id = m.nodeid) " + "ORDER BY ipaddr"); for(i=0; idb_nrows(res); i++) { @@ -260,12 +268,22 @@ for(j=0; jhost); - g->str_replace(&s, "%i", inet_ntoa(inet_makeaddr(htonl(hosts[j].ipaddr), 0))); - g->str_replace(&s, "%n", hosts[j].name); - g->str_replace(&s, "%m", hosts[j].mac); - fprintf(fh, "%s\n", s); - free(s); + for(mac = strtok(hosts[j].mac, ","), m = 0; mac != NULL; mac = strtok(NULL, ","), m++) + { + static char name_suffix[12]; + char *name; + name_suffix[0] = 0; + if (m > 0) + sprintf(name_suffix, "-%d", m); + name = g->str_concat(hosts[j].name, name_suffix); + s = strdup(dhcp->host); + g->str_replace(&s, "%i", inet_ntoa(inet_makeaddr(htonl(hosts[j].ipaddr), 0))); + g->str_replace(&s, "%n", name); + g->str_replace(&s, "%m", mac); + fprintf(fh, "%s\n", s); + free(s); + free(name); + } } } From cvs w lms.org.pl Thu May 6 22:24:57 2010 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 6 May 2010 22:24:57 +0200 (CEST) Subject: [lms-commits] CVS update of lms/doc (ChangeLog, lms.mysql, lms.pgsql) Message-ID: <20100506202457.646D23027B2C@hydra.altec.pl> Date: Thursday, May 6, 2010 @ 22:24:57 Author: chilek Path: /cvsroot/lms/doc Modified: ChangeLog lms.mysql lms.pgsql - we can bind many macs to one node (chilan) Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/doc/ChangeLog.diff?&r1=1.1493&r2=1.1494 http://cvs.lms.org.pl/viewvc/Development/lms/doc/lms.mysql.diff?&r1=1.166&r2=1.167 http://cvs.lms.org.pl/viewvc/Development/lms/doc/lms.pgsql.diff?&r1=1.157&r2=1.158 Index: lms/doc/ChangeLog diff -u lms/doc/ChangeLog:1.1493 lms/doc/ChangeLog:1.1494 --- lms/doc/ChangeLog:1.1493 Tue May 4 09:23:42 2010 +++ lms/doc/ChangeLog Thu May 6 22:24:57 2010 @@ -1,9 +1,10 @@ -$Id: ChangeLog,v 1.1493 2010/05/04 07:23:42 alec Exp $ +$Id: ChangeLog,v 1.1494 2010/05/06 20:24:57 chilek Exp $ version ? (????-??-??) - fixed SQL queries in postfix configuration manual (alec) - BTS#0000832: fixed stats compacting (alec) + - we can bind many macs to one node (chilan) version 1.11.10 Kri (2010-04-19) Index: lms/doc/lms.mysql diff -u lms/doc/lms.mysql:1.166 lms/doc/lms.mysql:1.167 --- lms/doc/lms.mysql:1.166 Wed Mar 31 12:46:29 2010 +++ lms/doc/lms.mysql Thu May 6 22:24:57 2010 @@ -1,5 +1,5 @@ # -------------------------------------------------------- -# $Id: lms.mysql,v 1.166 2010/03/31 10:46:29 alec Exp $ +# $Id: lms.mysql,v 1.167 2010/05/06 20:24:57 chilek Exp $ # -------------------------------------------------------- # @@ -307,7 +307,6 @@ CREATE TABLE nodes ( id int(11) NOT NULL auto_increment, name varchar(32) NOT NULL DEFAULT '', - mac varchar(20) NOT NULL DEFAULT '', ipaddr int(16) unsigned NOT NULL DEFAULT '0', ipaddr_pub int(16) unsigned NOT NULL DEFAULT '0', passwd varchar(32) NOT NULL DEFAULT '', @@ -337,6 +336,20 @@ # -------------------------------------------------------- # +# Structure of table macs +# +DROP TABLE IF EXISTS macs; +CREATE TABLE macs ( + id int(11) NOT NULL auto_increment, + mac varchar(17) NOT NULL DEFAULT '', + nodeid int(11) NOT NULL, + PRIMARY KEY (id), + FOREIGN KEY (nodeid) REFERENCES nodes (id) ON DELETE CASCADE ON UPDATE CASCADE, + UNIQUE KEY mac (mac, nodeid) +) ENGINE=InnoDB; + +# -------------------------------------------------------- +# # Structure of table nodegroups # DROP TABLE IF EXISTS nodegroups; @@ -1335,4 +1348,4 @@ # -------------------------------------------------------- -INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2010031100'); +INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2010050600'); Index: lms/doc/lms.pgsql diff -u lms/doc/lms.pgsql:1.157 lms/doc/lms.pgsql:1.158 --- lms/doc/lms.pgsql:1.157 Thu Mar 11 14:06:19 2010 +++ lms/doc/lms.pgsql Thu May 6 22:24:57 2010 @@ -1,4 +1,4 @@ -/* $Id: lms.pgsql,v 1.157 2010/03/11 13:06:19 alec Exp $ */ +/* $Id: lms.pgsql,v 1.158 2010/05/06 20:24:57 chilek Exp $ */ /* -------------------------------------------------------- Structure of table "users" @@ -110,7 +110,6 @@ CREATE TABLE nodes ( id integer DEFAULT nextval('nodes_id_seq'::text) NOT NULL, name varchar(32) DEFAULT '' NOT NULL, - mac varchar(20) DEFAULT '' NOT NULL, ipaddr bigint DEFAULT 0 NOT NULL, ipaddr_pub bigint DEFAULT 0 NOT NULL, passwd varchar(32) DEFAULT '' NOT NULL, @@ -140,6 +139,21 @@ CREATE SEQUENCE nodegroups_id_seq; /* -------------------------------------------------------- + Structure of table "macs" +-------------------------------------------------------- */ +DROP SEQUENCE macs_id_seq; +CREATE SEQUENCE macs_id_seq; +DROP TABLE macs; +CREATE TABLE macs ( + id integer DEFAULT nextval('macs_id_seq'::text) NOT NULL, + mac varchar(17) DEFAULT '' NOT NULL, + nodeid integer NOT NULL + REFERENCES nodes (id) ON DELETE CASCADE ON UPDATE CASCADE, + PRIMARY KEY (id), + UNIQUE (mac, nodeid) +); + +/* -------------------------------------------------------- Structure of table "nodegroups" -------------------------------------------------------- */ DROP SEQUENCE nodegroups_id_seq; @@ -1370,6 +1384,15 @@ WHERE n.nas = 1; /* --------------------------------------------------- + Aggregates +------------------------------------------------------*/ +CREATE AGGREGATE array_agg(anyelement) ( + SFUNC=array_append, + STYPE=anyarray, + INITCOND='{}' +); + +/* --------------------------------------------------- Data records ------------------------------------------------------*/ INSERT INTO uiconfig (section, var) @@ -1427,4 +1450,4 @@ INSERT INTO nastypes (name) VALUES ('usrhiper'); INSERT INTO nastypes (name) VALUES ('other'); -INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2010031100'); +INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2010050600'); From cvs w lms.org.pl Thu May 6 22:24:57 2010 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 6 May 2010 22:24:57 +0200 (CEST) Subject: [lms-commits] CVS update of lms/lib (6 files) Message-ID: <20100506202457.AFACB3027B2D@hydra.altec.pl> Date: Thursday, May 6, 2010 @ 22:24:57 Author: chilek Path: /cvsroot/lms/lib Modified: LMS.class.php LMSDB_common.class.php LMSDB_driver_mysql.class.php LMSDB_driver_mysqli.class.php LMSDB_driver_postgres.class.php upgradedb.php - we can bind many macs to one node (chilan) Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/lib/LMS.class.php.diff?&r1=1.1026&r2=1.1027 http://cvs.lms.org.pl/viewvc/Development/lms/lib/LMSDB_common.class.php.diff?&r1=1.52&r2=1.53 http://cvs.lms.org.pl/viewvc/Development/lms/lib/LMSDB_driver_mysql.class.php.diff?&r1=1.57&r2=1.58 http://cvs.lms.org.pl/viewvc/Development/lms/lib/LMSDB_driver_mysqli.class.php.diff?&r1=1.13&r2=1.14 http://cvs.lms.org.pl/viewvc/Development/lms/lib/LMSDB_driver_postgres.class.php.diff?&r1=1.49&r2=1.50 http://cvs.lms.org.pl/viewvc/Development/lms/lib/upgradedb.php.diff?&r1=1.172&r2=1.173 Index: lms/lib/LMS.class.php diff -u lms/lib/LMS.class.php:1.1026 lms/lib/LMS.class.php:1.1027 --- lms/lib/LMS.class.php:1.1026 Tue Apr 13 15:01:47 2010 +++ lms/lib/LMS.class.php Thu May 6 22:24:57 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: LMS.class.php,v 1.1026 2010/04/13 13:01:47 alec Exp $ + * $Id: LMS.class.php,v 1.1027 2010/05/06 20:24:57 chilek Exp $ */ // LMS Class - contains internal LMS database functions used @@ -34,7 +34,7 @@ var $CONFIG; // table including lms.ini options var $cache = array(); // internal cache var $_version = '1.11-cvs'; // class version - var $_revision = '$Revision: 1.1026 $'; + var $_revision = '$Revision: 1.1027 $'; function LMS(&$DB, &$AUTH, &$CONFIG) // class variables setting { @@ -820,13 +820,17 @@ function GetCustomerNodes($id, $count=NULL) { - if($result = $this->DB->GetAll('SELECT id, name, mac, ipaddr, + if($result = $this->DB->GetAll('SELECT id, name, m.mac AS mac, ipaddr, inet_ntoa(ipaddr) AS ip, ipaddr_pub, inet_ntoa(ipaddr_pub) AS ip_pub, passwd, access, warning, info, ownerid, location, lastonline, (SELECT COUNT(*) FROM nodegroupassignments WHERE nodeid = nodes.id) AS gcount - FROM nodes WHERE ownerid=? + FROM nodes + LEFT JOIN ( + SELECT nodeid, '.$this->DB->GroupConcat('mac', ',').' AS mac FROM macs GROUP BY nodeid + ) m ON (nodes.id = m.nodeid) + WHERE ownerid=? ORDER BY name ASC '.($count ? 'LIMIT '.$count : ''), array($id))) { // assign network(s) to node record @@ -1142,14 +1146,13 @@ function NodeUpdate($nodedata, $deleteassignments=FALSE) { $this->DB->Execute('UPDATE nodes SET name=UPPER(?), ipaddr_pub=inet_aton(?), - ipaddr=inet_aton(?), mac=UPPER(?), passwd=?, netdev=?, moddate=?NOW?, + ipaddr=inet_aton(?), passwd=?, netdev=?, moddate=?NOW?, modid=?, access=?, warning=?, ownerid=?, info=?, location=?, chkmac=?, halfduplex=?, linktype=?, port=?, nas=? WHERE id=?', array($nodedata['name'], $nodedata['ipaddr_pub'], $nodedata['ipaddr'], - $nodedata['mac'], $nodedata['passwd'], $nodedata['netdev'], $this->AUTH->id, @@ -1165,7 +1168,13 @@ isset($nodedata['nas']) ? $nodedata['nas'] : 0, $nodedata['id'] )); - + $this->DB->Execute('DELETE FROM macs WHERE nodeid=?', array($nodedata['id'])); + foreach($nodedata['macs'] as $mac) + { + $this->DB->Execute('INSERT INTO macs (mac, nodeid) VALUES(?, ?)', + array(strtoupper($mac), $nodedata['id'])); + } + if($deleteassignments) $this->DB->Execute('DELETE FROM nodeassignments WHERE nodeid = ?', array($nodedata['id'])); } @@ -1175,12 +1184,13 @@ $this->DB->BeginTrans(); $this->DB->Execute('DELETE FROM nodes WHERE id = ?', array($id)); $this->DB->Execute('DELETE FROM nodegroupassignments WHERE nodeid = ?', array($id)); + $this->DB->Execute('DELETE FROM macs WHERE nodeid = ?', array($id)); $this->DB->CommitTrans(); } function GetNodeNameByMAC($mac) { - return $this->DB->GetOne('SELECT name FROM nodes WHERE mac=UPPER(?)', array($mac)); + return $this->DB->GetOne('SELECT name FROM nodes LEFT JOIN macs ON nodes.id = macs.nodeid WHERE mac=UPPER(?)', array($mac)); } function GetNodeIDByIP($ipaddr) @@ -1191,7 +1201,7 @@ function GetNodeIDByMAC($mac) { - return $this->DB->GetOne('SELECT id FROM nodes WHERE mac=UPPER(?)', array($mac)); + return $this->DB->GetOne('SELECT nodeid FROM macs WHERE mac=UPPER(?)', array($mac)); } function GetNodeIDByName($name) @@ -1211,7 +1221,7 @@ function GetNodeMACByID($id) { - return $this->DB->GetOne('SELECT mac FROM nodes WHERE id=?', array($id)); + return $this->DB->GetOne('SELECT '.$this->DB->GroupConcat('mac', ',').' AS mac FROM macs GROUP BY nodeid WHERE nodeid=?', array($id)); } function GetNodeName($id) @@ -1227,17 +1237,23 @@ function GetNode($id) { if($result = $this->DB->GetRow('SELECT id, name, ownerid, ipaddr, inet_ntoa(ipaddr) AS ip, - ipaddr_pub, inet_ntoa(ipaddr_pub) AS ip_pub, mac, passwd, access, + ipaddr_pub, inet_ntoa(ipaddr_pub) AS ip_pub, m.mac AS mac, passwd, access, warning, creationdate, moddate, creatorid, modid, netdev, lastonline, - info, location, chkmac, halfduplex, linktype, port, nas - FROM nodes WHERE id = ?', array($id))) + info, location, chkmac, halfduplex, linktype, port, nas + FROM nodes + LEFT JOIN ( + SELECT nodeid, '.$this->DB->GroupConcat('mac', ',').' AS mac FROM macs GROUP BY nodeid + ) m ON (nodes.id = m.nodeid) WHERE id = ?', array($id))) { $result['owner'] = $this->GetCustomerName($result['ownerid']); $result['createdby'] = $this->GetUserName($result['creatorid']); $result['modifiedby'] = $this->GetUserName($result['modid']); $result['creationdateh'] = date('Y/m/d, H:i',$result['creationdate']); $result['moddateh'] = date('Y/m/d, H:i',$result['moddate']); - $result['producer'] = get_producer($result['mac']); + $result['mac'] = split(',', $result['mac']); + foreach($result['mac'] as $mac) + $result['macs'][] = array('mac' => $mac, 'producer' => get_producer($mac)); + unset($result['mac']); $delta = time()-$result['lastonline']; if($delta>$this->CONFIG['phpui']['lastonline_limit']) @@ -1280,7 +1296,7 @@ $sqlord = ' ORDER BY id'; break; case 'mac': - $sqlord = ' ORDER BY mac'; + $sqlord = ' ORDER BY m.mac'; break; case 'ip': $sqlord = ' ORDER BY ipaddr'; @@ -1329,10 +1345,13 @@ $net = $this->GetNetworkParams($network); if($nodelist = $this->DB->GetAll('SELECT nodes.id AS id, ipaddr, inet_ntoa(ipaddr) AS ip, ipaddr_pub, - inet_ntoa(ipaddr_pub) AS ip_pub, mac, nodes.name AS name, ownerid, access, warning, + inet_ntoa(ipaddr_pub) AS ip_pub, m.mac AS mac, nodes.name AS name, ownerid, access, warning, netdev, lastonline, nodes.info AS info, ' - .$this->DB->Concat('c.lastname',"' '",'c.name').' AS owner + .$this->DB->Concat('c.lastname',"' '",'c.name').' AS owner FROM nodes + LEFT JOIN ( + SELECT nodeid, '.$this->DB->GroupConcat('mac', ',').' AS mac FROM macs GROUP BY nodeid + ) m ON (nodes.id = m.nodeid) JOIN customersview c ON (nodes.ownerid = c.id) ' .($customergroup ? 'JOIN customerassignments ON (customerid = c.id) ' : '') .($nodegroup ? 'JOIN nodegroupassignments ON (nodeid = nodes.id) ' : '') @@ -1427,13 +1446,12 @@ function NodeAdd($nodedata) { - if($this->DB->Execute('INSERT INTO nodes (name, mac, ipaddr, ipaddr_pub, ownerid, + if($this->DB->Execute('INSERT INTO nodes (name, ipaddr, ipaddr_pub, ownerid, passwd, creatorid, creationdate, access, warning, info, netdev, linktype, port, location, chkmac, halfduplex, nas) - VALUES (?, ?, inet_aton(?),inet_aton(?), ?, ?, ?, + VALUES (?, inet_aton(?),inet_aton(?), ?, ?, ?, ?NOW?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(strtoupper($nodedata['name']), - strtoupper($nodedata['mac']), $nodedata['ipaddr'], $nodedata['ipaddr_pub'], $nodedata['ownerid'], @@ -1452,7 +1470,11 @@ ))) { $id = $this->DB->GetLastInsertID('nodes'); - + + foreach($nodedata['macs'] as $mac) + $this->DB->Execute('INSERT INTO macs (mac, nodeid) VALUES(?, ?)', + array(strtoupper($mac), $id)); + // EtherWerX support (devices have some limits) // We must to replace big ID with smaller (first free) if($id > 99999 && chkconfig($this->CONFIG['phpui']['ewx_support'])) @@ -3168,9 +3190,13 @@ function GetNetDevIPs($id) { - return $this->DB->GetAll('SELECT id, name, mac, ipaddr, inet_ntoa(ipaddr) AS ip, + return $this->DB->GetAll('SELECT id, name, m.mac AS mac, ipaddr, inet_ntoa(ipaddr) AS ip, ipaddr_pub, inet_ntoa(ipaddr_pub) AS ip_pub, access, info, port - FROM nodes WHERE ownerid = 0 AND netdev = ?', array($id)); + FROM nodes + LEFT JOIN ( + SELECT nodeid, '.$this->DB->GroupConcat('mac', ',').' AS mac FROM macs GROUP BY nodeid + ) m ON (nodes.id = m.nodeid) + WHERE ownerid = 0 AND netdev = ?', array($id)); } /* Index: lms/lib/LMSDB_common.class.php diff -u lms/lib/LMSDB_common.class.php:1.52 lms/lib/LMSDB_common.class.php:1.53 --- lms/lib/LMSDB_common.class.php:1.52 Tue Apr 13 19:01:44 2010 +++ lms/lib/LMSDB_common.class.php Thu May 6 22:24:57 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: LMSDB_common.class.php,v 1.52 2010/04/13 17:01:44 alec Exp $ + * $Id: LMSDB_common.class.php,v 1.53 2010/05/06 20:24:57 chilek Exp $ */ /* @@ -31,7 +31,7 @@ Class LMSDB_common { var $_version = '1.11-cvs'; - var $_revision = '$Revision: 1.52 $'; + var $_revision = '$Revision: 1.53 $'; // Driver powinien nadpisać tą zmienną wartością TRUE, żeby // funkcja inicjująca baze danych wiedziała że driver się poprawnie @@ -298,6 +298,10 @@ $this->Execute('SET NAMES ?', array($name)); } + function GroupConcat($field, $separator) + { + return $this->_driver_groupconcat($field, $separator); + } } ?> Index: lms/lib/LMSDB_driver_mysql.class.php diff -u lms/lib/LMSDB_driver_mysql.class.php:1.57 lms/lib/LMSDB_driver_mysql.class.php:1.58 --- lms/lib/LMSDB_driver_mysql.class.php:1.57 Thu Mar 11 14:07:34 2010 +++ lms/lib/LMSDB_driver_mysql.class.php Thu May 6 22:24:57 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: LMSDB_driver_mysql.class.php,v 1.57 2010/03/11 13:07:34 alec Exp $ + * $Id: LMSDB_driver_mysql.class.php,v 1.58 2010/05/06 20:24:57 chilek Exp $ */ /* @@ -42,7 +42,7 @@ return; } - $this->_version .= ' ('.preg_replace('/^.Revision: ([0-9.]+).*/','\1',$this->_revision).'/'.preg_replace('/^.Revision: ([0-9.]+).*/','\1','$Revision: 1.57 $').')'; + $this->_version .= ' ('.preg_replace('/^.Revision: ([0-9.]+).*/','\1',$this->_revision).'/'.preg_replace('/^.Revision: ([0-9.]+).*/','\1','$Revision: 1.58 $').')'; $this->Connect($dbhost, $dbuser, $dbpasswd, $dbname); } @@ -195,6 +195,11 @@ { return $this->GetOne('SELECT LAST_INSERT_ID()'); } + + function _driver_groupconcat($field, $separator) + { + return 'GROUP_CONCAT('.$field.' SEPARATOR \''.$field.'\')'; + } } ?> Index: lms/lib/LMSDB_driver_mysqli.class.php diff -u lms/lib/LMSDB_driver_mysqli.class.php:1.13 lms/lib/LMSDB_driver_mysqli.class.php:1.14 --- lms/lib/LMSDB_driver_mysqli.class.php:1.13 Thu Mar 11 14:07:34 2010 +++ lms/lib/LMSDB_driver_mysqli.class.php Thu May 6 22:24:57 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: LMSDB_driver_mysqli.class.php,v 1.13 2010/03/11 13:07:34 alec Exp $ + * $Id: LMSDB_driver_mysqli.class.php,v 1.14 2010/05/06 20:24:57 chilek Exp $ */ /* @@ -42,7 +42,7 @@ return; } - $this->_version .= ' ('.preg_replace('/^.Revision: ([0-9.]+).*/','\1',$this->_revision).'/'.preg_replace('/^.Revision: ([0-9.]+).*/','\1','$Revision: 1.13 $').'-mysqli)'; + $this->_version .= ' ('.preg_replace('/^.Revision: ([0-9.]+).*/','\1',$this->_revision).'/'.preg_replace('/^.Revision: ([0-9.]+).*/','\1','$Revision: 1.14 $').'-mysqli)'; $this->Connect($dbhost, $dbuser, $dbpasswd, $dbname); } @@ -187,6 +187,11 @@ { return $this->GetOne('SELECT LAST_INSERT_ID()'); } + + function _driver_groupconcat($field, $separator) + { + return 'GROUP_CONCAT('.$field.' SEPARATOR \''.$field.'\')'; + } } ?> Index: lms/lib/LMSDB_driver_postgres.class.php diff -u lms/lib/LMSDB_driver_postgres.class.php:1.49 lms/lib/LMSDB_driver_postgres.class.php:1.50 --- lms/lib/LMSDB_driver_postgres.class.php:1.49 Thu Mar 11 14:07:34 2010 +++ lms/lib/LMSDB_driver_postgres.class.php Thu May 6 22:24:57 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: LMSDB_driver_postgres.class.php,v 1.49 2010/03/11 13:07:34 alec Exp $ + * $Id: LMSDB_driver_postgres.class.php,v 1.50 2010/05/06 20:24:57 chilek Exp $ */ /* @@ -42,7 +42,7 @@ return; } - $this->_version .= ' ('.preg_replace('/^.Revision: ([0-9.]+).*/','\1',$this->_revision).'/'.preg_replace('/^.Revision: ([0-9.]+).*/','\1','$Revision: 1.49 $').')'; + $this->_version .= ' ('.preg_replace('/^.Revision: ([0-9.]+).*/','\1',$this->_revision).'/'.preg_replace('/^.Revision: ([0-9.]+).*/','\1','$Revision: 1.50 $').')'; $this->Connect($dbhost,$dbuser,$dbpasswd,$dbname); } @@ -196,6 +196,11 @@ { return $this->GetOne('SELECT currval(\''.$table.'_id_seq\')'); } + + function _driver_groupconcat($field, $separator) + { + return 'array_to_string(array_agg('.$field.'), \''.$separator.'\')'; + } } ?> Index: lms/lib/upgradedb.php diff -u lms/lib/upgradedb.php:1.172 lms/lib/upgradedb.php:1.173 --- lms/lib/upgradedb.php:1.172 Thu Mar 11 14:07:34 2010 +++ lms/lib/upgradedb.php Thu May 6 22:24:57 2010 @@ -21,10 +21,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: upgradedb.php,v 1.172 2010/03/11 13:07:34 alec Exp $ + * $Id: upgradedb.php,v 1.173 2010/05/06 20:24:57 chilek Exp $ */ -define('DBVERSION', '2010031100'); // here should be always the newest version of database! +define('DBVERSION', '2010050600'); // here should be always the newest version of database! // it placed here to avoid read disk every time when we call this file. /* From cvs w lms.org.pl Thu May 6 22:24:57 2010 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 6 May 2010 22:24:57 +0200 (CEST) Subject: [lms-commits] CVS update of lms/lib/locale/pl (strings.php) Message-ID: <20100506202457.CEAB33027B29@hydra.altec.pl> Date: Thursday, May 6, 2010 @ 22:24:57 Author: chilek Path: /cvsroot/lms/lib/locale/pl Modified: strings.php - we can bind many macs to one node (chilan) Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/lib/locale/pl/strings.php.diff?&r1=1.355&r2=1.356 Index: lms/lib/locale/pl/strings.php diff -u lms/lib/locale/pl/strings.php:1.355 lms/lib/locale/pl/strings.php:1.356 --- lms/lib/locale/pl/strings.php:1.355 Fri Apr 9 19:01:32 2010 +++ lms/lib/locale/pl/strings.php Thu May 6 22:24:57 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: strings.php,v 1.355 2010/04/09 17:01:32 alec Exp $ + * $Id: strings.php,v 1.356 2010/05/06 20:24:57 chilek Exp $ */ $_LANG['$0 ($1 addresses)'] = '$0 ($1 adresów)'; @@ -2369,5 +2369,6 @@ $_LANG['Select algorithm used to generate the fingerprint'] = 'Wybierz algorytm użyty do wygenerowania odcisku klucza'; $_LANG['Select algorithm of the public key'] = 'Wybierz algorytm klucza publicznego'; $_LANG['Weight:'] = 'Ważność:'; +$_LANG['Add MAC address'] = 'Dodaj adres MAC'; ?> From cvs w lms.org.pl Thu May 6 22:24:57 2010 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 6 May 2010 22:24:57 +0200 (CEST) Subject: [lms-commits] CVS update of lms/modules (nodeadd.php, nodeedit.php, quicksearch.php) Message-ID: <20100506202458.011EB3027B2B@hydra.altec.pl> Date: Thursday, May 6, 2010 @ 22:24:57 Author: chilek Path: /cvsroot/lms/modules Modified: nodeadd.php nodeedit.php quicksearch.php - we can bind many macs to one node (chilan) Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/modules/nodeadd.php.diff?&r1=1.91&r2=1.92 http://cvs.lms.org.pl/viewvc/Development/lms/modules/nodeedit.php.diff?&r1=1.110&r2=1.111 http://cvs.lms.org.pl/viewvc/Development/lms/modules/quicksearch.php.diff?&r1=1.65&r2=1.66 Index: lms/modules/nodeadd.php diff -u lms/modules/nodeadd.php:1.91 lms/modules/nodeadd.php:1.92 --- lms/modules/nodeadd.php:1.91 Thu Mar 11 14:07:47 2010 +++ lms/modules/nodeadd.php Thu May 6 22:24:57 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: nodeadd.php,v 1.91 2010/03/11 13:07:47 alec Exp $ + * $Id: nodeadd.php,v 1.92 2010/05/06 20:24:57 chilek Exp $ */ $nodedata['access'] = 1; @@ -43,22 +43,24 @@ $nodedata['ipaddr'] = $_GET['preip']; if(isset($_GET['premac'])) - $nodedata['mac'] = $_GET['premac']; + $nodedata['macs'][] = $_GET['premac']; if(isset($_GET['prename'])) $nodedata['name'] = $_GET['prename']; -if(isset($_POST['nodedata'])) +if(isset($_POST['nodedata']) && !isset($_GET['newmac'])) { $nodedata = $_POST['nodedata']; $nodedata['ipaddr'] = $_POST['nodedataipaddr']; $nodedata['ipaddr_pub'] = $_POST['nodedataipaddr_pub']; - $nodedata['mac'] = $_POST['nodedatamac']; - $nodedata['mac'] = str_replace('-',':',$nodedata['mac']); + $nodedata['macs'] = $_POST['nodedata']['macs']; + foreach($nodedata['macs'] as $key => $value) + $nodedata['macs'][$key] = str_replace('-',':',$value); foreach($nodedata as $key => $value) - $nodedata[$key] = trim($value); + if($key != 'macs') + $nodedata[$key] = trim($value); if($nodedata['ipaddr']=='' && $nodedata['ipaddr_pub'] && $nodedata['mac']=='' && $nodedata['name']=='') if($_GET['ownerid']) @@ -102,13 +104,22 @@ else $nodedata['ipaddr_pub'] = '0.0.0.0'; - if(!$nodedata['mac']) + $macs = array(); + foreach($nodedata['macs'] as $key => $value) + if(check_mac($value)) + { + if($value!='00:00:00:00:00:00' && (!isset($CONFIG['phpui']['allow_mac_sharing']) || !chkconfig($CONFIG['phpui']['allow_mac_sharing']))) + { + if($LMS->GetNodeIDByMAC($value)) + $error['mac'.$key] = trans('Specified MAC address is in use!'); + } + $macs[] = $value; + } + elseif($value!='') + $error['mac'.$key] = trans('Incorrect MAC address!'); + if(empty($macs)) $error['mac'] = trans('MAC address is required!'); - elseif(!check_mac($nodedata['mac'])) - $error['mac'] = trans('Incorrect MAC address!'); - elseif($nodedata['mac']!='00:00:00:00:00:00' && (!isset($CONFIG['phpui']['allow_mac_sharing']) || !chkconfig($CONFIG['phpui']['allow_mac_sharing']))) - if($LMS->GetNodeIDByMAC($nodedata['mac'])) - $error['mac'] = trans('Specified MAC address is in use!'); + $nodedata['macs'] = $macs; if(strlen($nodedata['passwd']) > 32) $error['passwd'] = trans('Password is too long (max.32 characters)!'); @@ -179,6 +190,18 @@ if($nodedata['ipaddr_pub']=='0.0.0.0') $nodedata['ipaddr_pub'] = ''; } +else +{ + if(isset($_POST['nodedata']) && isset($_GET['newmac'])) + { + $nodedata = $_POST['nodedata']; + $nodedata['ipaddr'] = $_POST['nodedataipaddr']; + $nodedata['ipaddr_pub'] = $_POST['nodedataipaddr_pub']; + $nodedata['macs'][] = ''; + } + elseif(empty($nodedata['macs'])) + $nodedata['macs'][] = ''; +} $layout['pagetitle'] = trans('New Node'); Index: lms/modules/nodeedit.php diff -u lms/modules/nodeedit.php:1.110 lms/modules/nodeedit.php:1.111 --- lms/modules/nodeedit.php:1.110 Thu Mar 11 14:07:47 2010 +++ lms/modules/nodeedit.php Thu May 6 22:24:57 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: nodeedit.php,v 1.110 2010/03/11 13:07:47 alec Exp $ + * $Id: nodeedit.php,v 1.111 2010/05/06 20:24:57 chilek Exp $ */ $action = isset($_GET['action']) ? $_GET['action'] : ''; @@ -62,6 +62,11 @@ $customerid = $LMS->GetNodeOwner($nodeid); $nodeinfo = $LMS->GetNode($nodeid); +$macs = array(); +foreach($nodeinfo['macs'] as $key => $value) + $macs[] = $nodeinfo['macs'][$key]['mac']; +$nodeinfo['macs'] = $macs; + if(!isset($_GET['ownerid'])) $SESSION->save('backto', $SESSION->get('backto') . '&ownerid='.$customerid); else @@ -69,18 +74,21 @@ $layout['pagetitle'] = trans('Node Edit: $0', $nodeinfo['name']); -if(isset($_POST['nodeedit'])) +if(isset($_POST['nodeedit']) && !isset($_GET['newmac'])) { $nodeedit = $_POST['nodeedit']; $nodeedit['ipaddr'] = $_POST['nodeeditipaddr']; $nodeedit['ipaddr_pub'] = $_POST['nodeeditipaddrpub']; - $nodeedit['mac'] = $_POST['nodeeditmac']; - $nodeedit['mac'] = str_replace('-',':',$nodeedit['mac']); + $nodeedit['macs'] = $_POST['nodeedit']['macs']; + foreach($nodeedit['macs'] as $key => $value) + $nodeedit['macs'][$key] = str_replace('-',':',$value); + foreach($nodeedit as $key => $value) - $nodeedit[$key] = trim($value); - - if($nodeedit['ipaddr']=='' && $nodeedit['ipaddr_pub']=='' && $nodeedit['mac']=='' && $nodeedit['name']=='' && $nodeedit['info']=='' && $nodeedit['passwd']=='') + if($key != 'macs') + $nodeedit[$key] = trim($value); + + if($nodeedit['ipaddr']=='' && $nodeedit['ipaddr_pub']=='' && empty($nodeedit['macs']) && $nodeedit['name']=='' && $nodeedit['info']=='' && $nodeedit['passwd']=='') { $SESSION->redirect('?m=nodeinfo&id='.$nodeedit['id']); } @@ -122,16 +130,22 @@ else $nodeedit['ipaddr_pub'] = '0.0.0.0'; - if(check_mac($nodeedit['mac'])) - { - if($nodeedit['mac']!='00:00:00:00:00:00' && (!isset($CONFIG['phpui']['allow_mac_sharing']) || !chkconfig($CONFIG['phpui']['allow_mac_sharing']))) + $macs = array(); + foreach($nodeedit['macs'] as $key => $value) + if(check_mac($value)) { - if($nodeinfo['mac'] != $nodeedit['mac'] && $LMS->GetNodeIDByMAC($nodeedit['mac'])) - $error['mac'] = trans('Specified MAC address is in use!'); + if($value!='00:00:00:00:00:00' && (!isset($CONFIG['phpui']['allow_mac_sharing']) || !chkconfig($CONFIG['phpui']['allow_mac_sharing']))) + { + if(($nodeid = $LMS->GetNodeIDByMAC($value)) != NULL && $nodeid != $nodeinfo['id']) + $error['mac'.$key] = trans('Specified MAC address is in use!'); + } + $macs[] = $value; } - } - else - $error['mac'] = trans('Incorrect MAC address!'); + elseif($value!='') + $error['mac'.$key] = trans('Incorrect MAC address!'); + if(empty($macs)) + $error['mac0'] = trans('MAC address is required!'); + $nodeedit['macs'] = $macs; if($nodeedit['name']=='') $error['name'] = trans('Node name is required!'); @@ -189,11 +203,10 @@ { $LMS->NodeUpdate($nodeedit, ($customerid != $nodeedit['ownerid'])); $SESSION->redirect('?m=nodeinfo&id='.$nodeedit['id']); - die; } $nodeinfo['name'] = $nodeedit['name']; - $nodeinfo['mac'] = $nodeedit['mac']; + $nodeinfo['macs'] = $nodeedit['macs']; $nodeinfo['ip'] = $nodeedit['ipaddr']; $nodeinfo['ip_pub'] = $nodeedit['ipaddr_pub']; $nodeinfo['passwd'] = $nodeedit['passwd']; @@ -206,6 +219,18 @@ if($nodeedit['ipaddr_pub']=='0.0.0.0') $nodeinfo['ipaddr_pub'] = ''; } +else +{ +// print_r($nodeinfo['macs']);die; + if(isset($_POST['nodeedit']) && isset($_GET['newmac'])) + { + $nodeedit = $_POST['nodeedit']; + $nodeedit['macs'][] = ''; + $nodeinfo = array_merge($nodeinfo, $nodeedit); + } + elseif(empty($nodeinfo['macs'])) + $nodeinfo['macs'][] = ''; +} include(MODULES_DIR.'/customer.inc.php'); Index: lms/modules/quicksearch.php diff -u lms/modules/quicksearch.php:1.65 lms/modules/quicksearch.php:1.66 --- lms/modules/quicksearch.php:1.65 Thu Mar 11 14:07:48 2010 +++ lms/modules/quicksearch.php Thu May 6 22:24:57 2010 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: quicksearch.php,v 1.65 2010/03/11 13:07:48 alec Exp $ + * $Id: quicksearch.php,v 1.66 2010/05/06 20:24:57 chilek Exp $ */ function macformat($mac) @@ -139,13 +139,16 @@ case 'node': if(isset($_GET['ajax'])) // support for AutoSuggest { - $candidates = $DB->GetAll('SELECT n.id, n.name, INET_NTOA(ipaddr) as ip, INET_NTOA(ipaddr_pub) AS ip_pub, mac - FROM nodes n + $candidates = $DB->GetAll('SELECT n.id, n.name, INET_NTOA(ipaddr) as ip, INET_NTOA(ipaddr_pub) AS ip_pub, m.mac AS mac + FROM nodes n + LEFT JOIN ( + SELECT nodeid, '.$DB->GroupConcat('mac', ',').' AS mac FROM macs GROUP BY nodeid + ) m ON (n.id = m.nodeid) WHERE ('.(preg_match('/^[0-9]+$/',$search) ? 'n.id = '.intval($search).' OR ' : '').' LOWER(n.name) ?LIKE? LOWER(\'%'.$search.'%\') OR INET_NTOA(ipaddr) ?LIKE? \'%'.$search.'%\' OR INET_NTOA(ipaddr_pub) ?LIKE? \'%'.$search.'%\' - OR LOWER(mac) ?LIKE? LOWER(\'%'.macformat($search).'%\') + OR LOWER(m.mac) ?LIKE? LOWER(\'%'.macformat($search).'%\') ) AND NOT EXISTS ( SELECT 1 FROM customerassignments a From cvs w lms.org.pl Thu May 6 22:24:58 2010 From: cvs w lms.org.pl (LMS CVS) Date: Thu, 6 May 2010 22:24:58 +0200 (CEST) Subject: [lms-commits] CVS update of lms/templates (4 files) Message-ID: <20100506202458.3A7173027B2C@hydra.altec.pl> Date: Thursday, May 6, 2010 @ 22:24:58 Author: chilek Path: /cvsroot/lms/templates Modified: nodeaddbox.html nodeeditbox.html nodeinfobox.html nodelist.html - we can bind many macs to one node (chilan) Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/templates/nodeaddbox.html.diff?&r1=1.78&r2=1.79 http://cvs.lms.org.pl/viewvc/Development/lms/templates/nodeeditbox.html.diff?&r1=1.82&r2=1.83 http://cvs.lms.org.pl/viewvc/Development/lms/templates/nodeinfobox.html.diff?&r1=1.71&r2=1.72 http://cvs.lms.org.pl/viewvc/Development/lms/templates/nodelist.html.diff?&r1=1.102&r2=1.103 Index: lms/templates/nodeaddbox.html diff -u lms/templates/nodeaddbox.html:1.78 lms/templates/nodeaddbox.html:1.79 --- lms/templates/nodeaddbox.html:1.78 Fri Nov 13 10:33:06 2009 +++ lms/templates/nodeaddbox.html Thu May 6 22:24:58 2010 @@ -1,4 +1,4 @@ - +
@@ -38,8 +38,15 @@ - @@ -184,6 +191,12 @@ document.forms['nodeadd'].elements['nodedata[passwd]'].value = passwd.join(""); } + + function newmac() + { + document.nodeadd.action += '&newmac=1'; + document.nodeadd.submit(); + } //--> {/literal} Index: lms/templates/nodeeditbox.html diff -u lms/templates/nodeeditbox.html:1.82 lms/templates/nodeeditbox.html:1.83 --- lms/templates/nodeeditbox.html:1.82 Fri Nov 13 10:33:06 2009 +++ lms/templates/nodeeditbox.html Thu May 6 22:24:58 2010 @@ -1,4 +1,4 @@ - + @@ -39,7 +39,14 @@ {t}MAC address:{/t} @@ -186,6 +193,12 @@ document.forms['editnode'].elements['nodeedit[passwd]'].value = passwd.join(""); } + + function newmac() + { + document.editnode.action += '&newmac=1'; + document.editnode.submit(); + } //--> {/literal} Index: lms/templates/nodeinfobox.html diff -u lms/templates/nodeinfobox.html:1.71 lms/templates/nodeinfobox.html:1.72 --- lms/templates/nodeinfobox.html:1.71 Mon Mar 8 10:59:21 2010 +++ lms/templates/nodeinfobox.html Thu May 6 22:24:58 2010 @@ -1,4 +1,4 @@ - + {/literal} Index: lms/templates/netdevipbox.html diff -u lms/templates/netdevipbox.html:1.19 lms/templates/netdevipbox.html:1.20 --- lms/templates/netdevipbox.html:1.19 Thu Dec 10 15:43:36 2009 +++ lms/templates/netdevipbox.html Fri May 7 14:22:31 2010 @@ -1,4 +1,4 @@ - +
{t}MAC address:{/t} - »»» + + + {foreach from=$nodedata.macs item=item key=key} + + + {/foreach} +
»»» +
+ {t}Add MAC address{/t} »»»
- »»» + + {foreach from=$nodeinfo.macs item=item key=key} + + + + {/foreach} +
»»»
+ {t}Add MAC address{/t} »»»
@@ -13,16 +13,17 @@ - + + {if $netdevips} {cycle values="light,lucid" print=false} {section name=list loop=$netdevips} - + - {/if} - Index: lms/templates/netdevipeditbox.html diff -u lms/templates/netdevipeditbox.html:1.29 lms/templates/netdevipeditbox.html:1.30 --- lms/templates/netdevipeditbox.html:1.29 Fri Nov 13 10:33:06 2009 +++ lms/templates/netdevipeditbox.html Fri May 7 14:22:31 2010 @@ -1,4 +1,4 @@ - + @@ -58,7 +58,14 @@ {t}MAC:{/t} @@ -171,6 +178,12 @@ } document.forms['editipaddr'].elements['ipadd[passwd]'].value = passwd.join(""); - } + } + + function newmac() + { + document.editipaddr.action += '&newmac=1'; + document.editipaddr.submit(); + } {/literal} Index: lms/templates/netdevipinfobox.html diff -u lms/templates/netdevipinfobox.html:1.19 lms/templates/netdevipinfobox.html:1.20 --- lms/templates/netdevipinfobox.html:1.19 Thu Dec 10 15:43:36 2009 +++ lms/templates/netdevipinfobox.html Fri May 7 14:22:31 2010 @@ -1,4 +1,4 @@ - + Index: lms/modules/core/templates/err_loginform.html diff -u lms/modules/core/templates/err_loginform.html:1.8 lms/modules/core/templates/err_loginform.html:1.9 --- lms/modules/core/templates/err_loginform.html:1.8 Thu Mar 11 14:07:51 2010 +++ lms/modules/core/templates/err_loginform.html Mon May 24 09:43:17 2010 @@ -1,10 +1,10 @@ - + - - + +::: {t}Welcome to LMS{/t} {$layout.lmsv} ::: @@ -56,7 +56,7 @@


- {t}Documentation{/t}
+ {t}Documentation{/t}
{t}LMS Project Homepage{/t} Index: lms/modules/core/templates/header.html diff -u lms/modules/core/templates/header.html:1.1 lms/modules/core/templates/header.html:1.2 --- lms/modules/core/templates/header.html:1.1 Sat Nov 5 14:28:25 2005 +++ lms/modules/core/templates/header.html Mon May 24 09:43:17 2010 @@ -1,11 +1,11 @@ - + - - + +::: LMS :{if $layout.pagetitle neq ""} {$layout.pagetitle|striphtml} :{/if}:: Index: lms/modules/core/templates/login.html diff -u lms/modules/core/templates/login.html:1.9 lms/modules/core/templates/login.html:1.10 --- lms/modules/core/templates/login.html:1.9 Thu Mar 11 14:07:51 2010 +++ lms/modules/core/templates/login.html Mon May 24 09:43:17 2010 @@ -1,10 +1,10 @@ - + - - + +::: {t}Welcome to LMS{/t} {$layout.lmsv} ::: @@ -56,7 +56,7 @@


- {t}Documentation{/t}
+ {t}Documentation{/t}
{t}LMS Project Homepage{/t} From cvs w lms.org.pl Mon May 24 09:43:18 2010 From: cvs w lms.org.pl (LMS CVS) Date: Mon, 24 May 2010 09:43:18 +0200 (CEST) Subject: [lms-commits] CVS update of lms/templates (17 files) Message-ID: <20100524074318.5EF143027B29@hydra.altec.pl> Date: Monday, May 24, 2010 @ 09:43:18 Author: chilek Path: /cvsroot/lms/templates Modified: calendar.html choosecustomer.html chooseip.html choosemac.html choosenode.html clearheader.html customerinfoshort.html dynpopup.html header.html invoiceheader.html login.html nodegrouplistshort.html nodelistshort.html noteheader.html receiptheader.html rtticketinfoshort.html trafficgraph.html - language -> ui_language Diff URLs: http://cvs.lms.org.pl/viewvc/Development/lms/templates/calendar.html.diff?&r1=1.8&r2=1.9 http://cvs.lms.org.pl/viewvc/Development/lms/templates/choosecustomer.html.diff?&r1=1.6&r2=1.7 http://cvs.lms.org.pl/viewvc/Development/lms/templates/chooseip.html.diff?&r1=1.35&r2=1.36 http://cvs.lms.org.pl/viewvc/Development/lms/templates/choosemac.html.diff?&r1=1.18&r2=1.19 http://cvs.lms.org.pl/viewvc/Development/lms/templates/choosenode.html.diff?&r1=1.1&r2=1.2 http://cvs.lms.org.pl/viewvc/Development/lms/templates/clearheader.html.diff?&r1=1.18&r2=1.19 http://cvs.lms.org.pl/viewvc/Development/lms/templates/customerinfoshort.html.diff?&r1=1.17&r2=1.18 http://cvs.lms.org.pl/viewvc/Development/lms/templates/dynpopup.html.diff?&r1=1.5&r2=1.6 http://cvs.lms.org.pl/viewvc/Development/lms/templates/header.html.diff?&r1=1.128&r2=1.129 http://cvs.lms.org.pl/viewvc/Development/lms/templates/invoiceheader.html.diff?&r1=1.3&r2=1.4 http://cvs.lms.org.pl/viewvc/Development/lms/templates/login.html.diff?&r1=1.56&r2=1.57 http://cvs.lms.org.pl/viewvc/Development/lms/templates/nodegrouplistshort.html.diff?&r1=1.2&r2=1.3 http://cvs.lms.org.pl/viewvc/Development/lms/templates/nodelistshort.html.diff?&r1=1.16&r2=1.17 http://cvs.lms.org.pl/viewvc/Development/lms/templates/noteheader.html.diff?&r1=1.2&r2=1.3 http://cvs.lms.org.pl/viewvc/Development/lms/templates/receiptheader.html.diff?&r1=1.2&r2=1.3 http://cvs.lms.org.pl/viewvc/Development/lms/templates/rtticketinfoshort.html.diff?&r1=1.2&r2=1.3 http://cvs.lms.org.pl/viewvc/Development/lms/templates/trafficgraph.html.diff?&r1=1.2&r2=1.3 Index: lms/templates/calendar.html diff -u lms/templates/calendar.html:1.8 lms/templates/calendar.html:1.9 --- lms/templates/calendar.html:1.8 Thu Nov 6 15:02:59 2008 +++ lms/templates/calendar.html Mon May 24 09:43:17 2010 @@ -1,9 +1,9 @@ - + - - + +::: LMS : {t}Select Date{/t} ::: {literal} Index: lms/templates/choosecustomer.html diff -u lms/templates/choosecustomer.html:1.6 lms/templates/choosecustomer.html:1.7 --- lms/templates/choosecustomer.html:1.6 Fri Oct 16 10:45:55 2009 +++ lms/templates/choosecustomer.html Mon May 24 09:43:17 2010 @@ -1,9 +1,9 @@ - + - - + +::: LMS :{if $layout.pagetitle neq ""} {$layout.pagetitle} :{/if}:: Index: lms/templates/chooseip.html diff -u lms/templates/chooseip.html:1.35 lms/templates/chooseip.html:1.36 --- lms/templates/chooseip.html:1.35 Tue Nov 10 15:01:07 2009 +++ lms/templates/chooseip.html Mon May 24 09:43:17 2010 @@ -1,9 +1,9 @@ - + - - + +::: LMS :{if $layout.pagetitle neq ""} {$layout.pagetitle} :{/if}:: Index: lms/templates/choosemac.html diff -u lms/templates/choosemac.html:1.18 lms/templates/choosemac.html:1.19 --- lms/templates/choosemac.html:1.18 Thu Nov 6 15:02:59 2008 +++ lms/templates/choosemac.html Mon May 24 09:43:17 2010 @@ -1,9 +1,9 @@ - + - - + +::: LMS :{if $layout.pagetitle neq ""} {$layout.pagetitle} :{/if}:: Index: lms/templates/choosenode.html diff -u lms/templates/choosenode.html:1.1 lms/templates/choosenode.html:1.2 --- lms/templates/choosenode.html:1.1 Wed Aug 30 11:03:14 2006 +++ lms/templates/choosenode.html Mon May 24 09:43:17 2010 @@ -1,9 +1,9 @@ - + - - + +::: LMS :{if $layout.pagetitle neq ""} {$layout.pagetitle} :{/if}:: Index: lms/templates/clearheader.html diff -u lms/templates/clearheader.html:1.18 lms/templates/clearheader.html:1.19 --- lms/templates/clearheader.html:1.18 Mon Apr 19 12:56:15 2010 +++ lms/templates/clearheader.html Mon May 24 09:43:18 2010 @@ -1,10 +1,10 @@ - + - - + +::: LMS :{if $layout.pagetitle neq ""} {$layout.pagetitle} :{/if}:: Index: lms/templates/customerinfoshort.html diff -u lms/templates/customerinfoshort.html:1.17 lms/templates/customerinfoshort.html:1.18 --- lms/templates/customerinfoshort.html:1.17 Mon Dec 14 15:35:03 2009 +++ lms/templates/customerinfoshort.html Mon May 24 09:43:18 2010 @@ -1,9 +1,9 @@ - + - - + +::: LMS ::: Index: lms/templates/dynpopup.html diff -u lms/templates/dynpopup.html:1.5 lms/templates/dynpopup.html:1.6 --- lms/templates/dynpopup.html:1.5 Thu Nov 6 15:02:59 2008 +++ lms/templates/dynpopup.html Mon May 24 09:43:18 2010 @@ -1,10 +1,10 @@ - + - - + +::: LMS ::: Index: lms/templates/header.html diff -u lms/templates/header.html:1.128 lms/templates/header.html:1.129 --- lms/templates/header.html:1.128 Thu Mar 11 14:07:52 2010 +++ lms/templates/header.html Mon May 24 09:43:18 2010 @@ -1,12 +1,12 @@ - +::: LMS :{if $layout.pagetitle neq ""} {$layout.pagetitle|striphtml} :{/if}:: - - + + Index: lms/templates/invoiceheader.html diff -u lms/templates/invoiceheader.html:1.3 lms/templates/invoiceheader.html:1.4 --- lms/templates/invoiceheader.html:1.3 Mon Apr 19 12:56:15 2010 +++ lms/templates/invoiceheader.html Mon May 24 09:43:18 2010 @@ -1,10 +1,10 @@ - + - - + +::: LMS :{if $layout.pagetitle neq ""} {$layout.pagetitle} :{/if}::
{t}Name:{/t}{t}Name:{/t} {t}ID:{/t} {t}Address:{/t}{t}MAC:{/t}  
+ {$netdevips[list].name} {if $netdevips[list].location}
{$netdevips[list].info|truncate:50:"...":true} @@ -32,7 +33,10 @@ ({$netdevips[list].id|string_format:"%04d"})
- {$netdevips[list].ip}{if $netdevips[list].ip_pub!="0.0.0.0"} ({$netdevips[list].ip_pub}){/if} / {$netdevips[list].mac}
+ {$netdevips[list].ip}{if $netdevips[list].ip_pub!="0.0.0.0"} ({$netdevips[list].ip_pub}){/if}
+
+ {$netdevips[list].mac|replace:",":"
"}
@@ -44,7 +48,7 @@ {/section} {else}
+

 

{t}No IP addresses on device.{/t}

 

@@ -52,7 +56,7 @@
+ {t}Connect{/t}/{t}Disconnect{/t} - »»» + + {foreach from=$nodeipdata.macs item=item key=key} + + + {/foreach} +
»»» +
+ {t}Add MAC address{/t} »»»