diff --git a/images/icon_clean.png b/images/icon_clean.png new file mode 100644 index 00000000..cf039f40 Binary files /dev/null and b/images/icon_clean.png differ diff --git a/lib/class/share.class.php b/lib/class/share.class.php index a5bfb453..fc3b2760 100644 --- a/lib/class/share.class.php +++ b/lib/class/share.class.php @@ -74,6 +74,12 @@ class Share extends database_object return Dba::write($sql, $params); } + public static function gc() + { + $sql = "DELETE FROM `share` WHERE (`expire_days` > 0 AND (`creation_date` + (`expire_days` * 86400)) < " . time() . ") OR (`max_counter` > 0 AND `counter` >= `max_counter`)"; + Dba::write($sql); + } + public static function delete_shares($object_type, $object_id) { $sql = "DELETE FROM `share` WHERE `object_type` = ? AND `object_id` = ?"; diff --git a/share.php b/share.php index 07129f76..8d783e49 100644 --- a/share.php +++ b/share.php @@ -108,6 +108,18 @@ switch ($action) { } UI::show_footer(); exit; + case 'clean': + if (AmpConfig::get('demo_mode')) { + UI::access_denied(); + exit; + } + + UI::show_header(); + Share::gc(); + $next_url = AmpConfig::get('web_path') . '/stats.php?action=share'; + show_confirmation(T_('Shared Objects cleaned'), T_('Expired shared objects have been cleaned.'), $next_url); + UI::show_footer(); + exit; case 'external_share': if (AmpConfig::get('demo_mode')) { UI::access_denied(); diff --git a/templates/show_shares.inc.php b/templates/show_shares.inc.php index b2e4123f..599f8a6b 100644 --- a/templates/show_shares.inc.php +++ b/templates/show_shares.inc.php @@ -21,5 +21,13 @@ */ ?> +