Revert "fixes #2166 add feature to send anonymous stats to piwigo.org"

This reverts commit 1106612fc3.

Theses changes were committed on 14.x by mistake
This commit is contained in:
plegall
2024-06-10 21:32:35 +02:00
parent 1106612fc3
commit ec5bce90bf
6 changed files with 119 additions and 512 deletions
-148
View File
@@ -3669,151 +3669,3 @@ function get_piwigo_news()
return $news;
}
function get_graphics_library()
{
global $conf;
include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
$library = pwg_image::get_library();
switch (pwg_image::get_library())
{
case 'imagick':
$img = new Imagick();
$version = $img->getVersion();
if (preg_match('/ImageMagick \d+\.\d+\.\d+-?\d*/', $version['versionString'], $match))
{
$library.= '/'.$match[0];
}
break;
case 'ext_imagick':
exec($conf['ext_imagick_dir'].'convert -version', $returnarray);
if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match))
{
$library.= '/'.$match[1];
}
break;
case 'gd':
$gd_info = gd_info();
$library.= '/'.@$gd_info['GD Version'];
break;
}
return $library;
}
function get_graphics_library_label()
{
list($library_code, $library_version) = explode('/', get_graphics_library());
$label_for_lib = array(
'imagick' => 'ImageMagick',
'ext_imagick' => 'External ImageMagick',
'gd' => 'GD',
);
return $label_for_lib[$library_code].' '.$library_version;
}
function get_pwg_general_statitics()
{
$stats = array();
$query = '
SELECT COUNT(*)
FROM '.IMAGES_TABLE.'
;';
list($stats['nb_photos']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.CATEGORIES_TABLE.'
;';
list($stats['nb_categories']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.TAGS_TABLE.'
;';
list($stats['nb_tags']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.IMAGE_TAG_TABLE.'
;';
list($stats['nb_image_tag']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.USERS_TABLE.'
;';
list($stats['nb_users']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT
COUNT(*)
FROM '.USER_INFOS_TABLE.'
WHERE status IN (\'webmaster\', \'admin\')
;';
list($stats['nb_admins']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM `'.GROUPS_TABLE.'`
;';
list($stats['nb_groups']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.RATE_TABLE.'
;';
list($stats['nb_rates']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT
SUM(nb_pages)
FROM '.HISTORY_SUMMARY_TABLE.'
WHERE month IS NULL
;';
list($stats['nb_views']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT
SUM(filesize)
FROM '.IMAGES_TABLE.'
;';
list($stats['disk_usage']) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT
COUNT(*),
SUM(filesize)
FROM '.IMAGE_FORMAT_TABLE.'
;';
list($stats['nb_formats'], $stats['formats_disk_usage']) = pwg_db_fetch_row(pwg_query($query));
$stats['disk_usage'] += $stats['formats_disk_usage'];
return $stats;
}
function get_installation_date()
{
$query = '
SELECT
registration_date
FROM '.USER_INFOS_TABLE.'
WHERE user_id = 2
;';
$users = query2array($query);
if (count($users) > 0)
{
return $users[0]['registration_date'];
}
return null;
}
+74 -10
View File
@@ -109,10 +109,74 @@ if ($conf['show_newsletter_subscription'] and userprefs_get_param('show_newslett
}
$stats = get_pwg_general_statitics();
$query = '
SELECT COUNT(*)
FROM '.IMAGES_TABLE.'
;';
list($nb_photos) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.CATEGORIES_TABLE.'
;';
list($nb_categories) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.TAGS_TABLE.'
;';
list($nb_tags) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.IMAGE_TAG_TABLE.'
;';
list($nb_image_tag) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.USERS_TABLE.'
;';
list($nb_users) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM `'.GROUPS_TABLE.'`
;';
list($nb_groups) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.RATE_TABLE.'
;';
list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT
SUM(nb_pages)
FROM '.HISTORY_SUMMARY_TABLE.'
WHERE month IS NULL
;';
list($nb_views) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT
SUM(filesize)
FROM '.IMAGES_TABLE.'
;';
list($disk_usage) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT
SUM(filesize)
FROM '.IMAGE_FORMAT_TABLE.'
;';
list($formats_disk_usage) = pwg_db_fetch_row(pwg_query($query));
$disk_usage+= $formats_disk_usage;
$du_decimals = 1;
$du_gb = $stats['disk_usage']/(1024*1024);
$du_gb = $disk_usage/(1024*1024);
if ($du_gb > 100)
{
$du_decimals = 0;
@@ -120,14 +184,14 @@ if ($du_gb > 100)
$template->assign(
array(
'NB_PHOTOS' => $stats['nb_photos'],
'NB_ALBUMS' => $stats['nb_categories'],
'NB_TAGS' => $stats['nb_tags'],
'NB_IMAGE_TAG' => $stats['nb_image_tag'],
'NB_USERS' => $stats['nb_users'],
'NB_GROUPS' => $stats['nb_groups'],
'NB_RATES' => $stats['nb_rates'],
'NB_VIEWS' => number_format_human_readable($stats['nb_views']),
'NB_PHOTOS' => $nb_photos,
'NB_ALBUMS' => $nb_categories,
'NB_TAGS' => $nb_tags,
'NB_IMAGE_TAG' => $nb_image_tag,
'NB_USERS' => $nb_users,
'NB_GROUPS' => $nb_groups,
'NB_RATES' => $nb_rates,
'NB_VIEWS' => number_format_human_readable($nb_views),
'NB_PLUGINS' => count($pwg_loaded_plugins),
'STORAGE_USED' => str_replace(' ', ' ', l10n('%sGB', number_format($du_gb, $du_decimals))),
'U_QUICK_SYNC' => PHPWG_ROOT_PATH.'admin.php?page=site_update&site=1&quick_sync=1&pwg_token='.get_pwg_token(),
+45 -11
View File
@@ -301,10 +301,33 @@ $template->assign(
);
// graphics library
$graphics_library = get_graphics_library_label();
if (!empty($graphics_library))
switch (pwg_image::get_library())
{
$template->assign('GRAPHICS_LIBRARY', $graphics_library);
case 'imagick':
$library = 'ImageMagick';
$img = new Imagick();
$version = $img->getVersion();
if (preg_match('/ImageMagick \d+\.\d+\.\d+-?\d*/', $version['versionString'], $match))
{
$library = $match[0];
}
$template->assign('GRAPHICS_LIBRARY', $library);
break;
case 'ext_imagick':
$library = 'External ImageMagick';
exec($conf['ext_imagick_dir'].'convert -version', $returnarray);
if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match))
{
$library .= ' ' . $match[1];
}
$template->assign('GRAPHICS_LIBRARY', $library);
break;
case 'gd':
$gd_info = gd_info();
$template->assign('GRAPHICS_LIBRARY', 'GD '.@$gd_info['GD Version']);
break;
}
if ($conf['gallery_locked'])
@@ -324,15 +347,26 @@ else
);
}
$installed_on = get_installation_date();
if (!empty($installed_on))
$query = '
SELECT
registration_date
FROM '.USER_INFOS_TABLE.'
WHERE user_id = 2
;';
$users = query2array($query);
if (count($users) > 0)
{
$template->assign(
array(
'INSTALLED_ON' => format_date($installed_on, array('day', 'month', 'year')),
'INSTALLED_SINCE' => time_since($installed_on, 'day'),
)
);
$installed_on = $users[0]['registration_date'];
if (!empty($installed_on))
{
$template->assign(
array(
'INSTALLED_ON' => format_date($installed_on, array('day', 'month', 'year')),
'INSTALLED_SINCE' => time_since($installed_on, 'day'),
)
);
}
}
// +-----------------------------------------------------------------------+