用PHP解压缩LZMA [英] Decompressing LZMA with PHP
问题描述
我有很多用LZMA压缩的SWF文件,我想以编程方式对服务器上的PHP进行解压缩和读取. 有人可以将我定向到PHP LZMA SDK吗?我已经为此进行了Google搜索,但到目前为止,除了指向损坏的链接的引用之外,什么都没有找到(针对php的7z扩展名?)
I have a load of SWF files compressed with LZMA that I would like to programatically decompress and read with PHP on my server. Can someone direct me to a PHP LZMA SDK? I've googled for it, but have so far found nothing but references to a broken link (7z extension for php?)
我有一个工作正常的python模块,该模块设法读取LZMA压缩SWF的标头,但它需要一个名为pyLZMA的模块,该模块似乎不想在我的服务器上安装,而让它在本地运行非常麻烦.屁股,所以我更喜欢一个PHP解决方案(如果存在).
I have a working python module that manages to read headers of LZMA compressed SWFs but it requires a module called pyLZMA which doesn't seem to want to install on my server, and getting it to work locally was a massive pain in the arse so I'd much prefer a PHP solution if one exists.
推荐答案
有一个名为 PHP-的库SevenZipArchive ,它是7za和7zr二进制文件的包装.在Linux中为我工作的简单测试方案:
There is a library called PHP-SevenZipArchive which is a wrapper to 7za and 7zr binaries. Simple test scenario working for me in linux:
安装p7zip软件包(yum install p7zip
或类似版本)
install p7zip package (yum install p7zip
or similar)
在linux shell中创建测试压缩文件
create test compressed file in linux shell
echo "Compressed data" | lzma -z > compressed.string
下载并解压缩PHP-SevenZipArchive
download and unzip PHP-SevenZipArchive
wget https://github.com/cmanley/PHP-SevenZipArchive/archive/master.zip
unzip master.zip
为解压缩的输出创建目录
create directory for decompressed output
mkdir out
创建测试php文件
<?php
require "./PHP-SevenZipArchive-master/SevenZipArchive.php";
$archive = new SevenZipArchive('compressed.string', array('binary'=>'/usr/bin/7za'));
$archive->extractTo('out');
?>
php -f ./index.php
将创建输出文件/将其压缩
php -f ./index.php
will create file out/compressed
cat out/compressed
压缩数据
注意:我先前的答案已被主持人删除,原因是它的质量较差,尽管我已经为此赢得了良好的声誉.因此,我将其详细地完全重写了.希望这能提供更多帮助.
NOTE: My previous answer was deleted by moderators for its poor quality, although I already got a positive reputation for it. So I rewrote it completely in a detailed way. Hope this helps even more.
这篇关于用PHP解压缩LZMA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!