Esempio n. 1
0
 public function processUpdate()
 {
     $result = array();
     $source_path = $this->file->getTempName();
     $destination_path = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'updates';
     if (!is_dir($destination_path)) {
         mkdir($destination_path, 0777);
     }
     $destination_path .= DIRECTORY_SEPARATOR . $this->update_version['stage'] . '_' . $this->update_version['sprint'] . '_' . $this->update_version['update'];
     if (!is_dir($destination_path)) {
         mkdir($destination_path, 0777);
     }
     $zip = new ZipArchive();
     // open archive
     if ($zip->open($source_path) !== TRUE) {
         $result['errors'][] = 'Could not open archive';
     } else {
         $zip->extractTo($destination_path);
         $result['total_entries'] = $zip->numFiles;
         if (file_exists($destination_path . DIRECTORY_SEPARATOR . 'src') && file_exists($destination_path . DIRECTORY_SEPARATOR . 'update.ini')) {
             It::fullCopy($destination_path . DIRECTORY_SEPARATOR . 'src', dirname(Yii::app()->request->scriptFile));
             $update_ini = $destination_path . DIRECTORY_SEPARATOR . 'update.ini';
             $values = parse_ini_file($update_ini, true);
             InstallConfig::setConfigSection('version', $values['version']);
         }
     }
     $zip->close();
     return $result;
 }
Esempio n. 2
0
 public static function fullCopy($source, $target)
 {
     if (is_dir($source)) {
         if (!is_dir($target)) {
             @mkdir($target);
         }
         $d = dir($source);
         while (FALSE !== ($entry = $d->read())) {
             if ($entry == '.' || $entry == '..') {
                 continue;
             }
             $Entry = $source . '/' . $entry;
             if (is_dir($Entry)) {
                 It::fullCopy($Entry, $target . '/' . $entry);
                 continue;
             }
             copy($Entry, $target . '/' . $entry);
         }
         $d->close();
     } else {
         copy($source, $target);
     }
 }