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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:17:46+00:00 2026-05-26T23:17:46+00:00

I wrote a CMS in PHP. It works fine on most servers but I

  • 0

I wrote a CMS in PHP. It works fine on most servers but I encountered a strange problem on my latest hosting account. This is either a path problem or a coding problem. The latter seems to be OK as this script works fine on all my other accounts, which is why I’m asking for help.

When I first install my CMS tool I run a script called “inventory.php” in which I attempt to get and display all the directories on the server from the location of my script, which is 2 or 3 directories down from the root, depending on the server. I try to use a global path that goes up to the root and from it to return all the directories it can find. If this file works then the entire CMS works; if not… well that’s why I’m here.

Here’s the code that scans the directories:

$main_root = realpath('../../');
echo '<b style="color:orange;">All The dirs on this server:</b><hr><br>';
$whats_on_the_server = array_filter(glob($main_root.'/*'), 'is_dir');
foreach($whats_on_the_server as $on_server) {
    $on_server = trim($on_server);
    if(stristr($on_server,'.')){    
        $arr1 = preg_split('^/^',$on_server);   
        echo $arr1[4].'<br>';
    }
}

The root is: chroot/home/account/ under which all my folders are located. I can’t run a script from that directory, so I must access it from elsewhere. This works fine on other servers but on the one I currently use, it doesn’t return anything if the path is set as above. It gets the directory contents if I set the path to a subfolder on the specific server, such as:

$main_root = realpath('../../SomeDir');

I must however get the name of all the directories located on the root.

  • 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-26T23:17:47+00:00Added an answer on May 26, 2026 at 11:17 pm

    So probably you don’t have the privileges to access the root but do have privilegs to access the given subdirectories?

    By the way, you can go to root by simply doing

    $main_root = realpath('/');
    

    which is always your most upper path!

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

Sidebar

Related Questions

I am in a pickle. I could easily solve this problem with PHP or
Hi I'm having some problem with a PHP page: I'm writing a little CMS
I need an advice about a php/MySql CMS which is: 1.Safe for shared hosting.
I wrote a simple CMS for one of my clients which does specifically what
I'm going to write a CMS, but right now I'm writing down all my
I'm looking at porting a custom-written PHP CMS into Django. One of the features
PHP ships with various methods of identifying the type of a file, but is
I'm writing a CMS application in PHP and one of the requirements is that
I would like to improve my PHP CMS security in that it writes failed
This is output from a mysql export function. Problem is I don't know the

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.