public function execute() { if ('' === ($filename = Common::getGetString('filename'))) { return GWF_Error::err('ERR_NO_PERMISSION'); } $path = $this->module->getContentPath(); $filename = $path . '/' . $filename; if (!Common::isFile($filename)) { return GWF_Error::err404($filename); } GWF_Upload::outputFile($filename); }
private function templateAttach(GWF_ForumAttachment $attach, GWF_ForumPost $post, $user) { $path = $attach->dbimgPath(); $mime = $attach->getVar('fatt_mime'); $as_attach = !$attach->isImage(); $filename = $as_attach ? $attach->getVar('fatt_filename') : true; if ($as_attach) { $attach->increase('fatt_downloads', 1); } GWF_Upload::outputFile($path, $as_attach, $mime, $filename); die; }
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 ''; }
private function onZip() { $client = GWF_Client::getClient(GWF_Session::getUserID()); $rand = Common::randomDateStamp(); $archivename = 'dbimg/gwf_purchase_' . $rand . '.zip'; $zipper = $this->module->getMethod('Zipper'); $zipper instanceof VersionServer_Zipper; $zipper->setArchiveName($archivename); $error = $zipper->onZip($client->getModuleNames(), 'default'); if ($zipper->hasError()) { return $error; } GWF_Upload::outputFile($archivename, 'arc/zip'); return $error; }