From: Roland Häder Date: Mon, 16 Nov 2009 06:17:11 +0000 (+0000) Subject: Login procedure rewritten to filters (internal TODO) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7cb246c51e8634735aaf24e546bcbc46c5ce3833;p=mailer.git Login procedure rewritten to filters (internal TODO) --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 102b463296..6a4e3d4e7c 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -10,32 +10,32 @@ ./inc/extensions/ext-newsletter.php:215: // @TODO Move these into configuration ./inc/extensions/ext-rallye.php:330: // @TODO Move this code into rallye_functions.php ./inc/extensions/ext-rallye.php:93: // @TODO Fix config_rallye_prices to list_rallye_prices -./inc/extensions/ext-sql_patches.php:737: // @TODO Rewrite this to a filter +./inc/extensions/ext-sql_patches.php:762: // @TODO Rewrite this to a filter ./inc/extensions/ext-sql_patches.php:94: /* @TODO SQL_ALTER_TABLE() should work now properly ./inc/extensions/ext-yoomedia.php:122: // @TODO Can this be moved into a database table? ./inc/extensions/ext-yoomedia.php:55:// @TODO Only deprecated when 'network' is ready! setExtensionDeprecated('Y'); ./inc/extensions-functions.php:376:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) ./inc/extensions-functions.php:489: // @TODO Extension is loaded, what next? -./inc/functions.php:1016:// @TODO $simple is deprecated -./inc/functions.php:1051: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates -./inc/functions.php:2351:// @TODO Try to move this to inc/libs/theme_functions.php +./inc/functions.php:1025:// @TODO $simple is deprecated +./inc/functions.php:1060: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates ./inc/functions.php:241: // @TODO Remove this sanity-check if all is fine ./inc/functions.php:244: // @TODO Try to rewrite all $DATA to $content -./inc/functions.php:2522:// @TODO Please describe this function -./inc/functions.php:2540: searchDirsRecursive($next_dir, $last_changed); // @TODO small change to API to $last_changed = searchDirsRecursive($next_dir, $time); -./inc/functions.php:2636: // @TODO Add a little more infos here -./inc/functions.php:2647: // @TODO This cannot be rewritten to app_die(), try to find a solution for this. -./inc/functions.php:2728: // @TODO Rewrite this old lost code to a template -./inc/functions.php:2817: // @TODO Are these convertions still required? -./inc/functions.php:2835:// @TODO Rewrite this function to use readFromFile() and writeToFile() -./inc/functions.php:3709:// @TODO Lame description for this function -./inc/functions.php:3731: // @TODO Move this in a filter -./inc/functions.php:467: // @TODO Do only use $contentn, not $DATA or raw variables -./inc/functions.php:537: // @TODO Extension 'msg' does not exist -./inc/functions.php:606:// @TODO Rewrite this to an extension 'smtp' +./inc/functions.php:2458:// @TODO Please describe this function +./inc/functions.php:2476: searchDirsRecursive($next_dir, $last_changed); // @TODO small change to API to $last_changed = searchDirsRecursive($next_dir, $time); +./inc/functions.php:2572: // @TODO Add a little more infos here +./inc/functions.php:2583: // @TODO This cannot be rewritten to app_die(), try to find a solution for this. +./inc/functions.php:2664: // @TODO Rewrite this old lost code to a template +./inc/functions.php:2753: // @TODO Are these convertions still required? +./inc/functions.php:2771:// @TODO Rewrite this function to use readFromFile() and writeToFile() +./inc/functions.php:3645:// @TODO Lame description for this function +./inc/functions.php:3667: // @TODO Move this in a filter +./inc/functions.php:3785: // @TODO This is still very static, rewrite it somehow +./inc/functions.php:476: // @TODO Do only use $contentn, not $DATA or raw variables +./inc/functions.php:546: // @TODO Extension 'msg' does not exist +./inc/functions.php:615:// @TODO Rewrite this to an extension 'smtp' ./inc/install-functions.php:62: // @TODO DEACTIVATED: changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0); -./inc/language/de.php:1145:// @TODO Rewrite these two constants -./inc/language/de.php:1161:// @TODO Rewrite these five constants +./inc/language/de.php:1146:// @TODO Rewrite these two constants +./inc/language/de.php:1162:// @TODO Rewrite these five constants ./inc/language/de.php:848:// @TODO Are these constants longer used? ./inc/language-functions.php:45:// @TODO Rewrite all language constants to this function. ./inc/language/holiday_de.php:49:// @TODO Rewrite these two constants to one @@ -46,12 +46,13 @@ ./inc/libs/admins_functions.php:418: // @TODO This can be, somehow, rewritten ./inc/libs/beg_functions.php:57: // @TODO Try to rewrite the following unset() ./inc/libs/bonus_functions.php:215: // @TODO Try to find a way for rewriting this constant +./inc/libs/bonus_functions.php:303: // @TODO This query isn't right, it will only update if the user was for a longer time away! ./inc/libs/doubler_functions.php:45:// @TODO Lame description ./inc/libs/rallye_functions.php:718: $EXPIRE = 3; // @TODO The hard-coded value... ./inc/libs/rallye_functions.php:782: // @TODO Rewrite this to our API function ./inc/libs/refback_functions.php:60: // @TODO Try to rewrite the following unset() -./inc/libs/surfbar_functions.php:1497: // @TODO This can be somehow rewritten -./inc/libs/surfbar_functions.php:950: // @TODO Invalid salt should be refused +./inc/libs/surfbar_functions.php:1491: // @TODO This can be somehow rewritten +./inc/libs/surfbar_functions.php:944: // @TODO Invalid salt should be refused ./inc/libs/task_functions.php:244: // @TODO These can be rewritten to filter ./inc/libs/task_functions.php:52:// @TODO Move all extension-dependent queries into filters ./inc/libs/user_functions.php:137: // @TODO These two constants are no longer used, maybe we reactivate this code? @@ -87,7 +88,6 @@ ./inc/modules/admin/what-config_rallye_prices.php:225: // @TODO Rewrite these two constants ./inc/modules/admin/what-config_register.php:67: // @TODO Move this HTML code into a template ./inc/modules/admin/what-edit_user.php:20: * @TODO Add support for ext-country * -./inc/modules/admin/what-email_archiv.php:91: // @TODO Rewrite to SQL_FETCHARRAY() ./inc/modules/admin/what-email_stats.php:47:// @TODO Unused at the moment ./inc/modules/admin/what-extensions.php:344: // @TODO Rewrite this to a filter ./inc/modules/admin/what-guest_add.php:136: // @TODO This can be somehow rewritten to a function @@ -148,7 +148,7 @@ ./inc/modules/member/what-payout.php:240: // @TODO Rewrite this to a filter ./inc/modules/member/what-points.php:54:// @TODO Should we rewrite this to a filter? ./inc/modules/member/what-rallyes.php:89: // @TODO Reactivate this: $content['admin'] = "".$content['login'].""; -./inc/modules/member/what-reflinks.php:59:// @TODO Move this into a filter +./inc/modules/member/what-reflinks.php:60:// @TODO Move this into a filter ./inc/modules/member/what-stats.php:118: // @TODO Rewrite in template: clix->clicks ./inc/modules/member/what-transfer.php:141: // @TODO Rewrite this to a filter ./inc/modules/member/what-transfer.php:231: // @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries @@ -158,13 +158,13 @@ ./inc/modules/member/what-unconfirmed.php:144: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() ./inc/modules/order.php:75: // @TODO Unused: 2,4 ./inc/monthly/monthly_bonus.php:68: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1564: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1788: // @TODO Rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:2110: // @TODO This can be somehow rewritten -./inc/mysql-manager.php:2133:// @TODO Fix inconsistency between last_module and getWhat() -./inc/mysql-manager.php:220: // @TODO Nothing helped??? -./inc/mysql-manager.php:255: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:576: // @TODO Try to rewrite this to one or more functions +./inc/mysql-manager.php:1545: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1769: // @TODO Rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:2091: // @TODO This can be somehow rewritten +./inc/mysql-manager.php:2114:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:224: // @TODO Nothing helped??? +./inc/mysql-manager.php:259: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:552: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:93:// @TODO Can we cache this? ./inc/reset/reset_beg.php:50:// @TODO This should be converted in a daily beg rallye ./inc/reset/reset_birthday.php:92: // @TODO 4 is hard-coded here, should we move it out in config? @@ -198,7 +198,7 @@ ./templates/de/html/guest/guest_login.tpl:21: @TODO Deactivated feature, try to implement it or remove it. ./templates/de/html/guest/guest_nickname_login.tpl:21: @TODO Deactivated feature, try to find a solution for this or remove it. ./templates/de/html/guest/guest_stats_member.tpl:23: @TODO We have to fix these counters. -./templates/de/html/surfbar/surfbar_frame_top.tpl:23:// @TODO Try to rewrite this JavaScript to js.php?js=surfbar_frame_top2 (wouldn't be easy) +./templates/de/html/surfbar/surfbar_frame_top.tpl:23:// @TODO Try to rewrite this JavaScript to js.php?js=surfbar_frame_top (wouldn't be easy) ### ### DEPRECATION FOLLOWS: ### ### ./inc/modules/admin/admin-inc.php:532:// @DEPRECATED ### ### template-warnings.log follows: ### ### diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index 49484c8512..ef0873492b 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -42,10 +42,10 @@ if (!defined('__SECURITY')) { } // END - if // Version of this extension -setThisExtensionVersion('0.8.9'); +setThisExtensionVersion('0.9.0'); // Version history array (add more with , '0.1.0' and so on) -setExtensionVersionHistory(array('0.0', '0.1.6', '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')); +setExtensionVersionHistory(array('0.0', '0.1.6', '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')); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running (modules.php?module=admin is called) @@ -87,6 +87,9 @@ PRIMARY KEY (`id`) addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bonus_urls`"); addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bonus_customer`"); addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_bonus_turbo`"); + + // Unregister filter + unregisterFilter('member_login_check', 'ADD_LOGIN_BONUS', true, getExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -538,6 +541,14 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC"); // Update notes setExtensionUpdateNotes("Benachrichtigungsmails für z.B. Bettel- oder Aktiv-Rallye werden nun angezeigt."); break; + + case '0.9.0': // SQL queries for v0.9.0 + // Register filter + registerFilter('member_login_check', 'ADD_LOGIN_BONUS', false, true, getExtensionDryRun()); + + // Update notes + setExtensionUpdateNotes("Filter hinzugefügt der den Login-Bonus aktualisiert (bzw. soll) (internes TODO)."); + break; } break; diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index 6171a37c42..b9e699e5c3 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -42,10 +42,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.6.8'); +setThisExtensionVersion('0.6.9'); // Version history array (add more with , '0.1.0' and so on) -setExtensionVersionHistory(array('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.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8')); +setExtensionVersionHistory(array('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.4', '0.6.5', '0.6.6', '0.6.7', '0.6.8', '0.6.9')); // Keep this extension always active! setExtensionAlwaysActive('Y'); @@ -119,6 +119,9 @@ switch (getExtensionMode()) { addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_cats` DROP INDEX `visible`"); addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_cats` DROP INDEX `sort`"); */ + + // Unregister filter + unregisterFilter('member_login_check', 'RESET_USER_LOGIN_FAILURE', true, getExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -729,6 +732,14 @@ CHANGE `what` `what` VARCHAR(50) NULL DEFAULT NULL'); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Spalten verkürzt, damit die Schlüssel passen."); break; + + case '0.6.9': // SQL queries for 0.6.9 + // Register filter + registerFilter('member_login_check', 'RESET_USER_LOGIN_FAILURE', false, true, getExtensionDryRun()); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Filter zum Zurücksetzens des fehlgeschlagenen Mitgliederlogins hinzugefügt (internes TODO)."); + break; } // END - switch break; diff --git a/inc/extensions/ext-theme.php b/inc/extensions/ext-theme.php index c6a2e3b7fa..2bd7f8182d 100644 --- a/inc/extensions/ext-theme.php +++ b/inc/extensions/ext-theme.php @@ -42,10 +42,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.1.0'); +setThisExtensionVersion('0.1.1'); // Version history array (add more with , '0.1.0' and so on) -setExtensionVersionHistory(array('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')); +setExtensionVersionHistory(array('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')); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running (modules.php?module=admin is called) @@ -65,8 +65,9 @@ switch (getExtensionMode()) { // Delete member menu entries addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='themes' OR `what`='themes'"); - // Unregister filter + // Unregister filters unregisterFilter('init', 'HANDLE_THEME_CHANGE', true, getExtensionDryRun()); + unregisterFilter('member_login_check', 'SET_USERS_THEME', true, getExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension @@ -167,6 +168,14 @@ INDEX (`theme_active`) // Update notes (these will be set as task text!) setExtensionUpdateNotes("Ändern des Designs nun im Filter (internes TODO)."); break; + + case '0.1.1': // SQL queries for v0.1.1 + // Register filter + registerFilter('member_login_check', 'SET_USERS_THEME', false, true, getExtensionDryRun()); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Setzen des Mitgliedes' eigener Design-Auswahl per Filter (internes TODO)."); + break; } // END - switch break; @@ -184,5 +193,5 @@ INDEX (`theme_active`) break; } // END - switch -// +// [EOF] ?> diff --git a/inc/filter-functions.php b/inc/filter-functions.php index e2cf53dd84..4c3cae095d 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -184,6 +184,9 @@ ORDER BY registerFilter('page_footer', 'HANDLE_FATAL_ERRORS'); registerFilter('page_footer', 'DISPLAY_COPYRIGHT'); registerFilter('page_footer', 'DISPLAY_PARSING_TIME'); + + // Member login check. Always keep FETCH_USER_DATA as first entry! + registerFilter('member_login_check', 'FETCH_USER_DATA'); } // "Registers" a new filter function diff --git a/inc/filters.php b/inc/filters.php index 8970f8ea32..7b6891497d 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -863,5 +863,47 @@ function FILTER_FLUSH_TEMPLATE_CACHE () { } // END - if } +// Filter for loading user data +function FILTER_FETCH_USER_DATA ($userid = 0) { + // Is the userid not set? Then use member id + if (($userid == '0') || (is_null($userid))) $userid = getMemberId(); + + // Get user data + if (!fetchUserData($userid)) { + // Userid is not valid + debug_report_bug('User id '.$userid . ' is invalid.'); + } // END - if + + // Set member id + setMemberId($userid); +} + +// Filter for reseting users' last login failure, only available with latest ext-sql_patches +function FILTER_RESET_USER_LOGIN_FAILURE () { + // Is the user data valid? + if (!isMember()) { + // Do only run for logged in members + debug_report_bug('Please only run this filter for logged in users.'); + } // END - if + + // Remmeber login failures if available + if (isExtensionInstalledAndNewer('sql_patches') >= '0.6.1') { + // Reset login failures + SQL_QUERY_ESC("UPDATE + `{?_MYSQL_PREFIX?}_user_data` +SET + `login_failures`=0, + `last_failure`='0000-00-00 00:00:00' +WHERE + `userid`=%s +LIMIT 1", + array(getMemberId()), __FILE__, __LINE__); + + // Store it in session + setSession('mxchange_member_failures' , getUserData('login_failures')); + setSession('mxchange_member_last_fail', getUserData('last_failure')); + } // END - if +} + // [EOF] ?> diff --git a/inc/functions.php b/inc/functions.php index a31c402069..77065f95dc 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2311,89 +2311,16 @@ function getCurrentTheme () { // The default theme is 'default'... ;-) $ret = 'default'; - // Load default theme if not empty from configuration - if ((isConfigEntrySet('default_theme')) && (getConfig('default_theme') != '')) $ret = getConfig('default_theme'); - - if (!isSessionVariableSet('mxchange_theme')) { - // Set default theme - setTheme($ret); - } elseif ((isSessionVariableSet('mxchange_theme')) && (isExtensionInstalledAndNewer('sql_patches', '0.1.4'))) { - //die("
".print_r($GLOBALS['cache_array']['themes'], true)."
"); - // Get theme from cookie - $ret = getSession('mxchange_theme'); - - // Is it valid? - if (getThemeId($ret) == '0') { - // Fix it to default - $ret = 'default'; - } // END - if - } elseif ((!isInstalled()) && ((isInstalling()) || (getOutputMode() == true)) && ((isGetRequestElementSet('theme')) || (isPostRequestElementSet('theme')))) { - // Prepare FQFN for checking - $theme = sprintf("%stheme/%s/theme.php", getConfig('PATH'), getRequestElement('theme')); - - // Installation mode active - if ((isGetRequestElementSet('theme')) && (isFileReadable($theme))) { - // Set cookie from URL data - setTheme(getRequestElement('theme')); - } elseif (isFileReadable(sprintf("%stheme/%s/theme.php", getConfig('PATH'), secureString(postRequestElement('theme'))))) { - // Set cookie from posted data - setTheme(secureString(postRequestElement('theme'))); - } - - // Set return value - $ret = getSession('mxchange_theme'); - } else { - // Invalid design, reset cookie - setTheme($ret); - } + // Do we have ext-theme installed and active? + if (isExtensionActive('theme')) { + // Call inner method + $ret = getActualTheme(); + } // END - if // Return theme value return $ret; } -// Setter for theme in session -function setTheme ($newTheme) { - setSession('mxchange_theme', $newTheme); -} - -// Get id from theme -// @TODO Try to move this to inc/libs/theme_functions.php -function getThemeId ($name) { - // Is the extension 'theme' installed? - if (!isExtensionActive('theme')) { - // Then abort here - return 0; - } // END - if - - // Default id - $id = '0'; - - // Is the cache entry there? - if (isset($GLOBALS['cache_array']['themes']['id'][$name])) { - // Get the version from cache - $id = $GLOBALS['cache_array']['themes']['id'][$name]; - - // Count up - incrementStatsEntry('cache_hits'); - } elseif (isExtensionInstalledAndNewer('cache', '0.1.8')) { - // Check if current theme is already imported or not - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' LIMIT 1", - array($name), __FUNCTION__, __LINE__); - - // Entry found? - if (SQL_NUMROWS($result) == 1) { - // Fetch data - list($id) = SQL_FETCHROW($result); - } // END - if - - // Free result - SQL_FREERESULT($result); - } - - // Return id - return $id; -} - // Generates an error code from given account status function generateErrorCodeFromUserStatus ($status='') { // If no status is provided, use the default, cached diff --git a/inc/gen_mediadata.php b/inc/gen_mediadata.php index 2d6a61c32b..02287536bc 100644 --- a/inc/gen_mediadata.php +++ b/inc/gen_mediadata.php @@ -45,8 +45,11 @@ if (!defined('__SECURITY')) { $bsent = '0'; $bclicks = '0'; $bcount = '0'; // Check for normal mails -$result_media = SQL_QUERY('SELECT SUM(max_rec) AS max_rec, SUM(clicks) AS clicks -FROM `{?_MYSQL_PREFIX?}_user_stats`', __FILE__, __LINE__); +$result_media = SQL_QUERY('SELECT + SUM(`max_rec`) AS max_rec, + SUM(`clicks`) AS clicks +FROM + `{?_MYSQL_PREFIX?}_user_stats`', __FILE__, __LINE__); list($nsent, $nclicks) = SQL_FETCHROW($result_media); if (empty($nsent)) $nsent = '0'; if (empty($nclicks)) $nclicks = '0'; @@ -82,17 +85,17 @@ updateMediadataEntry(array('total_clicks', 'bonus_clicks') , 'init', $bclicks); updateMediadataEntry(array('total_orders', 'bonus_orders') , 'init', $bcount); // Aquire total used points -$result = SQL_QUERY('SELECT SUM(used_points) AS used_points FROM `{?_MYSQL_PREFIX?}_user_data`', __FILE__, __LINE__); +$result = SQL_QUERY('SELECT SUM(`used_points`) AS used_points FROM `{?_MYSQL_PREFIX?}_user_data`', __FILE__, __LINE__); list($used) = SQL_FETCHROW($result); SQL_FREERESULT($result); // ... and total points -$result = SQL_QUERY('SELECT SUM(points) AS points FROM `{?_MYSQL_PREFIX?}_user_points`', __FILE__, __LINE__); +$result = SQL_QUERY('SELECT SUM(`points`) AS points FROM `{?_MYSQL_PREFIX?}_user_points`', __FILE__, __LINE__); list($points) = SQL_FETCHROW($result); SQL_FREERESULT($result); // Update database updateMediadataEntry(array('total_points'), 'init', ($points - $used)); -// +// [EOF] ?> diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index 556473257c..af551a1b82 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -284,5 +284,50 @@ function purgeExpiredTurboBonus() { } // END - if } +/////////////////////////////////////////////////////////////////////////////// +// Only filter functions +/////////////////////////////////////////////////////////////////////////////// + +// Filter for adding login bonus to the user's account +function FILTER_ADD_LOGIN_BONUS () { + // Is the user data valid? + if (!isMember()) { + // Do only run for logged in members + debug_report_bug('Please only run this filter for logged in users.'); + } // END - if + + // Bonus is not given by default ;-) + $bonus = false; + if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (getConfig('bonus_active') == 'Y') && (getConfig('bonus_login_yn') == 'Y')) { + // Update last login if far enougth away + // @TODO This query isn't right, it will only update if the user was for a longer time away! + SQL_QUERY_ESC("UPDATE + `{?_MYSQL_PREFIX?}_user_data` +SET + `last_login`=UNIX_TIMESTAMP() +WHERE + `userid`=%s AND + `last_login` < (UNIX_TIMESTAMP() - {?login_timeout?}) +LIMIT 1", + array( + getMemberId() + ), __FILE__, __LINE__ + ); + + // Updated entry? + $bonus = (SQL_AFFECTEDROWS() == 1); + } // END - if + + if (($bonus === true) && (getRequestElement('mode') == 'bonus')) { + // Output message with added points + $GLOBALS['message'] .= "
+ ".sprintf(getMessage('BONUS_LOGIN_BONUS_ADDED'), translateComma(getConfig('login_bonus')))." +
"; + } elseif (isExtensionActive('bonus')) { + // No login bonus added! + $GLOBALS['message'] .= "
{--BONUS_LOGIN_BONUS_NOT_ADDED--}
"; + } +} + // [EOF] ?> diff --git a/inc/libs/theme_functions.php b/inc/libs/theme_functions.php index 70a2199102..ed45abc62e 100644 --- a/inc/libs/theme_functions.php +++ b/inc/libs/theme_functions.php @@ -44,11 +44,8 @@ if (!defined('__SECURITY')) { // Create a selection box with installed and activated themes or all if admin function generateThemeSelectionBox () { // Init variables and fill them if set - $what = ''; + $what = getWhat(); $mod = getModule(); - if (isWhatSet()) { - $what = getWhat(); - } // END - if // Construction URL $formAction = "{?URL?}/modules.php?module=" . $mod; @@ -67,7 +64,13 @@ function generateThemeSelectionBox () { if (isAdmin()) $add = ''; // Select all themes we want - $result = SQL_QUERY("SELECT `theme_path`, `theme_name` FROM `{?_MYSQL_PREFIX?}_themes`".$add." ORDER BY `theme_name` ASC", __FILE__, __LINE__); + $result = SQL_QUERY("SELECT + `theme_path`, `theme_name` +FROM + `{?_MYSQL_PREFIX?}_themes` +".$add." +ORDER BY + `theme_name` ASC", __FILE__, __LINE__); // Load all themes while ($content = SQL_FETCHARRAY($result)) { @@ -144,7 +147,7 @@ function getThemeVersion ($name) { // Checks wether a theme is found in db function ifThemeExists ($name) { // Get theme and is it not nul? - return (getThemeId($name) > 0); + return ((isExtensionActive('theme')) && (getThemeId($name) > 0)); } // Checks if a theme is active @@ -215,6 +218,91 @@ function getCurrentThemeName () { return $name; } +// Get current theme name +function getActualTheme () { + // The default theme is 'default'... ;-) + $ret = 'default'; + + // Load default theme if not empty from configuration + if ((isConfigEntrySet('default_theme')) && (getConfig('default_theme') != '')) $ret = getConfig('default_theme'); + + if (!isSessionVariableSet('mxchange_theme')) { + // Set default theme + setTheme($ret); + } elseif ((isSessionVariableSet('mxchange_theme')) && (isExtensionInstalledAndNewer('sql_patches', '0.1.4'))) { + //die("
".print_r($GLOBALS['cache_array']['themes'], true)."
"); + // Get theme from cookie + $ret = getSession('mxchange_theme'); + + // Is it valid? + if ((!isExtensionActive('theme')) || (getThemeId($ret) == '0')) { + // Fix it to default + $ret = 'default'; + } // END - if + } elseif ((!isInstalled()) && ((isInstalling()) || (getOutputMode() == true)) && ((isGetRequestElementSet('theme')) || (isPostRequestElementSet('theme')))) { + // Prepare filename for checking + $themeFile = sprintf("theme/%s/theme.php", getRequestElement('theme')); + + // Installation mode active + if ((isGetRequestElementSet('theme')) && (isIncludeReadable($theme))) { + // Set cookie from URL data + setTheme(getRequestElement('theme')); + } elseif (isIncludeReadable(sprintf("theme/%s/theme.php", secureString(postRequestElement('theme'))))) { + // Set cookie from posted data + setTheme(secureString(postRequestElement('theme'))); + } + + // Set return value + $ret = getSession('mxchange_theme'); + } else { + // Invalid design, reset cookie + setTheme($ret); + } + + // Return theme value + return $ret; +} + +// Setter for theme in session +function setTheme ($newTheme) { + setSession('mxchange_theme', $newTheme); +} + +// Get id from theme +function getThemeId ($name) { + // Default id + $id = '0'; + + // Is the cache entry there? + if (isset($GLOBALS['cache_array']['themes']['id'][$name])) { + // Get the version from cache + $id = $GLOBALS['cache_array']['themes']['id'][$name]; + + // Count up + incrementStatsEntry('cache_hits'); + } elseif (isExtensionInstalledAndNewer('cache', '0.1.8')) { + // Check if current theme is already imported or not + $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_themes` WHERE `theme_path`='%s' LIMIT 1", + array($name), __FUNCTION__, __LINE__); + + // Entry found? + if (SQL_NUMROWS($result) == 1) { + // Fetch data + list($id) = SQL_FETCHROW($result); + } // END - if + + // Free result + SQL_FREERESULT($result); + } + + // Return id + return $id; +} + +/////////////////////////////////////////////////////////////////////////////// +// Only filter functions +/////////////////////////////////////////////////////////////////////////////// + // Filter for generic handling of theme change function FILTER_HANDLE_THEME_CHANGE () { // Check if new theme is selcted @@ -233,5 +321,17 @@ function FILTER_HANDLE_THEME_CHANGE () { } // END - if } +// Filter for settings theme from user profile, must be executed only if FILTER_FETCH_USER_DATA() ran before +function FILTER_SET_USERS_THEME () { + // Is the user data valid? + if (!isMember()) { + // Do only run for logged in members + debug_report_bug('Please only run this filter for logged in users.'); + } // END - if + + // Change to new theme + setTheme(getUserData('curr_theme')); +} + // [EOF] ?> diff --git a/inc/modules/admin/what-list_bonus.php b/inc/modules/admin/what-list_bonus.php index 2605fa99e4..b50b650a79 100644 --- a/inc/modules/admin/what-list_bonus.php +++ b/inc/modules/admin/what-list_bonus.php @@ -57,11 +57,11 @@ if (getConfig('bonus_active') == 'Y') { if (getExtensionVersion('bonus') >= '0.6.9') { // Add more bonus points here $USE = '(0'; - if (getConfig('bonus_click_yn') == 'Y') $USE .= " + `turbo_bonus`"; - if (getConfig('bonus_login_yn') == 'Y') $USE .= " + `login_bonus`"; - if (getConfig('bonus_order_yn') == 'Y') $USE .= " + `bonus_order`"; - if (getConfig('bonus_stats_yn') == 'Y') $USE .= " + `bonus_stats`"; - if (getConfig('bonus_ref_yn') == 'Y') $USE .= " + `bonus_ref`"; + if (getConfig('bonus_click_yn') == 'Y') $USE .= ' + `turbo_bonus`'; + if (getConfig('bonus_login_yn') == 'Y') $USE .= ' + `login_bonus`'; + if (getConfig('bonus_order_yn') == 'Y') $USE .= ' + `bonus_order`'; + if (getConfig('bonus_stats_yn') == 'Y') $USE .= ' + `bonus_stats`'; + if (getConfig('bonus_ref_yn') == 'Y') $USE .= ' + `bonus_ref`'; $USE .= ')'; } else { // Old version ??? diff --git a/inc/modules/chk_login.php b/inc/modules/chk_login.php index 216166dc99..ad4bc4c97d 100644 --- a/inc/modules/chk_login.php +++ b/inc/modules/chk_login.php @@ -42,82 +42,22 @@ if (!defined('__SECURITY')) { } // END - if // Initial message part -$message = "{--VALIDATING_LOGIN--}"; +$GLOBALS['message'] = '{--VALIDATING_LOGIN--}'; // Is the member id and u_hash set? -if (isMemberIdSet() && (isSessionVariableSet('u_hash'))) { - // Is 'theme' installed and activated? - if (isExtensionActive('theme')) { - // Get theme from profile - if (!fetchUserData(getMemberId())) { - // Userid is not valid - debug_report_bug('User id '.getMemberId() . ' is invalid.'); - } // END - if - - // Load data - $data = getUserDataArray(); - - // Change to new theme - setTheme($data['curr_theme']); - - // Remmeber login failures if available - if (getExtensionVersion('sql_patches') >= '0.6.1') { - // Reset login failures - SQL_QUERY_ESC("UPDATE - `{?_MYSQL_PREFIX?}_user_data` -SET - `login_failures`=0, - `last_failure`='0000-00-00 00:00:00' -WHERE - `userid`=%s -LIMIT 1", - array(getMemberId()), __FILE__, __LINE__); - - // Store it in session - setSession('mxchange_member_failures', $data['login_failures']); - setSession('mxchange_member_last_fail', $data['last_failure']); - } // END - if - } // END - if - - // Bonus is not given by default ;-) - $bonus = false; - if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (isExtensionInstalledAndNewer('bonus', '0.2.1')) && (getConfig('bonus_active') == 'Y') && (getConfig('bonus_login_yn') == 'Y')) { - // Update last login if far enougth away - SQL_QUERY_ESC("UPDATE - `{?_MYSQL_PREFIX?}_user_data` -SET - `last_login`=UNIX_TIMESTAMP() -WHERE - `userid`=%s AND - `last_login` < (UNIX_TIMESTAMP() - %s) -LIMIT 1", - array( - getMemberId(), - getConfig('login_timeout') - ), __FILE__, __LINE__ - ); - if (SQL_AFFECTEDROWS() == 1) $bonus = true; - } // END - if - - if (($bonus === true) && (getRequestElement('mode') == 'bonus') && (isExtensionActive('bonus'))) { - // Output message with added points - $message .= "
- ".sprintf(getMessage('BONUS_LOGIN_BONUS_ADDED'), translateComma(getConfig('login_bonus')))." -
"; - } elseif (isExtensionActive('bonus')) { - // No login bonus added! - $message .= "
{--BONUS_LOGIN_BONUS_NOT_ADDED--}
"; - } +if (isMember()) { + // Run filter chain here + runFilterChain('member_login_check'); // Redirect to member area - $message .= loadTemplate('member_login_js', true); + $GLOBALS['message'] .= loadTemplate('member_login_js', true); } else { // Login failed! - $message .= loadTemplate('login_failed_js', true); + $GLOBALS['message'] .= loadTemplate('login_failed_js', true); } // Output final message -loadTemplate('admin_settings_saved', false, $message); +loadTemplate('admin_settings_saved', false, $GLOBALS['message']); // [EOF] ?> diff --git a/inc/modules/member/what-logout.php b/inc/modules/member/what-logout.php index 4e7ccf68d6..b29aa2d1a8 100644 --- a/inc/modules/member/what-logout.php +++ b/inc/modules/member/what-logout.php @@ -48,7 +48,7 @@ $URL = 'modules.php?module=index&code='; if (destroyMemberSession()) { // Remove theme cookie as well - setTheme(''); + if (isExtensionActive('theme')) setTheme(''); // Logout completed $URL .= getCode('LOGOUT_DONE'); diff --git a/inc/stylesheet.php b/inc/stylesheet.php index c5e0d7a80a..d8e1514d01 100644 --- a/inc/stylesheet.php +++ b/inc/stylesheet.php @@ -42,12 +42,12 @@ if (!defined('__SECURITY')) { } // Default styles -$STYLES = array( +$stylesList = array( 'general.css', ); // Add stylesheet for installation -if ((isInstallationPhase())) $STYLES[] = 'install.css'; +if ((isInstallationPhase())) $stylesList[] = 'install.css'; // When no CSS output-mode is set, set it to file-output if (!isConfigEntrySet('css_php')) setConfigEntry('css_php', 'FILE'); @@ -55,13 +55,13 @@ if (!isConfigEntrySet('css_php')) setConfigEntry('css_php', 'FILE'); // Output CSS files or content or link to css.php ? if ((getOutputMode() == 1) || (getConfig('css_php') == 'DIRECT')) { // Load CSS files - $STYLES = merge_array($STYLES, getExtensionCssFiles()); + $stylesList = merge_array($stylesList, getExtensionCssFiles()); // Generate base path $basePath = sprintf("%stheme/%s/css/", getConfig('PATH'), getCurrentTheme()); // Output inclusion lines - foreach ($STYLES as $value) { + foreach ($stylesList as $value) { // Only include found CSS files (to reduce 404 requests) $FQFN = $basePath . $value; @@ -84,14 +84,14 @@ if ((getOutputMode() == 1) || (getConfig('css_php') == 'DIRECT')) { } // END - foreach } elseif ((getOutputMode() == '0') || (getConfig('css_php') == 'INLINE')) { // Load CSS files - $STYLES = merge_array($STYLES, getExtensionCssFiles()); + $stylesList = merge_array($stylesList, getExtensionCssFiles()); // Generate base path $basePath = sprintf("%stheme/%s/css/", getConfig('PATH'), getCurrentTheme()); // Output inclusion lines $OUT = ''; - foreach ($STYLES as $value) { + foreach ($stylesList as $value) { // Only include found CSS files (to reduce 404 requests) $FQFN = $basePath . $value;