Page MenuHomeIn-Portal Phabricator

D165.id407.diff
No OneTemporary

File Metadata

Created
Wed, Feb 26, 9:05 AM

D165.id407.diff

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 @@
<PHRASE Label="la_config_SessionBrowserSignatureCheck" Module="Core" Type="1">U2Vzc2lvbiBTZWN1cml0eSBDaGVjayBiYXNlZCBvbiBCcm93c2VyIFNpZ25hdHVyZQ==</PHRASE>
<PHRASE Label="la_config_SessionCookieDomains" Module="Core" Type="1">U2Vzc2lvbiBDb29raWUgRG9tYWlucyAoc2luZ2xlIGRvbWFpbiBwZXIgbGluZSk=</PHRASE>
<PHRASE Label="la_config_SessionIPAddressCheck" Module="Core" Type="1">U2Vzc2lvbiBTZWN1cml0eSBDaGVjayBiYXNlZCBvbiBJUA==</PHRASE>
+ <PHRASE Label="la_config_SessionLogRotationInterval" Module="Core" Type="1">S2VlcCAiU2Vzc2lvbiBMb2ciIGZvcg==</PHRASE>
<PHRASE Label="la_config_SiteNameSubTitle" Module="Core" Type="1">V2Vic2l0ZSBTdWJ0aXRsZQ==</PHRASE>
<PHRASE Label="la_config_site_zone" Module="Core" Type="1">VGltZSB6b25lIG9mIHRoZSBzaXRl</PHRASE>
<PHRASE Label="la_config_SoftMaintenanceTemplate" Module="Core" Type="1" Hint="VGhpcyB0ZW1wbGF0ZSB3aWxsIGJlIHNob3duIHRvIHRoZSBGcm9udCBFbmQgdXNlcnMgd2hlbiBTb2Z0IE1haW50ZW5hbmNlIG1vZGUgaXMgYWN0aXZlLg==">VGVtcGxhdGUgZm9yIFNvZnQgTWFpbnRlbmFuY2U=</PHRASE>
@@ -923,6 +924,7 @@
<PHRASE Label="la_opt_Failed" Module="Core" Type="1">RmFpbGVk</PHRASE>
<PHRASE Label="la_opt_February" Module="Core" Type="1">RmVicnVhcnk=</PHRASE>
<PHRASE Label="la_opt_FirstName" Module="Core" Type="1">Rmlyc3QgTmFtZQ==</PHRASE>
+ <PHRASE Label="la_opt_FiveYears" Module="Core" Type="1">NSB5ZWFycw==</PHRASE>
<PHRASE Label="la_opt_Friday" Module="Core" Type="1">RnJpZGF5</PHRASE>
<PHRASE Label="la_opt_Group" Module="Core" Type="1">R3JvdXA=</PHRASE>
<PHRASE Label="la_opt_GuestsOnly" Module="Core" Type="1">R3Vlc3RzIE9ubHk=</PHRASE>
@@ -994,10 +996,12 @@
<PHRASE Label="la_opt_Tab" Module="Core" Type="1">VGFi</PHRASE>
<PHRASE Label="la_opt_Template" Module="Core" Type="1">VGVtcGxhdGU=</PHRASE>
<PHRASE Label="la_opt_ThreeMonths" Module="Core" Type="1">MyBtb250aHM=</PHRASE>
+ <PHRASE Label="la_opt_ThreeYears" Module="Core" Type="1">MyB5ZWFycw==</PHRASE>
<PHRASE Label="la_opt_Thursday" Module="Core" Type="1">VGh1cnNkYXk=</PHRASE>
<PHRASE Label="la_opt_Title" Module="Core" Type="1">VGl0bGU=</PHRASE>
<PHRASE Label="la_opt_Tuesday" Module="Core" Type="1">VHVlc2RheQ==</PHRASE>
<PHRASE Label="la_opt_TwoWeeks" Module="Core" Type="1">MiB3ZWVrcw==</PHRASE>
+ <PHRASE Label="la_opt_TwoYears" Module="Core" Type="1">MiB5ZWFycw==</PHRASE>
<PHRASE Label="la_opt_User" Module="Core" Type="1">VXNlcg==</PHRASE>
<PHRASE Label="la_opt_UserEmailActivation" Module="Core" Type="1">RW1haWwgQWN0aXZhdGlvbg==</PHRASE>
<PHRASE Label="la_opt_UserInstantRegistration" Module="Core" Type="1">SW1tZWRpYXRlIA==</PHRASE>
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 @@
+<?php
+/**
+ * Temp tables helper
+ *
+ * @version $Id$
+ * @package In-Portal
+ * @copyright Copyright (C) 1997 - 2015 Intechnic. All rights reserved.
+ * @license GNU/GPL
+ * In-Portal is Open Source software.
+ * This means that this software may have been modified pursuant
+ * the GNU General Public License, and as distributed it includes
+ * or is derivative of works licensed under the GNU General Public License
+ * or other free or open source software licenses.
+ * See http://www.in-portal.org/license for copyright notices and details.
+ */
+
+defined('FULL_PATH') or die('restricted access!');
+
+class TempTablesHelper extends kHelper
+{
+
+ /**
+ * 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: 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,62 @@
}
}
- }
\ 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 ) {
+ 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);
+ }
+
+ $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
+);

Event Timeline