From: Roland Häder Date: Wed, 7 Oct 2009 19:59:56 +0000 (+0000) Subject: Login form for guests in surfbar added, some trigger_error() added, misc rewrites X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;ds=inline;h=fe1e1d3b8291b1ca991e3d2e639cb28097c53d74;hp=160c118f767dd39fdef7007c170a5bac4d876b8e;p=mailer.git Login form for guests in surfbar added, some trigger_error() added, misc rewrites --- diff --git a/.gitattributes b/.gitattributes index 1b24abb51c..28ddfde261 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1542,6 +1542,7 @@ templates/de/html/surfbar/surfbar_frame_stats.tpl -text templates/de/html/surfbar/surfbar_frame_textlinks.tpl -text templates/de/html/surfbar/surfbar_frame_top.tpl -text templates/de/html/surfbar/surfbar_frameset.tpl -text +templates/de/html/surfbar/surfbar_login_form.tpl -text templates/de/html/surfbar/surfbar_start_banner.tpl -text templates/de/html/surfbar/surfbar_stopped.tpl -text templates/de/html/task/.htaccess -text diff --git a/beg.php b/beg.php index 27bb97df84..29ed819466 100644 --- a/beg.php +++ b/beg.php @@ -237,5 +237,5 @@ if (REQUEST_ISSET_GET('uid')) { // Really all done here... ;-) shutdown(); -// +// [EOF] ?> diff --git a/confirm.php b/confirm.php index 41ca856c24..53446c5325 100644 --- a/confirm.php +++ b/confirm.php @@ -68,5 +68,5 @@ if ((isInstalled()) && (isAdminRegistered())) { // Really all done here... ;-) shutdown(); -// +// [EOF] ?> diff --git a/css.php b/css.php index 4a9c8ed36f..608c11e387 100644 --- a/css.php +++ b/css.php @@ -61,5 +61,5 @@ loadInclude('inc/stylesheet.php'); // Load footer loadIncludeOnce('inc/footer.php'); -// +// [EOF] ?> diff --git a/debug.php b/debug.php index f7e28dc25c..4bf0774391 100644 --- a/debug.php +++ b/debug.php @@ -88,5 +88,5 @@ if ((isInstalled()) && (getTotalFatalErrors() == 0)) { // Really all done here... ;-) shutdown(); -// +// [EOF] ?> diff --git a/inc/config-functions.php b/inc/config-functions.php index c70857e9af..fe1e3d7058 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -42,9 +42,24 @@ if (!defined('__SECURITY')) { require($INC); } -// Merges $GLOBALS['config'] with data in given array -function mergeConfig ($newConfig) { - $GLOBALS['config'] = merge_array(getConfigArray(), $newConfig); +// Init the config array +function initConfig () { + // Init not if already found + if ((isset($GLOBALS['config'])) && (count($GLOBALS['config']) >= 3)) { + // Already initialized + trigger_error(sprintf("[%s:%s] Configuration is already initialized.", __FUNCTION__, __LINE__)); + } // END - if + + // Set a minimum dummy configuration + $GLOBALS['config'] = array( + 'code_length' => 0, + 'patch_level' => 0, + 'last_update' => time(), + 'DEBUG_MODE' => 'N', + 'sql_count' => 0, + 'num_templates' => 0, + 'default_theme' => 'default', + ); } // Getter for $GLOBALS['config'] entries @@ -53,13 +68,13 @@ function getConfig ($configEntry) { $value = null; // Is the entry there? - if (isConfigEntrySet($configEntry)) { - // Then use it - $value = $GLOBALS['config'][$configEntry]; + if (!isConfigEntrySet($configEntry)) { + // Raise an error of missing entries + trigger_error(sprintf("[%s:%s] Configuration entry %s is missing.", __FUNCTION__, __LINE__, $configEntry)); } // END - if // Return it - return $value; + return $GLOBALS['config'][$configEntry]; } // Setter for $GLOBALS['config'] entries @@ -82,6 +97,11 @@ function isConfigEntrySet ($configEntry) { return (isset($GLOBALS['config'][$configEntry])); } +// Merges $GLOBALS['config'] with data in given array +function mergeConfig ($newConfig) { + $GLOBALS['config'] = merge_array(getConfigArray(), $newConfig); +} + // Increment or init with given value or 1 as default the given config entry function incrementConfigEntry ($configEntry, $value=1) { // Increment it if set or init it with 1 @@ -98,16 +118,6 @@ function isConfigLoaded () { return ((isset($GLOBALS['config'])) && (is_array($GLOBALS['config'])) && (count($GLOBALS['config']) > 0)); } -// Init the config array -function initConfig () { - // Set a minimum dummy configuration - $GLOBALS['config'] = array( - 'code_length' => 0, - 'patch_level' => 0, - 'last_update' => time() - ); -} - // Load configuration and return it as an arry function loadConfiguration ($no = '0') { // Check for cache extension, cache-array and if the requested configuration is in cache diff --git a/inc/databases.php b/inc/databases.php index ff3555e01e..f4cf158ba3 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -93,7 +93,6 @@ $GLOBALS['replacer'] = array( // One day setConfigEntry('one_day', (60*60*24)); -// // Timestamp for yesterday, today ... all at 00:00 am setConfigEntry('START_YDAY', makeTime(0, 0, 0, time() - getConfig('one_day'))); setConfigEntry('START_TDAY', makeTime(0, 0, 0, time())); diff --git a/inc/extensions.php b/inc/extensions.php index 1b17f1101f..d50ff70309 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -93,7 +93,7 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = '', $EXT_VER = '', $dry_run loadIncludeOnce($funcsInclude); } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) { // No functions file is not so good... - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no own functions file or we cannot read from it.", + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("NOTICE: Extension %s has no own functions file or we cannot read from it.", $ext_name )); } // END - if diff --git a/inc/extensions/ext-surfbar.php b/inc/extensions/ext-surfbar.php index 78bac496a4..9a1845f422 100644 --- a/inc/extensions/ext-surfbar.php +++ b/inc/extensions/ext-surfbar.php @@ -172,6 +172,7 @@ UNIQUE KEY `status_action` (`status`,`action`) ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_low_interval` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".getConfig('one_day').""); ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_migrate_order` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_notification_mode` ENUM('INSTANT','RESET') NOT NULL DEFAULT 'INSTANT'"); + ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_guest_login_form` ENUM('Y','N') NOT NULL DEFAULT 'Y'"); // Extend user data ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD `surfbar_low_notified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'"); diff --git a/inc/functions.php b/inc/functions.php index 508112789f..fa2b69e694 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2654,7 +2654,7 @@ function debug_report_bug ($message = '') { if (!empty($message)) { // Use and log it $debug = sprintf("Note: %s
\n", - $message + $message ); // @TODO Add a little more infos here diff --git a/inc/handler.php b/inc/handler.php index 344b88a6f0..1c28ca893f 100644 --- a/inc/handler.php +++ b/inc/handler.php @@ -52,17 +52,8 @@ function __errorHandler ($errno, $errstr, $errfile, $errline) { $errline ); - // Write debug log message - DEBUG_LOG($errfile, $errline, $message, true); - // Output message to user and die - if (EXT_IS_ACTIVE('debug')) { - // Debug extension found! So Output a small message - app_die($errfile, $errline, "Error message written to debug.log. Please try to call the main page to continue."); - } elseif ($GLOBALS['error_handler']['exit_on_error'] === true) { - // No debug extension found, so regular output - debug_report_bug($message); - } + debug_report_bug($message); } // Init error handler diff --git a/inc/language-functions.php b/inc/language-functions.php index c2cde5f34f..693fed1674 100644 --- a/inc/language-functions.php +++ b/inc/language-functions.php @@ -146,7 +146,7 @@ function loadLanguageFile ($ext_name = '') { loadIncludeOnce($languageInclude); } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) { // No language file is not so good... - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no language file or we cannot read from it. lang=%s", + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("NOTICE: Extension %s has no language file or we cannot read from it. lang=%s", $ext_name, getLanguage() )); } diff --git a/inc/language/surfbar_de.php b/inc/language/surfbar_de.php index 9aec4dd962..31404c69c3 100644 --- a/inc/language/surfbar_de.php +++ b/inc/language/surfbar_de.php @@ -71,6 +71,9 @@ define('ADMIN_CONFIG_SURFBAR_LOW_INTERVAL', "Wiederholungsinterval für Nach define('ADMIN_CONFIG_SURFBAR_NOTIFICATION_MODE', "Benachrichtigungen sofort oder beim täglichen Reset aussenden? ("Sofort" kann zu Verzögerungen und/oder Belastung des Servers führen!"); define('ADMIN_CONFIG_SURFBAR_NOTIFICATION_MODE_INSTANT', "Sofort aussenden"); define('ADMIN_CONFIG_SURFBAR_NOTIFICATION_MODE_RESET', "Beim täglichen Reset"); +define('ADMIN_CONFIG_SURFBAR_GUEST_LOGIN_FORM', "Soll bei Aufruf der Surfbar durch einen Gast ein Loginformular angezeigt oder zur Startseite weitergeleitet werden?"); +define('ADMIN_CONFIG_SURFBAR_GUEST_LOGIN_FORM_Y', "Loginformular angzeigen."); +define('ADMIN_CONFIG_SURFBAR_GUEST_LOGIN_FORM_N', "Zur Startseite weiterleiten."); // Admin non-config titles define('ADMIN_SURFBAR_STATS_TITLE', "Mitglieder-Statistik der Surfbar"); @@ -244,5 +247,7 @@ define('MEMBER_SURFBAR_EXECUTE_ACTION_404', "Auszuführende Funktion diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 08b2bd1645..10a2ba6583 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -879,6 +879,12 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = 0) { // Determine depleted user account $UIDs = SURFBAR_DETERMINE_DEPLETED_USERIDS(); + // If we dont get any user ids back, there are no URLs + if (count($UIDs['uid']) == 0) { + // No user ids found, no URLs! + return 0; + } // END - if + // Is the exlude userid set? if ($excludeUserId > 0) { // Then add it @@ -886,10 +892,10 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = 0) { } // END - if // Get amount from database - $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt + $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS cnt FROM `{!_MYSQL_PREFIX!}_surfbar_urls` -WHERE userid NOT IN (".implode(',', $UIDs['uid']).") AND `status`='%s'", - array($status), __FUNCTION__, __LINE__ +WHERE `userid` NOT IN (".implode(', ', $UIDs['uid']).") AND `status`='%s'", + array($status), __FUNCTION__, __LINE__ ); // Fetch row diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 4519800782..cfb52655e3 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -258,14 +258,14 @@ function determineRandomReferalId () { } // Do the user login -function USER_DO_LOGIN ($uid, $passwd) { +function USER_DO_LOGIN ($uid, $passwd, $successUrl = '') { // Init variables - $dmy = ''; + $dmy = ''; $add = ''; // Add last_login if available $lastOnline = ''; if (GET_EXT_VERSION('sql_patches') >= '0.2.8') { - $lastOnline = ', last_login'; + $lastOnline = ', `last_login`'; } // END - if // Init array @@ -346,13 +346,19 @@ function USER_DO_LOGIN ($uid, $passwd) { SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `total_logins`=`total_logins`+1" . $add . " WHERE `userid`=%s LIMIT 1", array($uid), __FUNCTION__, __LINE__); if (SQL_AFFECTEDROWS() == 1) { - // Procedure to checking for login data - if (($GLOBALS['bonus_payed']) && (EXT_IS_ACTIVE('bonus'))) { - // Bonus added (just displaying!) - $URL = 'modules.php?module=chk_login&mode=bonus'; + // Is a success URL set? + if (empty($successUrl)) { + // Procedure to checking for login data + if (($GLOBALS['bonus_payed']) && (EXT_IS_ACTIVE('bonus'))) { + // Bonus added (just displaying!) + $URL = 'modules.php?module=chk_login&mode=bonus'; + } else { + // Bonus not added + $URL = 'modules.php?module=chk_login&mode=login'; + } } else { - // Bonus not added - $URL = 'modules.php?module=chk_login&mode=login'; + // Use this URL + $URL = $successUrl; } } else { // Cannot update counter! diff --git a/inc/modules/admin/what-config_surfbar.php b/inc/modules/admin/what-config_surfbar.php index 8d15d73c6d..84b4e89fe0 100644 --- a/inc/modules/admin/what-config_surfbar.php +++ b/inc/modules/admin/what-config_surfbar.php @@ -127,6 +127,17 @@ if (isFormSent()) { define('__CONFIG_SURFBAR_MIGRATE_ORDER_N', ' checked="checked"'); } + // Prepare order migration + if (getConfig('surfbar_guest_login_form') == 'Y') { + // Yes selected + define('__CONFIG_SURFBAR_GUEST_LOGIN_FORM_Y', ' checked="checked"'); + define('__CONFIG_SURFBAR_GUEST_LOGIN_FORM_N', ''); + } else { + // No selected + define('__CONFIG_SURFBAR_GUEST_LOGIN_FORM_Y', ''); + define('__CONFIG_SURFBAR_GUEST_LOGIN_FORM_N', ' checked="checked"'); + } + // Pause URL mode if (getConfig('surfbar_pause_mode') == 'INTERNAL') { // Internal pause page diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index ba583c1cc1..697ad84610 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -49,11 +49,14 @@ require('inc/functions.php'); require('inc/wrapper-functions.php'); // Load more function libraries or includes -foreach (array('request-functions', 'session-functions', 'config-functions', 'code-functions', 'inc-functions', 'language-functions', 'filters', 'mysql-manager', 'extensions', 'db/lib', 'handler', 'hooks') as $lib) { +foreach (array('request-functions', 'session-functions', 'config-functions', 'code-functions', 'inc-functions', 'language-functions', 'filters', 'mysql-manager', 'extensions', 'handler', 'hooks') as $lib) { // Load special functions loadIncludeOnce('inc/' . $lib . '.php'); } // END - foreach +// Initialize the configuration +initConfig(); + // Set error handler set_error_handler('__errorHandler'); @@ -80,6 +83,9 @@ if ((!isInstalling()) && (isInstalled())) { // Load configuration file(s) here loadIncludeOnce('inc/load_config.php'); + // Load database layer here + loadIncludeOnce('inc/db/lib.php'); + // Check for write-permission for config.php and inc directory if (!isModuleSet()) setModule(REQUEST_GET('module')); if (!isModuleSet()) setModule('index'); diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 738b5b6e3d..05f5a056e6 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -285,10 +285,10 @@ function isInstalled () { return ( ( // New config file found and loaded - getConfig('MXCHANGE_INSTALLED') == 'Y' + isIncludeReadable('inc/cache/config-local.php') ) || ( - // Fall-back! - isIncludeReadable('inc/config.php') + // Fall-back to config + getConfig('MXCHANGE_INSTALLED') == 'Y' ) || ( ( // New config file found, but not yet read diff --git a/install.php b/install.php index 9e28d9c2aa..99c1f76593 100644 --- a/install.php +++ b/install.php @@ -96,5 +96,5 @@ LOAD_TEMPLATE('install_footer'); // Footer loadIncludeOnce('inc/footer.php'); -// +// [EOF] ?> diff --git a/js.php b/js.php index cf93e394b3..c991ed3a83 100644 --- a/js.php +++ b/js.php @@ -78,5 +78,5 @@ if ((isInstalled()) && (REQUEST_ISSET_GET('tag'))) { // Shutdown shutdown(); -// +// [EOF] ?> diff --git a/modules.php b/modules.php index ade1260209..2eb272b2be 100644 --- a/modules.php +++ b/modules.php @@ -62,7 +62,7 @@ loadIncludeOnce('inc/header.php'); $isModuleValid = false; $check = 'failed'; // Is the maintenance mode active or goes all well? -if ((getConfig('maintenance') == 'Y') && (!IS_ADMIN()) && (getModule() != 'admin')) { +if ((EXT_IS_ACTIVE('maintenance')) && (getConfig('maintenance') == 'Y') && (!IS_ADMIN()) && (getModule() != 'admin')) { // Maintain mode is active and you are no admin addFatalMessage(__FILE__, __LINE__, getMessage('LANG_DOWN_MAINTAINCE')); } elseif ((SQL_IS_LINK_UP()) && (getTotalFatalErrors() == 0)) { diff --git a/surfbar.php b/surfbar.php index 2da2cea3a2..ec7ce0e6f1 100644 --- a/surfbar.php +++ b/surfbar.php @@ -68,9 +68,32 @@ redirectOnUninstalledExtension('surfbar'); // No member? if (!IS_MEMBER()) { - // Redirect - // @TODO Display quick login form here or redirect as configured - redirectToUrl('modules.php?module=index'); + // Should we display login window or redirect to main page? + if ((getConfig('surfbar_guest_login_form') == 'Y') && (EXT_IS_ACTIVE('user'))) { + // Is the form sent? + if ((isFormSent()) && (REQUEST_ISSET_POST('id')) && (REQUEST_ISSET_POST('password'))) { + // Do the login procedure + $URL = USER_DO_LOGIN(REQUEST_POST('id'), REQUEST_POST('password'), basename(__FILE__)); + + // And redirect to the URL + redirectToUrl($URL); + } else { + // Load header + loadIncludeOnce('inc/header.php'); + + // Display login form + LOAD_TEMPLATE('surfbar_login_form'); + + // Allow footer here + $GLOBALS['header_sent'] = 2; + + // Load footer + loadIncludeOnce('inc/footer.php'); + } + } else { + // Redirect + redirectToUrl('index.php'); + } } // END - if // Initialize the surfbar diff --git a/templates/de/html/admin/admin_config_surfbar.tpl b/templates/de/html/admin/admin_config_surfbar.tpl index 04206b84e7..4482ff36bb 100644 --- a/templates/de/html/admin/admin_config_surfbar.tpl +++ b/templates/de/html/admin/admin_config_surfbar.tpl @@ -7,10 +7,10 @@   - + {--ADMIN_CONFIG_SURFBAR_STATIC_REWARD--} - + {!POINTS!} @@ -19,7 +19,7 @@ {--ADMIN_CONFIG_SURFBAR_STATIC_COSTS--} - + {!POINTS!} @@ -28,7 +28,7 @@ {--ADMIN_CONFIG_SURFBAR_STATIC_TIME--} - + $content[surfbar_static_time] @@ -37,7 +37,7 @@ {--ADMIN_CONFIG_SURFBAR_STATIC_LOCK--} - + $content[surfbar_static_lock] @@ -46,7 +46,7 @@ {--ADMIN_CONFIG_SURFBAR_DYNAMIC_PERCENT--} - + % @@ -55,7 +55,7 @@ {--ADMIN_CONFIG_SURFBAR_MAX_ORDER--} - + @@ -64,7 +64,7 @@ {--ADMIN_CONFIG_SURFBAR_RESTART_TIME--} - + $content[surfbar_restart_time] @@ -73,7 +73,7 @@ {--ADMIN_CONFIG_SURFBAR_STATS_RELOAD--} - + $content[surfbar_stats_reload] @@ -82,7 +82,7 @@ {--ADMIN_CONFIG_SURFBAR_PURGE_DELETED--} - + $content[surfbar_purge_deleted] @@ -91,7 +91,7 @@ {--ADMIN_CONFIG_SURFBAR_PURGE_MIGRATED--} - + $content[surfbar_purge_migrated] @@ -106,7 +106,7 @@ {--ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_STATIC--} - + @@ -114,7 +114,7 @@ {--ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_DYNAMIC--} - + @@ -129,7 +129,7 @@ {--ADMIN_CONFIG_SURFBAR_PAUSE_MODE_INTERNAL--} - + @@ -137,7 +137,7 @@ {--ADMIN_CONFIG_SURFBAR_PAUSE_MODE_EXTERNAL--} - + @@ -146,7 +146,7 @@ {--ADMIN_CONFIG_SURFBAR_PAUSE_URL--} - + @@ -202,7 +202,7 @@ {--ADMIN_CONFIG_SURFBAR_WARN_LOW_POINTS--} - + {!POINTS!} @@ -211,7 +211,7 @@ {--ADMIN_CONFIG_SURFBAR_LOW_INTERVAL--} - + $content[surfbar_low_interval] @@ -227,6 +227,17 @@   +   + + + {--ADMIN_CONFIG_SURFBAR_GUEST_LOGIN_FORM--} + + +  {--ADMIN_CONFIG_SURFBAR_GUEST_LOGIN_FORM_Y--}
+  {--ADMIN_CONFIG_SURFBAR_GUEST_LOGIN_FORM_N--} + + +   diff --git a/templates/de/html/surfbar/surfbar_login_form.tpl b/templates/de/html/surfbar/surfbar_login_form.tpl new file mode 100644 index 0000000000..42ff90b3cd --- /dev/null +++ b/templates/de/html/surfbar/surfbar_login_form.tpl @@ -0,0 +1,48 @@ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/view.php b/view.php index cf6207ed84..ce508be798 100644 --- a/view.php +++ b/view.php @@ -71,5 +71,5 @@ if (((REQUEST_ISSET_GET('user')) || (REQUEST_ISSET_GET('reseller'))) && (REQUEST // Shutdown shutdown(); -// +// [EOF] ?>