Welcome Guest, Not a member yet? Register   Sign In
Domain basepath question
#1

[eluser]Nevio[/eluser]
Hi guys,

I'm trying to find out basepath of some domain. For example if I enter www.example.com to see /home/~/www or for example C:/www/example. Is there any method for that? I did not attempt ever to find that out and now that would be really interesting. Probably not due to security but still for my localhost I think that there must exist some way.

Thanks.
#2

[eluser]TheFuzzy0ne[/eluser]
No, there's no method for it. I'd have thought it would be best to maintain the mappings yourself in a file or database.
#3

[eluser]Nevio[/eluser]
I'm doing script for CI autoinstaller. It will be done like this bellow:

- enter domain name
- check domainname/filename.extension
- if it exists, retrieve basepath
- if not say that file must exist!

This installer is just for localhost purposes. FTP is out of a range for now lol Big Grin


ADDED:

I did this... Anyone got better idea? Thanks.

Code:
$data = $this->_toObject( $data );
        
        if(! $data->domainname || strlen( $data->domainname ) < 4 )
        {
            return json_encode( array (
                'status'  => 'false',
                'title'   => 'Domain name error!',
                'message' => 'Domain name must be specified! Current value isn\'t set nor that it exist!'
            ));    
        }
        
        if(! preg_match ("/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i", $data->domainname ) )
        {
            return json_encode( array (
                'status'  => 'false',
                'title'   => 'Domain name not valid!',
                'message' => 'Domain name is incorrect! Please use fully qualified domain name without http:// or https://'
            ));    
        }
        
        // Okay it passes! lets check now if required file is accessable!
        $url = $data->domainname . self::URL_SEPARATOR . $this->_ci->config->item( 'system_installer_file' );
        
        // okay, lets go curl it!
        $ch = curl_init();    // initialize curl handle
        curl_setopt($ch, CURLOPT_URL,            $url ); // set url to post to
        curl_setopt($ch, CURLOPT_FAILONERROR,    1    );
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1    );// allow redirects
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1    ); // return into a variable
        curl_setopt($ch, CURLOPT_TIMEOUT,        3    ); // times out after 4s
        
        $result = curl_exec($ch); // run the whole process
        curl_close($ch);
        
        $response = json_decode( $result );
        
        if(! is_object( $response ) )
        {
            return json_encode( array (
                'status'  => 'false',
                'title'   => 'Domain name coudn\'t be reached',
                'message' => 'Please check for domain name and file existance! They don\'t exist or are invalid!'
            ));    
        }
        
        $path = base64_decode( $response->pathinfo ) . DIRECTORY_SEPARATOR;
        
        
        // now it's the time to extract codeigniter!
        $archive = $this->_retrieveCiArchivePath();
        
        if(! file_exists( $archive ) )
        {
            return json_encode( array (
                'status'  => 'false',
                'title'   => 'CodeIgniter archive error',
                'message' => 'We cannot allocate codeigniter archive package. Please reinstall application!'
            ));    
        }
        
        $zip = new ZipArchive();
        
        if(! $zip->open( $archive ) )
        {
            return json_encode( array (
                'status'  => 'false',
                'title'   => 'CodeIgniter archive error',
                'message' => 'We cannot open archive. Archive got some errors! It must be zip type!'
            ));    
        }
        
        $zip->extractTo( $path );
        $zip->close();
        
        // okay! lets's go update and say that frontend is installed!
        $obj = new stdClass();
        
        $obj->f_installed = YES;
        $obj->f_url       = $data->domainname;
        $obj->f_basepath  = $path;
        
        //$this->_ci->db->where( "id", $this->_ci->config->item('system_table_id') );
        //$this->_ci->db->update( 'system', $obj );
        
        return json_encode( array (
            'status'  => 'true',
            'title'   => 'Frontend successfully installed!',
            'message' => 'We did just base extractions. Still you need to setup database and change configuration file url! Please wait...',
            'url'     => site_url('settings/frontend')
        ));




Theme © iAndrew 2016 - Forum software by © MyBB