View Single Post
  #1  
Old 17th August 2012, 14:58
Croydon Croydon is offline
ISPConfig Developer
 
Join Date: Jul 2007
Location: Koblenz, Germany
Posts: 927
Thanks: 16
Thanked 261 Times in 208 Posts
Post Getting ajaxplorer to work with multiserver ISPC (no real integration)

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 Code:
        "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 Code:
$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 Code:

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 Code:
               $repoId $this->options["REPOSITORY_ID"]; 
this
PHP Code:
                $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 Code:
                $this->urlBase $wrapperData["protocol"]."://".$this->repository->getId(); 
this
PHP Code:
                if(isset($_SESSION['ISPC_HOST'])) {
                        
$this->repository->addOption('FTP_HOST'$_SESSION['ISPC_HOST']);
                        
ConfService::tmpReplaceRepository($this->repository);
                } 
and around line 221 replace
PHP Code:
return is_writable($path); 
with
PHP Code:
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.
__________________
Marius Cramer

pixcept KG

Last edited by Croydon; 18th August 2012 at 10:22.
Reply With Quote
Sponsored Links