diff options
| author | 2016-11-05 20:57:04 +0100 | |
|---|---|---|
| committer | 2016-11-05 20:57:04 +0100 | |
| commit | e66247f01271eb96ac96aad6c0631d9f544ce80c (patch) | |
| tree | 5913bdb716f5e3025963bcc9dc93c34c4d521601 /cli/user-info.php | |
| parent | 28bb2813f3121a7c992eba279d0c566269d619aa (diff) | |
| parent | aeda49a7d271c2196fcba0d3b2b15d31ad0b33b5 (diff) | |
Merge pull request #1358 from Alkarex/cli-list-users
Add CLI for user information + Fix last user activity
Diffstat (limited to 'cli/user-info.php')
| -rw-r--r-- | cli/user-info.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/cli/user-info.php b/cli/user-info.php new file mode 100644 index 000000000..5b26ecb15 --- /dev/null +++ b/cli/user-info.php @@ -0,0 +1,43 @@ +#!/usr/bin/php +<?php +require('_cli.php'); + +function formatSize($bytes) +{//http://www.php.net/manual/function.disk-free-space.php#103382 + $si_prefix = array('', 'k', 'M', 'G', 'T', 'P'); + $i = min((int)log($bytes, 1024), count($si_prefix) - 1); + return ($i <= 0) ? $bytes.'B' : + round($bytes / pow(1024, $i), 2).' '.$si_prefix[$i].'B'; +} + +$options = getopt('h', array( + 'user:', + )); + +if (empty($options['user'])) { + fail('Usage: ' . basename(__FILE__) . " -h --user username"); +} + +$users = $options['user'] === '*' ? listUsers() : array($options['user']); + +foreach ($users as $username) { + $username = cliInitUser($username); + + $entryDAO = FreshRSS_Factory::createEntryDao($username); + + echo $username === FreshRSS_Context::$system_conf->default_user ? '*' : ' ', "\t"; + + if (isset($options['h'])) { //Human format + echo + $username, "\t", + date('c', FreshRSS_UserDAO::mtime($username)), "\t", + formatSize($entryDAO->size()), "\t", + "\n"; + } else { + echo + $username, "\t", + FreshRSS_UserDAO::mtime($username), "\t", + $entryDAO->size(), "\t", + "\n"; + } +} |
