Changeset 6179
- Timestamp:
- May 14, 2010, 7:57:00 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/History_cleanup/main.inc.php
r6139 r6179 2 2 /* 3 3 Plugin Name: History cleanup 4 Version: 2.1. a4 Version: 2.1.b 5 5 Description: A background process which cleans your history table on regular basis 6 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=392 … … 17 17 : array( 'each' => 30, 'remove' => 90 ); # DAYs 18 18 $latest = strtotime('-' . $w['each'] . ' days'); 19 $limit = date ('Y-m-d',strtotime('-' . $w['remove'] . ' days')); 19 20 $previous = pwg_get_session_var('history_check', $latest); 20 21 if ( $previous <= $latest ) { 21 22 $q = ' 22 23 DELETE FROM ' . HISTORY_TABLE . ' 23 WHERE date < DATE_SUB(NOW(), INTERVAL ' . $w['remove'] . ' DAY)24 WHERE date < ' . $limit . ' 24 25 AND summarized = "true";'; 25 26 26 $r = pwg_query($q); 27 27 if($r) 28 28 { 29 if (defined('DB_ENGINE') and DB_ENGINE == 'PostgreSQL') 30 $q = 'VACUUM FULL '.HISTORY_TABLE; 31 else $q = 'OPTIMIZE TABLE '.HISTORY_TABLE; 32 $r=pwg_query($q); 29 if (!defined('DB_ENGINE') ) define('DB_ENGINE', 'MySQL'); 30 switch (DB_ENGINE) { 31 case 'PostgreSQL': 32 $q = 'VACUUM FULL '.HISTORY_TABLE.';'; 33 break; 34 case 'MySQL': 35 $q = 'OPTIMIZE TABLE '.HISTORY_TABLE.';'; 36 break; 37 default: 38 $q = 'VACUUM;'; 39 } 40 $r=pwg_query($q); 33 41 } 34 42 pwg_set_session_var('history_check', strtotime("now"));
Note: See TracChangeset
for help on using the changeset viewer.