Discussion:
get file from directory.
hadi
2014-06-23 18:17:43 UTC
Permalink
Can someone help.

How to get specific file from directory.

Thank you.
Daniel Brown
2014-06-23 18:23:36 UTC
Permalink
Post by hadi
Can someone help.
How to get specific file from directory.
With just one hand. Despite how it appears, the opening is
actually too small for two at the same time. This is a regression
introduced in PHP 3.14.15926535 that has yet to be properly addressed.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-06-23 18:37:29 UTC
Permalink
Post by hadi
Can someone help.
How to get specific file from directory.
Thank you.
If you know the directory and you know the filename, why do a search at
all? Just open it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
hadi
2014-06-23 19:10:44 UTC
Permalink
Post by Jim Giner
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
Here is my problem I want to search a directory and get file match "$ip"
variable as mention in my code.

Can this be done.
Post by Jim Giner
<?php
function timeout($username, $ip)
{
$iplookup = glob('/var/log/phplogs/iplogs/');
foreach(glob('/tmp/sess*') as $file) {
if (time()- filemtime($ip) > 60)
{
$old = "$username";
$content = file_get_contents($file);
if(strpos($content, $old) !== false) {
unlink($file);
}
}
}
}
?>
Can someone help.
How to get specific file from directory.
Thank you.
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
--
http://www.php.net/unsub.php
Jim Lucas
2014-06-23 19:14:44 UTC
Permalink
Post by hadi
Post by Jim Giner
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
Here is my problem I want to search a directory and get file match "$ip"
variable as mention in my code.
Can this be done.
Does $ip represent the entire file name or is it a partial file name?
Post by hadi
Post by Jim Giner
<?php
function timeout($username, $ip)
{
$iplookup = glob('/var/log/phplogs/iplogs/');
foreach(glob('/tmp/sess*') as $file) {
if (time()- filemtime($ip) > 60)
{
$old = "$username";
$content = file_get_contents($file);
if(strpos($content, $old) !== false) {
unlink($file);
}
}
}
}
?>
Can someone help.
How to get specific file from directory.
Thank you.
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
--
http://www.php.net/unsub.php
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
hadi
2014-06-23 19:27:28 UTC
Permalink
Post by Jim Lucas
Does $ip represent the entire file name or is it a partial file name?
$ip getting passed to the function with the system ip.
I have files with system ips names in directory. Ip name of file.
I want my code to get the ip which already done and match it with directory
which not done. Can you do it according to my code.
Post by Jim Lucas
Post by hadi
Post by Jim Giner
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
Here is my problem I want to search a directory and get file match "$ip"
variable as mention in my code.
Can this be done.
Does $ip represent the entire file name or is it a partial file name?
Post by hadi
Post by Jim Giner
<?php
function timeout($username, $ip)
{
$iplookup = glob('/var/log/phplogs/iplogs/');
foreach(glob('/tmp/sess*') as $file) {
if (time()- filemtime($ip) > 60)
{
$old = "$username";
$content = file_get_contents($file);
if(strpos($content, $old) !== false) {
unlink($file);
}
}
}
}
?>
Can someone help.
How to get specific file from directory.
Thank you.
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
--
http://www.php.net/unsub.php
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
Jim Lucas
2014-06-23 19:35:24 UTC
Permalink
Post by hadi
Post by Jim Lucas
Does $ip represent the entire file name or is it a partial file name?
$ip getting passed to the function with the system ip.
I have files with system ips names in directory. Ip name of file.
I want my code to get the ip which already done and match it with directory
which not done. Can you do it according to my code.
So, $ip would be something like '1.1.1.1' ?

So, are you trying to find something like this?
/var/log/phplogs/1.1.1.1/files...

or like this?
/var/log/phplogs/iplogs/1.1.1.1 <- 1.1.1.1 being the actual file?


If $ip is your full file name, then do this:

if ( file_exists('/var/log/phplogs/iplogs/' . $ip ) ) {
echo 'file found, now do something...';
}



Here are a few things you need to understand as well.

Read this: http://www.php.net//manual/en/function.glob.php It will help you
better understand how to use this function.

If you do this: print_r(glob("/tmp/"));
You get this: Array
(
[0] => /tmp/
)

But, if you do this: print_r(glob("/tmp/*"));
You get the listing from the directory of all files and folders.
Post by hadi
Post by Jim Lucas
Post by hadi
Post by Jim Giner
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
Here is my problem I want to search a directory and get file match "$ip"
variable as mention in my code.
Can this be done.
Does $ip represent the entire file name or is it a partial file name?
Post by hadi
Post by Jim Giner
<?php
function timeout($username, $ip)
{
$iplookup = glob('/var/log/phplogs/iplogs/');
foreach(glob('/tmp/sess*') as $file) {
if (time()- filemtime($ip) > 60)
{
$old = "$username";
$content = file_get_contents($file);
if(strpos($content, $old) !== false) {
unlink($file);
}
}
}
}
?>
Can someone help.
How to get specific file from directory.
Thank you.
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
--
http://www.php.net/unsub.php
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
hadi
2014-06-23 19:48:49 UTC
Permalink
or like this?
/var/log/phplogs/iplogs/1.1.1.1 <- 1.1.1.1 being the actual file?

Yes $ip its being the file name.
What is my problem here all ip file set in /var/www/html/myproject <-----.
I need to move them to different place instead.

But if you see my code " if (time()- filemtime($ip) > 60)" read ip file
residing in /var/www/html/myproject.
I need " if (time()- filemtime($ip) > 60)" to look for ip file in different
directory. But also keep in mind "$ip" variable itself being passed to the
function here " function timeout($username, $ip)"

How can I ask " if (time()- filemtime($ip) > 60)" to look for ip files in
different folder.
-----Original Message-----
Sent: Monday, June 23, 2014 10:35 PM
Subject: Re: [PHP] Re: get file from directory.
Post by hadi
Post by Jim Lucas
Does $ip represent the entire file name or is it a partial file name?
$ip getting passed to the function with the system ip.
I have files with system ips names in directory. Ip name of file.
I want my code to get the ip which already done and match it with
directory which not done. Can you do it according to my code.
So, $ip would be something like '1.1.1.1' ?
So, are you trying to find something like this?
/var/log/phplogs/1.1.1.1/files...
or like this?
/var/log/phplogs/iplogs/1.1.1.1 <- 1.1.1.1 being the actual file?
if ( file_exists('/var/log/phplogs/iplogs/' . $ip ) ) {
echo 'file found, now do something...';
}
Here are a few things you need to understand as well.
Read this: http://www.php.net//manual/en/function.glob.php It will help
you better understand how to use this function.
If you do this: print_r(glob("/tmp/"));
You get this: Array
(
[0] => /tmp/
)
But, if you do this: print_r(glob("/tmp/*")); You get the listing from the
directory of all files and folders.
Post by hadi
Post by Jim Lucas
Post by hadi
Post by Jim Giner
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
Here is my problem I want to search a directory and get file match "$ip"
variable as mention in my code.
Can this be done.
Does $ip represent the entire file name or is it a partial file name?
Post by hadi
Post by Jim Giner
<?php
function timeout($username, $ip)
{
$iplookup = glob('/var/log/phplogs/iplogs/');
foreach(glob('/tmp/sess*') as $file) {
if (time()- filemtime($ip) > 60)
{
$old = "$username";
$content = file_get_contents($file);
if(strpos($content, $old) !== false) {
unlink($file);
}
}
}
}
?>
Can someone help.
How to get specific file from directory.
Thank you.
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
--
http://www.php.net/unsub.php
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
http://www.php.net/unsub.php
Ashley Sheridan
2014-06-23 19:52:42 UTC
Permalink
Post by Jim Lucas
or like this?
/var/log/phplogs/iplogs/1.1.1.1 <- 1.1.1.1 being the actual file?
Yes $ip its being the file name.
What is my problem here all ip file set in /var/www/html/myproject <-----.
I need to move them to different place instead.
But if you see my code " if (time()- filemtime($ip) > 60)" read ip file
residing in /var/www/html/myproject.
I need " if (time()- filemtime($ip) > 60)" to look for ip file in different
directory. But also keep in mind "$ip" variable itself being passed to the
function here " function timeout($username, $ip)"
How can I ask " if (time()- filemtime($ip) > 60)" to look for ip files in
different folder.
-----Original Message-----
Sent: Monday, June 23, 2014 10:35 PM
Subject: Re: [PHP] Re: get file from directory.
Post by hadi
Post by Jim Lucas
Does $ip represent the entire file name or is it a partial file name?
$ip getting passed to the function with the system ip.
I have files with system ips names in directory. Ip name of file.
I want my code to get the ip which already done and match it with
directory which not done. Can you do it according to my code.
So, $ip would be something like '1.1.1.1' ?
So, are you trying to find something like this?
/var/log/phplogs/1.1.1.1/files...
or like this?
/var/log/phplogs/iplogs/1.1.1.1 <- 1.1.1.1 being the actual file?
if ( file_exists('/var/log/phplogs/iplogs/' . $ip ) ) {
echo 'file found, now do something...';
}
Here are a few things you need to understand as well.
Read this: http://www.php.net//manual/en/function.glob.php It will help
you better understand how to use this function.
If you do this: print_r(glob("/tmp/"));
You get this: Array
(
[0] => /tmp/
)
But, if you do this: print_r(glob("/tmp/*")); You get the listing from the
directory of all files and folders.
Post by hadi
Post by Jim Lucas
Post by hadi
Post by Jim Giner
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
Here is my problem I want to search a directory and get file match
"$ip"
Post by hadi
Post by Jim Lucas
Post by hadi
variable as mention in my code.
Can this be done.
Does $ip represent the entire file name or is it a partial file name?
Post by hadi
Post by Jim Giner
<?php
function timeout($username, $ip)
{
$iplookup = glob('/var/log/phplogs/iplogs/');
foreach(glob('/tmp/sess*') as $file) {
if (time()- filemtime($ip) > 60)
{
$old = "$username";
$content = file_get_contents($file);
if(strpos($content, $old) !== false) {
unlink($file);
}
}
}
}
?>
Can someone help.
How to get specific file from directory.
Thank you.
If you know the directory and you know the filename, why do a search at
all?
Post by Jim Giner
Just open it.
--
http://www.php.net/unsub.php
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
http://www.php.net/unsub.php
What have you tried already to open a file from a directory?
--
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...