// If no account was found set default refid and status to CONFIRMED
if (empty($GLOBALS['refid'])) {
- $GLOBALS['refid'] = getConfig('def_refid');
+ // Determine referal id again
+ $GLOBALS['refid'] = determineReferalId();
$status = 'CONFIRMED';
} // END - if
// Set a minimum of configuration, required to by-pass some error triggers in getConfig()
$GLOBALS['config'] = array(
- 'code_length' => 0,
- 'patch_level' => 0,
- 'last_update' => time(),
- 'activate_xchange' => 100,
- 'enable_mod_title' => 'Y',
- 'update_filter_usage' => 'N',
- 'ADMIN_REGISTERED' => 'N',
- 'MXCHANGE_INSTALLED' => 'N',
- 'DEFAULT_LANG' => 'de',
- 'DEFAULT_SALT_LENGTH' => 40,
- 'DEBUG_MODE' => 'N',
- 'DEBUG_RESET' => 'N',
- 'DEBUG_MONTHLY' => 'N',
- 'DEBUG_WEEKLY' => 'N',
- 'DEBUG_REGEX' => 'N',
- 'ADMIN_REGISTERED' => 'N',
- 'sql_count' => 0,
'sql_time' => 0,
+ 'sql_count' => 0,
'num_templates' => 0,
- 'default_theme' => 'default',
- 'verbose_sql' => 'Y',
- 'def_refid' => 0,
- 'ENABLE_BACKLINK' => 'Y',
- 'display_debug_sqls' => 'N',
+ // 'DEFAULT_SALT_LENGTH' => 40,
+ // 'DEBUG_MODE' => 'N',
+ // 'DEBUG_RESET' => 'N',
+ // 'DEBUG_MONTHLY' => 'N',
+ // 'DEBUG_WEEKLY' => 'N',
+ // 'DEBUG_REGEX' => 'N',
+ // 'ADMIN_REGISTERED' => 'N',
+ // 'verbose_sql' => 'Y',
+ // 'ENABLE_BACKLINK' => 'Y',
+ // 'display_debug_sqls' => 'N',
// Keep session_save_path to fall-back to php.ini setting
- 'session_save_path' => '',
+ // 'session_save_path' => '',
// For installation phase:
'SMTP_HOSTNAME' => '',
'SMTP_USER' => '',
setConfigEntry('START_YDAY', makeTime(0, 0, 0, time() - getConfig('ONE_DAY')));
setConfigEntry('START_TDAY', makeTime(0, 0, 0, time()));
-// Take a prime number which is long (if you know a longer one please try it out!)
-setConfigEntry('_PRIME', 591623);
-
-// Calculate "entropy" with the prime number (for code generation)
-setConfigEntry('_ADD', (getConfig('_PRIME') * getConfig('_PRIME') / (pi() * getConfig('code_length') + 1)));
-
// HTTP-EOL
setConfigEntry('HTTP_EOL', "\r\n");
incrementConfigEntry('sql_count');
// Debug output
- if ((getOutputMode() != 1) && (isDebugModeEnabled()) && (getConfig('DEBUG_SQL') == 'Y')) {
+ if ((getOutputMode() != 1) && (isDebugModeEnabled()) && (isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y')) {
//
// Debugging stuff...
//
} // END - if
// Version number
-setThisExtensionVersion('0.2.4');
+setThisExtensionVersion('0.2.5');
// 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'));
+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'));
// Keep this extension always active!
setExtensionAlwaysActive('Y');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Filter zum Anzeigen (Debug) von ausgeführten SQL-Anweisungen hinzugefügt.");
break;
+
+ case '0.2.5': // SQL queries for v0.2.5
+ addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `code_length` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5");
+
+ // Update notes (these will be set as task text!)
+ setExtensionUpdateNotes("Codelänge aus tables.sql rausgeholt.");
+ break;
}
break;
// Filter for initializing randomizer
function FILTER_INIT_RANDOMIZER () {
+ // Only execute this filter if installed
+ if ((!isInstalled()) || (!isExtensionInstalledAndNewer('other', '0.2.5'))) return;
+
+ // Take a prime number which is long (if you know a longer one please try it out!)
+ setConfigEntry('_PRIME', 591623);
+
+ // Calculate "entropy" with the prime number (for code generation)
+ setConfigEntry('_ADD', (getConfig('_PRIME') * getConfig('_PRIME') / (pi() * getConfig('code_length') + 1)));
+
// Simply init the randomizer with seed and _ADD value
mt_srand(generateSeed() + getConfig('_ADD'));
}
setIncludePool('reset', getArrayFromDirectory('inc/reset/', 'reset_'));
// Update database
- if (getConfig('DEBUG_RESET') != 'Y') updateConfiguration('last_update', time());
+ if ((!isConfigEntrySet('DEBUG_RESET')) || (getConfig('DEBUG_RESET') != 'Y')) updateConfiguration('last_update', time());
// Is the config entry set?
if (isExtensionInstalledAndNewer('sql_patches', '0.4.2')) {
// Filter for checking and updating SVN revision
function FILTER_CHECK_SVN_REVISION () {
+ // Only execute this filter if installed and all config entries are there
+ if ((!isInstalled()) || (!isConfigEntrySet('patch_level'))) return;
+
// Check for patch level differences between databases and current hard-coded
if ((getConfig('CURR_SVN_REVISION') > getConfig('patch_level')) || (getConfig('patch_level') == 'CURR_SVN_REVISION') || (getConfig('patch_ctime') == 'UNIX_TIMES')) {
// Update database and CONFIG array
// Filter for running daily reset
function FILTER_RUN_DAILY_RESET () {
+ // Only execute this filter if installed
+ if ((!isInstalled()) || (!isAdminRegistered())) return;
+
// Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D
// 012 3 4 43 3 4432 2 3 3 21 1 221 1 221 1 2 21 1 22 10
- if (((date('d', getConfig('last_update')) != date('d', time())) || (getConfig('DEBUG_RESET') == 'Y')) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestElementSet('register')) && (getOutputMode() != 1)) {
+ if (((date('d', getConfig('last_update')) != date('d', time())) || ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'))) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestElementSet('register')) && (getOutputMode() != 1)) {
// Tell every module we are in reset-mode!
doReset();
} // END - if
// Shall we display the copyright notice?
if ((!isGetRequestElementSet('frame')) && (basename($_SERVER['PHP_SELF']) != 'mailid_top.php') && ((getConfig('WRITE_FOOTER') == 'Y') || (isInstalling())) && ($GLOBALS['header_sent'] == 2)) {
// Backlink enabled?
- if ((getConfig('ENABLE_BACKLINK') == 'Y') || (isInstalling())) {
+ if (((isConfigEntrySet('ENABLE_BACKLINK')) && (getConfig('ENABLE_BACKLINK') == 'Y')) || (isInstalling())) {
// Copyright with backlink, thanks! :-)
loadTemplate('copyright_backlink');
} else {
$ret = 'default';
// Load default theme if not empty from configuration
- if (getConfig('default_theme') != '') $ret = getConfig('default_theme');
+ if ((isConfigEntrySet('default_theme')) && (getConfig('default_theme') != '')) $ret = getConfig('default_theme');
if (!isSessionVariableSet('mxchange_theme')) {
// Set default theme
// Output a debug backtrace to the user
function debug_report_bug ($message = '') {
+ // Is this already called?
+ if (isset($GLOBALS[__FUNCTION__])) {
+ // Other backtrace
+ print 'Message:'.$message.'<br />Backtrace:<pre>';
+ debug_print_backtrace();
+ die('</pre>');
+ } // END - if
+
+ // Set this function as called
+ $GLOBALS[__FUNCTION__] = true;
+
// Init message
$debug = '';
}
// Set cookie when default refid > 0
- if (!isSessionVariableSet('refid') || (!empty($GLOBALS['refid'])) || ((getSession('refid') == 0) && (getConfig('def_refid') > 0))) {
+ if (!isSessionVariableSet('refid') || (!empty($GLOBALS['refid'])) || ((getSession('refid') == 0) && (isConfigEntrySet('def_refid')) && (getConfig('def_refid') > 0))) {
// Set cookie
setSession('refid', $GLOBALS['refid']);
} // END - if
// Add SQL debug data to array for later output
function addSqlToDebug ($result, $sqlString, $timing, $F, $L) {
- // Don't execute anything here if we don't need
- if (getConfig('display_debug_sqls') != 'Y') return;
+ // Already executed?
+ if (isset($GLOBALS['debug_sqls'][$F][$L][$sqlString])) {
+ // Then abort here, we don't need to profile a query twice
+ return;
+ } // END - if
+
+ // Remeber this as profiled (or not, but we don't care here)
+ $GLOBALS['debug_sqls'][$F][$L][$sqlString] = true;
+
+ // Do we have cache?
+ if (!isset($GLOBALS['debug_sql_available'])) {
+ // Check it and cache it in $GLOBALS
+ $GLOBALS['debug_sql_available'] = ((isExtensionInstalledAndNewer('other', '0.2.2')) && (getConfig('display_debug_sqls') == 'Y'));
+ } // END - if
+
+ // Don't execute anything here if we don't need or ext-other is missing
+ if ($GLOBALS['debug_sql_available'] === false) {
+ return;
+ } // END - if
// Generate record
$record = array(
// If not in CSS mode generate the header
if (getOutputMode() != 1) {
// Config and database connection valid?
- if ((isConfigLocalLoaded()) && (isConfigLoaded()) && (SQL_IS_LINK_UP()) && (isExtensionActive('sql_patches'))) {
+ if ((isConfigLocalLoaded()) && (isConfigLoaded()) && (SQL_IS_LINK_UP()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) {
// Init title
$TITLE = '';
// "Getter" for language
function getLanguage () {
+ // Default is 'de'. DO NOT CHANGE THIS!!!
+ $ret = 'de';
+
// Set default return value to default language from config
- $ret = getConfig('DEFAULT_LANG');
+ if (isConfigEntrySet('DEFAULT_LANG')) $ret = getConfig('DEFAULT_LANG');
// Init variable
$lang = '';
'ADMIN_EXT_TEXT_FILE_MISSING' => "Die Erweiterung <span class=\"data\">%s</span> hat keinen Beschreibungstext. Bitte melden Sie dies uns <a href=\"http://bugs.mxchange.org\" target=\"_blank\" title=\"Direkter Link zum Bug-Tracker\">im Bug-Tracker</a>.",
'GUEST_STATS_NO_CLICKS' => "Keine Klicks in Ihrem {?mt_word?} verzeichnet.",
'ADMIN_EXTENSIONS_REMOVED' => "Es wurden <span class=\"data\">%s</span> Erweiterungen aus Ihrem {?mt_word?} entfernt.",
+ 'ADMIN_WARNING_SQL_PATCHES_MISSING' => "Ein essentielle Erweiterung <span=\"data\">sql_patches</span> ist noch nicht installiert. Bitte erledigen Sie dies bald, da Ihr {?mt_word?} sonst nicht funktioniert.",
'MEMBER_MAIL_BONUS_CONFIRMED_ON' => "Sie haben diese Bonusmail <span class=\"data\">%s</span> bestätigt.",
'MEMBER_MAIL_NORMAL_CONFIRMED_ON' => "Sie haben diese Klickmail <span class=\"data\">%s</span> bestätigt.",
} else {
// This little call constructs the whole default old and lacky menu system
// on left side. It also renders the content on right side
- doAdminAction(getWhat());
+ doAdminAction();
}
break;
}
// Do an admin action
-function doAdminAction ($what) {
+function doAdminAction () {
+ // Get default what
+ $what = getWhat();
+
//* DEBUG: */ outputHtml(__LINE__."*".$what.'/'.getModule().'/'.getAction().'/'.getWhat()."*<br />");
// Remove any spaces from variable
// Tableset header
loadTemplate('admin_main_header', false, $content);
+ // Is sql_patches not yet installed?
+ if (!isExtensionInstalled('sql_patches')) {
+ // Output warning
+ loadTemplate('admin_settings_saved', false, getMessage('ADMIN_WARNING_SQL_PATCHES_MISSING'));
+ } // END - if
+
// Check if action/what pair is valid
$result_action = SQL_QUERY_ESC("SELECT
`id`
)
)
)
-LIMIT 1", array($action, $what, $what), __FUNCTION__, __LINE__);
+LIMIT 1",
+ array($action, $what, $what), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result_action) == 1) {
// Is valid but does the inlcude file exists?
$inc = sprintf("inc/modules/admin/action-%s.php", $action);
initMessages();
// Check if this file is writeable or read-only and warn the user
-if ((!isInstalling()) && (!isInstallationPhase())) {
- // Load "databases" aka static arrays
- loadIncludeOnce('inc/databases.php');
-
+if (!isInstalling()) {
// Load database layer here
loadIncludeOnce('inc/db/lib.php');
// Run the init filter chain
runFilterChain('init');
+ // Load "databases" aka static arrays
+ loadIncludeOnce('inc/databases.php');
+
// Check module for permissions
$checkModule = checkModulePermissions();
if (!isOutputModeSet()) setOutputMode(0);
// Include more
- foreach (array('inc/databases.php','inc/db/lib.php','inc/session.php','inc/versions.php','inc/install-functions.php','inc/load_config.php') as $inc) {
+ foreach (array('inc/databases.php','inc/versions.php','inc/db/lib.php','inc/session.php','inc/install-functions.php','inc/load_config.php') as $inc) {
// Load the include
loadIncludeOnce($inc);
} // END - foreach
// Deletes a user account with given reason
function deleteUserAccount ($userid, $reason) {
$points = 0;
- $result = SQL_QUERY_ESC("SELECT (SUM(p.points) - d.used_points) AS points
-FROM `{?_MYSQL_PREFIX?}_user_points` AS p
-LEFT JOIN `{?_MYSQL_PREFIX?}_user_data` AS d
-ON p.userid=d.userid
-WHERE p.userid=%s", array(bigintval($userid)), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT
+ (SUM(p.points) - d.used_points) AS points
+FROM
+ `{?_MYSQL_PREFIX?}_user_points` AS p
+LEFT JOIN
+ `{?_MYSQL_PREFIX?}_user_data` AS d
+ON
+ p.userid=d.userid
+WHERE
+ p.userid=%s",
+ array(bigintval($userid)), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Save his points to add them to the jackpot
list($points) = SQL_FETCHROW($result);
// Some security stuff...
if (!defined('__SECURITY')) {
die();
-}
+} // END - if
-// Set session save path if set
-if (getConfig('session_save_path') != '') {
- // Please make sure this valid!
- session_save_path(getConfig('session_save_path'));
+// Is ext-sql_patches there and newer?
+if (isExtensionInstalledAndNewer('sql_patches', '0.5.3')) {
+ // Set session save path if set
+ if (getConfig('session_save_path') != '') {
+ // Please make sure this valid!
+ session_save_path(getConfig('session_save_path'));
+ } // END - if
} // END - if
+// Is a session id there?
if (session_id() == '') {
// Start the session
session_start();
$GLOBALS['is_installed'] = (
(
// First is config
- getConfig('MXCHANGE_INSTALLED') == 'Y'
+ (
+ (
+ isConfigEntrySet('MXCHANGE_INSTALLED')
+ ) && (
+ getConfig('MXCHANGE_INSTALLED') == 'Y'
+ )
+ )
) || (
// New config file found and loaded
isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php')
// Check wether an admin is registered
function isAdminRegistered () {
- return (getConfig('ADMIN_REGISTERED') == 'Y');
+ return ((isConfigEntrySet('ADMIN_REGISTERED')) && (getConfig('ADMIN_REGISTERED') == 'Y'));
}
// Checks wether the reset mode is active
// Checks wether the debug mode is enabled
function isDebugModeEnabled () {
// Simply check it
- return (getConfig('DEBUG_MODE') == 'Y');
+ return ((isConfigEntrySet('DEBUG_MODE')) && (getConfig('DEBUG_MODE') == 'Y'));
}
// Checks wether we shall debug regular expressions
function isDebugRegExpressionEnabled () {
// Simply check it
- return (getConfig('DEBUG_REGEX') == 'Y');
+ return ((isConfigEntrySet('DEBUG_REGEX')) && (getConfig('DEBUG_REGEX') == 'Y'));
}
// Checks wether the cache instance is valid
`resend_profile_update` BIGINT(20) UNSIGNED NOT NULL DEFAULT '172800',
`patch_level` VARCHAR(100) NOT NULL DEFAULT '78',
`patch_ctime` VARCHAR(10) NOT NULL DEFAULT 0,
- `code_length` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5,
`guest_stats` ENUM('MEMBERS','MODULES','INACTIVE') NOT NULL DEFAULT 'MEMBERS',
`ref_payout` TINYINT(3) UNSIGNED NOT NULL DEFAULT 5,
`activate_xchange` BIGINT(20) UNSIGNED NOT NULL DEFAULT 100,
// Set content type
setContentType('text/html');
-// Is the extension active
+// Is the extension mailid active?
redirectOnUninstalledExtension('mailid');
+// Is the extension other active?
+redirectOnUninstalledExtension('other');
+
// Init variables
$url_userid = 0;
$url_bid = 0;