From aeda49a7d271c2196fcba0d3b2b15d31ad0b33b5 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 5 Nov 2016 20:48:46 +0100 Subject: Add CLI for user information + Fix last user activity https://github.com/FreshRSS/FreshRSS/issues/1345 --- cli/user-info.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 cli/user-info.php (limited to 'cli/user-info.php') 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 +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"; + } +} -- cgit v1.2.3 From 6b85f8cf12f7d83bc7a6a599b48abe779dc263f0 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 5 Nov 2016 21:32:08 +0100 Subject: CLI: IEC prefix (binary) for units Updated according to https://wiki.ubuntu.com/UnitsPolicy (I got confused due `ls`, which is still using 1024 but is listed as an exception) And use the formatting function already included in FreshRSS --- cli/user-info.php | 10 +--------- lib/lib_rss.php | 2 ++ 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'cli/user-info.php') diff --git a/cli/user-info.php b/cli/user-info.php index 5b26ecb15..dd38e6c7f 100644 --- a/cli/user-info.php +++ b/cli/user-info.php @@ -2,14 +2,6 @@ size()), "\t", + format_bytes($entryDAO->size()), "\t", "\n"; } else { echo diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 143b55bee..fc68a96d3 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -127,6 +127,8 @@ function format_bytes($bytes, $precision = 2, $system = 'IEC') { } elseif ($system === 'SI') { $base = 1000; $units = array('B', 'KB', 'MB', 'GB', 'TB'); + } else { + return format_number($bytes, $precision); } $bytes = max(intval($bytes), 0); $pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base)); -- cgit v1.2.3 From 1f37424c09a2b0e6769f8250b65f3652f4e80f14 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 5 Nov 2016 21:37:57 +0100 Subject: +x execution rights user-info --- cli/user-info.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 cli/user-info.php (limited to 'cli/user-info.php') diff --git a/cli/user-info.php b/cli/user-info.php old mode 100644 new mode 100755 -- cgit v1.2.3