problems with permissions or getting access to a file
problems with permissions or getting access to a file
am 10.02.2010 17:31:37 von Patrick Rice
hi all
having trouble here with a site that I am hosting on go-daddy
I want to keep my php and my images apart
so to do this I have the base directory which contains the php scripts.
On the directory above that I have
my photos stored in /photos
when I run my scripts I get the following:
time -4 hours1265815323 <
*Warning*: filemtime() [function.filemtime
]: stat failed
for testPanasonicCamMotion20100201022429140.jpg in
*/home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Ho urs.php* on
line *16*
1265815323
*Warning*: filemtime() [function.filemtime
]: stat failed
for testPanasonicCamMotion20100201022429140.jpg in
*/home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Ho urs.php* on
line *28*
0
time -4 hours1265815323 <
*Warning*: filemtime() [function.filemtime
]: stat failed
for testPanasonicCamMotion20100201022619570.jpg in
*/home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Ho urs.php* on
line *16
*_The script is the following below _from running this script, I keep
getting this error, now when I copy this script in to the directory
photo where the photos are stored, the script displays the images with
no problems leaving me think that the issue is with the permissions, I
have modified the pre-emptions to give all access as a test and still
problems. Anyone got any Ideas??
Thanks in advance.
Pat
6
7 $debug =1;
8 $d = dir('/home/content/j/a/c/jackcards/html/tomdcam/photo/') or
die($php_errormsg);
9 while (false !== ($f = $d->read())) {
10 // only match alphabetic names
11 if (preg_match('/testPanasonicCamMotion/',$f)) {
12
13 if ($debug == 1) {
14 echo "time -4 hours" . strtotime("- 1 hours" ). " < ";
15
16 echo filemtime($f);
17 echo "
";
18 }//end debug
19
20 $FourHoursAgo = intval(strtotime("- 1 hours" ));
21
22 if ($debug == 1) {
23 echo $FourHoursAgo;
24 #
25 echo "
";
26 }
27
28 $dateOfFileModify = intval(date((filemtime($f)) ));
29
30 if ($debug == 1) {
31 echo $dateOfFileModify;
32 echo "
";
33 }
34
35
36 if ($FourHoursAgo < $dateOfFileModify)
37 # if(intval(strtotime("- 4 hours" )) <
intval(strtotime(filemtime($f))) )
38
39 # if (strcmp(strtotime("- 4 hours" ),strtotime(filemtime($f))
) > 0)
40
41 {
42 #echo '
Images less than 4 hours
';
43
44
45
46
47 print "filename: $f
";
48 print "
\n";
49
50 # echo "Last accessed on: " . date("d-m-y H:i:s", strtotime("+
8 hours", fileatime($f)) );
51 # echo "
";
52 echo "Last modified on: " . date("d-m-y H:i:s", strtotime("+
8 hours", filemtime($f)) );
53 echo "
";
54 }//end of if statment
55
56
57 # else {
58 # print "
None Found
";
59 # }
60 }
61 }
62 $d->close();
63
64
65 ?>
*
*
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: problems with permissions or getting access to a file
am 10.02.2010 17:56:56 von Richard Quadling
On 10 February 2010 16:31, Pat wrote:
> hi all
> having trouble here with a site that I am hosting on go-daddy
>
> I want to keep my php and my images apart
>
> so to do this I have the base directory which contains the php scripts. O=
n
> the directory above that I have
> my photos stored in /photos
>
> when I run my scripts I get the following:
>
> time -4 hours1265815323 <
> *Warning*: filemtime() [function.filemtime
> ]: stat failed for
> testPanasonicCamMotion20100201022429140.jpg in
> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Ho urs.php* on l=
ine
> *16*
>
> 1265815323
>
> *Warning*: filemtime() [function.filemtime
> ]: stat failed for
> testPanasonicCamMotion20100201022429140.jpg in
> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Ho urs.php* on l=
ine
> *28*
> 0
> time -4 hours1265815323 <
> *Warning*: filemtime() [function.filemtime
> ]: stat failed for
> testPanasonicCamMotion20100201022619570.jpg in
> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Ho urs.php* on l=
ine
> *16
>
> *_The script is the following below _from running this script, I keep
> getting this error, now when I copy this script in to the directory photo
> where the photos are stored, the script displays the images with no probl=
ems
> leaving me think that the issue is with the permissions, I have modified =
the
> pre-emptions to give all access as a test and still problems. Anyone got =
any
> Ideas??
>
> Thanks in advance.
> Pat
>
> Â 6
> Â 7 $debug =3D1;
> Â 8 $d =3D dir('/home/content/j/a/c/jackcards/html/tomdcam/photo/') o=
r
> die($php_errormsg);
> Â 9 while (false !== ($f =3D $d->read())) {
> 10 Â Â // only match alphabetic names
> 11 Â Â if (preg_match('/testPanasonicCamMotion/',$f)) {
> 12
> 13 Â Â Â Â if ($debug == 1) {
> 14 Â Â Â Â echo "time -4 hours" . strtotime("- 1 hour=
s" ). " Â Â Â < Â Â ";
> 15
> 16 Â Â Â Â echo filemtime($f);
> 17 Â Â Â Â echo " Â
";
> 18 Â Â Â Â }//end debug
> 19
> 20 Â Â Â Â $FourHoursAgo =3D intval(strtotime("- 1 ho=
urs" ));
> 21
> 22 Â Â Â Â if ($debug == 1) {
> 23 Â Â Â Â echo $FourHoursAgo;
> 24 # Â Â Â 25 Â Â Â Â echo "
";
> 26 Â Â Â Â }
> 27
> 28 Â Â Â Â $dateOfFileModify =3D intval(date((filemti=
me($f)) ));
> 29
> 30 Â Â Â Â if ($debug == 1) {
> 31 Â Â Â Â echo $dateOfFileModify;
> 32 Â Â Â Â echo "
";
> 33 Â Â Â Â }
> 34
> 35
> 36 Â Â Â Â if ($FourHoursAgo < $dateOfFileModify)
> 37 # Â Â Â if(intval(strtotime("- 4 hours" )) <
> intval(strtotime(filemtime($f))) )
> 38
> 39 # Â Â Â if (strcmp(strtotime("- 4 hours" ),strtotime(fi=
lemtime($f)) ) >
> 0)
> 40
> 41 Â Â Â Â {
> 42 Â Â Â Â #echo '
Images less than 4 hours
'=
;
> 43
> 44
> 45
> 46
> 47 Â Â Â Â print "filename: $f
";
> 48 Â Â Â Â print "
\n";
> 49
> 50 # Â Â Â echo "Last accessed on: " . date("d-m-y H:i:s",=
strtotime("+ 8
> hours", fileatime($f)) );
> 51 # Â Â Â echo "
";
> 52 Â Â Â Â echo "Last modified on: " . date("d-m-y H:=
i:s", strtotime("+ 8
> hours", filemtime($f)) );
> 53 Â Â Â Â echo "
";
> 54 Â Â Â Â }//end of if statment
> 55
> 56
> 57 # Â Â Â else {
> 58 # Â Â Â Â Â Â Â print "
None F=
ound
";
> 59 # Â Â Â }
> 60 Â Â }
> 61 }
> 62 $d->close();
> 63
> 64
> 65 ?>
>
> *
> *
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
read() only returns the filename, not the full path.
So, when the script is in the same directory, the current directory
contains the required file.
Try using ...
filemtime(realpath($f))
instead.
--=20
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: problems with permissions or getting access to a file
am 11.02.2010 13:42:00 von Richard Quadling
On 11 February 2010 09:31, Pat wrote:
> Richard Quadling wrote:
>>
>> On 10 February 2010 16:31, Pat wrote:
>>
>>>
>>> hi all
>>> having trouble here with a site that I am hosting on go-daddy
>>>
>>> I want to keep my php and my images apart
>>>
>>> so to do this I have the base directory which contains the php scripts.
>>> On
>>> the directory above that I have
>>> my photos stored in /photos
>>>
>>> when I run my scripts I get the following:
>>>
>>> time -4 hours1265815323 <
>>> *Warning*: filemtime() [function.filemtime
>>> ]: stat failed for
>>> testPanasonicCamMotion20100201022429140.jpg in
>>> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Ho urs.php* on
>>> line
>>> *16*
>>>
>>> 1265815323
>>>
>>> *Warning*: filemtime() [function.filemtime
>>> ]: stat failed for
>>> testPanasonicCamMotion20100201022429140.jpg in
>>> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Ho urs.php* on
>>> line
>>> *28*
>>> 0
>>> time -4 hours1265815323 <
>>> *Warning*: filemtime() [function.filemtime
>>> ]: stat failed for
>>> testPanasonicCamMotion20100201022619570.jpg in
>>> */home/content/j/a/c/jackcards/html/tomdcam/MotionCamLast1Ho urs.php* on
>>> line
>>> *16
>>>
>>> *_The script is the following below _from running this script, I keep
>>> getting this error, now when I copy this script in to the directory photo
>>> where the photos are stored, the script displays the images with no
>>> problems
>>> leaving me think that the issue is with the permissions, I have modified
>>> the
>>> pre-emptions to give all access as a test and still problems. Anyone got
>>> any
>>> Ideas??
>>>
>>> Thanks in advance.
>>> Pat
>>
>> read() only returns the filename, not the full path.
>>
>> So, when the script is in the same directory, the current directory
>> contains the required file.
>>
>> Try using ...
>>
>> filemtime(realpath($f))
>>
>> instead.
>>
>>
>
> Thanks Richard, It was really wrecking my head.
> Pat
>
No problem.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php