user-info.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/php
  2. <?php
  3. require('_cli.php');
  4. function formatSize($bytes)
  5. {//http://www.php.net/manual/function.disk-free-space.php#103382
  6. $si_prefix = array('', 'k', 'M', 'G', 'T', 'P');
  7. $i = min((int)log($bytes, 1024), count($si_prefix) - 1);
  8. return ($i <= 0) ? $bytes.'B' :
  9. round($bytes / pow(1024, $i), 2).' '.$si_prefix[$i].'B';
  10. }
  11. $options = getopt('h', array(
  12. 'user:',
  13. ));
  14. if (empty($options['user'])) {
  15. fail('Usage: ' . basename(__FILE__) . " -h --user username");
  16. }
  17. $users = $options['user'] === '*' ? listUsers() : array($options['user']);
  18. foreach ($users as $username) {
  19. $username = cliInitUser($username);
  20. $entryDAO = FreshRSS_Factory::createEntryDao($username);
  21. echo $username === FreshRSS_Context::$system_conf->default_user ? '*' : ' ', "\t";
  22. if (isset($options['h'])) { //Human format
  23. echo
  24. $username, "\t",
  25. date('c', FreshRSS_UserDAO::mtime($username)), "\t",
  26. formatSize($entryDAO->size()), "\t",
  27. "\n";
  28. } else {
  29. echo
  30. $username, "\t",
  31. FreshRSS_UserDAO::mtime($username), "\t",
  32. $entryDAO->size(), "\t",
  33. "\n";
  34. }
  35. }