/** * @param string $destinationFile * @param string $extensionRequired * @dataProvider tarProvider */ public function testExtract($destinationFile, $extensionRequired) { if ($extensionRequired && !extension_loaded($extensionRequired)) { $this->markTestSkipped("The extension '{$extensionRequired}' is not enabled."); } $this->packed = $this->archive->pack($this->sourceFilePath, $this->destinationDir . $destinationFile); $this->assertFileExists($this->packed); $this->assertEquals($this->destinationDir . $destinationFile, $this->packed); $filename = pathinfo($this->sourceFilePath, PATHINFO_BASENAME); $this->unpacked = $this->archive->extract($filename, $this->packed, $this->destinationDir); $this->assertFileExists($this->unpacked); $this->assertStringStartsWith($this->destinationDir, $this->unpacked); }
/** * Get a list of deployments * * @return remote.server.deploy.Deployable[] */ public function scanDeployments() { clearstatcache(); $this->changed = FALSE; while ($entry = $this->folder->getEntry()) { if (!preg_match($this->pattern, $entry)) { continue; } $f = new File($this->folder->getURI() . $entry); if (isset($this->files[$entry]) && $f->lastModified() <= $this->files[$entry]) { // File already deployed continue; } $this->changed = TRUE; $ear = new Archive(new File($this->folder->getURI() . $entry)); try { $ear->open(ARCHIVE_READ) && ($meta = $ear->extract('META-INF/bean.properties')); } catch (Throwable $e) { $this->deployments[$entry] = new IncompleteDeployment($entry, $e); continue; } $prop = Properties::fromString($meta); $beanclass = $prop->readString('bean', 'class'); if (!$beanclass) { $this->deployments[$entry] = new IncompleteDeployment($entry, new FormatException('bean.class property missing!')); continue; } $d = new Deployment($entry); $d->setClassLoader(new ArchiveClassLoader($ear)); $d->setImplementation($beanclass); $d->setInterface($prop->readString('bean', 'remote')); $d->setDirectoryName($prop->readString('bean', 'lookup')); $this->deployments[$entry] = $d; $this->files[$entry] = time(); delete($f); } // Check existing deployments foreach (array_keys($this->deployments) as $entry) { $f = new File($this->folder->getURI() . $entry); if (!$f->exists()) { unset($this->deployments[$entry], $this->files[$entry]); $this->changed = TRUE; } delete($f); } $this->folder->close(); return $this->changed; }
public function codiad_CFG($hash) { $dir_relative = GlobalMas::$filesPath_relative . $hash . "/"; $dir = GlobalMas::$filesPath_absolute . $hash . "/"; //----------------------------------------------------- if (!file_exists($dir . "codiad")) { Archive::extract(GlobalMas::$filesPath_absolute . "/codiad.zip", $dir); //----------------------------------------------------- $config_contents = FileFolder::file_get_contents($dir . "codiad/config.php"); $config_contents = str_replace("{BASE_PATH}", $dir . "codiad", $config_contents); $config_contents = str_replace("{BASE_URL}", GenFun::get_full_url($dir . "codiad"), $config_contents); FileFolder::file_put_contents($dir . "codiad/config.php", $config_contents); //--------------------------------------------------------- exec("ln -s " . $dir . "compile " . $dir . "codiad/workspace/compile" . " 2>&1", $output); exec("ln -s " . $dir . " " . $dir . "codiad/workspace/root" . " 2>&1", $output); //--------------------------------------------------------- if (strpos(join($output), "Errno::") !== false) { krumo($output); die; } } }
public function extractNonExistant() { $a = new Archive($this->archiveBytesAsStream()); $a->open(ARCHIVE_READ); $this->assertEquals($this->version(), $a->version); $a->extract('DOES-NOT-EXIST'); }
public function init($obj) { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'result' => array(), "func" => "init"); //---------------------------------------------------------- if (!is_null($obj)) { if (isset($obj['zip'])) { $getFile = GetTable::go("files", array("id" => $obj['zip'])); //------------------------------------------------------ if (!$getFile['bool']) { return $getFile; } if (sizeof($getFile['result']) > 0) { //-------------------------------------------------- $projectName = $obj['project_name']; $hash = $getFile['result'][0]['hash']; $dir_relative = GlobalMas::$filesPath_relative . $hash . "/"; $dir = GlobalMas::$filesPath_absolute . $hash . "/"; $zip_path = $dir . $getFile['result'][0]['name']; $savePath = dirname($zip_path) . "/compile/" . $projectName . "/"; //----------------------------------------------------- Archive::extract($zip_path, $this->extractTo = dirname($zip_path) . "/" . FileFolder::getFileName($zip_path)); //----------------------------------------------------- //if (isset($obj['take_file_name']) && $obj['take_file_name'] == "true") $projectName = FileFolder::getFileName($zip_path); //----------------------------------------------------- $url = GenFun::get_full_url(dirname($zip_path) . "/" . rawurlencode(FileFolder::getFileName($zip_path)) . "/"); //----------------------------------------------------- $bool = $this->htmlExist_CHK($this->extractTo); } } else { if (isset($obj['url']) || is_string($obj)) { $url = isset($obj['url']) ? $obj['url'] : $obj; $bool = $this->htmlExist_CHK($url_local = GenFun::get_local_url($url)); //------------------------------------------------------ $output = CurlUtil::go(array("url" => $url)); $projectName = $this->getTitle($output); //------------------------------------------------------ if (is_null($projectName)) { $projectName = date("YmdHis"); $hash = alphaID(strtotime($projectName)); $projectName = "untitled_" . $projectName; } //------------------------------------------------------ $savePath_relative = $hash . "/" . "compile/" . $projectName . "/"; $savePath = GlobalMas::$filesPath_absolute . $savePath_relative; /*if (isset($obj['take_file_name']) && $obj['take_file_name'] == "true")*/ $useTitle = true; } else { $chk = array(); $chk['bool'] = false; $chk['error'] = true; $chk['message'] = $this->notifications_CFG(["message" => "Url could not be obtained!!!"]); die(json_encode($chk)); } } //--------------------------------------------------------- $compiler = $this->compile_CFG($url, $projectName, $savePath); //--------------------------------------------------------- if (!is_null($compiler->error)) { return $compiler->error; } //--------------------------------------------------------- //$chk['bool'] = true; // $chk['compiler'] = $compiler; $notifications = $compiler->compilerGlobal->notifications; //--------------------------------------------------------- /*if (sizeof($notifications) > 0) { $chk = $this->deleteFile($getFile['result'][0]['id'], true); $chk['message'] = $this->notifications_CFG($notifications); $chk['bool'] = false; $chk['error'] = true; return $chk; }*/ //--------------------------------------------------------- $new_zip_path = Archive::zipDir($compiler->compilePath); //--------------------------------------------------------- $prop = array(); $prop['hash'] = "{hash}"; $prop['url'] = $url; $prop['name'] = $projectName; $prop['dir'] = $savePath_relative; $prop["filesize"] = FileFolder::getFileSize($new_zip_path); if (isset($obj['zip'])) { $prop['files_id'] = $obj['zip']; } //--------------------------------------------------------- $chk = InsertINTO::go("compiles", $prop); //--------------------------------------------------------- $chk['download_link'] = GenFun::get_full_url(Import::$uber_src_path . "server/werm/services/Download.php") . "?url=" . GenFun::get_full_url($new_zip_path); $chk["filesize"] = $prop["filesize"]; $chk["url"] = $url; //--------------------------------------------------------- //$chk['project_location'] = GenFun::get_full_url($compiler->compilePath); } return $chk; }
#!/usr/bin/env php <?php /** * The installer sub-stub for extension phars */ namespace pharext; define("PHAREXT_PHAR", __FILE__); spl_autoload_register(function ($c) { return include strtr($c, "\\_", "//") . ".php"; }); #include <pharext/Exception.php> #include <pharext/Tempname.php> #include <pharext/Tempfile.php> #include <pharext/Tempdir.php> #include <pharext/Archive.php> namespace pharext; if (extension_loaded("Phar")) { \Phar::interceptFileFuncs(); \Phar::mapPhar(); $phardir = "phar://" . __FILE__; } else { $archive = new Archive(__FILE__); $phardir = $archive->extract(); } set_include_path("{$phardir}:" . get_include_path()); $installer = new Installer(); $installer->run($argc, $argv); __halt_compiler();