Esempio 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'];
 }
Esempio 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;
 }
Esempio 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");
     }
 }
Esempio n. 4
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 */