The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[case 45745] livephp/API2 Fileman::fileop issue

Discussion in 'cPanel Developers' started by kris.x15, Nov 22, 2010.

  1. kris.x15

    kris.x15 Member

    Joined:
    Sep 20, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I've recently stumbled upon a problem, i think its something with api2.
    Using /usr/local/cpanel/php/cpanel.php class I'm trying to extract zip archive which is placed in home directory of user.

    - archive is correct, using Fileman frontend i'm able to extract it correctly
    - i'm sending valid details, i've compared them to those which are send with ajax by Fileman
    - other calls to API2 works fine

    I'm using following code (in a file with .live.php extension) :
    PHP:
    $cp = new CPANEL();
    $cp->api2("Fileman","fileop",array(
                       
    'destfiles'=>'public_html',
                        
    'sourcefiles'=>'/home/acctst/archive.zip',
                        
    'op'=>'extract',
                        
    'doubledecode'=>'0',
                        
    'metadata'=>''
                    
    ));
    Api call returns:
    PHP:
    array(1) {
      [
    "cpanelresult"]=>
      array(
    4) {
        [
    "apiversion"]=>
        
    string(1"2"
        
    ["event"]=>
        array(
    1) {
          [
    "result"]=>
          
    string(1"1"
        
    }
        [
    "func"]=>
        
    string(6"fileop"
        
    ["module"]=>
        
    string(7"Fileman"
      
    }
    }
    but no data, and archive is not extracted ;( Am I missing something?
     
  2. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    I haven't gotten a chance to test this but are you sure the destination would be 'public_html'. Since you're executing under cPanel, there's not going to be a relative 'public_html' directory. Try the full path for the destination.
     
  3. kris.x15

    kris.x15 Member

    Joined:
    Sep 20, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    I believe I've tried it with this and other various combination, I've switched to API1 - it works with it.
     
  4. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi kris.x15,

    I also tried to execute the API2 Fileman::fileop via LivePHP without success. The same arguments, when used via XML-API, work as expected. So, something is amiss or I'm unclear about some internal process of the Fileman module.

    I will post back after I've had an opportunity to investigate it further.

    Best Regards,
    -DavidN
     
  5. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi all,

    This issue has been resolved in cPanel version 11.28.63 and beyond. You can watch the change log for internal case number 45757 for confirmation of the fix in your cPanel build.

    Regards,
    -DavidN

    TESTING via PHP client class with "archive.zip" in the user's home directory (/home/ctest1):
    PHP:
    <?php
    include("xmlapi.php");

    $ip "10.1.1.1";
    $user 'ctest1';
    $upass 'secr3t!';

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth($user,$upass);
    $xmlapi->set_port('2083');
    $xmlapi->set_debug(1);

    $args = array(
               
    'destfiles'=>'/public_html',          
               
    'sourcefiles'=>'archive.zip',             
               
    'op'=>'extract',
               
    'doubledecode'=>'0',
               
    'metadata'=>''
           
    );

    $xmlapi->api2_query($user,"Fileman","fileop",$args);
     

Share This Page