Results 1 to 6 of 6

Thread: How to check if login details are correct?

  1. #1
    Member
    Join Date
    Aug 2004
    Posts
    31

    Default How to check if login details are correct?

    Hi,

    I'm using the API1 to do remote backups for a couple of my clients.
    I would like to check if they username/password is correct before I try to create the backups.

    How do I do that?

    This is my current code to create the backups (using the xmlapi.php provided by cpanel).

    PHP Code:
        function start() {

            
    $xmlapi = new xmlapi($this->host);
            
    $xmlapi->password_auth($this->cpuser,$this->cppass);
            
    $xmlapi->set_http_client($this->http_client); // Default: cURL
            
    $xmlapi->set_port($this->port);
            
    $xmlapi->set_debug(1);

            
    $api_args = array( 
                
    'ftp'// destination type
                
    $this->ftphost// destination address
                
    $this->ftpuser// ftp user
                
    $this->ftppass// ftp password
                
    $this->notify// email to notify
                
    21// port
                
    '/'.$this->ftpfolder // remote path to put file
            
    );

            return 
    $xmlapi->api1_query($this->cpuser,'Fileman','fullbackup',$api_args);
        } 

  2. #2
    Member
    Join Date
    Aug 2004
    Posts
    31

    Default Re: How to check if login details are correct?

    I tried to do a "dummy query", to see if it's possible to use the output for anything, but it's empty.

    PHP Code:
    function check_login() {

        
    $xmlapi = new xmlapi($this->host);
        
    $xmlapi->password_auth($this->cpuser,$this->cppass);
        
    $xmlapi->set_http_client($this->http_client); // Default: cURL
        
    $xmlapi->set_port($this->port);
        
    $xmlapi->set_debug(1);
            
        return 
    $xmlapi->api1_query($this->cpuser,'Serverinfo','servicestatus');


  3. #3
    Member
    Join Date
    Aug 2004
    Posts
    31

    Default Re: How to check if login details are correct?

    No one knows what to do?

  4. #4
    Member
    Join Date
    Jul 2011
    Location
    Palmerston North, New Zealand
    Posts
    41
    cPanel/WHM Access Level

    Root Administrator

    Default Re: How to check if login details are correct?

    Why do you require the XMLAPI to check your Username and Password? If its just you using it then hardcode in the correct login details and just secure the script.
    Usually the XMLAPI will return an object telling you that access is denied, try multiple queries with correct and incorrect login details and print_r the results to the browser. Thats the best way to find out what you are working with.
    Regards
    Stefan Andres Charsley
    WebFront.co.nz

  5. #5
    Member
    Join Date
    Aug 2004
    Posts
    31

    Default Re: How to check if login details are correct?

    If it's just me using it, then I would probably not even bother using the xmlapi in the first place
    it's for my clients.

  6. #6
    Member
    Join Date
    Jul 2011
    Location
    Palmerston North, New Zealand
    Posts
    41
    cPanel/WHM Access Level

    Root Administrator

    Default Re: How to check if login details are correct?

    Well the best way is to dump all the variables on screen and see what you get, that way you know whats happening at every step.
    Regards
    Stefan Andres Charsley
    WebFront.co.nz

Similar Threads

  1. Some details to double check when moving servers
    By ianmarie in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 01-28-2009, 06:40 PM
  2. Login Details Lost
    By onestopkidshop in forum New User Questions
    Replies: 1
    Last Post: 12-27-2007, 06:34 AM
  3. cpanel login details
    By deno in forum New User Questions
    Replies: 2
    Last Post: 07-07-2007, 04:37 PM
  4. Help to check my hack Wildcard DNS right or correct or not
    By iamnewbies in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 05-23-2007, 09:49 PM
  5. How do I check if my nameservers are correct.
    By Stevie in forum cPanel & WHM Discussions
    Replies: 3
    Last Post: 02-28-2004, 01:03 PM