-$FAILED = false; $SHORT_PASS = false; $cats = 0; $IP_TIMEOUT = false;
-if (!isset($_POST['ok'])) unset($_POST['ok']);
-if (empty($_POST['agree'])) $_POST['agree'] = "";
-if (empty($_POST['addy'])) $_POST['addy'] = "";
-if (empty($_POST['surname'])) $_POST['surname'] = "";
-if (empty($_POST['family_name'])) $_POST['family_name'] = "";
-if (empty($_POST['pass1'])) $_POST['pass1'] = "";
-if (empty($_POST['pass2'])) $_POST['pass2'] = "";
-if (empty($_POST['day'])) $_POST['day'] = "";
-if (empty($_POST['month'])) $_POST['month'] = "";
-if (empty($_POST['year'])) $_POST['year'] = "";
-if (empty($_POST['max_mails'])) $_POST['max_mails'] = "";
-if (empty($_POST['street_nr'])) $_POST['street_nr'] = "";
-if (empty($_POST['zip'])) $_POST['zip'] = "";
-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']))
-{
+$isFailed = false;
+$shortPass = false;
+$cats = 0;
+$ipTimedOut = false;
+
+/**
+ * @TODO Commented out, do we need this ugly code?
+if (!isFormSent()) REQUEST_UNSET_POST('ok');
+
+if (!REQUEST_ISSET_POST('agree')) REQUEST_SET_POST('agree' , '');
+if (!REQUEST_ISSET_POST('addy')) REQUEST_SET_POST('addy' , '');
+if (!REQUEST_ISSET_POST('surname')) REQUEST_SET_POST('surname' , '');
+if (!REQUEST_ISSET_POST('family')) REQUEST_SET_POST('family' , '');
+if (!REQUEST_ISSET_POST('pass1')) REQUEST_SET_POST('pass1' , '');
+if (!REQUEST_ISSET_POST('pass2')) REQUEST_SET_POST('pass2' , '');
+if (!REQUEST_ISSET_POST('day')) REQUEST_SET_POST('day' , '');
+if (!REQUEST_ISSET_POST('month')) REQUEST_SET_POST('month' , '');
+if (!REQUEST_ISSET_POST('year')) REQUEST_SET_POST('year' , '');
+if (!REQUEST_ISSET_POST('max_mails')) REQUEST_SET_POST('max_mails' , '');
+if (!REQUEST_ISSET_POST('street_nr')) REQUEST_SET_POST('street_nr' , '');
+if (!REQUEST_ISSET_POST('zip')) REQUEST_SET_POST('zip' , '');
+if (!REQUEST_ISSET_POST('city')) REQUEST_SET_POST('city' , '');
+if (!REQUEST_ISSET_POST('cntry')) REQUEST_SET_POST('cntry' , '');
+if (!REQUEST_ISSET_POST('country_code')) REQUEST_SET_POST('country_code', '1');
+*/
+
+// Default refid is zero
+REQUEST_SET_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__);
+
+ // Userid found?
+ //* DEBUG: */ die("refid={$GLOBALS['refid']}/numRows=".SQL_NUMROWS($result)."");
+ if (SQL_NUMROWS($result) == 0) {
+ // Not found so we set your refid!
+ REQUEST_SET_POST('refid', getConfig('def_refid'));
+ setSession('refid', getConfig('def_refid'));
+ } else {
+ // Use the refid here
+ REQUEST_SET_POST('refid', $GLOBALS['refid']);
+ }
+} // END - if
+
+if (isFormSent()) {