eXtplorer for ISPconfig 3

Discussion in 'Tips/Tricks/Mods' started by ahrasis, Aug 21, 2010.

  1. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Hi,

    I am attempting to use eXtplorer for my ISPconfig 3 (Perfect Server Ubuntu 10.04).

    Firstly, I am going to download eXtplorer and extract it at /usr/share/filemanager.

    Second, I am going to set correct permission so eXtplorer can work in the browser.

    Third, I will share it with other user ln -s /usr/share/filemanager/ /var/www/filemanager.

    Fourth, I intend to make eXtplorer to use ISPconfig 3 database particularly ftp user(s) table that it created. This is where I am now.

    As far as I know, eXtplorer can call or use database when it is installed as a component to Joomla. However, I am not sure how it works.

    Anybody here who is willing to help on this? It is nicer to have a file manager for ISPconfig 3 which its every user can share.

    Thanks in advance.
     
  2. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    I guess it is not that easy to make this work.

    Anyway, I play around and find out that I need to create a plugin and enable it before every site created under ISPconfig 3 can automatically use /filemanager like they use /phpmyadmin and /webmail.

    I am creating one using the available plugins as sample. The problem is, how do I enable it.
    Code:
    <?php
    
    /*
    Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
    All rights reserved.
    Modification (c) 2009, Marius Cramer, pixcept KG 
    
    Redistribution and use in source and binary forms, with or without modification,
    are permitted provided that the following conditions are met:
    
        * Redistributions of source code must retain the above copyright notice,
          this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        * Neither the name of ISPConfig nor the names of its contributors
          may be used to endorse or promote products derived from this software without
          specific prior written permission.
    
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    
    class fm_symlink_plugin {
    	
    	var $plugin_name = 'fm_symlink_plugin';
    	var $class_name = 'fm_symlink_plugin';
    	
        var $action;
        
    	//* This function is called during ispconfig installation to determine
    	//  if a symlink shall be created for this plugin.
    	function onInstall() {
    		global $conf;
    		
            return false;
    		
    	}
    	
    		
    	/*
    	 	This function is called when the plugin is loaded
    	*/
    	
    	function onLoad() {
    		global $app;
    		
    		/*
    		Register for the events
    		*/
    		
    		$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert');
    		$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
    	}
    	
    	function insert($event_name,$data) {
    		global $app, $conf;
    		
    		$this->action = 'insert';
    		// just run the update function
    		$this->update($event_name,$data);
    	}
    	
    	function update($event_name,$data) {
    		global $app, $conf;
    		
    		if($this->action != 'insert') $this->action = 'update';
    		
    		if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
    			
    			$old_parent_domain_id = intval($data["old"]["parent_domain_id"]);
    			$new_parent_domain_id = intval($data["new"]["parent_domain_id"]);
    			
    			// If the parent_domain_id has been chenged, we will have to update the old site as well.
    			if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
    				$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
    				$data["new"] = $tmp;
    				$data["old"] = $tmp;
    				$this->action = 'update';
    				$this->update($event_name,$data);
    			}
    			
    			// This is not a vhost, so we need to update the parent record instead.
    			$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
    			$data["new"] = $tmp;
    			$data["old"] = $tmp;
    			$this->action = 'update';
    		}
    		
    		if($data["new"]["document_root"] == '') {
    			$app->log("document_root not set",LOGLEVEL_WARN);
    			return 0;
    		}
    		
            $symlink = true;
            if($data["new"]["php"] == "suphp") $symlink = false;
            elseif($data["new"]["php"] == "cgi" && $data["new"]["suexec"] == "y") $symlink = false;
            elseif($data["new"]["php"] == "fast-cgi" && $data["new"]["suexec"] == "y") $symlink = false;
            
            
            if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
            if($symlink == false) {
                if(is_link($data["new"]["document_root"]."/web/filemanager")) exec("rm -f ".$data["new"]["document_root"]."/web/filemanager");
            } else {
                if(!is_link($data["new"]["document_root"]."/web/filemanager")) exec("ln -s /var/www/filemanager ".$data["new"]["document_root"]."/web/filemanager");
                else exec("ln -sf /var/www/filemanager ".$data["new"]["document_root"]."/web/filemanager");
            }
    	}
    	
    
    } // end class
    
    ?>

    Please do check and help give some directions / ideas / suggestions.



    Thanks in advance.
     
  3. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Really I dont know how the code works, because it doesn't. I will have to create for each sites using ln -s /usr/share/filemanager/ /var/www/clientx/webx/web then.

    In the mean time, I am trying to see how it basically shares Joomla users and their permissions in order to use ftp login as its login.
     
  4. Horfic

    Horfic Member

    why don't you create the vhost for /filemanager manually for apache?

    That is so much easier!
     
  5. astewart

    astewart New Member

    Tried that but no luck.
    I created the following vhost file in the '/etc/apache2/sites-available' then created a symlink of it in '/etc/apache2/sites-enabled'

    It contains the following:
    Restarted Apache but no luck :(
     
  6. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    How does it work. Any tutorial?

    So far I manage to get eXtplorer to work well on all subdomain via clientdomain/filemanager. I use similar method allow webmail to be open from clientdomain/webmail/ . This is the same as phpmyadmin method but I dont how to automate this like phpmyadmin do.

    Btw, I haven't finish learning from Joomla + eXtplorer yet.
     
  7. Horfic

    Horfic Member

    Try this, not tested. (It's just a modified phpmyadmin default vhost)
    Code:
    # eXtplorer default Apache configuration
    
    Alias /explorer /usr/share/explorer
    
    <Directory /usr/share/explorer>
            Options Indexes FollowSymLinks
            DirectoryIndex index.php
    
            <IfModule mod_php4.c>
                    AddType application/x-httpd-php .php
    
                    php_flag magic_quotes_gpc Off
                    php_flag track_vars On
                    php_flag register_globals Off
                    php_value include_path .
            </IfModule>
            <IfModule mod_php5.c>
                    AddType application/x-httpd-php .php
    
                    php_flag magic_quotes_gpc Off
                    php_flag track_vars On
                    php_flag register_globals Off
                    php_value include_path .
            </IfModule>
    </Directory>
    PS: Don't forget to restart apache, after creating and symlinking the file.
     
  8. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Thank you very much. I'll be testing it by this weekend. I'll announce the result here thereafter.
     
  9. Erih-Gres

    Erih-Gres New Member

    Before start make:

    Code:
    sudo apt-get install pwgen
    pwgen
    And select one word. Remember this secret word!
    Replace MyPasswd to your secret word.

    Create directory for extplorer:

    ...
     
    Last edited: Oct 18, 2010
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    The part that you describe in "reconfigure ispconfig" will make your setup incompatible to updates and is really insecure. The salt in a password should be different for every and not a static word as you open the password database for dictionary attackes.

    Instead of modifying ispconfig, you should use a correct routine to create salts in extplorer e.g by using the salt creation routine from ispconfig.
     
  11. Erih-Gres

    Erih-Gres New Member

    Good day Till!

    What do think about this:

    Create directory for extplorer:

    Code:
    cd /usr/share
    mkdir extplorer
    cd extplorer
    Download and unzip extplorer:

    Code:
    wget http://sourceforge.net/projects/extplorer/files/extplorer/eXtplorer 2.1.0/eXtplorer_2.1.0b6.zip/download
    unzip download
    rm download
    Set permissions:

    Code:
    chown root:root /usr/share/extplorer
    chmod 777 /usr/share/extplorer
    chown root:root /usr/share/extplorer/ftp_tmp
    chmod 777 /usr/share/extplorer/ftp_tmp
    Create the following symlink:

    Code:
    ln -s /usr/share/extplorer /usr/local/ispconfig/interface/web/
    Reconfigure extplorer
    Edit functions.php:

    Code:
    nano ./include/functions.php
    Find line:

    Code:
    	return md5( $pass );
    And replace it for:

    Code:
    //      return md5($pass);
            $return = 'bad_pass';
            $cnt=count($GLOBALS["users"]);
            for($i=0;$i<$cnt;++$i) {
                    if(crypt($pass,substr($GLOBALS["users"][$i][1],0,12))==$GLOBALS["users"][$i][1]){
                            $return = $GLOBALS["users"][$i][1];
                            break;
                    }
            }
            return $return;
    
    Save file.
    And edit .htusers.php file

    Code:
    nano ./config/.htusers.php
    Clear this file and place this code:

    Code:
    <?php 
    	// ensure this file is being included by a parent file
    	if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' );
    $djin_dblocation = "localhost";
    $djin_dbuser = "root";
    $djin_dbpasswd = "your_mysql_root_password";
    $djin_dbname="dbispconfig";
    
    $djin_dbcnx = @mysql_connect($djin_dblocation,$djin_dbuser,$djin_dbpasswd);
    if (!$djin_dbcnx) 
     {
     echo("<p>Cannot connect</p>");
     exit();
     }
    if (!@mysql_select_db($djin_dbname, $djin_dbcnx))
     {
     echo( "<p>Connot select database</p>" );
     exit();
     }
    $djin_sql=mysql_query ("SELECT `username`,`password`,`dir` FROM `ftp_user`");
    $djin_count=0;
    while ($djin_record = mysql_fetch_array($djin_sql)) {
    $GLOBALS["users"][$djin_count][0]=$djin_record['username'];
    $GLOBALS["users"][$djin_count][1]=$djin_record['password'];
    $GLOBALS["users"][$djin_count][2]=$djin_record['dir'];
    $GLOBALS["users"][$djin_count][3]='';
    $GLOBALS["users"][$djin_count][4]=1;
    $GLOBALS["users"][$djin_count][5]='';
    $GLOBALS["users"][$djin_count][6]=1;
    $GLOBALS["users"][$djin_count][7]=1;
    $djin_count=$djin_count*1+1;
    }
    ?>
    Configure connect to database in lines:

    Code:
    $djin_dblocation = "localhost";
    $djin_dbuser = "root";
    $djin_dbpasswd = "your_mysql_root_password";
    $djin_dbname="dbispconfig";
    Reconfigure ISPConfig

    Edit ftp_user_list.htm file:

    Code:
    nano /usr/local/ispconfig/interface/web/sites/templates/ftp_user_list.htm
    After line:

    Code:
                  <div class="buttons icons16">
    Write this line:

    Code:
    <a class="icons16 icoDbAdmin" href="extplorer/" target="extplorer"><span></span></a>
    Save and exit.
    And now in ftp users list we can see new button, what navigate us to extplorer.
     
    Last edited: Oct 18, 2010
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    Looks much better! :) One question though, is this line correct:

    if(crypt($pass,substr($GLOBALS["users"][$i][1],0,12))==$GLOBALS$

    or should it be something like this

    if(crypt($pass,substr($GLOBALS["users"][$i][1],0,12)) {
     
  13. Erih-Gres

    Erih-Gres New Member

    I'm sorry:(. I'm "copy-paste" from nano....
    This string is to long...

    Now it's right:).

    And, like always: sorry for my english.
     
  14. lordblacksuca

    lordblacksuca New Member

    Hello, thanks for the info. I followed this steps, and everything worked good!!

    the only problem that I have is when unzip files, the owner of them is the PHP user, wich is not the client:web user, so that files are not accessible then by the shell or FTP.


    any idea?
     
  15. Erih-Gres

    Erih-Gres New Member

    No idea....:(
    I don't know ISPConfig and eXtplorer code so good.
    May be Till or Falko or someone else have any idea?

    I can write, but i'm not linux-master.
     
    Last edited: May 16, 2011
  16. lordblacksuca

    lordblacksuca New Member

    Thanks for the answer.

    I also tried to find some way to run PHP from client#:web# user, without sucess.
     
  17. soeren

    soeren New Member

    Hi lordblacksuca,

    please read about your problem here:
    http://extplorer.net/wiki/Frequentl...edirectory-the-link-is-grayed-out-Whats-wrong

    It's the same type of problems as described on the eXtplorer Wiki. you can get around this problem by running PHP in CGI/FastCGI mode or using mod_suphp instead of the normal PHP module for Apache.
    If you edit your domain in ISPconfig and select "mod_suphp" (make sure it's installed!) or FastCGI, ISPconfig should care for setting up the Apache config files correctly. Just wait a moment and it should work.

    ciao, Sören
     
  18. adti

    adti New Member

    help my case using SSL "https://youdomain.com:8080/extplorer/" not run extplorer

    help my case using SSL "https://youdomain.com:8080/extplorer/" not run extplorer
     
  19. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Open this file using nano or whatever editor:

    Code:
    nano /usr/share/extplorer/include/init.php
    Find:

    Code:
    if ($_SERVER['SERVER_PORT'] == 443 ) {
    Change 443 to your SSL port number.

    It should work, IMO.

    Note: I am working on a different approach though as the prescribed method limits the ability to upload and extract to the users thus is not working as it supposed to be.
     
  20. webguyz

    webguyz Active Member HowtoForge Supporter

    I know this is a super old post, but I just found about eXTplorer. Was trying to get Net2ftp working but really did not care for the clunky looking interface. Ran across this while doing some searches and love the look and feel of this file manager.

    Was wondering if anyone has this file explorer integrated into 3.0.5.3 or if they knew that these instructions still apply.

    Thanks!
     

Share This Page