XFileSharing Pro - Simple way to get the total number of users/files and total storage stats?

Message
Author
Dundil
Posts: 4
Joined: Apr 22, 2020 11:52 am

Simple way to get the total number of users/files and total storage stats?

#1 Postby Dundil » Jul 03, 2021 3:03 pm

Is there a simple way to get:
- Total number of users
- Total number of files
- Total storage
?

I'm looking to display them on the home page so they should be in a TMPL_VAR.

verzing
Posts: 174
Joined: Mar 02, 2011 7:00 pm

Re: Simple way to get the total number of users/files and total storage stats?

#2 Postby verzing » Jul 12, 2021 9:12 pm

Go to your site setting, and checked to enable :
Show server stats on main page

Dundil
Posts: 4
Joined: Apr 22, 2020 11:52 am

Re: Simple way to get the total number of users/files and total storage stats?

#3 Postby Dundil » Jul 13, 2021 1:38 am

verzing wrote:Go to your site setting, and checked to enable :
Show server stats on main page
I actually have it enabled but I cannot find the variables for it. It's supposed to be either in main.html or splash.html if I'm understanding well, but there is nothing referring to stats.

verzing
Posts: 174
Joined: Mar 02, 2011 7:00 pm

Re: Simple way to get the total number of users/files and total storage stats?

#4 Postby verzing » Jul 14, 2021 7:56 am

Dundil wrote:
verzing wrote:Go to your site setting, and checked to enable :
Show server stats on main page
I actually have it enabled but I cannot find the variables for it. It's supposed to be either in main.html or splash.html if I'm understanding well, but there is nothing referring to stats.
Those code in upload_form

Dundil
Posts: 4
Joined: Apr 22, 2020 11:52 am

Re: Simple way to get the total number of users/files and total storage stats?

#5 Postby Dundil » Jul 15, 2021 7:29 am

verzing wrote:
Dundil wrote:
verzing wrote:Go to your site setting, and checked to enable :
Show server stats on main page
I actually have it enabled but I cannot find the variables for it. It's supposed to be either in main.html or splash.html if I'm understanding well, but there is nothing referring to stats.
Those code in upload_form
Found it thank you!

In case someone needs the same tip, the variables are:

Code: Select all

<TMPL_VAR user_total>
<TMPL_VAR used_total>
<TMPL_VAR files_total>
In my case, I needed to display those in splash.html so i had to add the following code to Engine/SplashScreen.pm:

Code: Select all

sub main
{
   my $stats;

      $stats =
        $db->SelectRow("SELECT SUM(srv_files) as files_total, ROUND(SUM(srv_disk)/1073741824,2) as used_total FROM Servers");
      $stats->{user_total} = $db->SelectOne("SELECT COUNT(*) FROM Users");

   
	$ses->PrintTemplate('splash.html',
	'user_total'    => $stats->{user_total},
	'files_total'    => $stats->{files_total},
	'used_total'    => $stats->{used_total},
      demo_mode => $c->{demo_mode});
}
:!: May not be recommended for a large number of files