Re: strange failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On March 22, 2018 12:04:16 AM UTC, Jeffry Killen <jekillen@xxxxxxxxxxx> wrote:
>Hello;
>
>If this is off topic forgive me.
>
>I have a php script file in a directory that is returning false
>for both is_file and is_dir.
>
>It is among a list of files and directories obtained from
>scandir. The files are tested in a loop and all other files
>in the directory do not have this problem.
>
>There is no evidence of any problem with the file.
>
>Is there any reason that this would happen with  and otherwise
>normal plain text script file?
>
>built in Apache/php on MacOSX Yosemite.
>
>private function listAsync($_a)
>               {
>                // $_ a: array from scandir.
>                $_owner = array();
>                $_data = [];
>                $_out = '';
>                for($_itr = 0; $_itr < count($_a); $_itr++)
>                  {
>                   $_item = $_a[$_itr];
>                   $_owner = self::getOwner($_item);
>                   if(!isset($_owner['owner']))
>                     {
>                 $_owner['owner'] = "Not determined ".$_owner['error'];
>                     }
>            $_octPerms = substr(sprintf('%o', @fileperms($_item)), -4);
>$_data[count($_data)] .=
>"owner:".$_owner['owner']."|rwx:".self::getWRXPerms($_item)."|oct:".$_octPerms."|item:".basename($_item);
>                  }
>                $_out = implode($_data, '{');
>                return $_out;
>               }
>
>private function getOwner($_target)
>        {
>         $_fileStat = array();
>         $_errHead = self::$_className." -> ".__FUNCTION__;
>         if(!is_file($_target) && !is_dir($_target))
>           {
>$_fileStat['error'] =  $_errHead." error ".$_target." was not found, or
>is not a file or directory";
>            return $_fileStat;
>           }
>         $_astat = stat($_target);
>         $_owner = '';
>         foreach(posix_getpwuid ( $_astat['uid'] ) as $_sKey=>$_value)
>            {
>             if($_sKey == 'name')
>               {
>                $_owner = self::$_users[$_value];
>               }
>             }
>          $_fileStat['owner'] = $_owner;
>          return $_fileStat;
>         }
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

This might happen if the user that PHP is running as does not have permission to read that file, e.g. it has something like 700 permissions and belongs to 'joe' but php is running as 'www'.
Thanks,
Ash

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux