Ejemplo n.º 1
0
 private function onPurge()
 {
     $form = $this->formPurge();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templatePurge();
     }
     $table = GDO::table('GWF_VersionFiles');
     if (false === $table->truncate()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     GWF_VersionFiles::populateAll();
     return $this->module->message('msg_purged', array($table->countRows(), GWF_Upload::humanFilesize(GWF_VersionFiles::getSizeUnpacked())));
 }
Ejemplo n.º 2
0
 private function templateUpgrade()
 {
     $haveError = false;
     $modules = GWF_Module::loadModulesFS();
     GWF_Module::sortModules($modules, 'module_name', 'asc');
     # No ZIP extension?
     if (!class_exists('ZipArchive', false)) {
         return $this->module->error('err_no_zip');
     }
     //		require_once 'core/inc/util/GWF_ZipArchive.php';
     # Populate the DB again
     GWF_VersionFiles::populateAll();
     # Open temp manifest file.
     $manifestName = sprintf('extra/temp/upgrade_manifest_%s_%s.gwf_manifest', $this->client->getVar('vsc_uid'), $this->datestamp);
     if (false === ($fhManifest = fopen($manifestName, 'w'))) {
         return GWF_HTML::err('ERR_WRITE_FILE', array($manifestName));
     }
     # Create ZIP
     $archive = new GWF_ZipArchive();
     $archivename = sprintf('extra/temp/upgrade_%s_%s.zip', $this->client->getVar('vsc_uid'), $this->datestamp);
     if (false === $archive->open($archivename, ZipArchive::CREATE | ZipArchive::CM_REDUCE_4)) {
         fclose($fhManifest);
         return $this->module->error('err_zip', __FILE__, __LINE__);
     }
     $files = GDO::table('GWF_VersionFiles');
     if (false === ($result = $files->queryReadAll('', 'vsf_path ASC'))) {
         //		if (false === ($result = $files->queryReadAll("vsf_date>='$this->datestamp'", "vsf_path ASC"))) {
         //		if (false === ($result = $files->queryAll())) {
         fclose($fhManifest);
         $archive->close();
         @unlink($archivename);
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     fprintf($fhManifest, 'GWF2:DATESTAMP:%s' . PHP_EOL, date('YmdHis'));
     while (false !== ($file = $files->fetchObject($result))) {
         //			echo GWF_HTML::message('VS_Upgrade', 'Adding File: '.$file->getVar('vsf_path'));
         $file instanceof GWF_VersionFiles;
         if (!$this->client->ownsModule($file->getVar('vsf_module'))) {
             continue;
         }
         if (!$this->client->ownsDesign($file->getVar('vsf_design'))) {
             continue;
         }
         $path = $file->getVar('vsf_path');
         if (!file_exists($path)) {
             $file->delete();
             continue;
         }
         if (!is_readable($path)) {
             echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array($path));
             $haveError = true;
             break;
         }
         // is file new?
         $isNew = $file->getVar('vsf_date') >= $this->datestamp;
         if ($isNew) {
             // add it to archive
             if (false === $archive->addFile($path)) {
                 echo GWF_HTML::err('ERR_WRITE_FILE', array($file->getVar('vsf_path')));
                 $haveError = true;
                 break;
             }
         }
         //			echo GWF_HTML::message('VS_Upgrade', 'Added File: '.$file->getVar('vsf_path'));
         // write manifest info
         fwrite($fhManifest, $file->asManifest($isNew));
     }
     fclose($fhManifest);
     if (false === $archive->addFile($manifestName)) {
         echo GWF_HTML::err('ERR_WRITE_FILE', array($manifestName));
         $haveError = true;
     }
     if (false === $archive->close()) {
         echo GWF_HTML::err('ERR_WRITE_FILE', array($archivename));
         $haveError = true;
     }
     if (!$haveError) {
         GWF_Upload::outputFile($archivename);
     }
     // Delete stuff??
     @unlink($manifestName);
     @unlink($archivename);
     return '';
 }
Ejemplo n.º 3
0
 public function onInstall($dropTable)
 {
     return GWF_VersionFiles::populateAll() . GWF_ModuleLoader::installVars($this, array());
 }