Ejemplo n.º 1
0
 function upload($incVersion)
 {
     $vs = qg::remoteGet($this->name);
     if (!is_dir(sysPATH . $this->name)) {
         return false;
     }
     $v = explode('.', $vs['version']);
     $v = @array((int) $v[0], (int) $v[1], (int) $v[2]);
     foreach ($v as $i => $vp) {
         if ($i >= $incVersion) {
             $v[$i] = 0;
         }
     }
     isset($v[$incVersion - 1]) && ++$v[$incVersion - 1];
     $vs['version'] = implode('.', $v);
     $tmpFile = appPATH . 'cache/tmp/module_export1.zip';
     is_file($tmpFile) && unlink($tmpFile);
     // zzz unlink???
     ini_set('max_execution_time', '600');
     $zip = new Zip();
     $zip->open($tmpFile, Zip::CREATE);
     $zip->addDir(sysPATH . $this->name, null, '/(\\.svn)|(zzz)/');
     $zip->close();
     $vs['size'] = filesize($tmpFile);
     $this->local_version = $vs['version'];
     @qg::Ftp()->mkdir('/module/' . $this->name . '/');
     qg::Ftp()->put('/module/' . $this->name . '/' . $vs['version'] . '.zip', $tmpFile, FTP_BINARY);
     qg::remoteSet($this->name, $vs);
     return $vs['version'];
 }
Ejemplo n.º 2
0
 /**
  * Compresses the directory with ZIP.
  * @param string $fileName The file name of the ZIP archive.
  * @param int $flags [optional] The mode to use to open the archive.
  * @return mixed The ZIP archive or an error code on failure.
  */
 public function compress($fileName, $flags = \ZipArchive::CREATE)
 {
     $zip = new Zip();
     if (($res = $zip->open($fileName, $flags)) === true) {
         $zip->addDir($this->path);
         $zip->close();
         return $zip;
     }
     return $res;
 }
Ejemplo n.º 3
0
 function run($args)
 {
     if (empty($args[1])) {
         echo $this->getHelp();
         return;
     }
     $path = $args[0];
     $version = $args[1];
     echo "Preparing {$path} release.\n";
     require dirname(__FILE__) . '/GenerateDocsCommand.php';
     $docProcessor = new GenerateDocsCommand($this->getName(), $this->getCommandRunner());
     $outFiles = $docProcessor->processDocuments($path);
     // copy extension dir to temp
     $extPath = Yii::getPathOfAlias('ext') . '/' . $path;
     $copiedExtRoot = Yii::getPathOfAlias('application.runtime.extension');
     echo "Removing {$copiedExtRoot}.\n";
     if (file_exists($copiedExtRoot)) {
         $this->recursiveDelete($copiedExtRoot);
     }
     $copiedExtPath = $copiedExtRoot . '/' . $path;
     if (!file_exists($copiedExtPath)) {
         mkdir($copiedExtPath, 0777, true);
     }
     echo "Copying extension files from {$extPath} to {$copiedExtPath}.\n";
     CFileHelper::copyDirectory($extPath, $copiedExtPath, array('exclude' => array('.svn', 'readme_en.txt', 'readme_ru.txt')));
     echo "Copying documentation to {$copiedExtPath}.\n";
     foreach ($outFiles as $file) {
         copy($file, $copiedExtPath . '/' . basename($file));
     }
     $pathExp = explode('/', $path);
     $zipName = end($pathExp) . '_' . $version . '.zip';
     $releasePath = Yii::getPathOfAlias('application.releases');
     if (!file_exists($releasePath)) {
         mkdir($releasePath, 0777, true);
     }
     $zipPath = "{$releasePath}/{$zipName}";
     if (file_exists($zipPath)) {
         unlink($zipPath);
     }
     //touch($zipPath);
     echo "Creating Zip {$zipPath}.\n";
     require dirname(__FILE__) . '/Zip.php';
     $zip = new Zip();
     if ($zip->open($zipPath, ZipArchive::OVERWRITE | ZipArchive::CREATE) !== TRUE) {
         die("Failed to open Zip {$zipPath}.\n");
     }
     if (!$zip->addDir($copiedExtRoot)) {
         die("Failed adding {$copiedExtRoot} to Zip.\n");
     }
     if ($zip->close()) {
         echo "Done.\n";
     } else {
         die("Failed to write Zip {$zipPath}.\n");
     }
 }
Ejemplo n.º 4
0
 static function download($name, $beta = false)
 {
     $vs = self::remoteGet($name, $beta);
     self::ftp()->get(appPATH . 'cache/tmp/pri/remoteModule.zip', '/module/' . $name . '/' . $vs['version'] . '.zip', FTP_BINARY);
     $zip = new Zip();
     $go = $zip->open(appPATH . 'cache/tmp/pri/remoteModule.zip');
     if (!$go) {
         return;
     }
     rrmdir(sysPATH . $name);
     $zip->extractTo(sysPATH);
     $zip->close();
     return $vs;
 }
Ejemplo n.º 5
0
            $File->replaceFromUpload($_FILES['cmsPageFile']);
            $res = array('id' => (string) $File, 'url' => $File->url() . '/' . $File->vs['name']);
            Answer($res);
        }
    }
    if (isset($_GET['qgCms_page_files_as_zip'])) {
        $P = Page($_GET['qgCms_page_files_as_zip']);
        if (!$P->access() > 1) {
            exit('no access');
        }
        if (!$P->Files()) {
            exit('no files');
        }
        $Zip = new Zip();
        $tmpfname = appPATH . 'cache/tmp/pri/' . randString() . '.zip';
        $Zip->open($tmpfname, Zip::CREATE);
        foreach ($P->Files() as $File) {
            $Zip->addFile($File->path, $File->name());
        }
        $Zip->close();
        $filename = isset($_GET['filename']) ? $_GET['filename'] : 'files_' . $P . '.zip';
        header('Content-Type: application/zip');
        header('Content-Disposition: attachment; filename=' . $filename);
        header('Content-Length: ' . filesize($tmpfname));
        readfile($tmpfname);
        unlink($tmpfname);
        exit;
    }
});
qg::on('dbFile::access', function ($e) {
    if ($e['access']) {
Ejemplo n.º 6
0
<?php

namespace qg;

if (!Usr()->superuser) {
    return;
}
if (isset($_GET['export'])) {
    //set_time_limit(0);
    $tmpFile = appPATH . 'cache/tmp/pri/modExport.zip';
    is_file($tmpFile) && unlink($tmpFile);
    $zip = new Zip();
    $zip->open($tmpFile, Zip::CREATE);
    $zip->addDir(appPATH . 'm', null, '/(\\.svn)/');
    $zip->addDir(appPATH . 'qg', null, '/(\\.svn)/');
    foreach (scandir(appPATH) as $file) {
        if (!is_file(appPATH . $file)) {
            continue;
        }
        if ($file === 'error_log') {
            continue;
        }
        $zip->addFile(appPATH . $file, $file);
    }
    /* only custom module:
    	foreach (dbEntry_module::all() as $M) {
    		If ($M->server_time) continue;
    		$zip->addDir(sysPATH.$name, 'm/'.$M->name, '/(\.svn)/');
    	}
    
    	/* add mysql export */