Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:35:07+00:00 2026-05-31T16:35:07+00:00

PHP has a is_readable function which checks to see if the file is readable

  • 0

PHP has a is_readable function which checks to see if the file is readable by the owner of the script. Is there a corresponding script to see if a file is readable by a specified user, for example

is_readable('Gavrilo Princip', 'black_hand.srj')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:35:08+00:00Added an answer on May 31, 2026 at 4:35 pm

    Thanks to the help of Chris and AndrewR I have come up with a, as of yet untested, solution. This solution is implemented in shell, and waits for input from standard in (designed to work with Apache RewriteMap). However, it can easily be modified to be called from either the command line or from a PHP script. It is a little bit more complicated than it has to be because we are piping the input of a function (getfacl) to a while loop. When we do this, it starts a new suprocess, so any variables declared or updated inside this loop (ie. result) will not be available to the outside world. Furthermore, I used getfacl as I can later expand it to also work with ACL permissions as well. Finally, for implementation reasons, I already know the owner of the file (user) before calling this script, however, if this is not the case, one can easily find this from the getfacl command.

    #!/bin/bash
    
    #USAGE: STDIN viewer:user:file
    
    while read line
    do
       viewer=`echo $4 | cut -d ':' -f 1`
       user=`echo $4 | cut -d ':' -f 2`
       file=`echo $4 | cut -d ':' -f 3`
    
       result=$(
          getfacl $file 2>/dev/null | while read line
          do
             if [[ $user == $viewer ]] && [[ $line =~ ^user: ]]
             then
                permissions=`echo $line | cut -d ':' -f 3`
                if [[ $permissions =~ r ]]
                then
                   echo true
                   break
                fi
             elif [[ $user == $viewer ]] && [ $line =~ ^group: ]]
             then
                #NOTE: I take advantage of the fact that each user has one single group and that group has the same name as the user's name
                permissions=`echo $line | cut -d ':' -f 3`
                if [[ $permissions =~ r ]]
                then
                   echo true
                   break
                fi
             elif [[ $line =~ ^other: ]]
             then
                permissions=`echo $line | cut -d ':' -f 3`
                if [[ $permissions =~ r ]]
                then
                   echo true
                   break
                fi
             fi
          done
       )
    
       if [[ $result == "true" ]]
       then
          echo true
       else
          echo false
       fi
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PHP has a very nice function, isset($variableName). It checks if $variableName is already defined
I have a php file which has a require_once Statement (?) this file is
A php script is giving this array (which has been passed through json_encode() )
Well, I'm starting to hate PHP. I have a file, which is perfectly readable
PHP has a function range('a','z') which prints the English alphabet a, b, c, d,
PHP has a var_dump() function which outputs the internal contents of an object, showing
PHP has a function called extract() which takes an associative array as the argument
PHP has a uniqid() function which generates a UUID of sorts. In the usage
http://steph.net23.net/work.php here is my test link. This page has a jquery script in it
What I'm trying to achieve: 1) http://localhost/en/script.php?param1=random is mapped to http://localhost/script.php?param1=random&language=English This has to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.