Getting ajaxplorer to work with multiserver ISPC (no real integration)

Discussion in 'Tips/Tricks/Mods' started by Croydon, Aug 17, 2012.

  1. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    I tried (and managed) to get ajaxplorer working with a multiserver setup of ISPConfig 3.
    It is not fully integrated but uses the remoting api to get the right server for a ftp user.

    This does only work with latest svn version of ISPConfig as I added a small function to the remoting.

    Step 1:
    Install Ajaxplorer as usual
    Be sure you have configured everything you want with the admin user before you proceed. Admin login is currently no longer working after completing the following steps, so you have to revert them temporarily if you need to login as admin again.

    Step 2:
    Create a remote user in ispconfig. This user needs the "Server functions" and "FTP-User functions" rights, nothing else.

    Step 3:
    Change the conf/bootstrap_plugins.php section
    PHP:
            "AUTH_DRIVER" => array(
                    
    "NAME"          => "ftp",
                    
    "OPTIONS"       => array(
                            
    "LOGIN_REDIRECT"                => false,
                            
    "REPOSITORY_ID"             => "ispc_ftp",
                            
    "ADMIN_USER"                => "admin",
                            
    "FTP_LOGIN_SCREEN"      => false,
                            
    "AUTOCREATE_AJXPUSER"   => true,
                            
    "TRANSMIT_CLEAR_PASS"   => true,
                    )
            ),
    Step 4:
    Add this as the first(!) repository in conf/bootstrap_repositories.php
    PHP:
    $REPOSITORIES["ispc_ftp"] = array(
            
    "DISPLAY"       => "Web FTP",
            
    "DRIVER"        => "ftp",
            
    "DRIVER_OPTIONS"=> array(
                
    "FTP_HOST"       => "localhost",
                
    "FTP_PORT"      => "21",
                
    "FTP_SECURE"   => false,
                
    "DEFAULT_RIGHTS"    => "rw",
                
    "USE_SESSION_CREDENTIALS"   => true,
                
    "FIX_PERMISSIONS" => "detect_remote_user_id",
                
    "TMP_UPLOAD" => "/tmp"
            
    )
    );
    Do not change the FTP_HOST, it is determined automatically later.
    You can change the DISPLAY setting if you like.
    If you want SSL connections to the ftp server you can set FTP_SECURE to true.

    I deleted all other repositories from the file, except ajaxp_shared and ajxp_conf.


    Step 5:
    in file plugins/auth.ftp/class.ftpAuthDriver.php add a new method to the class:
    PHP:

    class ftpAuthDriver extends AbstractAuthDriver {
        
    // stripped content

    function get_ispc_host($username) {
           
    // connect to ispc via remoting and read ftp user
           
    $server '';             
           
    $login 'YOURREMOTEUSER';
           
    $pass 'YOURREMOTEPASS';
           
           
    $soap_uri 'http://your.server.com:8080/remote/';
           
    $soap_location $soap_uri 'index.php';

           
    $client = new SoapClient(null, array('location' => $soap_location'uri'      => $soap_uri));
           try {
               if(
    $session_id $client->login($login,$pass)) {
                   
    $check $client->sites_ftp_user_server_get($session_id$username);
                   if(
    $check) {
                       
    $server = isset($check['ip_address']) ? $check['ip_address'] : $check['hostname'];
                   }

                   
    $client->logout($session_id);
              }
          } catch (
    SoapFault $e) {
          }

          return (
    $server != '' $server 'localhost');
    }

    // stripped content
    }

    Step 6:
    Search for function checkPassword($login, $pass, $seed)
    In this function add after
    PHP:
                   $repoId $this->options["REPOSITORY_ID"];
    this
    PHP:
                    $repository ConfService::getRepositoryById($repoId);
                    
    $_SESSION['ISPC_HOST'] = $this->get_ispc_host($login);
                    
    $repository->addOption('FTP_HOST'$_SESSION['ISPC_HOST']);
    Step 7:
    In file plugins/access.ftp/class.ftpAccessDriver.php search for function initRepository() - should be around line 55.
    add after
    PHP:
                    $this->urlBase $wrapperData["protocol"]."://".$this->repository->getId();
    this
    PHP:
                    if(isset($_SESSION['ISPC_HOST'])) {
                            
    $this->repository->addOption('FTP_HOST'$_SESSION['ISPC_HOST']);
                            
    ConfService::tmpReplaceRepository($this->repository);
                    }
    and around line 221 replace
    PHP:
    return is_writable($path);
    with
    PHP:
    return true;
    This leads to ajaxexplorer showing the raw ftp errors like "ftp_fput() permission denied" instead of "Cannot write file ... " but makes it working at least as ajaxplorer compares the file's owner uid with the login name. This differs due to virtual users in ispconfig pureftp.


    This should be everything that is needed.

    What is done:
    On login (checkPassword method) a function is called that calls the ISPConfig remoting api and gets some server infos for the given ftp user.
    It then returns the server-ip (or hostname) and overwrites the Ajaxplorer repository config temporarily.

    No warranty for this howto, as always ;) Use at your own risk.
     
    Last edited: Aug 18, 2012
  2. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    There is a "dirty" quick fix if you need to login as admin later on.

    Step 1:
    Login to ISPConfig as admin and goto System -> Interface -> Main config

    Step 2:
    Remove the [CLIENTNAME] from the ftp user prefix field and save it.

    Step 3:
    Create a new ftp user named "admin" at any website.

    Step 4:
    Wait for the ftp user to be created and then reinsert the [CLIENTNAME] to the field at step 2 and save it.

    Step 5:
    Login with the new "admin" ftp user to ajaxplorer.
     
  3. ferra

    ferra Member

    Hi Croudon, I'm trying to follow your howto, using ISPConfig 3.0.5.3 and pydio-5.0.4.
    Pydio is installed and running. I cannot find the file conf/bootstrap_plugins.php,
    just a symbolic link to /etc/pydio/bootstrap_plugins.php, but there is no bootstrap_plugins.php.

    Any help?

    Thanks
     
  4. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Sorry, I don't hink I can help there. The howto was for Ajaxplorer 4, I did not get V5 running, either.
     

Share This Page