Getting absolute directory path
Some users keep contributed modules outside the Drupal directory and create symlinks to them in sites/all/modules. This causes problems for Chat Room, which uses a PHP file in its own directory for AJAX updates (to avoid loading all of Drupal on each update) but must include some files from Drupal. I was using the following code to find the Drupal files: $chatroom_base = urldecode($_POST['chatroom_base']); $depth = substr_count($chatroom_base, '/'); chdir(str_repeat('../', $depth+1)); If people are keeping Chat Room outside of Drupal, chdir() will need the absolute path to the Drupal directory. What is the best way to get this?
See http://www.php.net/realpath *realpath()* expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in the input *path* and return the canonicalized absolute pathname. The resulting path will have no symbolic link, '/./' or '/../' components. On 3/14/07, Darren Oh <darrenoh@sidepotsinternational.com> wrote:
Some users keep contributed modules outside the Drupal directory and create symlinks to them in sites/all/modules. This causes problems for Chat Room, which uses a PHP file in its own directory for AJAX updates (to avoid loading all of Drupal on each update) but must include some files from Drupal. I was using the following code to find the Drupal files:
$chatroom_base = urldecode($_POST['chatroom_base']); $depth = substr_count($chatroom_base, '/'); chdir(str_repeat('../', $depth+1));
If people are keeping Chat Room outside of Drupal, chdir() will need the absolute path to the Drupal directory. What is the best way to get this?
-- 2bits.com http://2bits.com Drupal development, customization and consulting.
On Mar 14, 2007, at 10:08 AM, Khalid Baheyeldin wrote:
realpath() expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in the input path and return the canonicalized absolute pathname. The resulting path will have no symbolic link, '/./' or '/../' components.
The problem is, users are not keeping their modules in the Drupal directory. I need to give the script the path to the Drupal root directory, not the real path to itself. I would use a URL instead of a filesystem path, but I don't want to depend on users to configure PHP to allow this.
participants (2)
-
Darren Oh -
Khalid Baheyeldin