// 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);
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);
}
// 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)
{
// 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;
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
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
Subject : ".$SUBJECT."
Message : ".$MSG."
</pre>\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)) {
//
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 "<pre>";
+ debug_print_backtrace();
+ die("</pre>");
+ } // END - if
+
$ARRAY = $SEC_CHARS;
// Select smaller set of chars to replace when we e.g. want to compile URLs
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")) {
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
// Is this a valid reset file?
//* DEBUG: */ echo __FUNCTION__.":baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}<br />\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);
// 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
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");
$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)
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
$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";
$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
// Check if password is same
//* DEBUG: */ echo "*".$ret.",".$data['password'].",".$password.",".$salt."*<br >\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);
// 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);
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')) {
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?
$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);
}
// 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") {
// 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']));
}
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 = "<SELECT name=\"country_code\" class=\"guest_select\" size=\"1\">\n";
$whereStatement = "WHERE is_active='Y'";
$OUT .= ADD_OPTION_LINES("countries", "id", "descr", $_POST['country_code'], "code", $whereStatement);
$OUT .= "</SELECT>";
define('__COUNTRY_CONTENT', $OUT);
- }
- else
- {
+ } else {
// Old out-dated variant
define('__COUNTRY_CONTENT', "<INPUT type=\"text\" name=\"cntry\" class=\"guest_normal\" size=\"2\" maxlength=\"3\" value=\"".__COUNTRY."\">");
}
$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=",
)
);
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
// Load row
list($ret) = SQL_FETCHROW($result);
- //* DEBUG: */ echo __LINE__."*".$DATA."/".$search."/".$tableName."/".$ret."*<br />\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;
}
/**
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'])) {
// 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'])) {
$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;
// 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";
<TR>
<TD align="right" width="50%" class="register_left">
- {--REFID_BY--}: </TD>
- <TD width="50%" class="register_right"><INPUT type="text"
- name="refid" class="register_normal" size="5" maxlength="10"
- value="$content" /></TD>
+ {--REFID_BY--}: </TD>
+ <TD width="50%" class="register_right">
+ <INPUT type="text" name="refid" class="register_normal" size="5" maxlength="10" value="$content" />
+ </TD>
</TR>
<TR>
<TD align="right" width="50%" class="register_left">
- {--REFID_BY--}: </TD>
- <TD width="50%" class="register_right"><STRONG>$content</STRONG> <INPUT
- type="hidden" name="refid" value="$content" /></TD>
+ {--REFID_BY--}: </TD>
+ <TD width="50%" class="register_right">
+ <STRONG>$content</STRONG>
+ <INPUT type="hidden" name="refid" value="$content" />
+ </TD>
</TR>