Search
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
pfSense
All Projects
pfSense
Overview
Activity
Roadmap
Issues
Download (745 Bytes)
Feature #403
» monitor-poll.php
znerol znerol
, 03/06/2010 05:22 AM
<?php
class
watchpath
{
function
__construct
(
$path
,
$interval
)
{
$this
->
path
=
$path
;
$this
->
interval
=
$interval
;
$this
->
last
=
time
();
}
function
wait
()
{
while
(
true
)
{
sleep
(
$this
->
interval
);
clearstatcache
();
if
(
FALSE
==
(
$stat
=
stat
(
$this
->
path
)))
{
continue
;
}
$ctime
=
$stat
[
10
];
if
(
$ctime
<=
$this
->
last
)
{
continue
;
}
$this
->
last
=
$ctime
;
break
;
}
}
}
function
printfile
(
$path
)
{
$lines
=
file
(
$path
);
echo
(
"
\n
*** "
.
$path
.
"@"
.
$ctime
.
" ***
\n
"
);
foreach
(
$lines
as
$num
=>
$line
)
{
echo
(
$line
);
}
}
$path
=
"/tmp/test.txt"
;
$seconds
=
1
;
printfile
(
$path
);
$watchdog
=
new
watchpath
(
$path
,
$seconds
);
while
(
true
)
{
$watchdog
->
wait
();
printfile
(
$path
);
}
?>
« Previous
1
2
3
4
5
Next »
(3-3/5)
Loading...