Index: branches/5.3.x/core/install/english.lang =================================================================== --- branches/5.3.x/core/install/english.lang +++ branches/5.3.x/core/install/english.lang @@ -208,6 +208,7 @@ U2Vzc2lvbiBTZWN1cml0eSBDaGVjayBiYXNlZCBvbiBCcm93c2VyIFNpZ25hdHVyZQ== U2Vzc2lvbiBDb29raWUgRG9tYWlucyAoc2luZ2xlIGRvbWFpbiBwZXIgbGluZSk= U2Vzc2lvbiBTZWN1cml0eSBDaGVjayBiYXNlZCBvbiBJUA== + S2VlcCAiU2Vzc2lvbiBMb2ciIGZvcg== V2Vic2l0ZSBTdWJ0aXRsZQ== VGltZSB6b25lIG9mIHRoZSBzaXRl VGVtcGxhdGUgZm9yIFNvZnQgTWFpbnRlbmFuY2U= @@ -923,6 +924,7 @@ RmFpbGVk RmVicnVhcnk= Rmlyc3QgTmFtZQ== + NSB5ZWFycw== RnJpZGF5 R3JvdXA= R3Vlc3RzIE9ubHk= @@ -994,10 +996,12 @@ VGFi VGVtcGxhdGU= MyBtb250aHM= + MyB5ZWFycw== VGh1cnNkYXk= VGl0bGU= VHVlc2RheQ== MiB3ZWVrcw== + MiB5ZWFycw== VXNlcg== RW1haWwgQWN0aXZhdGlvbg== SW1tZWRpYXRlIA== Index: branches/5.3.x/core/install/install_data.sql =================================================================== --- branches/5.3.x/core/install/install_data.sql +++ branches/5.3.x/core/install/install_data.sql @@ -106,6 +106,7 @@ INSERT INTO SystemSettings VALUES(DEFAULT, 'EmailLogRotationInterval', '2419200', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_EmailLogRotationInterval', 'select', NULL, '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_EmailLogKeepForever', 65.02, 0, 0, 'hint:la_config_EmailLogRotationInterval'); INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogRotationInterval', '2419200', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogRotationInterval', 'select', NULL, '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_SystemLogKeepForever', 65.03, 0, 1, 'hint:la_config_SystemLogRotationInterval'); INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogNotificationEmail', '', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogNotificationEmail', 'text', 'a:5:{s:4:"type";s:6:"string";s:9:"formatter";s:10:"kFormatter";s:6:"regexp";s:85:"/^([-a-zA-Z0-9!\\#$%&*+\\/=?^_`{|}~.]+@[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\\.[a-zA-Z]{2,6})$/i";s:10:"error_msgs";a:1:{s:14:"invalid_format";s:18:"!la_invalid_email!";}s:7:"default";s:0:"";}', NULL, 65.04, 0, 1, 'hint:la_config_SystemLogNotificationEmail'); +INSERT INTO SystemSettings VALUES(DEFAULT, 'SessionLogRotationInterval', '2629800', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SessionLogRotationInterval', 'select', '', '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2629800=la_opt_OneMonth||7889400=la_opt_ThreeMonths||31557600=la_opt_OneYear||63115200=la_opt_TwoYears||94672800=la_opt_ThreeYears||157788000=la_opt_FiveYears||-1=la_opt_EmailLogKeepForever', 65.05, 0, 1, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'CSVExportDelimiter', '1', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportDelimiter', 'select', NULL, '0=la_opt_Tab||1=la_opt_Comma||2=la_opt_Semicolon||3=la_opt_Space||4=la_opt_Colon', 70.01, 0, 1, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'CSVExportEnclosure', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportEnclosure', 'radio', NULL, '0=la_Doublequotes||1=la_Quotes', 70.02, 0, 1, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'CSVExportSeparator', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportSeparator', 'radio', NULL, '0=la_Linux||1=la_Windows', 70.03, 0, 1, NULL); Index: branches/5.3.x/core/install/upgrades.sql =================================================================== --- branches/5.3.x/core/install/upgrades.sql +++ branches/5.3.x/core/install/upgrades.sql @@ -3037,3 +3037,5 @@ ALTER TABLE SiteDomains ADD `Status` TINYINT NOT NULL DEFAULT '1' AFTER Priority, ADD INDEX (`Status`); + +INSERT INTO SystemSettings VALUES(DEFAULT, 'SessionLogRotationInterval', '2629800', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SessionLogRotationInterval', 'select', '', '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2629800=la_opt_OneMonth||7889400=la_opt_ThreeMonths||31557600=la_opt_OneYear||63115200=la_opt_TwoYears||94672800=la_opt_ThreeYears||157788000=la_opt_FiveYears||-1=la_opt_EmailLogKeepForever', 65.05, 0, 1, NULL); Index: branches/5.3.x/core/units/logs/session_logs/session_log_eh.php =================================================================== --- branches/5.3.x/core/units/logs/session_logs/session_log_eh.php +++ branches/5.3.x/core/units/logs/session_logs/session_log_eh.php @@ -129,4 +129,72 @@ } } - } \ No newline at end of file + /** + * [SCHEDULED TASK] Will remove old session logs + * + * @param kEvent $event Event. + * + * @return void + */ + protected function OnRotate(kEvent $event) + { + $rotation_interval = (int)$this->Application->ConfigValue('SessionLogRotationInterval'); + + if ( $rotation_interval === -1 ) { + // Forever. + return; + } + + $session_log_temp_handler = $this->getTempTablesHandler($event->getPrefixSpecial(), $event); + $change_log_temp_handler = $this->getTempTablesHandler('change-log', $event); + + $limit = 100; + $session_log_config = $event->getUnitConfig(); + $session_log_select_sql = ' SELECT ' . $session_log_config->getIDField() . ' + FROM ' . $session_log_config->getTableName() . ' + WHERE ' . TIMENOW . ' - SessionEnd > ' . $rotation_interval . ' + LIMIT 0,' . $limit; + $change_log_config = $this->Application->getUnitConfig('change-log'); + + do { + $session_log_ids = $this->Conn->GetCol($session_log_select_sql); + + if ( !$session_log_ids ) { + break; + } + + $change_log_select_sql = ' SELECT ' . $change_log_config->getIDField() . ' + FROM ' . $change_log_config->getTableName() . ' + WHERE SessionLogId IN (' . implode(',', $session_log_ids) . ') + LIMIT 0,' . $limit; + + do { + $change_log_ids = $this->Conn->GetCol($change_log_select_sql); + + if ( $change_log_ids ) { + $change_log_temp_handler->DeleteItems('change-log', '', $change_log_ids); + } + } while ( count($change_log_ids) == $limit ); + + $session_log_temp_handler->DeleteItems($event->Prefix, $event->Special, $session_log_ids); + } while ( count($session_log_ids) == $limit ); + } + + /** + * Get temp tables handler instance. + * + * @param string $prefix_special Prefix, special. + * @param kEvent $event Event. + * + * @return kTempTablesHandler + */ + public function getTempTablesHandler($prefix_special, kEvent $event) + { + return $this->Application->recallObject( + $prefix_special . '_TempHandler', + 'kTempTablesHandler', + array('parent_event' => $event) + ); + } + + } Index: branches/5.3.x/core/units/logs/session_logs/session_logs_config.php =================================================================== --- branches/5.3.x/core/units/logs/session_logs/session_logs_config.php +++ branches/5.3.x/core/units/logs/session_logs/session_logs_config.php @@ -55,6 +55,10 @@ 5 => 'mode', ), + 'ScheduledTasks' => array( + 'rotate_session_logs' => array('EventName' => 'OnRotate', 'RunSchedule' => '0 0 * * *'), + ), + 'IDField' => 'SessionLogId', 'StatusField' => Array ('Status'), @@ -150,4 +154,4 @@ ), ), ), -); \ No newline at end of file +);