Index: core/install/cache/class_structure.php =================================================================== --- core/install/cache/class_structure.php +++ core/install/cache/class_structure.php @@ -36,6 +36,7 @@ 'ConfigurationItem' => '/core/units/configuration/configuration.php', 'ConfigurationTagProcessor' => '/core/units/configuration/configuration_tag_processor.php', 'ConfigurationValidator' => '/core/units/configuration/configuration_validator.php', + 'ContentBlockCopier' => '/core/units/helpers/content_block_copier.php', 'ContentEventHandler' => '/core/units/content/content_eh.php', 'ContentTagProcessor' => '/core/units/content/content_tp.php', 'CoreUpgrades' => '/core/install/upgrades.php', @@ -167,6 +168,7 @@ 'SiteConfigTagProcessor' => '/core/units/sections/site_config_tp.php', 'SiteDomainEventHandler' => '/core/units/site_domains/site_domain_eh.php', 'SiteHelper' => '/core/units/helpers/site_helper.php', + 'SitemapHelper' => '/core/units/helpers/sitemap_helper.php', 'SkinEventHandler' => '/core/units/skins/skin_eh.php', 'SkinHelper' => '/core/units/helpers/skin_helper.php', 'SpamHelper' => '/core/units/helpers/spam_helper.php', @@ -184,6 +186,7 @@ 'SystemEventSubscriptionTagProcessor' => '/core/units/system_event_subscriptions/system_event_subscription_tp.php', 'SystemLogEventHandler' => '/core/units/logs/system_logs/system_log_eh.php', 'SystemLogTagProcessor' => '/core/units/logs/system_logs/system_log_tp.php', + 'TempTablesHelper' => '/core/units/helpers/temp_tables_helper.php', 'TemplateHelper' => '/core/units/helpers/template_helper.php', 'TemplatesCache' => '/core/kernel/nparser/template_cache.php', 'ThemeFileEventHandler' => '/core/units/theme_files/theme_file_eh.php', @@ -548,6 +551,13 @@ 0 => 'kValidator', ), ), + 'ContentBlockCopier' => array( + 'type' => 1, + 'modifiers' => 0, + 'extends' => array( + 0 => 'kBase', + ), + ), 'ContentEventHandler' => array( 'type' => 1, 'modifiers' => 0, @@ -1403,6 +1413,13 @@ 0 => 'kHelper', ), ), + 'SitemapHelper' => array( + 'type' => 1, + 'modifiers' => 0, + 'extends' => array( + 0 => 'kHelper', + ), + ), 'SkinEventHandler' => array( 'type' => 1, 'modifiers' => 0, @@ -1516,6 +1533,13 @@ 0 => 'kDBTagProcessor', ), ), + 'TempTablesHelper' => array( + 'type' => 1, + 'modifiers' => 0, + 'extends' => array( + 0 => 'kHelper', + ), + ), 'TemplateHelper' => array( 'type' => 1, 'modifiers' => 0, Index: core/install/english.lang =================================================================== --- core/install/english.lang +++ 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: core/install/install_data.sql =================================================================== --- core/install/install_data.sql +++ 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: core/install/upgrades.sql =================================================================== --- core/install/upgrades.sql +++ core/install/upgrades.sql @@ -3026,3 +3026,6 @@ UPDATE Modules SET ClassNamespace = 'InPortal\\Core' WHERE `Name` IN ('Core', 'In-Portal'); + +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: core/units/helpers/temp_tables_helper.php =================================================================== --- /dev/null +++ core/units/helpers/temp_tables_helper.php @@ -0,0 +1,39 @@ +Application->recallObject( + $prefix_special . '_TempHandler', + 'kTempTablesHandler', + array('parent_event' => $event) + ); + } + +} Index: core/units/logs/session_logs/session_log_eh.php =================================================================== --- core/units/logs/session_logs/session_log_eh.php +++ core/units/logs/session_logs/session_log_eh.php @@ -129,4 +129,59 @@ } } - } \ 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; + } + + /** @var TempTablesHelper $temp_tables_helper */ + $temp_tables_helper = $this->Application->recallObject('TempTablesHelper'); + + $session_log_temp_handler = $temp_tables_helper->getTempTablesHandler($event->getPrefixSpecial(), $event); + $change_log_temp_handler = $temp_tables_helper->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 ) { + $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); + } + + $change_log_need_more_iteration = count($change_log_ids) == $limit; + } while ( $change_log_need_more_iteration ); + + $session_log_temp_handler->DeleteItems($event->Prefix, $event->Special, $session_log_ids); + } + + $session_log_need_more_iteration = count($session_log_ids) == $limit; + } while ( $session_log_need_more_iteration ); + } + + } Index: core/units/logs/session_logs/session_logs_config.php =================================================================== --- core/units/logs/session_logs/session_logs_config.php +++ 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 +); Index: core/units/logs/system_logs/system_logs_config.php =================================================================== --- core/units/logs/system_logs/system_logs_config.php +++ core/units/logs/system_logs/system_logs_config.php @@ -202,4 +202,4 @@ ), ), ), -); \ No newline at end of file +);