本文整理汇总了PHP中PharData::decompress方法的典型用法代码示例。如果您正苦于以下问题:PHP PharData::decompress方法的具体用法?PHP PharData::decompress怎么用?PHP PharData::decompress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PharData
的用法示例。
在下文中一共展示了PharData::decompress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: diy_compile
//.........这里部分代码省略.........
$stmt2 = $storage->prepare('SELECT * FROM oauth_clients WHERE client_id = :device');
$stmt2->execute(array('device' => trim($device)));
$row2 = $stmt2->fetch(PDO::FETCH_ASSOC);
if ($row2["apiport"]) {
// *************************************** compiler *********************************
// srcfile echeis se base64 ton kodika
// compiler echeis ton compiler pou thelei o user mechri stigmis echoume gcc, ino
// filename to filename pou edosse o user
// o poros compilesketch
// afou kanei compile
// epistrefei
// error ta lathi h noerrors
// binfile to hex file
$compilerserver = diyConfig::read("compiler.host");
$compilerserver .= ":" . diyConfig::read("compiler.port");
$data1 = 'filename=' . $filename;
$data1 .= '&compiler=' . $comp;
$data1 .= '&srcfile=' . $srcfile;
$fixedFiles = array();
foreach ($srclib as $curName => $curFile) {
$fixedFiles[] = 'srclib[' . $curName . ']=' . $curFile;
}
$data1 .= '&' . implode('&', $fixedFiles);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "{$compilerserver}/api/compilesketch");
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data1);
curl_setopt($ch, CURLOPT_POST, 1);
$or = curl_exec($ch);
if (!$or) {
$or = curl_error($ch);
}
$result["compiler"] = $or;
$result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: NoErrors";
$result["status"] = "200";
$r = json_decode($or, true);
if (!$r) {
$result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: CompilationError";
$result["compiler"] = $or;
$result["status"] = "500";
return $result;
}
if ($r['status'] != 200) {
$result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: CompilationError";
$result["status"] = "500";
return $result;
}
unset($result["compiler"]);
// No need to transfer this to the user
//$srcfilebase64encode = base64_encode($srcfile);
$apiport = trim($row2["apiport"]);
// *************************************** compiler *********************************
if ($r['status'] == 200 && $writedevice == "yes") {
$apiport = trim($row2["apiport"]);
$binfile = $r['hex'];
$data1 = 'file=base64';
$data1 .= '&binfile=' . $binfile;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:{$apiport}/api/writesketch");
curl_setopt($ch, CURLOPT_TIMEOUT, 90);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data1);
curl_setopt($ch, CURLOPT_POST, 1);
$r = curl_exec($ch);
$result["sketch"] = $r;
$result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: NoErrors";
$result["status"] = "200";
//$result["result"]= $r;
}
// If we are here with no exceptions then everything went well. Lets save the sketch.
$ziptmp = tempnam(sys_get_temp_dir(), 'diytmpzip') . '.tgz';
file_put_contents($ziptmp, base64_decode($r['zip']));
$p = new PharData($ziptmp);
$p->decompress();
// creates /path/to/my.tar
$ziptmpextracted = str_replace('.tgz', '.tar', $ziptmp);
$phar = new PharData($ziptmpextracted);
$writeDir = __DIR__ . '/../../../data/sketches/' . $client_id . '/' . $filename;
$phar->extractTo($sourceWriteDir);
}
} catch (Exception $e) {
$diy_error["db"] = $e->getCode();
$result["status"] = $e->getCode();
$result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $e->getMessage();
}
}
} catch (Exception $e) {
$diy_error["db"] = $e->getCode();
$result["status"] = $e->getCode();
$result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $e->getMessage();
}
}
if (diyConfig::read('debug') == 1) {
$result["debug"] = $diy_error;
}
return $result;
}
示例2: action
public function action($parent)
{
$c = $parent->config;
$util = new Utility();
if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0) {
$this->r = array('wrong path', 400);
return;
}
$path = $c['current_path'] . $_POST['path'];
$info = pathinfo($path);
$base_folder = $c['current_path'] . $util->fix_dirname($_POST['path']) . "/";
switch ($info['extension']) {
case "zip":
$zip = new \ZipArchive();
if ($zip->open($path) === true) {
//make all the folders
for ($i = 0; $i < $zip->numFiles; $i++) {
$OnlyFileName = $zip->getNameIndex($i);
$FullFileName = $zip->statIndex($i);
if (substr($FullFileName['name'], -1, 1) == "/") {
$util->create_folder($base_folder . $FullFileName['name']);
}
}
//unzip into the folders
for ($i = 0; $i < $zip->numFiles; $i++) {
$OnlyFileName = $zip->getNameIndex($i);
$FullFileName = $zip->statIndex($i);
if (!(substr($FullFileName['name'], -1, 1) == "/")) {
$fileinfo = pathinfo($OnlyFileName);
if (in_array(strtolower($fileinfo['extension']), $ext)) {
copy('zip://' . $path . '#' . $OnlyFileName, $base_folder . $FullFileName['name']);
}
}
}
$zip->close();
} else {
$this->r = array('Could not extract. File might be corrupt.', 500);
return;
}
break;
case "gz":
$p = new \PharData($path);
$p->decompress();
// creates files.tar
break;
case "tar":
// unarchive from the tar
$phar = new \PharData($path);
$phar->decompressFiles();
$files = array();
$util->check_files_extensions_on_phar($phar, $files, '', $ext);
$phar->extractTo($current_path . fix_dirname($_POST['path']) . "/", $files, true);
break;
default:
$this->r = array('This extension is not supported. Valid: zip, gz, tar.', 400);
return;
break;
}
}
示例3: extract
public function extract()
{
$varDir = $this->rootDir . DIRECTORY_SEPARATOR . 'var';
$tarFile = $varDir . DIRECTORY_SEPARATOR . 'magento.tar';
if (file_exists($tarFile)) {
unlink($tarFile);
}
$phar = new \PharData($this->filename);
$phar->decompress();
$phar = new \PharData($tarFile);
$phar->extractTo($varDir, null, true);
}
示例4: unzipArchive
/**
* Unzip specified archive
*
* @param string $backupFilePath
* @throws \RuntimeException
* @return $this
*/
private function unzipArchive($backupFilePath)
{
$phar = new \PharData($backupFilePath);
$tarFile = str_replace('.tgz', '.tar', $backupFilePath);
if (@file_exists($tarFile)) {
@unlink($tarFile);
}
$phar->decompress();
$tar = new \PharData($tarFile);
if (strpos($backupFilePath, BackupInfo::BACKUP_MEDIA) > 0) {
$this->deleteDirectory($this->restoreTargetDir . '/pub/media');
} elseif (strpos($backupFilePath, BackupInfo::BACKUP_CODE) > 0) {
$blackListFolders = $this->backupInfo->getBlacklist();
$exclusions = [];
foreach ($blackListFolders as $blackListFolder) {
$exclusions[] = $this->restoreTargetDir . '/' . $blackListFolder;
}
try {
$this->deleteDirectory($this->restoreTargetDir, $exclusions);
} catch (\Exception $e) {
$this->status->setUpdateError();
$this->status->add('Error during rollback ' . $e->getMessage(), \Psr\Log\LogLevel::ERROR);
}
} else {
$this->status->setUpdateError();
$this->status->add('Invalid backup type', \Psr\Log\LogLevel::INFO);
}
$tar->extractTo($this->restoreTargetDir, null, true);
@unlink($tarFile);
//TODO Temporary solution, can be removed when MAGETWO-38589 is fixed.
if (strpos($backupFilePath, BackupInfo::BACKUP_MEDIA) > 0) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->restoreTargetDir . '/pub/media'), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $item) {
@chmod($item, 0777);
}
} elseif (strpos($backupFilePath, BackupInfo::BACKUP_CODE) > 0) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->restoreTargetDir), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $item) {
@chmod($item, 0755);
}
$writeAccessFolders = ['/pub/media', '/pub/static', '/var'];
foreach ($writeAccessFolders as $folder) {
if (file_exists($this->restoreTargetDir . $folder)) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->restoreTargetDir . $folder), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $item) {
@chmod($item, 0777);
}
}
}
}
//TODO Till here
}
示例5: extract
/**
* @param \SplFileInfo $archive
*
* @return bool
* @throws \Exception
*/
public function extract(\SplFileInfo $archive, \SplFileInfo $destination)
{
if (preg_match('/^win/i', PHP_OS)) {
$targz = new \PharData($archive->getPathname());
/** @var \PharData $tar */
$tar = $targz->decompress();
$tar->extractTo($destination->getPathname());
unlink(str_replace('.tar.gz', '.tar', $archive->getPathname()));
} else {
exec('tar xzf ' . $archive->getPathname() . ' -C ' . $destination->getPathname());
}
return true;
}
示例6: unpack
public function unpack($files = [])
{
$this->isPackageFileValid();
// decompress from gz
$tarFile = str_replace('.tar.gz', '.tar', $this->filePath);
@unlink($tarFile);
$gz = new \PharData($this->filePath);
$gz->decompress();
$this->cleanupFiles[] = $tarFile;
$unzipDir = str_replace('.tar', '', $tarFile);
// un-archive from the tar
$phar = new \PharData($tarFile);
$extractFiles = $files ? array_map(function ($file) {
return Package::ARCHIVE_INNER_DIR . DIRECTORY_SEPARATOR . $file;
}, $files) : null;
$phar->extractTo($unzipDir, $extractFiles, true);
$this->cleanupFiles[] = $unzipDir;
$this->unpackedDir = $unzipDir . DIRECTORY_SEPARATOR . self::ARCHIVE_INNER_DIR;
return $this->unpackedDir;
}
示例7: extensionExists
/**
* @Then /^"([^"]*)" ((?:\d+\.?)+(?:RC\d*|beta\d*|alpha\d*)?) extension exists$/
*/
public function extensionExists($name, $version)
{
$url = 'http://pecl.php.net/get/' . $name . '/' . $version;
$file = $name . '-' . $version . '.tgz';
$dir = $this->workingDir . '/' . basename($file, '.tgz');
if (is_dir($dir) === false) {
mkdir($dir, 0777, true);
}
file_put_contents($dir . '/' . $file, file_get_contents($url));
$p = new PharData($dir . '/' . $file);
$phar = $p->decompress('.tgz');
$phar->extractTo($dir);
}
示例8: analyzeFiles
function analyzeFiles($downloadedFiles)
{
$count = 0;
foreach ($downloadedFiles as $downloadedFile) {
try {
echo "Analyzing {$downloadedFile}:\n";
$tmpFilename = "./testExtract/temp{$count}.tar.gz";
copy($downloadedFile, $tmpFilename);
$pharData = new PharData($tmpFilename);
@unlink("./testExtract/temp{$count}.tar");
$pharData->decompress();
// creates files.tar
$tarFileName = "./testExtract/temp{$count}.tar";
$decompPhar = new PharData($tarFileName);
//$result = @rmdir("./testExtract/blahblah");
$count++;
removeDirectory("./testExtract/blahblah");
@mkdir("./testExtract/blahblah");
$decompPhar->extractTo("./testExtract/blahblah");
analyzeCodeInPath("./testExtract/blahblah");
@unlink($tmpFilename);
@unlink($tarFileName);
removeDirectory("./testExtract/blahblah");
} catch (\PharException $pe) {
echo "Failed to extract files: " . $pe->getMessage() . "\n";
}
}
}
示例9: Untar
public static function Untar($File)
{
$Path = File::FileDir($File);
$TarGzFile = new PharData($File);
$TarGzFile->decompress();
preg_match('/(.*)\\.([^.]*)$/', $File, $matches);
$TarPath = str_replace('.' . $matches[2], '', $File);
$TarFile = new PharData($TarPath);
$TarFile->extractTo($Path);
}
示例10: untargz
function untargz($app)
{
$phar = new PharData($this->tempArchive);
if (!$phar->decompress('tmp.tar')) {
$this->setMessage('Can\'t untargz this app (error decompressing the archive).', PAD_MESSAGE_ERROR);
return false;
}
@unlink($this->tempArchive);
$phar2 = new PharData($this->tempArchive . '.tar');
if (!$phar2->extractTo('.', null, true)) {
$this->setMessage('Can\'t untargz this app (error extracting the archive).', PAD_MESSAGE_ERROR);
return false;
}
@unlink($this->tempArchive . '.tar');
return true;
}
示例11: rand
<?php
// Get Input JSON
$data = json_decode(file_get_contents('php://input'), true);
// Init Variables
$tmp_path = "tmp/" . rand();
// Load Config
$config_string = file_get_contents("../config/config.json");
$config_json = json_decode($config_string, true);
// Copy files to temp folder
$res_bool = mkdir($tmp_path);
$res_bool = copy($config_json['mapping_path'] . "/" . $data['app'], $tmp_path . "/" . $data['app']);
$res_bool = file_put_contents($tmp_path . "/trace.txt", $data['trace'], LOCK_EX);
$p1 = new PharData($tmp_path . "/" . $data['app']);
$p1->decompress();
$p2 = new PharData($tmp_path . "/" . dirGetFileWithExt($tmp_path . "/", ".tar"));
$p2->extractTo($tmp_path);
$tmp_mapping_path = dirFindFile($tmp_path, "mapping.txt");
// Execute Command
exec($config_json['sdk_path'] . "/tools/proguard/bin/retrace.sh -verbose " . $tmp_mapping_path . " " . $tmp_path . "/trace.txt", $output, $return_var);
// Clean
delTree($tmp_path);
// Build JSON and return
$res_out = "";
foreach ($output as $value) {
$res_out .= $value . "\n";
}
$res_array = array("retrace_output" => $res_out, "return_code" => $return_var);
$res_json = json_encode($res_array);
echo $res_json;
/** Functions *********************/
示例12: install
public function install($tmpfilepath, $updateOnce = false)
{
// Checks if the given path is a directory. This may happen when not
// giving a file to the application installation page.
if (is_dir($tmpfilepath)) {
return false;
}
$result = false;
$innomatic = $this->container;
if ($innomatic->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) {
$innomatic->getLoadTimer()->Mark('applicationinstallstart');
}
if (file_exists($tmpfilepath)) {
// Moves temp file to applications repository and extracts it
//
$fname = $this->container->getHome() . 'core/applications/' . basename($tmpfilepath);
@copy($tmpfilepath, $fname);
$basetmpdir = $tmpdir = $this->container->getHome() . 'core/temp/appinst/' . md5(microtime());
@mkdir($tmpdir, 0755);
$olddir = getcwd();
@chdir($tmpdir);
if (substr($fname, -4) == '.zip') {
} else {
try {
$appArchive = new \PharData($fname);
$tarFileName = substr($fname, 0, strpos($fname, '.')) . '.tar';
if (file_exists($tarFileName)) {
unlink($tarFileName);
}
$appArchive->decompress();
} catch (\BadMethodCallException $e) {
}
try {
$appArchive->extractTo($tmpdir);
} catch (Exception $e) {
}
}
// Checks if the files are into a directory instead of the root
//
if (!@is_dir($tmpdir . '/setup')) {
$dhandle = opendir($tmpdir);
while (false != ($file = readdir($dhandle))) {
if ($file != '.' && $file != '..' && (is_dir($tmpdir . '/' . $file . '/setup') or is_dir($tmpdir . '/' . $file . '/innomatic/setup'))) {
if (is_dir($tmpdir . '/' . $file . '/setup')) {
$tmpdir = $tmpdir . '/' . $file;
} else {
$tmpdir = $tmpdir . '/' . $file . '/innomatic';
}
break;
}
}
closedir($dhandle);
}
$this->basedir = $tmpdir;
// Checks for definition and structure files
//
if (file_exists($tmpdir . '/setup/bundle.ini')) {
$applicationsArray = file($tmpdir . '/setup/bundle.ini');
$result = true;
while (list(, $application) = each($applicationsArray)) {
$application = trim($application);
if (strlen($application) and file_exists($tmpdir . '/applications/' . $application)) {
$tempApplication = new Application($this->rootda);
if (!$tempApplication->Install($tmpdir . '/applications/' . $application)) {
$result = false;
}
}
}
} elseif (file_exists($tmpdir . '/setup/application.xml')) {
$genconfig = $this->parseApplicationDefinition($tmpdir . '/setup/application.xml');
$this->appname = $genconfig['ApplicationIdName'];
// Checks if the application has been already installed
//
$tmpquery = $this->rootda->execute('SELECT id,appfile FROM applications WHERE appid=' . $this->rootda->formatText($this->appname));
if (!$tmpquery->getNumberRows()) {
// Application is new, so it will be installed
//
// Dependencies check
//
$this->unmetdeps = array();
$this->unmetsuggs = array();
$appdeps = new ApplicationDependencies();
$deps = $appdeps->explodeDependencies($genconfig['ApplicationDependencies']);
$suggs = $appdeps->explodeDependencies($genconfig['ApplicationSuggestions']);
if ($deps != false) {
$this->unmetdeps = $appdeps->checkApplicationDependencies(0, '', $deps);
} else {
$this->unmetdeps = false;
}
// Suggestions check
//
if ($suggs != false) {
$unmetsuggs = $appdeps->checkApplicationDependencies(0, '', $suggs);
if (is_array($unmetsuggs)) {
$this->unmetsuggs = $unmetsuggs;
}
}
// If dependencies are ok, go on
//
if ($this->unmetdeps == false) {
//.........这里部分代码省略.........
示例13: extract
protected function extract($file, $path)
{
$archive = new \PharData($file);
$archive->decompress()->extractTo($path, null, true);
}
示例14: download_variant_pdf
/**
* Download Variant PDF
*
* Download the variant data page in PDF format using the
* dompdf library (found in application/third_party/dompdf/)
*
* More info on dompdf at https://github.com/dompdf/dompdf
*
* @author Sean Ephraim, Nikhil Anand
* @access public
* @param int $id Variant's unique ID
* @return void
*/
public function download_variant_pdf($id)
{
// Install DomPDF (if it's missing)
if (!file_exists(APPPATH . 'third_party/dompdf')) {
$dir = APPPATH . "third_party/";
// Download DomPDF
file_put_contents($dir . "dompdf.tar.gz", file_get_contents("https://dompdf.googlecode.com/files/dompdf_0-6-0_beta3.tar.gz"));
// Decompress from gz
$p = new PharData($dir . 'dompdf.tar.gz');
$p->decompress();
// creates dompdf.tar
// Unarchive from the tar
$p = new PharData($dir . 'dompdf.tar');
$p->extractTo($dir . 'dompdf_temp');
rename($dir . 'dompdf_temp/dompdf', $dir . 'dompdf');
// Remove unwanted files/directories
unlink($dir . 'dompdf.tar.gz');
unlink($dir . 'dompdf.tar');
rmdir($dir . 'dompdf_temp');
}
// 'full' and 'print' must be set as parameters for proper PDF display
if (!isset($_GET['print']) || !isset($_GET['full'])) {
// ... set these parameters if they aren't already
redirect("pdf/{$id}?full&print");
}
define("DOMPDF_ENABLE_REMOTE", true);
// Override default config
require_once APPPATH . "third_party/dompdf/dompdf_config.inc.php";
$data = $this->variations_model->get_variant_display_variables($id);
$data['title'] = $data['variation'];
$content = 'variations/variant/index';
// Get HTML
$target_html = $this->load->view($content, $data, true);
// Make the PDF using DOMPDF and offer it for download
$pdf_object = new DOMPDF();
$pdf_object->load_html($target_html);
$pdf_object->render();
$pdf_object->stream($this->strings['site_short_name'] . '-pdf.' . $id . '.pdf');
}
示例15: unpackTarGz
/**
* Unpack a tar.gz file
*
* @param string $path
* @param string $target
* return bool
*/
public function unpackTarGz($path, $target)
{
// decompress from gz
$p = new PharData($path);
$p->decompress();
// creates /path/to/my.tar
// unarchive from the tar
$phar = new PharData(strtok($path, '.') . '.gz');
$phar->extractTo(strtok($path, '.'));
return true;
//var_dump($path,$target,strtok($path, '.'));
//die;
}