From: Roland Haeder Date: Sat, 2 Apr 2016 10:52:07 +0000 (+0200) Subject: Introduceed new extension ext-server_name which has been extracted from X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f40ee6b3fe47308625f3490dedb1c52174ddf9f1;p=mailer.git Introduceed new extension ext-server_name which has been extracted from ext-sql_patches. So now you can decided to have this feature or not. Signed-off-by: Roland Häder --- diff --git a/inc/extensions/ext-server_name.php b/inc/extensions/ext-server_name.php new file mode 100644 index 0000000000..aec4dd26da --- /dev/null +++ b/inc/extensions/ext-server_name.php @@ -0,0 +1,100 @@ + diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index 0a8bbe524a..767ec32932 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('1.0.2'); +setThisExtensionVersion('1.0.3'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4', '0.8.5', '0.8.6', '0.8.7', '0.8.8', '0.8.9', '0.9.0', '0.9.1', '0.9.2', '0.9.3', '0.9.4', '0.9.5', '0.9.6', '0.9.7', '0.9.8', '0.9.9', '1.0.0', '1.0.1', '1.0.2')); +setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6', '0.5.7', '0.5.8', '0.5.9', '0.6.0', '0.6.1', '0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9', '0.7.0', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9', '0.8.0', '0.8.1', '0.8.2', '0.8.3', '0.8.4', '0.8.5', '0.8.6', '0.8.7', '0.8.8', '0.8.9', '0.9.0', '0.9.1', '0.9.2', '0.9.3', '0.9.4', '0.9.5', '0.9.6', '0.9.7', '0.9.8', '0.9.9', '1.0.0', '1.0.1', '1.0.2', '1.0.3')); // Keep this extension always active! setExtensionAlwaysActive('Y'); diff --git a/inc/extensions/server_name/.htaccess b/inc/extensions/server_name/.htaccess new file mode 100644 index 0000000000..3a42882788 --- /dev/null +++ b/inc/extensions/server_name/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/extensions/server_name/mode-remove.php b/inc/extensions/server_name/mode-remove.php new file mode 100644 index 0000000000..80883a55e9 --- /dev/null +++ b/inc/extensions/server_name/mode-remove.php @@ -0,0 +1,55 @@ + diff --git a/inc/extensions/server_name/mode-setup.php b/inc/extensions/server_name/mode-setup.php new file mode 100644 index 0000000000..e35e77ed8b --- /dev/null +++ b/inc/extensions/server_name/mode-setup.php @@ -0,0 +1,67 @@ + diff --git a/inc/extensions/sql_patches/mode-remove.php b/inc/extensions/sql_patches/mode-remove.php index 6817daa4ba..6920fe5a8e 100644 --- a/inc/extensions/sql_patches/mode-remove.php +++ b/inc/extensions/sql_patches/mode-remove.php @@ -40,7 +40,6 @@ addDropTableSql('admin_menu_las'); addDropTableSql('admin_menu_las_data'); addDropTableSql('admin_las_stats'); addDropTableSql('dns_cache'); -addDropTableSql('server_name_log'); // Delete admin menu entries addExtensionSql("DELETE LOW_PRIORITY FROM @@ -84,7 +83,6 @@ unregisterExtensionPointsData('admin_add_all'); unregisterFilter(__FILE__, __LINE__, 'member_login_check', 'RESET_USER_LOGIN_FAILURE', TRUE, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'add_history_entry', 'ADD_HISTORY_ENTRY', TRUE, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'init', 'GENERATE_FILE_SECRET_HASH', TRUE, isExtensionDryRun()); -unregisterFilter(__FILE__, __LINE__, 'extra_autopurge', 'SERVER_NAME_EXTRA_AUTOPURGE', TRUE, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'determine_menu_mode', 'DETERMINE_MENU_MODE_GENERIC', TRUE, isExtensionDryRun()); unregisterFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXCLUDE_DEFAULT_REFID', TRUE, isExtensionDryRun()); diff --git a/inc/extensions/sql_patches/mode-update.php b/inc/extensions/sql_patches/mode-update.php index 12f05d7202..afe6ec9a6d 100644 --- a/inc/extensions/sql_patches/mode-update.php +++ b/inc/extensions/sql_patches/mode-update.php @@ -834,44 +834,10 @@ INDEX (`history_last_used` DESC)", break; case '0.9.1': // SQL queries for v0.9.1 - // Add admin menu - addAdminMenuSql('misc', 'list_server_name', 'Verkehrte Domains auflisten', 'Listet alle als verkehrt erkannten Domains auf.', 4); - - // Create table - addCreateTableSql('server_name_log', " -`server_name_id` BIGINT (20) NOT NULL AUTO_INCREMENT, -`server_name` VARCHAR (255) NOT NULL DEFAULT 'invalid', -`server_name_remote_addr` VARCHAR (15) NOT NULL DEFAULT '0.0.0.0', -`server_name_ua` TINYTEXT NULL DEFAULT NULL, -`server_name_referrer` TINYTEXT NULL DEFAULT NULL, -`server_name_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -`server_name_counter` BIGINT (20) NOT NULL DEFAULT 1, -PRIMARY KEY (`server_name_id`) -", 'Logging of wrong SERVER_NAME'); - - // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Loggen von falschen SERVER_NAME Einträgen hinzugefügt."); - break; - case '0.9.2': // SQL queries for v0.9.2 - addExtensionAddTableColumnSql('server_name_log', 'server_name_remote_addr', "VARCHAR (15) NOT NULL DEFAULT '0.0.0.0'"); - addExtensionAddTableColumnSql('server_name_log', 'server_name_counter', 'BIGINT (20) NOT NULL DEFAULT 0'); - addExtensionAddTableColumnSql('server_name_log', 'server_name_ua', 'TINYTEXT NULL DEFAULT NULL'); - addExtensionAddTableColumnSql('server_name_log', 'server_name_referrer', 'TINYTEXT NULL DEFAULT NULL'); - - // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Sorry, hatte noch IP-Nummer, User-Agent, aufrufende Seite und Zähler vergessen."); - break; - case '0.9.3': // SQL queries for v0.9.3 - addConfigAddSql('ap_server_name', "ENUM('Y','N') NOT NULL DEFAULT 'Y'"); - addConfigAddSql('ap_server_name_since', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 7)); - - // Register filter - registerFilter(__FILE__, __LINE__, 'extra_autopurge', 'SERVER_NAME_EXTRA_AUTOPURGE', FALSE, TRUE, isExtensionDryRun()); - // Update notes (these will be set as task text!) - setExtensionUpdateNotes("Bereinigung von verkehrten SERVER_NAME Einträgen hinzugefügt."); + setExtensionUpdateNotes("Dieses Update wurde nach ext-server_name verschoben."); break; case '0.9.4': // SQL queries for v0.9.4 @@ -951,6 +917,16 @@ PRIMARY KEY (`server_name_id`) setExtensionUpdateNotes("registerExtensionPointsData() klappt bei der ersten Installation nicht, da die Spalte account_provider fehlt."); break; + case '1.0.3': // SQL queries for v1.0.3 + // Remove admin menu + addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='list_server_name' LIMIT 1"); + + // Unregister filter (moved to ext-server_name) + unregisterFilter(__FILE__, __LINE__, 'extra_autopurge', 'SERVER_NAME_EXTRA_AUTOPURGE', TRUE, isExtensionDryRun()); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Dieses Feature wurde nach ext-server_name verschoben, damit dies klappt, muss zuvor der Filter manuell aus der Datenbank gelöscht werden, da sonst ein Auto-Unregister erfolgt, was auskommentiert ist. Dies gilt nur für bestehende Installationen, nicht neue."); + break; } // END - switch // [EOF] diff --git a/inc/filter/server_name_filter.php b/inc/filter/server_name_filter.php new file mode 100644 index 0000000000..882784c51c --- /dev/null +++ b/inc/filter/server_name_filter.php @@ -0,0 +1,84 @@ + 0)) { + // Then start purging + sqlQuery('DELETE LOW_PRIORITY FROM + `{?_MYSQL_PREFIX?}_server_name_log` +WHERE + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`server_name_added`)) >= {?ap_server_name_since?}', + __FILE__, __LINE__); + + // Are some entries deleted? + if (sqlAffectedRows() > 0) { + // Okay, then send an email to the admin + sendAdminNotification('{--ADMIN_PURGE_SERVER_NAME_LOG_SUBJECT--}', 'admin_purge_user_server_name_log', sqlAffectedRows()); + } // END - if + } // END - if + + // Return filter data + return $filterData; +} + +// [EOF] +?> diff --git a/inc/filters.php b/inc/filters.php index cff23e8a9f..82fb319679 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -1387,24 +1387,6 @@ function FILTER_HANDLE_REFERRER_BANNER_VIEW ($filterData) { redirectToUrl('modules.php?module=index'); } -// Filter for redirecting on wrong server name (e.g. bad.your-server.tld will be redirected to your-server.tld) -function FILTER_REDIRECT_WRONG_SERVER_NAME ($filterData) { - // Get URL - $url = getUrl(); - - // Is the configured URL same as SERVER_NAME? - if (extractHostnameFromUrl($url) != detectServerName()) { - // Log all attempts - logWrongServerNameRedirect(); - - // Then redirect to configured URL - redirectToRequestUri(); - } // END - if - - // Return filter data - return $filterData; -} - // Filter for adding hidden session id function FILTER_ADD_INPUT_HIDDEN_SESSION_ID ($filterData) { // Is a spider detected? @@ -1417,28 +1399,6 @@ function FILTER_ADD_INPUT_HIDDEN_SESSION_ID ($filterData) { return $filterData; } -// Filter for purging old SERVER_NAME entries -function FILTER_SERVER_NAME_EXTRA_AUTOPURGE ($filterData) { - // Is purging configured? - if ((isApServerNameEnabled()) && (getApServerNameSince() > 0)) { - // Then start purging - sqlQuery('DELETE LOW_PRIORITY FROM - `{?_MYSQL_PREFIX?}_server_name_log` -WHERE - (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`server_name_added`)) >= {?ap_server_name_since?}', - __FILE__, __LINE__); - - // Are some entries deleted? - if (sqlAffectedRows() > 0) { - // Okay, then send an email to the admin - sendAdminNotification('{--ADMIN_PURGE_SERVER_NAME_LOG_SUBJECT--}', 'admin_purge_user_server_name_log', sqlAffectedRows()); - } // END - if - } // END - if - - // Return filter data - return $filterData; -} - // Filter for detecting menu mode function FILTER_DETERMINE_MENU_MODE_GENERIC ($filterData) { // "Detect" it diff --git a/inc/http-functions.php b/inc/http-functions.php index e82ca2ce19..cf921efc6b 100644 --- a/inc/http-functions.php +++ b/inc/http-functions.php @@ -906,7 +906,7 @@ function getContentType () { // Logs wrong SERVER_NAME attempts function logWrongServerNameRedirect () { // Is ext-sql_patches at least version 0.9.2? - if (isExtensionInstalledAndNewer('sql_patches', '0.9.2')) { + if (isExtensionInstalled('server_name')) { // Is there an entry? if (countSumTotalData(detectServerName(), 'server_name_log', 'server_name_id', 'server_name', TRUE, str_replace('%', '{PER}', sprintf(" AND `server_name_remote_addr`='%s' AND `server_name_ua`='%s' AND `server_name_referrer`='%s'", sqlEscapeString(detectRemoteAddr(TRUE)), sqlEscapeString(detectUserAgent(TRUE)), sqlEscapeString(detectReferer(TRUE))))) == 1) { // Update counter, as all are the same diff --git a/inc/language/de.php b/inc/language/de.php index 9a390d45d1..47bc860585 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -1379,23 +1379,6 @@ addMessages(array( 'ADMIN_ACTION_DELETE_HISTORY_SUBMIT' => "Alle Historie-Einträge löschen", 'ADMIN_LIST_HISTORY_NOTICE' => "Vorsicht: Mit Klick auf {--ADMIN_ACTION_DELETE_HISTORY_SUBMIT--} werden die Historie-Einträge sofort bereinigt, ohne zusätzliche Sicherheitsabfrage.", - // Admin - server_name_log - generic - 'ADMIN_LIST_SERVER_NAME_LOG_TITLE' => "Auflisten aller geloggten SERVER_NAME-Einträge", - 'ADMIN_LIST_SERVER_NAME_LOG_404' => "Es wurden keine SERVER_NAME-Einträge gefunden.", - 'ADMIN_ACTION_DELETE_LOG_SUBMIT' => "Gesamtes Logbuch löschen", - 'ADMIN_LIST_LOG_NOTICE' => "Vorsicht: Mit Klick auf {--ADMIN_ACTION_DELETE_LOG_SUBMIT--} wird das gesamte Logbuch sofort bereinigt, ohne zusätzliche Sicherheitsabfrage.", - 'ADMIN_TASK_LIST_SERVER_NAME_LOG' => "Logbuch für SERVER_NAME-Einträge", - 'ADMIN_TASK_LIST_SERVER_NAME_LOG_TITLE' => "Es sind geloggte SERVER_NAME-Logbucheinträge vorhanden.", - 'ADMIN_SERVER_NAME' => "Host-Kopfzeile", - - // Admin - server_name_log - config - 'ADMIN_CONFIG_AUTOPURGE_SERVER_NAME_LOG_LEGEND' => "Bereinigung von SERVER_NAME-Einträgen", - 'ADMIN_CONFIG_AUTOPURGE_SERVER_NAME_LOG' => "Sollen verkehrte SERVER_NAME-Einträge bereinigt werden?", - 'ADMIN_CONFIG_AUTOPURGE_SERVER_NAME_LOG_TIME' => "Dauer bis SERVER_NAME-Einträge gelöscht werden:", - - // Admin - server_name_log - subject lines - 'ADMIN_PURGE_SERVER_NAME_LOG_SUBJECT' => "Es wurden verkehrte SERVER_NAME-Einträge bereinigt", - // Admin - user's points amount 'ADMIN_LIST_USER_AMOUNTS_TITLE' => "Verteilung des {?POINTS?}-Gesamtvolumens", 'ADMIN_TOTAL_POINTS' => "Gesamtguthaben", diff --git a/inc/language/server_name_de.php b/inc/language/server_name_de.php new file mode 100644 index 0000000000..8eb2f9bd5b --- /dev/null +++ b/inc/language/server_name_de.php @@ -0,0 +1,65 @@ + "Auflisten aller geloggten SERVER_NAME-Einträge", + 'ADMIN_LIST_SERVER_NAME_LOG_404' => "Es wurden keine SERVER_NAME-Einträge gefunden.", + 'ADMIN_ACTION_DELETE_LOG_SUBMIT' => "Gesamtes Logbuch löschen", + 'ADMIN_LIST_LOG_NOTICE' => "Vorsicht: Mit Klick auf {--ADMIN_ACTION_DELETE_LOG_SUBMIT--} wird das gesamte Logbuch sofort bereinigt, ohne zusätzliche Sicherheitsabfrage.", + 'ADMIN_TASK_LIST_SERVER_NAME_LOG' => "Logbuch für SERVER_NAME-Einträge", + 'ADMIN_TASK_LIST_SERVER_NAME_LOG_TITLE' => "Es sind geloggte SERVER_NAME-Logbucheinträge vorhanden.", + 'ADMIN_SERVER_NAME' => "Host-Kopfzeile", + + // Admin - server_name_log - config + 'ADMIN_CONFIG_AUTOPURGE_SERVER_NAME_LOG_LEGEND' => "Bereinigung von SERVER_NAME-Einträgen", + 'ADMIN_CONFIG_AUTOPURGE_SERVER_NAME_LOG' => "Sollen verkehrte SERVER_NAME-Einträge bereinigt werden?", + 'ADMIN_CONFIG_AUTOPURGE_SERVER_NAME_LOG_TIME' => "Dauer bis SERVER_NAME-Einträge gelöscht werden:", + + // Admin - server_name_log - subject lines + 'ADMIN_PURGE_SERVER_NAME_LOG_SUBJECT' => "Es wurden verkehrte SERVER_NAME-Einträge bereinigt", +)); + +// [EOF] +?> diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index 95be2052d6..9142672cab 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -516,7 +516,7 @@ ORDER BY $TITLEs[] = '{--ADMIN_TASK_LIST_SURFBAR_URLS_PENDING_TITLE--}'; } // END - if - if (isExtensionInstalledAndNewer('sql_patches', '0.9.2')) { + if (isExtensionInstalled('server_name')) { // Check for wrong "SERVER_NAME" entries addSql('SELECT `server_name_id` FROM `{?_MYSQL_PREFIX?}_server_name_log`'); $DESCRs[] = '{--ADMIN_TASK_LIST_SERVER_NAME_LOG--}'; diff --git a/templates/de/html/admin/admin_config_server_name.tpl b/templates/de/html/admin/admin_config_server_name.tpl new file mode 100644 index 0000000000..4f4b21b539 --- /dev/null +++ b/templates/de/html/admin/admin_config_server_name.tpl @@ -0,0 +1,30 @@ +
+{%form,formMethodPost=modules.php?module=admin&what=config_autopurge%} +
+
+ {--ADMIN_CONFIG_SERVER_NAME_TITLE--} +
+ +
+ {--ADMIN_CONFIG_AUTOPURGE_SERVER_NAME_LOG_LEGEND--} + +
+ +
{%template,ConfigurationYesNoSelectionBox=ap_server_name%}
+
+ +
+ +
+ +
$content[ap_server_name_since]
+
+
+ + +
+{%form_close%} +
diff --git a/templates/de/html/ext/ext_server_name.tpl b/templates/de/html/ext/ext_server_name.tpl new file mode 100644 index 0000000000..993e4b5e0b --- /dev/null +++ b/templates/de/html/ext/ext_server_name.tpl @@ -0,0 +1,13 @@ +
+ Ung&uum;ltige Hostnamen können entstehen, wenn der Hoster + "Wildcat-Domains" aktiv hat. Damit sind beliebige Subdomains + möglich, die dann auf die Hauptdomain weiterleiten, da sie nicht mit + den im Server konfigurierten "virtuellen Hosteinträgen" + übereinstimmen. +
+ +
+ Ist diese Erweiterung installiert, wird immer auf die konfigurierte URL + weitergeleitet und ungültige Einträge gesammelt und im + Adminbereich angezeigt. +