Determine path to FTP base directory?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Markus

    Determine path to FTP base directory?

    Hello

    Is it possible to determine the PHP path to the FTP base directory?
    ftp_pwd($conn_i d) returns '/', while I need something like
    '/data/users/domain.com/'.

    I used a construct such as:

    $list = ftp_nlist($conn _id, ftp_pwd($conn_i d));
    foreach ($list as $entry) {
    if (stristr($_SERV ER['DOCUMENT_ROOT'], '/'.$entry)) {
    $split = explode($entry, $_SERVER['DOCUMENT_ROOT']);
    $ftp_basedir = $split[0];
    break;
    }

    That works well in most cases; anyway now I have a case where
    $_SERVER['DOCUMENT_ROOT'] has a duplicate folder name, such as
    '/data/htdocs/domain.com/htdocs/', which makes the above process fail. I
    think of complicated things like have FTP write a file into the base
    directory, and let PHP search for it, but I hope there is an easier method!

    Thanks for a comment
    Markus
  • Jerry Stuckle

    #2
    Re: Determine path to FTP base directory?

    Markus wrote:
    Hello
    >
    Is it possible to determine the PHP path to the FTP base directory?
    ftp_pwd($conn_i d) returns '/', while I need something like
    '/data/users/domain.com/'.
    >
    I used a construct such as:
    >
    $list = ftp_nlist($conn _id, ftp_pwd($conn_i d));
    foreach ($list as $entry) {
    if (stristr($_SERV ER['DOCUMENT_ROOT'], '/'.$entry)) {
    $split = explode($entry, $_SERVER['DOCUMENT_ROOT']);
    $ftp_basedir = $split[0];
    break;
    }
    >
    That works well in most cases; anyway now I have a case where
    $_SERVER['DOCUMENT_ROOT'] has a duplicate folder name, such as
    '/data/htdocs/domain.com/htdocs/', which makes the above process fail. I
    think of complicated things like have FTP write a file into the base
    directory, and let PHP search for it, but I hope there is an easier method!
    >
    Thanks for a comment
    Markus
    Which "ftp base directory"? Every user can have a different one.

    And as you've found, the directory the user sees is relative to his ftp
    root. The ftp user has no knowledge of any directory outside of his own
    root - which is how it should be.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Markus

      #3
      Re: Determine path to FTP base directory?

      Jerry Stuckle schrieb:
      Markus wrote:
      >Hello
      >>
      >Is it possible to determine the PHP path to the FTP base directory?
      >ftp_pwd($conn_ id) returns '/', while I need something like
      >'/data/users/domain.com/'.
      [...]
      >
      Which "ftp base directory"? Every user can have a different one.
      >
      And as you've found, the directory the user sees is relative to his ftp
      root. The ftp user has no knowledge of any directory outside of his own
      root - which is how it should be.
      I understand... The issue I am struggling with is the fact that
      directories and files uploaded with FTP are not writable for user PHP.

      After installing my application on a server, it provides some nice guis
      for editing configuration files or translate language files, but of
      course those files or their destination folders have to be chmoded
      first. So I wrote an FTP class that can do this, using the same FTP
      login as the one that uploaded the application. I hoped to make the FTP
      class able to translate the absolute paths from PHP into the FTP user's
      directory structure.

      I think I will add a configuration option to enter the appropriate FTP
      base directory and hand it over to the FTP class.

      Thank you for your clarification!

      Comment

      Working...