protected function getModuleData($moduleName)
 {
     $xxtea = new XXTEA();
     $xxtea->setKey($this->config['key']);
     $srcPath = $this->config['srcpath'] . DS . $moduleName;
     $bytes = file_get_contents($srcPath);
     $bytes = $this->config['sign'] . $xxtea->encrypt($bytes);
     return $bytes;
 }
 protected function createOutputZIP(array $modules, array $bytes)
 {
     // create ZIP archive
     $zipfile = $this->config['output'];
     $zip = new ZipArchive();
     if (!$zip->open($zipfile, ZIPARCHIVE::OVERWRITE | ZIPARCHIVE::CM_STORE)) {
         return false;
     }
     if (!$this->config['quiet']) {
         printf("create ZIP archive file: %s\n", $zipfile);
     }
     foreach ($modules as $path => $module) {
         $zip->addFromString($this->config['prefix'] . $module['moduleName'], $bytes[$path]);
     }
     $zip->close();
     if ($this->config['encrypt'] == self::ENCRYPT_XXTEA_ZIP) {
         $xxtea = new XXTEA();
         $xxtea->setKey($this->config['key']);
         file_put_contents($zipfile, $this->config['sign'] . $xxtea->encrypt(file_get_contents($zipfile)));
     }
     if (!$this->config['quiet']) {
         printf("done.\n\n");
     }
     return true;
 }
Ejemplo n.º 3
0
 protected function getModulesData(array $modules, $key = null, $sign = null)
 {
     if (!empty($key)) {
         $xxtea = new XXTEA();
         $xxtea->setKey($key);
     }
     $modulesBytes = array();
     foreach ($modules as $path => $module) {
         $bytes = file_get_contents($path);
         if (!empty($key)) {
             $bytes = $sign . $xxtea->encrypt($bytes);
         }
         file_put_contents($module['tempFilePath'], $bytes);
         if (!$bytes) {
             print "\n";
             return false;
         }
         $modulesBytes[$path] = $bytes;
         if (!$this->config['quiet']) {
             printf("  > get bytes [% 3d KB] %s\n", ceil(strlen($bytes) / 1024), $module['moduleName']);
         }
     }
     return $modulesBytes;
 }