Search
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
pfSense
All Projects
pfSense
Overview
Activity
Roadmap
Issues
Download (692 Bytes)
Feature #403
» dhcpd-leases.php
znerol znerol
, 03/06/2010 05:22 AM
<?php
function
parse_dhcpd_leases
(
$path
)
{
$keys
=
array
(
"starts"
,
"ends"
,
"binding state"
,
"client-hostname"
);
$leases
=
array
();
$fd
=
fopen
(
$path
,
"r"
);
$entry
=
NULL
;
while
(
!
feof
(
$fd
))
{
# ignore empty lines and comments
list
(
$line
,
$ignored
)
=
explode
(
"#"
,
$line
,
1
);
$line
=
trim
(
fgets
(
$fd
));
if
(
strlen
(
$line
)
==
0
)
{
continue
;
}
if
(
1
==
sscanf
(
$line
,
"lease %s {"
,
$ip
))
{
$leases
[
$ip
]
=
array
();
$entry
=
&
$leases
[
$ip
];
continue
;
}
if
(
$line
==
"}"
)
{
unset
(
$entry
);
continue
;
}
foreach
(
$keys
as
$key
)
{
if
(
1
==
sscanf
(
$line
,
$key
.
" %[^;];"
,
$val
))
{
$entry
[
$key
]
=
trim
(
$val
,
'"'
);
break
;
}
}
}
return
$leases
;
}
« Previous
1
2
3
…
5
Next »
(1-1/5)
Loading...