From 831c60d4cec333ea95e0ce23d9e53fd5d8133ce6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 27 Sep 2008 18:22:02 +0000 Subject: [PATCH] More fixes for reflink and rallye extension --- inc/config.php | 3 + inc/databases.php | 2 +- inc/extensions/ext-sql_patches.php | 13 +++- inc/functions.php | 37 ++++++++-- inc/libs/rallye_functions.php | 57 ++++++++++---- inc/modules/admin.php | 2 + inc/modules/admin/admin-inc.php | 6 +- inc/modules/guest/what-confirm.php | 39 ++++------ inc/modules/guest/what-register.php | 74 +++++++------------ inc/modules/guest/what-wernis_portal.php | 8 +- inc/mysql-manager.php | 20 ++--- inc/session.php | 6 +- lead-confirm.php | 5 +- ref.php | 12 ++- .../de/html/guest/guest_register_refid.tpl | 8 +- .../html/guest/guest_register_refid_hide.tpl | 8 +- 16 files changed, 173 insertions(+), 127 deletions(-) diff --git a/inc/config.php b/inc/config.php index 08df3c6eff..4f90620e1a 100644 --- a/inc/config.php +++ b/inc/config.php @@ -106,6 +106,9 @@ define('admin_registered', false); // CFG: DEBUG-MODE (if enabled all mails will be *displayed* and *not* send!) define('DEBUG_MODE', false); +// CFG: DEBUG-MAIL (turn this on if you need to debug mails, only affects if DEBUG_MODE is true) +//define('DEBUG_MAIL', true); + // When we are not installing if (!defined('mxchange_installing')) define('mxchange_installing', false); diff --git a/inc/databases.php b/inc/databases.php index 1ee3935f7d..16d8b8cdaf 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -113,7 +113,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // This current patch level -define('CURR_SVN_REVISION', "397"); +define('CURR_SVN_REVISION', "399"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index 2efdb59de6..7e99c8bfa4 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -38,13 +38,13 @@ if (!defined('__SECURITY')) { } // Version number -$EXT_VERSION = "0.4.8"; +$EXT_VERSION = "0.4.9"; // Auto-set extension version if (!isset($EXT_VER)) $EXT_VER = $EXT_VERSION; // Version history array (add more with , "0.1" and so on) -$EXT_VER_HISTORY = 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"); +$EXT_VER_HISTORY = 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"); switch ($EXT_LOAD_MODE) { @@ -623,6 +623,15 @@ PRIMARY KEY (id) // Update notes (these will be set as task text!) $UPDATE_NOTES = "Index für Betreff eingefügt."; break; + + case "0.4.9": // SQL queries for v0.4.9 + $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data CHANGE `user_hash` `user_hash` VARCHAR(255) NULL DEFAULT NULL"; + $SQLs[] = "UPDATE "._MYSQL_PREFIX."_user_data SET user_hash=NULL WHERE user_hash IS NOT NULL AND status='CONFIRMED'"; + $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_user_data` ADD UNIQUE (`user_hash`)"; + + // Update notes (these will be set as task text!) + $UPDATE_NOTES = "User-Hash zum Bestätigen wird auf NULL gesetzt, wenn Account bestätigt wird."; + break; } break; diff --git a/inc/functions.php b/inc/functions.php index 9a7b1fc6f1..3dcee7a5cc 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -134,7 +134,7 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { ob_end_clean(); // Extension "rewrite" installed? - if ((EXT_IS_ACTIVE("rewrite", true)) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) { + if ((EXT_IS_ACTIVE("rewrite")) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) { $OUTPUT = REWRITE_LINKS($OUTPUT); } // END - if @@ -157,7 +157,7 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { OUTPUT_RAW($OUTPUT); } elseif ((OUTPUT_MODE == "render") && (!empty($OUTPUT))) { // Rewrite links when rewrite extension is active - if ((EXT_IS_ACTIVE("rewrite", true)) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) { + if ((EXT_IS_ACTIVE("rewrite")) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) { $OUTPUT = REWRITE_LINKS($OUTPUT); } // END - if @@ -420,7 +420,10 @@ To : ".$TO." Subject : ".$SUBJECT." Message : ".$MSG." \n"; - } elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail", true))) { + + // Log the mail away + if (defined('DEBUG_MAIL')) DEBUG_LOG(__FUNCTION__.":to={$TO},subject={$SUBJECT},msg={$MSG}"); + } elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail"))) { // Send mail as HTML away SEND_HTML_EMAIL($TO, $SUBJECT, $MSG, $FROM); } elseif (!empty($TO)) { @@ -898,6 +901,15 @@ function LOAD_URL($URL, $addUrlData=true) { // function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) { global $SEC_CHARS, $URL_CHARS; + // Is the code a string? + if (!is_string($code)) { + // Abort here with backtrace + DEBUG_LOG(__FUNCTION__.": code is not string!"); + print "
";
+		debug_print_backtrace();
+		die("
"); + } // END - if + $ARRAY = $SEC_CHARS; // Select smaller set of chars to replace when we e.g. want to compile URLs @@ -1908,7 +1920,7 @@ function CREATE_EMAIL_LINK($email, $table="admins") { if ((EXT_IS_ACTIVE("admins")) && ($table == "admins")) { // Create email link for contacting admin in guest area $EMAIL = ADMINS_CREATE_EMAIL_LINK($email); - } elseif ((EXT_IS_ACTIVE("user", true)) && (GET_EXT_VERSION("user") >= "0.3.3") && ($table == "user_data")) { + } elseif ((EXT_IS_ACTIVE("user")) && (GET_EXT_VERSION("user") >= "0.3.3") && ($table == "user_data")) { // Create email link for contacting a member within admin area (or later in other areas, too?) $EMAIL = USER_CREATE_EMAIL_LINK($email); } elseif ((EXT_IS_ACTIVE("sponsor")) && ($table == "sponsor_data")) { @@ -1927,7 +1939,7 @@ function generateHash ($plainText, $salt = "") { global $_CONFIG, $_SERVER; // Is the required extension "sql_patches" there and a salt is not given? - if (((EXT_VERSION_IS_OLDER("sql_patches", "0.3.6")) || (EXT_IS_ACTIVE("sql_patches"))) && (empty($salt))) { + if (((EXT_VERSION_IS_OLDER("sql_patches", "0.3.6")) || (!EXT_IS_ACTIVE("sql_patches"))) && (empty($salt))) { // Extension sql_patches is missing/outdated so we return the plain text return $plainText; } // END - if @@ -2333,7 +2345,7 @@ function GET_DIR_AS_ARRAY ($baseDir, $prefix) { // Is this a valid reset file? //* DEBUG: */ echo __FUNCTION__.":baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}
\n"; - if ((is_file($file)) && (is_readable($file)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) { + if ((FILE_READABLE($file)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) { // Remove both for extension name $extName = substr($baseFile, strlen($prefix), -4); @@ -2529,8 +2541,17 @@ function REBUILD_CACHE ($cache, $inc="") { // Include file given? if (!empty($inc)) { - // And rebuild it from scratch - require_once(PATH."inc/loader/load_cache-".$inc.".php"); + // Construct FQFN + $fqfn = sprintf("%sinc/loader/load_cache-%s.php", PATH, $inc); + + // Is the include there? + if (FILE_READABLE($fqfn)) { + // And rebuild it from scratch + require_once($fqfn); + } else { + // Include not found! + DEBUG_LOG(__FUNCTION__.":Include {$inc} not found. cache={$cache}"); + } } // END - if } // END - if } // END - if diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index 796356caca..36e85f6c07 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -280,32 +280,44 @@ LIMIT 1", array(bigintval($uid), $_CONFIG['ref_payout'], $since), __FILE__, __LI function RALLYE_AUTOADD_USER($uid) { global $DATA; + $ADD = ""; + + // Updated extension? + if (GET_EXT_VERSION("rallye") >= "0.2.0") { + $ADD .= ", min_users, min_prices"; + } // END - if + // Check for an auto-add rallye - $result = SQL_QUERY("SELECT id, title, start_time, end_time, send_notify FROM "._MYSQL_PREFIX."_rallye_data WHERE is_active='Y' AND notified='Y' AND auto_add_new_user='Y' AND expired='N' LIMIT 1", __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + $result = SQL_QUERY("SELECT id, title, start_time, end_time, send_notify".$ADD." FROM "._MYSQL_PREFIX."_rallye_data WHERE is_active='Y' AND notified='Y' AND auto_add_new_user='Y' AND expired='N' LIMIT 1", __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { + // Init variables + $min_users = 0; $min_prices = 0; // Load data - list($id, $title, $start, $end, $notify) = SQL_FETCHROW($result); + if (GET_EXT_VERSION("rallye") >= "0.2.0") { + list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result); + } else { + list($id, $title, $start, $end, $notify) = SQL_FETCHROW($result); + } + + // Free result SQL_FREERESULT($result); // Check if line is already included... $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%s AND userid=%s LIMIT 1", - array(bigintval($id), bigintval($uid)), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) - { + array(bigintval($id), bigintval($uid)), __FILE__, __LINE__); + + // Is this user added? + if (SQL_NUMROWS($result) == 0) { // Add userid and his ref count to table $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_rallye_users (rallye_id, userid, refs) VALUES ('%s','%s','0')", array(bigintval($id), bigintval($uid)), __FILE__, __LINE__); - } - else - { + } else { // Free memory SQL_FREERESULT($result); } - if ($notify == "Y") - { + if ($notify == "Y") { // Transfer all neccessary data to the global $DATA array $DATA['start'] = MAKE_DATETIME($start, "2"); $DATA['end'] = MAKE_DATETIME($end , "2"); @@ -313,15 +325,32 @@ VALUES ('%s','%s','0')", $DATA['title'] = $title; $DATA['id'] = $id; // ID for the rallye details link $DATA['ref'] = 0; + $DATA['refs'] = GET_TOTAL_DATA($uid, "user_data", "userid", "refid", true); // Load prices $prices = RALLYE_ADD_PRICES($id); + if ($min_users == 0) { + // Rallye ends without user limitation + $DATA['min_users'] = RALLYE_END_NO_USER_LIMITATION; + } else { + // Rallye ends when X members are totally in your exchange + $DATA['min_users'] = RALLYE_END_USERS_1." ".$min_users." ".RALLYE_END_USERS_2; + } + + if ($min_prices == 0) { + // Rallye ends without user limitation + $DATA['min_prices'] = RALLYE_END_NO_PRICE_LIMITATION; + } else { + // Rallye ends when X members are totally in your exchange + $DATA['min_prices'] = RALLYE_END_PRICES_1." ".$min_prices." ".RALLYE_END_PRICES_2; + } + // Send notification to member $msg = LOAD_EMAIL_TEMPLATE("member_rallye_notify", array('prices' => $prices), $uid); SEND_EMAIL($uid, RALLYE_MEMBER_NOTIFY.$title, $msg); - } - } + } // END - if + } // END - if } // function RALLYE_EXPIRE_RALLYES($result) diff --git a/inc/modules/admin.php b/inc/modules/admin.php index d1a7284046..06823fef11 100644 --- a/inc/modules/admin.php +++ b/inc/modules/admin.php @@ -203,6 +203,8 @@ if (!isBooleanConstantAndTrue('admin_registered')) { if ((isset($_POST['ok'])) && ($_POST['ok'] != "***")) { // All required data was entered so we check his account $ret = CHECK_ADMIN_LOGIN($_POST['login'], $_POST['pass']); + + // Which status do we have? switch ($ret) { case "done": // Admin and password are okay, so we log in now diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index f391b42a8c..74ba0ce258 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -67,7 +67,7 @@ function CHECK_ADMIN_LOGIN ($admin_login, $password) $data = array(); // Is the cache valid? - if (!empty($cacheArray['admins']['aid'][$admin_login])) { + if (!empty($cacheArray['admins']['password'][$admin_login])) { // Get password from cache $data['password'] = $cacheArray['admins']['password'][$admin_login]; $ret = "pass"; @@ -79,7 +79,7 @@ function CHECK_ADMIN_LOGIN ($admin_login, $password) $data['login_failtures'] = $cacheArray['admins']['login_failtures'][$admin_login]; $data['last_failture'] = $cacheArray['admins']['last_failture'][$admin_login]; } // END - if - } elseif (GET_EXT_VERSION("cache") == "") { + } elseif (EXT_IS_ACTIVE("cache")) { $ADD = ""; if (GET_EXT_VERSION("admins") >= "0.7.0") { // Load them here @@ -122,7 +122,7 @@ function CHECK_ADMIN_LOGIN ($admin_login, $password) // Check if password is same //* DEBUG: */ echo "*".$ret.",".$data['password'].",".$password.",".$salt."*
\n"; - if (($ret == "pass") && ($data['password'] == generateHash($password, $salt)) && (!empty($salt))) { + if (($ret == "pass") && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == $password)) { // Re-hash the plain passord with new random salt $data['password'] = generateHash($password); diff --git a/inc/modules/guest/what-confirm.php b/inc/modules/guest/what-confirm.php index 7d554b5f3d..22acf14e50 100644 --- a/inc/modules/guest/what-confirm.php +++ b/inc/modules/guest/what-confirm.php @@ -40,37 +40,32 @@ if (!defined('__SECURITY')) { // Add description as navigation point ADD_DESCR("guest", basename(__FILE__)); -if (!empty($_GET['hash'])) -{ +if (!empty($_GET['hash'])) { // Initialize the user ID $uid = 0; // Search for an unconfirmed or confirmed account $result = SQL_QUERY_ESC("SELECT userid, email, refid FROM "._MYSQL_PREFIX."_user_data WHERE user_hash='%s' AND (status='UNCONFIRMED' OR status='CONFIRMED') LIMIT 1", - array($_GET['hash']), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + array($_GET['hash']), __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 1) { // Ok, he want's to confirm now so we load some data list ($uid, $email, $rid) = SQL_FETCHROW($result); // Unlock his account (but only when it is on UNCONFIRMED!) - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED', ref_payout='%s' WHERE user_hash='%s' AND status='UNCONFIRMED' LIMIT 1", - array($_CONFIG['ref_payout'], $_GET['hash']), __FILE__, __LINE__); - if (SQL_AFFECTEDROWS() == 1) - { + $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED', ref_payout=%s, user_hash=NULL WHERE user_hash='%s' AND status='UNCONFIRMED' LIMIT 1", + array($_CONFIG['ref_payout'], $_GET['hash']), __FILE__, __LINE__); + if (SQL_AFFECTEDROWS() == 1) { $msg = LOAD_EMAIL_TEMPLATE("confirm-member", array('points' => $_CONFIG['points_register']), bigintval($uid)); // And send him right away the confirmation mail SEND_EMAIL($email, GUEST_THANX_CONFIRM, $msg); // Maybe he got "referraled"? - if (($rid > 0) && ($rid != $uid)) - { + if (($rid > 0) && ($rid != $uid)) { // Select the referral userid $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($rid)), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + if (SQL_NUMROWS($result) == 1) { // Update ref counter... UPDATE_REF_COUNTER($rid); @@ -78,38 +73,34 @@ if (!empty($_GET['hash'])) unset($DEPTH); // Shall I "pay" the referral points imidiately? - if ($_CONFIG['ref_payout'] == "0") - { + if ($_CONFIG['ref_payout'] == "0") { // Yes, "pay" it now $locked = false; - } - else - { + } else { // No, "pay" it later $locked = true; } // If version matches add ref bonus to refid's account - if ((GET_EXT_VERSION("bonus") >= "0.4.4") && ($_CONFIG['bonus_active'] == "Y")) - { + if ((GET_EXT_VERSION("bonus") >= "0.4.4") && ($_CONFIG['bonus_active'] == "Y")) { // Add points (directly only!) $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET bonus_ref=bonus_ref+%s WHERE userid=%s LIMIT 1", array($_CONFIG['bonus_ref'], bigintval($rid)), __FILE__, __LINE__); // Subtract points from system BONUS_POINTS_HANDLER($_CONFIG['bonus_ref']); - } + } // END - if // Add one-time referral bonus over referral system or directly $DEPTH = 0; ADD_POINTS_REFSYSTEM($rid, $_CONFIG['points_ref'], true, bigintval($uid), $locked, $_CONFIG['reg_points_mode']); - } - } + } // END - if + } // END - if if (EXT_IS_ACTIVE("rallye")) { // Add user to rallye (or not?) RALLYE_AUTOADD_USER(bigintval($uid)); - } + } // END - if // Account confirmed! if (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) { diff --git a/inc/modules/guest/what-register.php b/inc/modules/guest/what-register.php index 71f2c44439..b020a6d4e2 100644 --- a/inc/modules/guest/what-register.php +++ b/inc/modules/guest/what-register.php @@ -68,8 +68,23 @@ if (empty($_POST['city'])) $_POST['city'] = ""; if (empty($_POST['cntry'])) $_POST['cntry'] = ""; if (empty($_POST['country_code'])) $_POST['country_code'] = "1"; -if (isset($_POST['ok'])) -{ +// Default refid is zero +$_POST['refid'] = 0; +if ($GLOBALS['refid'] > 0) { + // Test if the refid is valid + $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", + array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__); + if (SQL_NUMROWS($result) == 0) { + // Not found so we set your refid! + $_POST['refid'] = $_CONFIG['def_refid']; + set_session('refid', $_CONFIG['def_refid']); + } else { + // Use the refid here + $_POST['refid'] = $GLOBALS['refid']; + } +} // END - if + +if (isset($_POST['ok'])) { // First we only check the submitted data then we continue... :) // // Did he agree to our Terms Of Usage? @@ -155,19 +170,6 @@ if (isset($_POST['ok'])) $FAILED = true; } - // Default refid is zero - $_POST['refid'] = 0; - if ($GLOBALS['refid'] > 0) { - // Test if the refid is valid - $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", - array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 0) { - // Not found so we set your refid! - $_POST['refid'] = $_CONFIG['def_refid']; - set_session("refid", $_CONFIG['def_refid']); - } // END - if - } // END - if - // Free memory SQL_FREERESULT($result); } @@ -183,25 +185,22 @@ if ((isset($_POST['ok'])) && (!$FAILED)) // Add design when extension sql_patches is v0.2.7 or greater $ADD1 = ""; $ADD2 = ""; - if (GET_EXT_VERSION("sql_patches") >= "0.2.7") - { + if (GET_EXT_VERSION("sql_patches") >= "0.2.7") { // Okay, add design here $ADD1 = ", curr_theme"; $ADD2 = ", '".GET_CURR_THEME()."'"; - } + } // END - if // Check if I shall disable sending mail to newly registered members out about active/begging rallye // // First comes first: begging rallye - if (GET_EXT_VERSION("beg") >= "0.1.7") - { + if (GET_EXT_VERSION("beg") >= "0.1.7") { // Okay, shall I disable now? - if ($_CONFIG['beg_new_mem_notify'] == "N") - { + if ($_CONFIG['beg_new_mem_notify'] == "N") { $ADD1 .= ", beg_ral_notify, beg_ral_en_notify"; $ADD2 .= ", UNIX_TIMESTAMP(), UNIX_TIMESTAMP()"; - } - } + } // END - if + } // END - if // Second: active rallye if (GET_EXT_VERSION("bonus") >= "0.7.7") { @@ -396,28 +395,12 @@ VALUES ('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONF // Adds maximum receiveable mails list... :) define('MAX_RECEIVE_LIST', ADD_MAX_RECEIVE_LIST("guest", "", true)); - // Check if nickname extension is active and get state if nickname is selected or userid - $nick = false; - if (EXT_IS_ACTIVE("nickname")) $nick = NICKNAME_IS_ACTIVE($GLOBALS['refid']); - - // Is the nickname valid? - if (!$nick) { - // Nope, disable it - if (GET_EXT_VERSION("sql_patches") != '') { - // Use default refid - $GLOBALS['refid'] = $_CONFIG['def_refid']; - } else { - // Set zero - $GLOBALS['refid'] = 0; - } - } // END - if - // Shall I display the refid or shall I make it editable? if ($_CONFIG['display_refid'] == "Y") { - // Load template to enter it + // Load "hide" form template define('REFID_CONTENT', LOAD_TEMPLATE("guest_register_refid_hide", true, $GLOBALS['refid'])); } else { - // Load "hide" form template + // Load template to enter it define('REFID_CONTENT', LOAD_TEMPLATE("guest_register_refid", true, $GLOBALS['refid'])); } @@ -437,8 +420,7 @@ VALUES ('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONF define('__ADDY', SQL_ESCAPE($_POST['addy'])); // Shall I add a counrty selection box or the old input box? - if (EXT_IS_ACTIVE("country")) - { + if (EXT_IS_ACTIVE("country")) { // New variant, good! $OUT = ""; define('__COUNTRY_CONTENT', $OUT); - } - else - { + } else { // Old out-dated variant define('__COUNTRY_CONTENT', ""); } diff --git a/inc/modules/guest/what-wernis_portal.php b/inc/modules/guest/what-wernis_portal.php index 5c82e8d187..c747674116 100644 --- a/inc/modules/guest/what-wernis_portal.php +++ b/inc/modules/guest/what-wernis_portal.php @@ -51,10 +51,10 @@ $rdf->set_salt(SITE_KEY); $rdf->set_max_item(10); $rdf->set_Options( array( - "textinput" => "hidden", - "sitelink" => "http://www.wds66.com", - "refid" => bigintval($_CONFIG['wernis_refid']), - "reflink" => "/ref.php?refid=", + 'textinput' => "hidden", + 'sitelink' => "http://www.wds66.com", + 'refid' => bigintval($_CONFIG['wernis_refid']), + 'reflink' => "/ref.php?refid=", ) ); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 717865cbaa..83677bd75b 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1060,8 +1060,7 @@ function REMOVE_RECEIVER(&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=fal return $ret; } // -function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false) -{ +function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false) { $ret = 0; if ($onlyRows) { // Count rows @@ -1075,15 +1074,16 @@ function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", // Load row list($ret) = SQL_FETCHROW($result); - //* DEBUG: */ echo __LINE__."*".$DATA."/".$search."/".$tableName."/".$ret."*
\n"; + + // Free result SQL_FREERESULT($result); - if (empty($ret)) { - if (($lookFor == "counter") || ($lookFor == "id")) { - $ret = 0; - } else { - $ret = "0.00000"; - } - } + + // Fix empty values + if ((empty($ret)) && ($lookFor != "counter") && ($lookFor != "id") && ($lookFor != "userid")) { + $ret = "0.00000"; + } // END - if + + // Return value return $ret; } /** diff --git a/inc/session.php b/inc/session.php index 2c7ab4488d..4c93c2267c 100644 --- a/inc/session.php +++ b/inc/session.php @@ -57,7 +57,7 @@ set_session("mx_lang", $mx_lang); require_once(PATH."inc/load_extensions.php"); // Check if refid is set -if ((!empty($_GET['user'])) && ($CLICK == 1) && ($_SERVER['PHP_SELF'] == "click.php")) { +if ((!empty($_GET['user'])) && ($CLICK == 1) && (basename($_SERVER['PHP_SELF']) == "click.php")) { // The variable user comes from the click-counter script click.php and we only accept this here $GLOBALS['refid'] = bigintval($_GET['user']); } elseif (!empty($_POST['refid'])) { @@ -83,8 +83,8 @@ if ((!empty($_GET['user'])) && ($CLICK == 1) && ($_SERVER['PHP_SELF'] == "click. // Set cookie when default refid > 0 if (!isSessionVariableSet('refid') || (!empty($GLOBALS['refid'])) || ((get_session('refid') == "0") && ($_CONFIG['def_refid'] > 0))) { // Set cookie - set_session("refid", $GLOBALS['refid']); -} + set_session('refid', $GLOBALS['refid']); +} // END - if // Transfer userid from session and validate it if (isset($_SESSION['userid'])) { diff --git a/lead-confirm.php b/lead-confirm.php index 0f62cef8d7..d9724b7696 100644 --- a/lead-confirm.php +++ b/lead-confirm.php @@ -66,7 +66,10 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { $content['lead_uid'] = bigintval(get_session('lead_uid')); // Load the email address - list($content['lead_email']) = COMPILE_CODE(SQL_FETCHROW($result)); + list($email) = SQL_FETCHROW($result); + + // Compile email + $content['lead_email'] = COMPILE_CODE($email); } else { // Not found! $content['lead_uid'] = 0; diff --git a/ref.php b/ref.php index e6e51d7b83..905abf7122 100644 --- a/ref.php +++ b/ref.php @@ -75,12 +75,18 @@ if (isBooleanConstantAndTrue('mxchange_installed')) { // Also edit this 0 ! if (empty($ref)) $ref = 0; + // Update session + set_session('refid', $ref); + // We have an refid here. So we simply add it $URL .= bigintval($ref); - // Update ref counter - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ref_clicks=ref_clicks+1 WHERE userid=%s LIMIT 1", - array(bigintval($ref)), __FILE__, __LINE__); + // Is the refid valid? + if ($ref > 0) { + // Update ref counter + $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ref_clicks=ref_clicks+1 WHERE userid=%s LIMIT 1", + array(bigintval($ref)), __FILE__, __LINE__); + } // END - if } else { // No refid and we add our refid (don't forget to set $def_refid!) $URL = URL."/index.php"; diff --git a/templates/de/html/guest/guest_register_refid.tpl b/templates/de/html/guest/guest_register_refid.tpl index 55fa291a84..ca630b76ab 100644 --- a/templates/de/html/guest/guest_register_refid.tpl +++ b/templates/de/html/guest/guest_register_refid.tpl @@ -1,7 +1,7 @@ - {--REFID_BY--}:   - + {--REFID_BY--}:   + + + diff --git a/templates/de/html/guest/guest_register_refid_hide.tpl b/templates/de/html/guest/guest_register_refid_hide.tpl index dd3e841ef8..dd219f69b6 100644 --- a/templates/de/html/guest/guest_register_refid_hide.tpl +++ b/templates/de/html/guest/guest_register_refid_hide.tpl @@ -1,6 +1,8 @@ - {--REFID_BY--}:   - $content + {--REFID_BY--}:   + + $content + + -- 2.39.5