Given an integer that represents a byte size, this will return a string
displaying the value in bytes, KB, MB, GB, TB or PB
public static GetByteSize ( integer $intBytes, $intNumberOfTenths = 1 ) : string | ||
$intBytes | integer | |
return | string |
/** * Get the HTML for this Control. * @return string */ public function GetControlHtml() { // Pull any Attributes $strAttributes = $this->GetAttributes(); // Pull any styles if ($strStyle = $this->GetStyleAttributes()) { $strStyle = 'style="' . $strStyle . '"'; } // Return the HTML $strHtml = null; if (!$this->strFilePath) { $strHtml .= sprintf('<input type="button" class="button" id="%s_button" value="Browse"/>', $this->strControlId); $strHtml .= sprintf('<span id="%s_ospan"><iframe id="%s_iframe" scrolling="no" style="display: none;"></iframe></span>', $this->strControlId, $this->strControlId); $strHtml .= sprintf('<div class="progress" id="%s_progress" style="display: none;">', $this->strControlId); $strHtml .= sprintf('<div class="size" id="%s_size">n/a</div>', $this->strControlId); $strHtml .= '<div class="bar">'; $strHtml .= sprintf('<div class="status" id="%s_status">Uploading...</div>', $this->strControlId); $strHtml .= sprintf('<div class="fill" id="%s_fill"></div>', $this->strControlId); $strHtml .= '</div>'; $strHtml .= '<div class="cancel"><a href="#">Cancel</a></div>'; $strHtml .= '</div>'; } else { $strHtml .= sprintf('<strong>%s</strong> (%s) <a href="#" %s>Remove</a>', $this->strFileName, QString::GetByteSize($this->intFileSize), $this->pxyRemoveFile->RenderAsEvents(null, false)); } return sprintf('<div id="%s" %s%s>%s</div>', $this->strControlId, $strAttributes, $strStyle, $strHtml); }
/** * This function displays helpful development info like queries sent to database and memory usage. * By default it shows only if database profiling is enabled in any configured database connections. * * If forced to show when profiling is disabled you can monitor qcodo memory usage more accurately, * as collecting database profiling information tends to noticeable bigger memory consumption. * * @param boolean $blnForceDisplay optional parameter, set true to always display info even if DB profiling is disabled * @return void */ public static function DisplayProfilingInfo($blnForceDisplay = false) { if (QDatabaseBase::IsAnyDatabaseProfilingEnabled() || $blnForceDisplay) { print '<br clear="all"/><div style="padding: 5px; text-align: left; margin: 1em auto; border: 1px solid #888888; width: 800px;">'; // Output DB Profiling Data foreach (QApplication::$Database as $objDb) { if ($objDb->EnableProfiling == true) { $objDb->OutputProfiling(); } } // Output runtime statistics if (function_exists('memory_get_peak_usage')) { print 'memory_get_peak_usage: ' . QString::GetByteSize(memory_get_peak_usage(true)) . ' / ' . ini_get('memory_limit') . '<br/>'; } print 'max_execution_time: ' . ini_get('max_execution_time') . ' s<br/>'; print 'max_input_time: ' . ini_get('max_input_time') . ' s<br/>'; print 'upload_max_filesize: ' . ini_get('upload_max_filesize') . '<br/>'; // Output any other PHPINI issues if (ini_get('safe_mode')) { print '<font color="red">safe_mode need to be disabled</font><br/>'; } if (ini_get('magic_quotes_gpc')) { print '<font color="red">magic_quotes_gpc need to be disabled</font><br/>'; } if (ini_get('magic_quotes_runtime')) { print '<font color="red">magic_quotes_runtime need to be disabled</font><br/>'; } print '</div>'; } }
/** * This function displays helpful development info like queries sent to database and memory usage. * By default it shows only if database profiling is enabled in any configured database connections. * * If forced to show when profiling is disabled you can monitor qcodo memory usage more accurately, * as collecting database profiling information tends to noticeable bigger memory consumption. * * @param boolean $blnForceDisplay optional parameter, set true to always display info even if DB profiling is disabled * @return void */ public static function DisplayProfilingInfo($blnForceDisplay = false) { if (QDatabaseBase::IsAnyDatabaseProfilingEnabled() || $blnForceDisplay) { print '<br style="clear: both; font-size: 0px"/>'; print '<div style="padding: 1em; text-align: left; margin: 1em; border: 1px solid #888; color: #000; background-color: #FFF;">'; // Output DB Profiling Data foreach (QApplication::$Database as $objDb) { if ($objDb->EnableProfiling == true) { $objDb->OutputProfiling(); } } // Output runtime statistics / settings print 'memory_get_peak_usage: ' . QString::GetByteSize(memory_get_peak_usage(true)) . ' / ' . ini_get('memory_limit') . '<br/>'; print 'max_execution_time: ' . ini_get('max_execution_time') . ' s<br/>'; print 'max_input_time: ' . ini_get('max_input_time') . ' s<br/>'; print 'upload_max_filesize: ' . ini_get('upload_max_filesize') . '<br/>'; // Output any other PHPINI issues if (ini_get('safe_mode')) { print '<span style="color: red;">safe_mode need to be disabled</span><br/>'; } if (ini_get('magic_quotes_gpc')) { print '<span style="color: red;">magic_quotes_gpc need to be disabled</span><br/>'; } if (ini_get('magic_quotes_runtime')) { print '<span style="color: red;">magic_quotes_runtime need to be disabled</span><br/>'; } print '<a href="#" onClick="qcodo.loadFirebugLite(); return false;">load Firebug Lite</a><br/>'; print '</div>'; } }
} else { printf("CodeGen settings (as evaluted from %s):\r\n%s\r\n\r\n", $_SERVER['argv'][1], QCodeGen::GetSettingsXml()); } foreach (QCodeGen::$CodeGenArray as $objCodeGen) { printf("%s\r\n---------------------------------------------------------------------\r\n", $objCodeGen->GetTitle()); printf("%s\r\n", $objCodeGen->GetReportLabel()); printf("%s\r\n", $objCodeGen->GenerateAll()); if ($strErrors = $objCodeGen->Errors) { printf("The following errors were reported:\r\n%s\r\n", $strErrors); } print "\r\n"; } foreach (QCodeGen::GenerateAggregate() as $strMessage) { printf("%s\r\n\r\n", $strMessage); } } catch (Exception $objExc) { print 'error: ' . trim($objExc->getMessage()) . "\r\n"; exit(1); } $intEndTime = microtime(); $intEndTime = explode(" ", $intEndTime); $intEndTime = $intEndTime[1] + $intEndTime[0]; echo 'Codegen took ', round($intEndTime - $intStartTime, 2), "s ("; if (ini_get('max_execution_time') == 0) { echo 'no execution time limit'; } else { echo 'maximum execution time ', ini_get('max_execution_time'), 's'; } echo ").\n"; echo 'Peak memory usage was ', QString::GetByteSize(memory_get_peak_usage(true)), ' (', ini_get('memory_limit'), " maximum available).\n";
} $strUploadData = apc_fetch('upload_' . $strApcUploadKey); if (!$strUploadData) { exit; } $fltPercent = floor(1000 * $strUploadData['current'] / $strUploadData['total']); $fltPercent = sprintf('%.1f%%', $fltPercent / 10); $intPercentFloor = floor($fltPercent); header('Content-Type: text/xml'); ?> <uploadData key="<?php _p($strApcUploadKey); ?> " total="<?php _p(QString::GetByteSize($strUploadData['total'])); ?> " current="<?php _p(QString::GetByteSize($strUploadData['current'])); ?> " percent="<?php _p($fltPercent); ?> " percentFloor="<?php _p($intPercentFloor); ?> " />
$this->btnGenerateQuarterly->Render('CssClass=primary'); ?> for <?php $this->lstQuarter->Render(); ?> </div> <?php $this->lstYear->RenderWithName(); ?> </div> <?php for ($intYear = 2000; $intYear <= date('Y') + 1; $intYear++) { if (count($strFileArray = $this->GetFileArrayForYear($intYear))) { print '<h3>Bulk Receipt PDFs for ' . $intYear . '</h3>'; print '<div class="section">'; print '<div class="sectionButtons"><button class="primary"'; $this->pxyDelete->RenderAsEvents($intYear); print '>Delete Receipts for ' . $intYear . '</button></div>'; print '<ul style="font-family: arial, helvetica, sans-serif; font-size: 12px;">'; foreach ($strFileArray as $strFile) { printf('<li style="margin: 5px 0;"><strong><a href="/stewardship/receipts/download.php/%s">%s</a></strong> <span style="font-size: 10px; color: #666;">%s | %s</span></li>', QApplication::HtmlEntities($strFile), QApplication::HtmlEntities($strFile), QDateTime::FromTimestamp(filectime(RECEIPT_PDF_PATH . '/' . $strFile))->ToString('MMM D YYYY, h:mm z'), QString::GetByteSize(filesize(RECEIPT_PDF_PATH . '/' . $strFile))); } print '</ul></div>'; } } ?> <?php require __INCLUDES__ . '/footer.inc.php';
if (isset($objOutput->serverErrors)) { echo "\r\n"; $objServerErrors = $objOutput->serverErrors; foreach ($objOutput->serverErrors as $objServerError) { echo '(', $objServerError->code, ') ', $objServerError->error, "\r\n"; } } //display statistics if (isset($objOutput->statistics)) { echo "\r\n"; $objStats = $objOutput->statistics; printf('Original file sizes: %s' . "\r\n", QString::GetByteSize($objStats->originalSize)); // if compilation was successful if (isset($objOutput->compiledCode) && strlen($objOutput->compiledCode) > 0) { printf('Minified file size: %s (%s%% of original)' . "\r\n", QString::GetByteSize($objStats->compressedSize), round($objStats->compressedSize / $objStats->originalSize * 100, 0)); printf('Minified and gziped file size: %s (%s%% of original)' . "\r\n", QString::GetByteSize($objStats->compressedGzipSize), round($objStats->compressedGzipSize / $objStats->originalSize * 100, 0)); } } //display warnings if (isset($objOutput->warnings)) { echo "\r\nWarnings:\r\n"; foreach ($objOutput->warnings as $objWarn) { $indexfile = substr($objWarn->file, 6); echo $arrScriptNames[$indexfile], ':', $objWarn->lineno, ' ', $objWarn->warning, "\r\n"; } } //display errors if (isset($objOutput->errors)) { echo "\r\nErrors:\r\n"; foreach ($objOutput->errors as $objError) { $indexfile = substr($objError->file, 6);
if ($strErrors = QCodeGen::$RootErrors) { printf("The following ROOT ERRORS were reported:\r\n%s\r\n\r\n", $strErrors); } else { printf("CodeGen settings (as evaluted from %s):\r\n%s\r\n\r\n", $_SERVER['argv'][1], QCodeGen::GetSettingsXml()); } foreach (QCodeGen::$CodeGenArray as $objCodeGen) { printf("%s\r\n---------------------------------------------------------------------\r\n", $objCodeGen->GetTitle()); printf("%s\r\n", $objCodeGen->GetReportLabel()); printf("%s\r\n", $objCodeGen->GenerateAll()); if ($strErrors = $objCodeGen->Errors) { printf("The following errors were reported:\r\n%s\r\n", $strErrors); } print "\r\n"; } foreach (QCodeGen::GenerateAggregate() as $strMessage) { printf("%s\r\n\r\n", $strMessage); } $intEndTime = microtime(); $intEndTime = explode(" ", $intEndTime); $intEndTime = $intEndTime[1] + $intEndTime[0]; printf('Codegen took %ss', round($intEndTime - $intStartTime, 2)); if (ini_get('max_execution_time')) { printf(' (%ss maximum)', ini_get('max_execution_time')); } print "\r\n"; printf('Peak memory usage %s (%s maximum allocation)', QString::GetByteSize(memory_get_peak_usage(true)), ini_get('memory_limit')); print "\r\n"; } catch (Exception $objExc) { print 'error: ' . trim($objExc->getMessage()) . "\r\n"; exit(1); }