From 834ffacce22ff6a2c0f1459476dc4a45e8ea06f9 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 19 Mar 2019 20:14:31 +0100 Subject: No old ID (#2276) * No old ID https://github.com/FreshRSS/FreshRSS/issues/2273 * PostgreSQL insert or ignore --- lib/lib_rss.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'lib/lib_rss.php') diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 89e9ddfea..bff59d5cc 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -303,12 +303,7 @@ function lazyimg($content) { function uTimeString() { $t = @gettimeofday(); - return $t['sec'] . str_pad($t['usec'], 6, '0'); -} - -function uSecString() { - $t = @gettimeofday(); - return str_pad($t['usec'], 6, '0'); + return $t['sec'] . str_pad($t['usec'], 6, '0', STR_PAD_LEFT); } function invalidateHttpCache($username = '') { -- cgit v1.2.3 From f2925594c7caf2753e1ac44941e029a3c1496117 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 23 Mar 2019 23:17:22 +0100 Subject: Add header to cli (#2296) * Add header to cli Now there is a switch to display the header on user info. While doing that, I've changed how the command is working to display all users by default and to accept more than one user at once. I also changed the display to make it more pleasing. As this command displays all users by default. I wonder if we still need the list user command. See #2294 * Minor format --- cli/user-info.php | 77 ++++++++++++++++++++++++++++++++++--------------------- lib/lib_rss.php | 2 +- 2 files changed, 49 insertions(+), 30 deletions(-) (limited to 'lib/lib_rss.php') diff --git a/cli/user-info.php b/cli/user-info.php index 125408c10..aa4db7c2f 100755 --- a/cli/user-info.php +++ b/cli/user-info.php @@ -2,19 +2,46 @@ default_user ? '*' : ' ', "\t"; $catDAO = FreshRSS_Factory::createCategoryDao(); $feedDAO = FreshRSS_Factory::createFeedDao($username); @@ -25,31 +52,23 @@ foreach ($users as $username) { $nbEntries = $entryDAO->countUnreadRead(); $nbFavorites = $entryDAO->countUnreadReadFavorites(); + $data = array( + 'default' => $username === FreshRSS_Context::$system_conf->default_user ? '*' : '', + 'user' => $username, + 'lastUpdate' => FreshRSS_UserDAO::mtime($username), + 'spaceUsed' => $databaseDAO->size(), + 'categories' => $catDAO->count(), + 'feeds' => count($feedDAO->listFeedsIds()), + 'reads' => $nbEntries['read'], + 'unreads' => $nbEntries['unread'], + 'favourites' => $nbFavorites['all'], + 'tags' => $tagDAO->count(), + ); if (isset($options['h'])) { //Human format - echo - $username, "\t", - date('c', FreshRSS_UserDAO::mtime($username)), "\t", - format_bytes($databaseDAO->size()), "\t", - $catDAO->count(), " categories\t", - count($feedDAO->listFeedsIds()), " feeds\t", - $nbEntries['read'], " reads\t", - $nbEntries['unread'], " unreads\t", - $nbFavorites['all'], " favourites\t", - $tagDAO->count(), " tags\t", - "\n"; - } else { - echo - $username, "\t", - FreshRSS_UserDAO::mtime($username), "\t", - $databaseDAO->size(), "\t", - $catDAO->count(), "\t", - count($feedDAO->listFeedsIds()), "\t", - $nbEntries['read'], "\t", - $nbEntries['unread'], "\t", - $nbFavorites['all'], "\t", - $tagDAO->count(), "\t", - "\n"; + $data['lastUpdate'] = date('c', $data['lastUpdate']); + $data['spaceUsed'] = format_bytes($data['spaceUsed']); } + vprintf(DATA_FORMAT, $data); } done(); diff --git a/lib/lib_rss.php b/lib/lib_rss.php index bff59d5cc..3e0033a61 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -170,7 +170,7 @@ function format_bytes($bytes, $precision = 2, $system = 'IEC') { $pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base)); $pow = min($pow, count($units) - 1); $bytes /= pow($base, $pow); - return format_number($bytes, $precision) . ' ' . $units[$pow]; + return format_number($bytes, $precision) . ' ' . $units[$pow]; } function timestamptodate ($t, $hour = true) { -- cgit v1.2.3