( API) CMD_FILE_MANAGER to download a file.

urgido

Verified User
Joined
Oct 28, 2008
Messages
429
Location
MX
Hi
I have my own CRM development on CI 3. I tried to use it to download a softaculous backups which generate all backups under /home/USER/softaculous_backups/

My function looks like this:
PHP:
function download_respaldos($ip_ld,$usuario_ld,$pass_ld,$path,$archivo){
                $sock = new HTTPSocket;
                $server_ip=$ip_ld;
                //$pass_hash=base64_decode($data['servidor']['password']);
                //$pass_hash_decode=explode('directadmin',$pass_hash);
                //$server_pass=$pass_hash_decode[1];
                $server_ssl="Y";
                $server_login='admin|'.$usuario_ld;
                $server_pass=$pass_ld;
                
                //
                
                if ($server_ssl == 'Y')
                {
                    $sock->connect("ssl://".$server_ip, 2222);
                }
                else
                {
                    $sock->connect($server_ip, 2222);
                }
                $sock->proxy = true;
                $sock->set_login($server_login,$server_pass);
                $sock->set_method('GET');
                $sock->query('/CMD_FILE_MANAGER/'.$path.$archivo.'?noredirect=true');
                            
                return $sock->fetch_parsed_body();
            }

The backups files are stores like the following name wp.26_70203.2021-10-16_15-33-03.tar.gz

When I try to download the file using an API call I receive just a $_GET['parameter'].gz instead of wp.26_70203.2021-10-16_15-33-03.tar.gz.
The file is more huge that the file selected and is totally corrupted.

The scenario turns more confused because if I test for file exists as explained on the following link https://www.directadmin.com/features.php?id=2165 it retuns "TRUE" so, the file is readed.

If I create a txt file or html file under /softaculous_backus/ I can view/download without issue.

I tried to rename the file extention to .zip but it fails too and still downloading as $_GET['parameter'].gz

softaculous_backups is permission set 0711 and files created on it are 0600.

I use the same code to download DA backups from /backups and still works perfectly.

I am under cloudlinux + litespeed web server + owasp mod_security rules.

Do I missing something?
Can somebody guide me?

Thanks
FYI: I am using latest httpsocket class.
 
Back
Top