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 7709983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:59:55+00:00 2026-06-01T00:59:55+00:00

For example I have in a conf.php file: $GLOBALS[no_access] = ‘^forbidden|restricted|xampp|apache\_pb’; blocking these files/folders

  • 0

For example I have in a conf.php file:

$GLOBALS["no_access"] = '^forbidden|restricted|xampp|apache\_pb';

blocking these files/folders from view and would like to restrict these strings (folders/files) a limited number of times. This is because this is an intranet project and there might be a folder I don’t want accessed with the same name of a file or folder I do want available. Also, is it possible to select first instance, but not later?

This is for altering a component of Joomla, called eXtplorer, a file manager.

  • 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-06-01T00:59:57+00:00Added an answer on June 1, 2026 at 12:59 am

    It will work either way but a whitelist would be safes instead of a blacklist (so you can only access directories starting with x).

    What you want is a regex you can use to check if the start of a string starts with a particular pattern that can match a folder.

    $regex = '/^(?:forbidden|restricted|xampp|apache_pb)/i';
    

    In php that could look like this:

    function startIsRestricted($string) {
        return preg_match('/^(?:forbidden|restricted|xampp|apache_pb)/i', $string);
    }
    

    Edit

    Reading that discussion it sounds more like you want to restrict access to folders. In that case you may want to look into protecting directories with htaccess and htpasswd documentation on this you can find on the apache website or this website, going in to the whole of it a bit more

    Doing the restriction in PHP would be unsafe…

    Edit 2

    Code is sorta tested; at least I do an implode now arround the array map (duh) and fixed obvious misspellings.

    But it should at least give a good idea of how you can do this check recursively for each directory in a string…

    /**
     * Function to check an entire string recursively to see if dissalowed directories are present
     * Assuming the string seperator will be a forwardslash
     *
     * @param string $string String to be evaluated against the dissalowed directory list given or else default
     * @param array $dissallow array of strings which are forbidden to be at the start of any of the directories
     * @param string $sep The seperator for the directory levels
     * 
     * @return string
     */
    function test_directory ($string, array $dissallow = array('forbidden', 'restricted', 'xampp', 'apache_pb'), $sep = '/') {
        $regex  = '/^(?:' . implode('|', array_map ('preg_quote', $dissallow)) . ')/i';
        $dirs   = explode($sep, $string);
    
        foreach($dirs as $dir) {
            // true will mean a match is found and thus present in the beginning of a directory in $string
            if(preg_match($regex, $dir))
                return true;
        }
        return false;
    }
    

    Now I should note that regexes in these kind of cases can slow things down and it should be used too much, if a direct match with any string in the dissalow array is fine to you should do it checking each $dir in $dirs against each entry of $dissallow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather confusing problem. I have a php file (http://example.com/delete.php) <?php session_start();
I have a rather confusing problem. I have a php file (http://example.com/delete.php) <?php session_start();
We have a custom PHP/MySQL CMS running on Linux/Apache thats rolled out to multiple
I have next SVN repositories structure running Apache 2.2 under Windows Server 2008: http://example.com/svn/
I'm trying to user RewriteRule in my .htaccess file to redirect example.com/page to example.com/page.php
I have numerous index.php scripts using SEO-friendly arg format like example.com/path/to/index.php/opt/arg and would like
I have a strange thing happening with php files. As an example: domain.com/test.php domain.com/test
I have a .htaccess file - looks something like this: RewriteEngine On <FilesMatch ^.*\.php.*$>
I have a config file stuff.conf in an open source project I'm working on.
Lets assume that I have the following configuration in my conf/InjectionConfig.groovy file: x {

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.