コード例 #1
1
function diy_compile($payload, $storage)
{
    global $app;
    $result["controller"] = __FUNCTION__;
    $result["function"] = substr($app->request()->getPathInfo(), 1);
    $result["method"] = $app->request()->getMethod();
    $params = loadParameters();
    $result->function = substr($app->request()->getPathInfo(), 1);
    $result->method = $app->request()->getMethod();
    $params = loadParameters();
    $srcfile = OAuth2\Request::createFromGlobals()->request["srcfile"];
    $srclib = OAuth2\Request::createFromGlobals()->request["srclib"];
    $device = OAuth2\Request::createFromGlobals()->request["device"];
    $comp = OAuth2\Request::createFromGlobals()->request["comp"];
    $filename = OAuth2\Request::createFromGlobals()->request["filename"];
    $writedevice = OAuth2\Request::createFromGlobals()->request["writedevice"];
    $up = json_decode(base64_decode($payload));
    $client_id = $up->client_id;
    $diy_error["post"]["device"] = $device;
    $post["srcfile"] = $srcfile;
    //organisation                                  oauth_devices
    $post["device"] = $device;
    //organisation                                  oauth_devices
    $post["comp"] = $comp;
    //organisation                                  oauth_devices
    $post["filename"] = $filename;
    //organisation                                  oauth_devices
    $post["writedevice"] = $writedevice;
    //organisation                                  oauth_devices
    $gump = new GUMP();
    $gump->validation_rules(array('device' => 'required|alpha_numeric', 'filename' => 'required|alpha_numeric', 'comp' => 'required|alpha_numeric', 'writedevice' => 'required|alpha_numeric'));
    $gump->filter_rules(array('device' => 'trim|sanitize_string', 'filename' => 'trim|sanitize_string', 'comp' => 'trim|sanitize_string', 'writedevice' => 'trim|sanitize_string'));
    $validated = $gump->run($post);
    if ($validated === false) {
        $result["parse_errors"] = $gump->get_readable_errors(true);
        $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $gump->get_readable_errors(true);
    } else {
        try {
            $sourceWriteDir = __DIR__ . '/../../../data/sketches/' . $client_id . '/' . $device . '/' . $filename;
            if (file_exists($sourceWriteDir)) {
                throw new \Exception('Filename ' . $filename . ' for user ' . $client_id . ' and device ' . $device . ' already exists');
            }
            $stmt2 = $storage->prepare('SELECT * FROM oauth_devices WHERE device = :device');
            $stmt2->execute(array('device' => trim($device)));
            $row2 = $stmt2->fetch(PDO::FETCH_ASSOC);
            if ($row2["organisation"]) {
                $org = trim($row2["organisation"]);
            }
            if ($row2["mode"]) {
                $mode = trim($row2["mode"]);
            }
            if ($row2["status"]) {
                $status = trim($row2["status"]);
            }
            if ($row2["client_id"]) {
                $devclient_id = trim($row2["client_id"]);
            }
            $orgscopeadmin = "no";
            $orgscopedevel = "no";
            if ($mode == "devel" && $status == "org") {
                $userscopes = explode(' ', trim($userscope));
                $adminscope = $org . "_admin";
                $develscope = $org . "_admin";
                // o user aniki sto scope
                for ($i = 0; $i <= count($userscopes); $i++) {
                    if (trim($userscopes[$i]) == $adminscope) {
                        $orgscopeadmin = "yes";
                    }
                    if (trim($userscopes[$i]) == $develscope) {
                        $orgscopedevel = "yes";
                    }
                }
                // einai o owner
                if ($devclient_id == $client_id) {
                    $orgscopeadmin = "yes";
                }
            }
            // einmai o owner
            if ($mode == "devel" && $status == "private" && $devclient_id == $client_id) {
                $orgscopeadmin = "yes";
            }
            $result["result"]["sketch1"] = $orgscopeadmin;
            if ($orgscopeadmin == "yes" || $orgscopedevel == "yes") {
                try {
                    $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
0
 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
0
 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
0
ファイル: Rollback.php プロジェクト: pradeep-wagento/magento2
 /**
  * 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
0
 /**
  * @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
0
ファイル: Package.php プロジェクト: martinsik/php-doc-parser
 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
0
ファイル: FeatureContext.php プロジェクト: jingdor/pickle
 /**
  * @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
0
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
0
 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
0
ファイル: pad.php プロジェクト: paspo/phpAppDownloader
 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
0
<?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
0
 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) {
                     // Gets serial number for the application
                     //
                     $this->serial = $this->rootda->getNextSequenceValue('applications_id_seq');
                     $this->rootda->execute('INSERT INTO applications VALUES ( ' . $this->serial . ',' . $this->rootda->formatText($genconfig['ApplicationIdName']) . ',' . $this->rootda->formatText($genconfig['ApplicationVersion']) . ',' . $this->rootda->formatText($genconfig['ApplicationDate']) . ',' . $this->rootda->formatText($genconfig['ApplicationDescription']) . ',' . $this->rootda->formatText(basename($tmpfilepath)) . ',' . $this->rootda->formatText($this->rootda->fmtfalse) . ',' . $this->rootda->formatText($genconfig['ApplicationAuthor']) . ',' . $this->rootda->formatText($genconfig['ApplicationAuthorEmail']) . ',' . $this->rootda->formatText($genconfig['ApplicationAuthorWeb']) . ',' . $this->rootda->formatText($genconfig['ApplicationSupportEmail']) . ',' . $this->rootda->formatText($genconfig['ApplicationBugsEmail']) . ',' . $this->rootda->formatText($genconfig['ApplicationCopyright']) . ',' . $this->rootda->formatText($genconfig['ApplicationLicense']) . ',' . $this->rootda->formatText($genconfig['ApplicationLicenseFile']) . ',' . $this->rootda->formatText($genconfig['ApplicationChangesFile']) . ',' . $this->rootda->formatText($genconfig['ApplicationMaintainer']) . ',' . $this->rootda->formatText($genconfig['ApplicationMaintainerEmail']) . ',' . $this->rootda->formatText($genconfig['ApplicationCategory']) . ',' . $this->rootda->formatText($genconfig['ApplicationIconFile']) . ')');
                     // Application dir creation
                     //
                     @mkdir($this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'], 0755);
                     // Defs files
                     //
                     if ($dhandle = @opendir($tmpdir . '/setup')) {
                         while (false != ($file = readdir($dhandle))) {
                             if ($file != '.' && $file != '..' && is_file($tmpdir . '/setup/' . $file)) {
                                 @copy($tmpdir . '/setup/' . $file, $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $file);
                             }
                         }
                         closedir($dhandle);
                     }
                     // Adds applications dependencies
                     //
                     $appdeps->addDependenciesArray($genconfig['ApplicationIdName'], $deps, ApplicationDependencies::TYPE_DEPENDENCY);
                     $appdeps->addDependenciesArray($genconfig['ApplicationIdName'], $suggs, ApplicationDependencies::TYPE_SUGGESTION);
                     $this->setOptions(explode(',', trim($genconfig['ApplicationOptions'], ' ,')));
                     $this->HandleStructure($tmpdir . '/setup/application.xml', Application::INSTALL_MODE_INSTALL, $tmpdir);
                     if (strlen($genconfig['ApplicationLicenseFile']) and file_exists($tmpdir . '/setup/' . $genconfig['ApplicationLicenseFile'])) {
                         @copy($tmpdir . '/setup/' . $genconfig['ApplicationLicenseFile'], $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $genconfig['ApplicationLicenseFile']);
                     }
                     if (strlen($genconfig['ApplicationChangesFile']) and file_exists($tmpdir . '/setup/' . $genconfig['ApplicationChangesFile'])) {
                         @copy($tmpdir . '/setup/' . $genconfig['ApplicationChangesFile'], $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $genconfig['ApplicationChangesFile']);
                     }
                     if (strlen($genconfig['ApplicationIconFile']) and file_exists($tmpdir . '/setup/' . $genconfig['ApplicationIconFile'])) {
                         @copy($tmpdir . '/setup/' . $genconfig['ApplicationIconFile'], $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $genconfig['ApplicationIconFile']);
                     }
                     // Checks if it is an extension application
                     //
                     $genconfig = $this->parseApplicationDefinition($tmpdir . '/setup/application.xml');
                     $ext = $this->rootda->fmtfalse;
                     if ($genconfig['ApplicationIsExtension'] == 'y') {
                         $ext = $this->rootda->fmttrue;
                         $this->onlyextension = true;
                     } elseif ($genconfig['ApplicationIsExtension'] == 'n') {
                         $ext = $this->rootda->fmtfalse;
                         $this->onlyextension = false;
                     } elseif ($this->onlyextension) {
                         $ext = $this->rootda->fmttrue;
                     }
                     $this->rootda->execute('UPDATE applications SET onlyextension=' . $this->rootda->formatText($ext) . ' WHERE appid=' . $this->rootda->formatText($this->appname));
                     $result = true;
                     if ($this->container->getConfig()->Value('SecurityAlertOnApplicationOperation') == '1') {
                         $innomaticSecurity = new \Innomatic\Security\SecurityManager();
                         $innomaticSecurity->SendAlert('Application ' . $this->appname . ' has been installed');
                         unset($innomaticSecurity);
                     }
                     if ($result == true) {
                         if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_SINGLETENANT and $this->appname != 'innomatic' and $ext != $this->rootda->fmttrue) {
                             $domainsQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT id FROM domains');
                             if ($domainsQuery->getNumberRows()) {
                                 $this->Enable($domainsQuery->getFields('id'));
                             }
                         }
                         $log = $this->container->getLogger();
                         $log->logEvent('Innomatic', 'Installed application ' . $this->appname, \Innomatic\Logging\Logger::NOTICE);
                     }
                 }
             } else {
                 $appdata = $tmpquery->getFields();
                 $this->serial = $appdata['id'];
                 // Application will be updated
                 //
                 if ($this->serial) {
                     // 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) {
                         // Creates lock file
                         //
                         touch($this->container->getHome() . 'core/temp/upgrading_system_lock');
                         // :WARNING: evil 20020506: possible problems on Windows systems
                         // It has a 'permission denied'.
                         // Removes old application file
                         //
                         if (basename($fname) != $appdata['appfile'] and file_exists($this->container->getHome() . 'core/applications/' . $appdata['appfile'])) {
                             @unlink($this->container->getHome() . 'core/applications/' . $appdata['appfile']);
                         }
                         // Updates applications table
                         //
                         $this->rootda->execute('UPDATE applications SET appversion=' . $this->rootda->formatText($genconfig['ApplicationVersion']) . ', appdate=' . $this->rootda->formatText($genconfig['ApplicationDate']) . ', appdesc=' . $this->rootda->formatText($genconfig['ApplicationDescription']) . ', appfile=' . $this->rootda->formatText(basename($tmpfilepath)) . ', author=' . $this->rootda->formatText($genconfig['ApplicationAuthor']) . ', authoremail=' . $this->rootda->formatText($genconfig['ApplicationAuthorEmail']) . ', authorsite=' . $this->rootda->formatText($genconfig['ApplicationAuthorWeb']) . ', supportemail=' . $this->rootda->formatText($genconfig['ApplicationSupportEmail']) . ', bugsemail=' . $this->rootda->formatText($genconfig['ApplicationBugsEmail']) . ', copyright=' . $this->rootda->formatText($genconfig['ApplicationCopyright']) . ', license=' . $this->rootda->formatText($genconfig['ApplicationLicense']) . ', licensefile=' . $this->rootda->formatText($genconfig['ApplicationLicenseFile']) . ', changesfile=' . $this->rootda->formatText($genconfig['ApplicationChangesFile']) . ', maintainer=' . $this->rootda->formatText($genconfig['ApplicationMaintainer']) . ', maintaineremail=' . $this->rootda->formatText($genconfig['ApplicationMaintainerEmail']) . ', category=' . $this->rootda->formatText($genconfig['ApplicationCategory']) . ', iconfile=' . $this->rootda->formatText($genconfig['ApplicationIconFile']) . ' WHERE id=' . (int) $this->serial);
                         $genconfig = $this->parseApplicationDefinition($tmpdir . '/setup/application.xml');
                         // Script files - only before handlestructure
                         //
                         if ($dhandle = @opendir($tmpdir . '/setup')) {
                             while (false != ($file = readdir($dhandle))) {
                                 if ($file != '.' and $file != '..' and $file != 'application.xml' and is_file($tmpdir . '/setup/' . $file)) {
                                     @copy($tmpdir . '/setup/' . $file, $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $file);
                                 }
                             }
                             closedir($dhandle);
                         }
                         $this->HandleStructure($tmpdir . '/setup/application.xml', Application::INSTALL_MODE_UPDATE, $tmpdir);
                         if (strlen($genconfig['ApplicationLicenseFile']) and file_exists($tmpdir . '/setup/' . $genconfig['ApplicationLicenseFile'])) {
                             @copy($tmpdir . '/setup/' . $genconfig['ApplicationLicenseFile'], $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $genconfig['ApplicationLicenseFile']);
                         }
                         if (strlen($genconfig['ApplicationChangesFile']) and file_exists($tmpdir . '/setup/' . $genconfig['ApplicationChangesFile'])) {
                             @copy($tmpdir . '/setup/' . $genconfig['ApplicationChangesFile'], $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $genconfig['ApplicationChangesFile']);
                         }
                         if (strlen($genconfig['ApplicationIconFile']) and file_exists($tmpdir . '/setup/' . $genconfig['ApplicationIconFile'])) {
                             @copy($tmpdir . '/setup/' . $genconfig['ApplicationIconFile'], $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/' . $genconfig['ApplicationIconFile']);
                         }
                         // setup files - only after handlestructure
                         //
                         @copy($tmpdir . '/setup/application.xml', $this->container->getHome() . 'core/applications/' . $genconfig['ApplicationIdName'] . '/application.xml');
                         // Checks if it is an extension application
                         //
                         $ext = $this->rootda->fmtfalse;
                         if ($genconfig['ApplicationIsExtension'] == 'y') {
                             $ext = $this->rootda->fmttrue;
                             $this->onlyextension = true;
                         } elseif ($genconfig['ApplicationIsExtension'] == 'n') {
                             $ext = $this->rootda->fmtfalse;
                             $this->onlyextension = false;
                         } elseif ($this->onlyextension) {
                             $ext = $this->rootda->fmttrue;
                         }
                         $this->rootda->execute('UPDATE applications SET onlyextension=' . $this->rootda->formatText($ext) . ' WHERE appid=' . $this->rootda->formatText($this->appname));
                         $this->setOptions(explode(',', trim($genconfig['ApplicationOptions'], ' ,')));
                         if ($this->appname != 'innomatic') {
                             // Remove old dependencies
                             //
                             $appdeps->removeAllDependencies($this->serial);
                             // Adds new Applications dependencies
                             //
                             $appdeps->addDependenciesArray($genconfig['ApplicationIdName'], $deps, ApplicationDependencies::TYPE_DEPENDENCY);
                             $appdeps->addDependenciesArray($genconfig['ApplicationIdName'], $suggs, ApplicationDependencies::TYPE_SUGGESTION);
                         }
                         $result = true;
                         if (function_exists('apc_reset_cache')) {
                             apc_reset_cache();
                         }
                         if ($updateOnce == false) {
                             $this->Install($tmpfilepath, true);
                             // Removes lock file
                             //
                             unlink($this->container->getHome() . 'core/temp/upgrading_system_lock');
                             if (\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getConfig()->Value('SecurityAlertOnApplicationOperation') == '1') {
                                 $innomaticSecurity = new \Innomatic\Security\SecurityManager();
                                 $innomaticSecurity->SendAlert('Application ' . $this->appname . ' has been updated');
                                 unset($innomaticSecurity);
                             }
                             if ($result == true) {
                                 $log = $this->container->getLogger();
                                 $log->logEvent('Innomatic', 'Updated application ' . $this->appname, \Innomatic\Logging\Logger::NOTICE);
                             }
                         }
                     }
                     /*
                     else $this->mLog->logEvent( 'innomatic.applications.applications.install',
                     'Structure definition file for application '.$this->appname.
                     ' does not exists', \Innomatic\Logging\Logger::ERROR );
                     */
                 } else {
                     $log = $this->container->getLogger();
                     $log->logEvent('innomatic.applications.applications.install', 'Empty application serial', \Innomatic\Logging\Logger::ERROR);
                 }
             }
         } else {
             $log = $this->container->getLogger();
             if (!file_exists($tmpdir . '/setup/application.xml')) {
                 $log->logEvent('innomatic.applications.applications.install', 'Application structure file ' . $tmpdir . '/setup/application.xml' . ' not found', \Innomatic\Logging\Logger::ERROR);
             }
         }
         // Cleans up temp stuff
         //
         @chdir($olddir);
         \Innomatic\Io\Filesystem\DirectoryUtils::unlinkTree($basetmpdir);
         if (file_exists($tmpfilepath)) {
             @unlink($tmpfilepath);
         }
     } else {
         if (!file_exists($tmpfilepath)) {
             $log = $this->container->getLogger();
             $log->logEvent('innomatic.applications.applications.install', 'Temporary application file (' . $tmpfilepath . ') does not exists', \Innomatic\Logging\Logger::ERROR);
         }
     }
     if ($innomatic->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) {
         $innomatic->getLoadTimer()->Mark('applicationinstallend');
         $log = $this->container->getLogger();
         $log->logEvent('innomatic.applications.application.install', 'Application installation load time: ' . $innomatic->getLoadTimer()->getSectionLoad('applicationinstallend'), \Innomatic\Logging\Logger::DEBUG);
     }
     return $result;
 }
コード例 #13
0
ファイル: TGZDownloader.php プロジェクト: staabm/pickle
 protected function extract($file, $path)
 {
     $archive = new \PharData($file);
     $archive->decompress()->extractTo($path, null, true);
 }
コード例 #14
0
ファイル: variations.php プロジェクト: mandress64/cordova
 /** 
  * 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
0
 /**
  * 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;
 }
コード例 #16
0
ファイル: Update.php プロジェクト: apiceweb/MageBridgeCore
 public function doUpgrade()
 {
     // File format
     $format = 'zip';
     // Set the umask
     $this->setFilesUmask();
     // Simple check for ZIP-support
     if ($format == 'zip' && !class_exists('ZipArchive') && !class_exists('PharData')) {
         $msg = 'WARNING: PHP-classes ZipArchive and PharData are missing. Updates might fail.';
         Mage::getSingleton('adminhtml/session')->addError($msg);
     }
     // Simple check for TAR-support
     if ($format == 'tgz' && !class_exists('PharData')) {
         $msg = 'WARNING: PHP-class PharData is missing.';
         Mage::getSingleton('adminhtml/session')->addError($msg);
     }
     // Check for the file
     $tmpdir = Mage::getConfig()->getOptions()->getTmpDir();
     if ($format == 'tgz') {
         $tmpfile = $tmpdir . DS . 'Yireo_MageBridge_patch.tgz';
     }
     if ($format == 'zip') {
         $tmpfile = $tmpdir . DS . 'Yireo_MageBridge_patch.zip';
     }
     // Make sure it does not contain just an error
     if (is_readable($tmpfile)) {
         $tmpcontents = file_get_contents($tmpfile);
         if (strstr($tmpcontents, 'Download denied')) {
             @unlink($tmpfile);
         }
     }
     // If the file is not there, download it
     if (is_readable($tmpfile) == false) {
         // Check whether the tmpdir is writable
         if (!is_writable($tmpdir)) {
             $msg = 'ERROR: ' . $tmpdir . ' is not writable';
             Mage::getSingleton('adminhtml/session')->addError($msg);
             return $msg;
         }
         // Construct the download-URL
         if ($format == 'tgz') {
             $download_file = 'Yireo_MageBridge_patch.tgz';
         }
         if ($format == 'zip') {
             $download_file = 'Yireo_MageBridge_patch.zip';
         }
         $download_url = $this->getApiLink(array('resource' => 'download', 'request' => $download_file));
         // Get the remote data
         $data = $this->_getRemote($download_url);
         if (empty($data)) {
             $msg = 'ERROR: Downloaded update-file is empty';
             Mage::getSingleton('adminhtml/session')->addError($msg);
             return $msg;
         }
         // Fill the local ZIP-file with the remote data
         file_put_contents($tmpfile, $data);
         chmod($tmpfile, 0644);
     }
     // Check the filesize of the patch
     $contents = file_get_contents($tmpfile);
     if (empty($contents)) {
         Mage::getSingleton('adminhtml/session')->addError('ERROR: Downloaded archive is empty');
     }
     // For safety, turn off error_reporting on this point
     ini_set('error_reporting', 0);
     // Set the root-directory
     $rootDir = Mage::getBaseDir();
     // ZIP-format
     if ($format == 'zip') {
         // Try to extract ZIP-archive using ZipArchive
         if (class_exists('ZipArchive')) {
             $zip = new ZipArchive();
             if ($zip->open($tmpfile) === true) {
                 $rt = $zip->extractTo($rootDir);
                 $zip->close();
                 if ($rt == false) {
                     $msg = 'ERROR: Failed to extract ZIP in ' . $rootDir;
                     Mage::getSingleton('adminhtml/session')->addError($msg);
                     return $msg;
                 }
                 @unlink($tmpfile);
             } else {
                 $msg = 'ERROR: Unable to open ZIP ' . $tmpfile;
                 Mage::getSingleton('adminhtml/session')->addError($msg);
                 return $msg;
             }
             // Try to extract ZIP-archive using PharData
         } elseif (class_exists('PharData')) {
             $zip = new PharData($tmpfile);
             $rt = $zip->extractTo($rootDir);
             if ($rt == false) {
                 $msg = 'ERROR: Failed to extract ZIP in ' . $rootDir;
                 Mage::getSingleton('adminhtml/session')->addError($msg);
                 return $msg;
             }
             @unlink($tmpfile);
             // Try to extra ZIP-archive using exec-function (assuming unzip is installed)
         } elseif (function_exists('exec')) {
             @exec('unzip -o ' . $tmpfile . ' -d ' . $rootDir);
             @unlink($tmpfile);
             // Failed to extract ZIP-archive
         } else {
             $msg = 'ERROR: Failed to extract the ZIP-archive';
             Mage::getSingleton('adminhtml/session')->addError($msg);
             return $msg;
         }
         // TGZ-format
     } elseif ($format == 'tgz') {
         // Try to extract TAR-archive using TGZ-class
         if (class_exists('PharData')) {
             $tgz = new PharData($tmpfile);
             $tgz->decompress();
             $tar = new PharData(preg_replace('/\\.(tar.gz|tgz)$/', '.tar', $tmpfile));
             $rt = $tar->extractTo($rootDir);
             if ($rt == false) {
                 $msg = 'ERROR: Failed to extract TGZ in ' . $rootDir;
                 Mage::getSingleton('adminhtml/session')->addError($msg);
                 return $msg;
             }
             @unlink($tmpfile);
             // Try to extra TGZ-archive using exec-function (assuming tar is installed)
         } elseif (function_exists('exec')) {
             @exec('tar -xzf ' . $tmpfile . ' -C ' . $rootDir);
             @unlink($tmpfile);
             // Failed to extract TGZ-archive
         } else {
             $msg = 'ERROR: Failed to extract the TGZ-archive';
             Mage::getSingleton('adminhtml/session')->addError($msg);
             return $msg;
         }
     }
     // Remove obsolete files
     Mage::helper('magebridge/update')->removeFiles();
     // Reset the cached API-details
     Mage::getConfig()->deleteConfig('magebridge/settings/xmlrpc_url');
     // legacy
     Mage::getConfig()->deleteConfig('magebridge/settings/api_url');
     Mage::getConfig()->deleteConfig('magebridge/settings/api_user');
     Mage::getConfig()->deleteConfig('magebridge/settings/api_key');
     // Rewove the cache
     Mage::getConfig()->removeCache();
     // Finalize with a notice
     Mage::getSingleton('adminhtml/session')->addSuccess('MageBridge has been upgraded');
     return null;
 }
コード例 #17
0
         if ($tar_gzip_files = $gz->decompress()) {
             $tar_gzip = new PharData($tar_gzip_files);
             if (${$tar_gzip}->extractTo($des)) {
                 echo '{"status":"success","message":"File extracted"}';
             } else {
                 echo '{"status":"error","message":"Failed to extract the files"}';
             }
         } else {
             echo '{"status":"error","message":"Failed to extract the .gzip file"}';
         }
     } else {
         echo '{"status":"error","message":"PharData extension missing or cloud not open tar archive"}';
     }
 } elseif ($source_info['extension'] == 'bz2') {
     if (class_exists('PharData') && ($bz = new PharData($source))) {
         if ($tar_bzip2_files = $bz->decompress()) {
             $tar_bzip2 = new PharData($tar_bzip2_files);
             if (${$tar_bzip2}->extractTo($des)) {
                 echo '{"status":"success","message":"File extracted"}';
             } else {
                 echo '{"status":"error","message":"Failed to extract the files"}';
             }
         } else {
             echo '{"status":"error","message":"Failed to extract the .bzip2 file"}';
         }
     } else {
         echo '{"status":"error","message":"PharData extension missing or cloud not open tar archive"}';
     }
 } elseif ($source_info['extension'] == 'rar') {
     if (class_exists('rar_open') && ($rar = new rar_open())) {
         if ($res = $rar->open($source)) {
コード例 #18
0
ファイル: utils.lib.php プロジェクト: carriercomm/teebx
function archiveExtract($srcFile, $destDir, $files = null, $overwrite = true)
{
    $result = array();
    try {
        $archive = new PharData($srcFile);
        if ($archive->isFileFormat(Phar::GZ)) {
            $archive->decompress('tar');
            $srcFile = pathinfo($srcFile, PATHINFO_DIRNAME) . '/' . pathinfo($srcFile, PATHINFO_FILENAME) . '.tar';
            unset($archive);
            $archive = new PharData($srcFile);
            $archive->extractTo($destDir, $files, $overwrite);
        } else {
            $result[] = _('Unsupported archive format');
        }
    } catch (Exception $err) {
        $result[] = $err;
    }
    //remove temporary uncompressed tar archive
    if (pathinfo($srcFile, PATHINFO_EXTENSION) == 'tar' && is_file($srcFile)) {
        unlink($srcFile);
    }
    return $result;
}
コード例 #19
0
ファイル: ajax_calls.php プロジェクト: kipps/sri-lanka
                 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 {
             response(trans('Zip_No_Extract'), 500)->send();
             exit;
         }
         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();
         check_files_extensions_on_phar($phar, $files, '', $ext);
         $phar->extractTo($current_path . fix_dirname($_POST['path']) . "/", $files, true);
         break;
     default:
         response(trans('Zip_Invalid'), 400)->send();
         exit;
 }
 break;
コード例 #20
0
ファイル: install.php プロジェクト: davetheapple/oakencraft
 /**
  * extraction using Phar
  */
 private function _usePhar($destinationPath)
 {
     $this->_joobiInfoLog("using PharData for extracting joobi folder");
     $this->_joobiInfoLog("step1");
     $p = new PharData($this->_joobiTarGzSourcePath);
     $p->decompress();
     // creates /path/to/my.tar
     $this->_joobiInfoLog("step2");
     // unarchive from the tar
     $phar = new PharData($this->_joobiTarSourcePath);
     if (!$phar->extractTo($destinationPath)) {
         throw new Exception("Joobi folder extraction failed using Phar");
     }
 }