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()))); }
<?php $lang = array('en' => array('help' => 'Usage: %CMD%. Print memory usage statistics.', 'usage' => 'Currently there are %s in use. Max memory peak was %s.'), 'de' => array('help' => 'Nutze: %CMD%. Gibt Statistiken über die Speichernutzung aus.', 'usage' => 'Zur Zeit werden %s Speicher verwendet. Die maximale Auslastung betrug %s.')); Dog::getPlugin()->rply('usage', array(GWF_Upload::humanFilesize(memory_get_usage(true), '1000'), GWF_Upload::humanFilesize(memory_get_peak_usage(true), '1000')));
public function onZipC() { # Create ZIP $archive = new GWF_ZipArchive(); chdir(GWF_PATH); $archivename = $this->getArchiveName(); if (false === $archive->open($archivename, ZipArchive::CREATE | ZipArchive::CM_REDUCE_4)) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # ZIP STUFF # Core if (false === $this->zipDir($archive, 'core/inc')) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # ZIP Module(Groups) foreach ($_POST as $group => $checked) { if (!Common::startsWith($group, 'mod_')) { continue; } # zip dir recursive, do not ignore style if (false === $this->zipDir($archive, 'core/module/' . substr($group, 4), true, false)) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } } # 3rd Party Core // if (false === ($this->zipDir($archive, 'inc3p'))) { // return $this->module->error('err_zip', array(__FILE__, __LINE__)); // } # Smarty // if (false === ($this->zipDir($archive, 'smarty_lib'))) { // return $this->module->error('err_zip', array(__FILE__, __LINE__)); // } # JS if (false === $this->zipDir($archive, 'www/js')) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # Installer if (false === $this->zipDir($archive, 'www/install')) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # Base Lang if (false === $this->zipDir($archive, 'core/lang')) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # Images if (false === $this->zipDir($archive, 'www/img', false)) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } // if (false === ($this->zipDir($archive, 'img/default/country', false))) { // return $this->module->error('err_zip', array(__FILE__, __LINE__)); // } // if (false === ($this->zipDir($archive, 'img/default/smile', false))) { // return $this->module->error('err_zip', array(__FILE__, __LINE__)); // } # Temp if (false === $this->addEmptyDirs($archive, self::$tempdirs)) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # Fonts if (false === $this->zipDir($archive, 'extra/font')) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # Templates if (false === $this->zipDir($archive, 'www/tpl', true, false)) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # Root Files if (false === $this->addFiles($archive, self::$rootfiles)) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # Protected Dirs // if (false === $this->zipDirs($archive, self::$protected_dirs)) { // return $this->module->error('err_zip', array(__FILE__, __LINE__)); // } # Protected Files if (false === $this->addFiles($archive, self::$protected_files)) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } # Module Extra Files and Dirs if (false === $this->zipDirs($archive, $this->getModuleExtraDirs())) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } if (false === $this->addFiles($archive, $this->getModuleExtraFiles())) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } // chdir(GWF_WWW_PATH); $total_files = $archive->getTotalFilesCounter(); if (false === $archive->close()) { return $this->module->error('err_zip', array(__FILE__, __LINE__)); } $this->has_error = false; return $this->module->message('msg_zipped', array($archivename, GWF_Upload::humanFilesize(filesize($archivename)), $total_files)); }
private static function debugFooter($precision = 4) { $db = gdo_db(); $queries = $db->getQueryCount(); $writes = $db->getQueryWriteCount(); $t_total = microtime(true) - GWF_DEBUG_TIME_START; $t_mysql = $db->getQueryTime(); $t_php = $t_total - $t_mysql; $f = sprintf('%%0.%dfs', (int) $precision); $bd = ''; #self::debugBrowser(); $mem = GWF_Upload::humanFilesize(memory_get_peak_usage(true)); $mods = GWF_Module::getModulesLoaded(); return sprintf("<div>%d Queries (%d writes) in {$f} - PHP Time: {$f} - Total Time: {$f}. Memory: %s<br/>Modules loaded: %s</div>", $queries, $writes, $t_mysql, $t_php, $t_total, $mem, $mods) . $bd; }
$a instanceof GWF_ForumAttachment; if (!$a->canSee(GWF_Session::getUser())) { $attach .= '<p>' . $tLang->lang('info_hidden_attach_guest'); continue; } $edit = GWF_Button::edit($a->hrefEdit(), $tLang->lang('btn_edit_attach')); $att_name = $a->display('fatt_filename'); if ($a->isImage()) { $attach .= sprintf('<div><img src="%s" title="%s" alt="%s" /></div>', $a->hrefDownload(), $att_name, $att_name); if ($can_edit) { $attach .= sprintf('<div>%s</div>', $edit); } } else { $attach .= '<div class="gwf_attachment">' . PHP_EOL; $attach .= sprintf('<div>%s: <a href="%s">%s</a></div>', $tLang->lang('th_file_name'), $a->hrefDownload(), $att_name); $attach .= sprintf('<div>%s: %s</div>', $tLang->lang('th_file_size'), GWF_Upload::humanFilesize($a->getVar('fatt_size'))); $attach .= sprintf('<div>%s: %s</div>', $tLang->lang('th_downloads'), $a->getVar('fatt_downloads')); if ($can_edit) { $attach .= sprintf('<div>%s</div>', $edit); } $attach .= '</div>' . PHP_EOL; } } $attach .= '</div>' . PHP_EOL; } ?> <div class="gwf_post_msg"> <?php echo '<div id="gwf_forum_post_' . $post->getVar('post_pid') . '">' . $post->displayMessage($tVars['term']) . '</div>'; echo $attach;
<p><?php echo $tLang->lang('pi_add', array(GWF_Upload::humanFilesize($tVars['max_size']))); ?> </p> <?php echo $tVars['form'];
private function inspectArchive(Module_VersionClient $module) { $archivename = $this->getArchiveName(); if (false === ($fh = fopen($archivename, 'r'))) { return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($archivename)); } if (false === ($magic = fread($fh, 2))) { fclose($fh); return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($archivename)); } fclose($fh); if ($magic === 'PK') { echo $module->message('msg_update_archive_ok', array(GWF_Upload::humanFilesize(filesize($archivename)))); return false; } return GWF_HTML::errorAjax(file_get_contents($archivename)); }