Reputation: 1
i create 10 files xml with onclick button on my site and i want put all 10 files in archive .cab extension in php.
I try to use a class MakeCAB found in https://www.phpclasses.org/package/4056-PHP-Create-CAB-archives-from-lists-of-files.html but this class is obsolete. i try to update (i change name of __construct) it, but still error and output fil .cab is corrupt. how can i do that? please.
I still have the 2 errors Undefined index and filettr but I don't know how to define them, I don't know if this is the cause of the problem, which is that the generation of the .cab works but there may be a size limit weight or other because it always truncates me one file.
function WriteFiles($res)
{ foreach ( $this->cabfiles as $file )
{ $this->WriteDword( $res, $file['ucomp'] );
$this->WriteDword( $res, $file['offset'] );
$this->WriteWord( $res, $file['index'] ); (line 314 ici)
$this->WriteWord( $res, $file['date'] );
$this->WriteWord( $res, $file['time'] );
$this->WriteWord( $res, $file['fileattr'] ); (line 317 ici)
$this->WriteByteBuffer( $res, $file['name'] );
} }
Some variables and index defined but maybe not all.
var $cabfile;
/** * Array of files to be added to archive
* * @var array *
@access protected */
var $cabfiles = array();
/** * Array of data for CAB folder
* * @var array *
@access protected*/
var $cabfolder = array(
'offset' => 44, ## offset of data
'numblocks' => 0, ## number of blocks
'typecmp' => 1, ## 0 = no compression; 1 = MSZIP; LZX
'fileoffset' => 0 );
/** * Array of data for CAB Header * *
@var array *
@access protected */
var $cabheader = array(
'sig' => "MSCF", ## signature
'res1' => 0, ## reserved space
'size' => 44, ## total size of cab file
'res2' => 0,
'offset' => 44, ## offset of first data block
'res3' => 0,
'vmaj' => 1, ## cab file format major version number 1
'vmin' => 3, ## cab file format minor version number 3
'numfolders' => 1, ## must have at least one folder
NewCABFolder()
'numfiles' => 0, ## number of files in cab file
'flags' => 0, ## not supported
'setid' => 1234, ## set ID (not supported)
'cabid' => 0, ##cab id not supported
);
/**
I call class like code bellow
//Send the MSCAB MIME type
header("Content-Type:application/vnd.ms-cab-
compressed");
//Make it an attachment
header('Content-Disposition: attachment;
filename="WinMSS.cab"');
//include the class file
include'lib/makecab/MakeCAB.class.php';
//create object
$cab = new MakeCAB("WinMSS.cab");
//add a local file system file
$cab->addfile("WinMSS/STAGE.xml");
$cab->addfile("WinMSS/THEMATCH.xml");
$cab->addfile("WinMSS/CLASSIFY.xml");
$cab->addfile("WinMSS/CLUB.xml");
$cab->addfile("WinMSS/ENROLLED.xml");
$cab->addfile("WinMSS/MEMBER.xml");
$cab->addfile("WinMSS/SCORE.xml");
$cab->addfile("WinMSS/SQUAD.xml");
$cab->addfile("WinMSS/TAG.xml");
$cab->addfile("WinMSS/TEAM.xml");
//Make the file
$cab->WriteCAB();
//output the file
readfile("WinMSS.cab");
//delete the file
unlink("WinMSS.cab"); } ?>
I am open to other technical solutions:
use an online compression tool but it takes time
use a language other than php compatible with an html css website etc ...
don't hesitate to give me ideas please Thank you.
Upvotes: 0
Views: 165