public function get_list() { $files = array(); $handle = opendir(BACKUP_PLUGIN_FOLDER); while (false !== ($file = readdir($handle))) { if (!preg_match("/(sql|zip)/", $file, $m)) { continue; } $date_create = preg_replace('![^\\d]*!', '', $file); $date_create = preg_replace('#^([\\d]{4})([\\d]{2})([\\d]{2})([\\d]{2})([\\d]{2})([\\d]{2})$#', '$3/$2/$1 $4:$5:$6', $date_create); $files[$file] = array('size' => Text::bytes(filesize(BACKUP_PLUGIN_FOLDER . $file)), 'path' => BACKUP_PLUGIN_FOLDER . $file, 'date' => $date_create); } closedir($handle); $this->response(View::factory('backup/list', array('files' => $files))->render()); }
/** * Проверка файлов на различия, проверяется по размеру файла и наличие файла в ФС * @retun array */ public static function check_files() { $respoonse = self::request('https://api.github.com/repos/:rep/git/trees/:branch?recursive=true'); $respoonse = json_decode($respoonse, TRUE); $files = array('new_files' => array(), 'diff_files' => array(), 'third_party_plugins' => array()); $cache = Cache::instance(); $cached_files = $cache->get(self::CACHE_KEY_FILES); if ($cached_files !== NULL) { return $cached_files; } if (isset($respoonse['tree'])) { $plugins = array(); foreach ($respoonse['tree'] as $row) { $filepath = DOCROOT . $row['path']; if (!file_exists($filepath)) { $files['new_files'][] = self::build_remote_url('https://raw.githubusercontent.com/:rep/:branch/' . $row['path']); continue; } if (is_dir($filepath)) { if (preg_match('/cms\\/plugins\\/([\\w\\_]+)/', $filepath, $matches)) { if (!empty($matches[1])) { $plugins[$matches[1]] = $matches[1]; } } continue; } $filesize = filesize($filepath); if ($filesize != $row['size']) { $diff = $filesize - self::_count_file_lines($filepath) - $row['size']; if ($diff > 1 or $diff < -1) { $files['diff_files'][] = array('diff' => Text::bytes($diff), 'url' => self::build_remote_url('https://raw.githubusercontent.com/:rep/:branch/' . $row['path'])); } } } if (!empty($plugins)) { $local_plugins = array_keys(Plugins::find_all()); $files['third_party_plugins'] = array_diff($local_plugins, $plugins); } $cache->set(self::CACHE_KEY_FILES, $files); } return $files; }
" data-pk="<?php echo $item['key']; ?> " data-url="<?php echo URL::site('phpredmin/expire/' . $curr_db); ?> " data-title="Key Expiration"><?php echo $item['ttl']; ?> </a></td> <td><?php echo $item['encode']; ?> </td> <td><?php echo Text::bytes($item['size']); ?> </td> <td> <a href="<?php echo URL::site('phpredmin/view/' . $curr_db . '?key=' . $item['key']); ?> " class="btn btn-info btn-xs view-detail" data-key="<?php echo $item['key']; ?> ">查看</a> <a href="<?php echo URL::site('phpredmin/del/' . $curr_db . '?key=' . $item['key']); ?> " class="btn btn-danger btn-xs" onclick="return confirm('确定删除吗?')">删除</a> </td>
?> <?php echo $snippet->name; ?> <?php } ?> </th> <td class="modified hidden-xs"> <?php echo Date::format($snippet->modified()); ?> </td> <td class="size"> <?php echo Text::bytes($snippet->size()); ?> </td> <td class="direction hidden-xs"> <?php echo UI::label($snippet->get_relative_path()); ?> </td> <td class="actions text-right"> <?php if (ACL::check('snippet.delete')) { ?> <?php echo UI::button(NULL, array('href' => Route::get('backend')->uri(array('controller' => 'snippet', 'action' => 'delete', 'id' => $snippet->name)), 'icon' => UI::icon('times fa-inverse'), 'class' => 'btn-xs btn-danger btn-confirm')); ?> <?php
public function getUploadsMaxSizeInBytes($directoryIndex, $primary) { $size = 0; $data = $this->getEditData($primary); if (!empty($data) && !empty($data['uploadsDirs']) && !empty($data['uploadsDirs'][$directoryIndex])) { $data = $data['uploadsDirs'][$directoryIndex]; $modelSize = null; if (!empty($data['uploadMaxSize']) && is_numeric($data['uploadMaxSize']) && $data['uploadMaxSize'] > 0) { $modelSize = intval($data['uploadMaxSize']); } $size = Admin::getMaximumFileUploadSize($modelSize); } return Text::bytes($size); }
<td><?php echo Text::bytes($file['size']); ?> </td> <td><?php echo $file['lines']; ?> </td> </tr> <?php $total_size += $file['size']; ?> <?php $total_lines += $file['lines']; ?> <?php } ?> <tr align="left"> <th colspan="2">total</th> <th><?php echo Text::bytes($total_size); ?> </th> <th><?php echo number_format($total_lines); ?> </th> </tr> </table> </div>
<?php echo Text::auto_p(Text::auto_link($codebench['description']), FALSE); ?> <?php } ?> <?php // echo '<h2>Raw output:</h2>', Kohana::debug($codebench) ?> <?php } ?> <p id="footer"> Page executed in <strong><?php echo round(microtime(TRUE) - KOHANA_START_TIME, 2); ?> s</strong> using <strong><?php echo Text::widont(Text::bytes(memory_get_usage(), 'MB')); ?> </strong> of memory.<br /> <a href="http://github.com/kohana/codebench">Codebench</a>, a <a href="http://kohanaframework.org/">Kohana</a> module by <a href="http://www.geertdedeckere.be/article/introducing-codebench">Geert De Deckere</a>. </p> </body> </html>
<?php if (Kohana::$config->load('debugger.panels.benchmarks')) { ?> <!-- Time --> <li id="time" onclick="debugToolbar.show('debug-benchmarks'); return false;"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAKrSURBVDjLpdPbT9IBAMXx/qR6qNbWUy89WS5rmVtutbZalwcNgyRLLMyuoomaZpRQCt5yNRELL0TkBSXUTBT5hZSXQPwBAvor/fZGazlb6+G8nIfP0znbgG3/kz+Knsbb+xxNV63DLxVLHzqV0vCrfMluzFmw1OW8ePEwf8+WgM1UXDnapVgLePr5Nj9DJBJGFEN8+TzKqL2RzkenV4yl5ws2BXob1WVeZxXhoB+PP0xzt0Bly0fKTePozV5GphYQPA46as+gU5/K+w2w6Ev2Ol/KpNCigM01R2uPgDcQIRSJEYys4JmNoO/y0tbnY9JlxnA9M15bfHZHCnjzVN4x7TLz6fMSJqsPgLAoMvV1niSQBGIbUP3Ki93t57XhItVXjulTQHf9hfk5/xgGyzQTgQjx7xvE4nG0j3UsiiLR1VVaLN3YpkTuNLgZGzRSq8wQUoD16flkOPSF28/cLCYkwqvrrAGXC1UYWtuRX1PR5RhgTJTI1Q4wKwzwWHk4kQI6a04nQ99mUOlczMYkFhPrBMQoN+7eQ35Nhc01SvA7OEMSFzTv8c/0UXc54xfQcj/bNzNmRmNy0zctMpeEQFSio/cdvqUICz9AiEPb+DLK2gE+2MrR5qXPpoAn6mxdr1GBwz1FiclDcAPCEkTXIboByz8guA75eg8WxxDtFZloZIdNKaDu5rnt9UVHE5POep6Zh7llmsQlLBNLSMTiEm5hGXXDJ6qb3zJiLaIiJy1Zpjy587ch1ahOKJ6XHGGiv5KeQSfFun4ulb/josZOYY0di/0tw9YCquX7KZVnFW46Ze2V4wU1ivRYe1UWI1Y1vgkDvo9PGLIoabp7kIrctJXSS8eKtjyTtuDErrK8jIYHuQf8VbK0RJUsLfEg94BfIztkLMvP3v3XN/5rfgIYvAvmgKE6GAAAAABJRU5ErkJggg==" alt="time"> <?php echo round(Debugger::get_benchmark_application()->current['time'] * 1000, 2); ?> ms </li> <!-- Memory --> <li id="memory" onclick="debugToolbar.show('debug-benchmarks'); return false;"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGvSURBVDjLpZO7alZREEbXiSdqJJDKYJNCkPBXYq12prHwBezSCpaidnY+graCYO0DpLRTQcR3EFLl8p+9525xgkRIJJApB2bN+gZmqCouU+NZzVef9isyUYeIRD0RTz482xouBBBNHi5u4JlkgUfx+evhxQ2aJRrJ/oFjUWysXeG45cUBy+aoJ90Sj0LGFY6anw2o1y/mK2ZS5pQ50+2XiBbdCvPk+mpw2OM/Bo92IJMhgiGCox+JeNEksIC11eLwvAhlzuAO37+BG9y9x3FTuiWTzhH61QFvdg5AdAZIB3Mw50AKsaRJYlGsX0tymTzf2y1TR9WwbogYY3ZhxR26gBmocrxMuhZNE435FtmSx1tP8QgiHEvj45d3jNlONouAKrjjzWaDv4CkmmNu/Pz9CzVh++Yd2rIz5tTnwdZmAzNymXT9F5AtMFeaTogJYkJfdsaaGpyO4E62pJ0yUCtKQFxo0hAT1JU2CWNOJ5vvP4AIcKeao17c2ljFE8SKEkVdWWxu42GYK9KE4c3O20pzSpyyoCx4v/6ECkCTCqccKorNxR5uSXgQnmQkw2Xf+Q+0iqQ9Ap64TwAAAABJRU5ErkJggg==" alt="memory"> <?php echo Text::bytes(Debugger::get_benchmark_application()->current['memory']); ?> </li> <?php } ?> <!-- Database --> <?php if (Kohana::$config->load('debugger.panels.database')) { ?> <li id="toggle-database" onclick="debugToolbar.show('debug-database'); return false;"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEYSURBVBgZBcHPio5hGAfg6/2+R980k6wmJgsJ5U/ZOAqbSc2GnXOwUg7BESgLUeIQ1GSjLFnMwsKGGg1qxJRmPM97/1zXFAAAAEADdlfZzr26miup2svnelq7d2aYgt3rebl585wN6+K3I1/9fJe7O/uIePP2SypJkiRJ0vMhr55FLCA3zgIAOK9uQ4MS361ZOSX+OrTvkgINSjS/HIvhjxNNFGgQsbSmabohKDNoUGLohsls6BaiQIMSs2FYmnXdUsygQYmumy3Nhi6igwalDEOJEjPKP7CA2aFNK8Bkyy3fdNCg7r9/fW3jgpVJbDmy5+PB2IYp4MXFelQ7izPrhkPHB+P5/PjhD5gCgCenx+VR/dODEwD+A3T7nqbxwf1HAAAAAElFTkSuQmCC" alt="database"> <?php echo count(Debugger::get_database_queries()); ?>
<?php echo Text::auto_link_emails('My email is someone@somewhere.ca and my web site is www.kohanaphp.com'); ?> <br/> <?php $string = "This is a block of\ntext that has\n\nSome line breaks in it."; echo Text::auto_p($string); ?> <br/> <pre> <?php echo "Simple:<br/>"; echo Text::bytes(5500), "\n"; echo Text::bytes(17139812000), "\n\n"; // Maximum unit echo "Max units in MB:\n"; echo Text::bytes(81620000000, 'MB'), "\n\n"; // 4 decimal accuracy echo "4 decimals:\n"; echo Text::bytes(91711816100, null, '%01.4f %s', TRUE), "\n\n"; // 1 decimal accuracy, units in brackets, max unit in MB echo "1 decimal, units in brackets, max unit of MB:\n"; $size = disk_total_space('/home'); echo Text::bytes($size, 'MB', '%01.1f (%s)', TRUE); ?> </pre>
</div> </div> </div> <p class="help-block"> <?php if (!empty($field->types)) { ?> <?php echo __('Allowed types: :types', array(':types' => is_array($field->types) ? implode(', ', $field->types) : '')); ?> . <?php } ?> <?php echo __('Max file size: :size', array(':size' => Text::bytes($field->max_size))); ?> </p> <?php if (!empty($value)) { ?> <hr class="no-margin-b"/> <?php } ?> </div> <?php if (!empty($value)) { ?>
public function testBytes() { $bytes = 60004; $size = Text::bytes($bytes); $this->assertSame('60.00 kB', $size); }
echo implode(', ', $layout->blocks()); ?> </span> </span> <?php } ?> </th> <td class="modified hidden-xs"> <?php echo Date::format($layout->modified()); ?> </td> <td class="size"> <?php echo Text::bytes($layout->size()); ?> </td> <td class="direction hidden-xs"> <?php echo UI::label($layout->get_relative_path()); ?> </td> <td class="actions text-right"> <?php if (ACL::check('layout.delete')) { ?> <?php echo UI::button(NULL, array('icon' => UI::icon('times fa-inverse'), 'href' => Route::get('backend')->uri(array('controller' => 'layout', 'action' => 'delete', 'id' => $layout->name)), 'class' => 'btn-danger btn-xs btn-confirm')); ?> <?php
/** * Render EXIF info. * * @return array */ public function exif() { // Basic info $info = array('<span>©</span> ' . __('Copyright') => $this->image->author_id ? HTML::user($this->image->author_id) : null, '<i class="fa fa-fw fa-upload"></i> ' . __('Added') => HTML::time(Date::format('DMYYYY_HM', $this->image->created), $this->image->created), '<i class="fa fa-fw fa-comment"></i> ' . __('Comments') => (int) $this->image->comment_count, '<i class="fa fa-fw fa-eye"></i> ' . __('Views') => (int) $this->image->view_count); // EXIF info if ($exif = $this->image->exif()) { if ($exif->make || $exif->model) { $info['<i class="fa fa-fw fa-camera-retro"></i> ' . __('Camera')] = ($exif->make ? HTML::chars($exif->make) : '') . ($exif->model ? ($exif->make ? '<br />' : '') . HTML::chars($exif->model) : ''); } if ($exif->exposure) { $info['<i class="fa fa-fw fa-sun-o"></i> ' . __('Shutter Speed')] = HTML::chars($exif->exposure); } if ($exif->aperture) { $info['<i class="fa fa-fw fa-circle-o"></i> ' . __('Aperture')] = HTML::chars($exif->aperture); } if ($exif->focal) { $info['<i class="fa fa-fw fa-road"></i> ' . __('Focal Length')] = HTML::chars($exif->focal); } if ($exif->iso) { $info['<span class="iso fa fa-fw">iso</span> ' . __('ISO Speed')] = HTML::chars($exif->iso); } if ($exif->lens) { $info['<i class="fa fa-fw fa-cd"></i> ' . __('Lens')] = HTML::chars($exif->lens); } if ($exif->flash) { $info['<i class="fa fa-fw fa-bolt"></i> ' . __('Flash')] = HTML::chars($exif->flash); } if ($exif->program) { $info['<i class="fa fa-fw fa-cloud"></i> ' . __('Program')] = HTML::chars($exif->program); } if ($exif->metering) { $info['<i class="fa fa-fw fa-th"></i> ' . __('Metering')] = HTML::chars($exif->metering); } if ($exif->latitude) { $info['<i class="fa fa-fw fa-arrows-h"></i> ' . __('Latitude')] = HTML::chars($exif->latitude); } if ($exif->longitude) { $info['<i class="fa fa-fw fa-arrows-v"></i> ' . __('Longitude')] = HTML::chars($exif->longitude); } if ($exif->altitude) { $info['<i class="fa fa-fw fa-long-arrow-up"></i> ' . __('Altitude')] = HTML::chars($exif->altitude) . 'm'; } if ($exif->taken) { $info['<i class="fa fa-fw fa-calendar"></i> ' . __('Taken')] = Date::format('DMYYYY_HM', $exif->taken); } } // Original image $info['<i class="fa fa-fw fa-external-link"></i> ' . __('Original')] = HTML::anchor($this->image->get_url(Model_Image::SIZE_ORIGINAL), sprintf('%d×%d <small>(%s)</small>', $this->image->original_width, $this->image->original_height, Text::bytes($this->image->original_size, 'kB')), array('target' => '_blank', 'title' => __('Open in new tab'))); return $info; }
</span> </div> </div> <hr /> <div class="form-group form-inline"> <label class="control-label col-md-3"><?php echo __('Max file size'); ?> </label> <div class="col-md-9"> <?php echo Form::input('max_size', $field->max_size, array('class' => 'form-control', 'id' => 'max_size', 'size' => 10)); ?> (<?php echo Text::bytes($field->max_size); ?> ) <span class="flags"> <span class="label" data-value="<?php echo NUM::bytes('100K'); ?> ">100k</span> <span class="label" data-value="<?php echo NUM::bytes('1MiB'); ?> ">1Mib</span> <span class="label" data-value="<?php echo NUM::bytes('5MiB'); ?> ">5Mib</span>
/** * 输出字节格式化 * * @param string a definitive unit * @param string the return string format * @param boolean whether to use SI prefixes or IEC * @return string */ public function byte($force_unit = null, $format = null, $si = true) { return Text::bytes((int) $this->data, $force_unit, $format, $si); }
/** * Get PHP memory_limit * * It can be used to obtain a human-readable form * of a PHP memory_limit. * * [!!] Note: If ini_get('memory_limit') returns 0, -1, NULL or FALSE * returns [System::MIN_MEMORY_LIMIT] * * @since 1.4.0 * * @return int|string * * @uses Num::bytes * @uses Text::bytes */ public static function get_memory_limit() { $memory_limit = Num::bytes(ini_get('memory_limit')); return Text::bytes((int) $memory_limit <= 0 ? self::MIN_MEMORY_LIMIT : $memory_limit, 'MiB'); }
?> x<?php echo $item['img_height']; ?> "> <?php echo HTML::image($item['file_src'] . '?imageView2/2/w/80/h/80', array('style' => 'max-width:80px')); ?> </a> </td> <td><?php echo strtoupper($item['file_type']); ?> </td> <td><?php echo Text::bytes($item['file_size']); ?> </td> <td><?php echo $item['img_width']; ?> x <?php echo $item['img_height']; ?> px</td> <td><?php echo date('Y-m-d H:i:s', $item['add_time']); ?> </td> <td> <a href="<?php
/** * Tests Text::bytes() * * @test * @dataProvider provider_bytes */ function test_bytes($expected, $bytes, $force_unit, $format, $si) { $this->assertSame($expected, Text::bytes($bytes, $force_unit, $format, $si)); }
?> </td> <td align="right"><?php echo sprintf('%.2f', $benchmark['stats']['average']['time'] * 1000); ?> ms</td> <td align="right"><?php echo sprintf('%.2f', $benchmark['stats']['total']['time'] * 1000); ?> ms</td> <td align="right"><?php echo Text::bytes($benchmark['stats']['average']['memory']); ?> </td> <td align="right"><?php echo Text::bytes($benchmark['stats']['total']['memory']); ?> </td> </tr> <?php } ?> <?php } ?> <?php } else { ?> <tr class="<?php echo Text::alternate('odd', 'even');