if (!defined('__SECURITY')) {
$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
require($INC);
+} elseif ((!EXT_IS_ACTIVE("sponsor"))) {
+ if (IS_ADMIN()) {
+ ADD_FATAL(sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "sponsor"));
+ } else {
+ ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "sponsor");
+ }
+ return;
}
// Add description as navigation point
// Check submitted form data
//
// 1. Salutation / Surname / family name
- if (empty($_POST['gender']))
- {
+ if (empty($_POST['gender'])) {
// Surname is empty
$FORM_ERRORS[] = SPONSOR_NO_GENDER_SELECTED;
}
- if (empty($_POST['surname']))
- {
+
+ if (empty($_POST['surname'])) {
// Surname is empty
$FORM_ERRORS[] = SPONSOR_SURNAME_IS_EMPTY;
}
- if (empty($_POST['family']))
- {
+
+ if (empty($_POST['family'])) {
// Surname is empty
$FORM_ERRORS[] = SPONSOR_FAMILY_IS_EMPTY;
}
+
// 2. Company name
- // 012 3 32 23 4 43 3 4 4321 12 3 32 2 3 3210
- if (((empty($_POST['company'])) && ((!empty($_POST['tax_ident'])) || (!empty($_POST['position'])))) || ((!empty($_POST['company'])) && (empty($_POST['tax_ident']))))
- {
- if (empty($_POST['company']))
- {
+ // 012 3 32 23 4 43 3 4 4321 12 3 32 2 3 3210
+ if (((empty($_POST['company'])) && ((!empty($_POST['tax_ident'])) || (!empty($_POST['position'])))) || ((!empty($_POST['company'])) && (empty($_POST['tax_ident'])))) {
+ if (empty($_POST['company'])) {
// Company name is empty
$FORM_ERRORS[] = SPONSOR_COMPANY_IS_EMPTY;
- }
- elseif (empty($_POST['tax_ident']))
- {
+ } elseif (empty($_POST['tax_ident'])) {
// Tax ident number name is empty
$FORM_ERRORS[] = SPONSOR_TAX_IDENT_IS_EMPTY;
}
- if (empty($_POST['position']))
- {
+
+ if (empty($_POST['position'])) {
// Not fatal but not nice: position in company is empty
$FORM_ERRORS[] = SPONSOR_POSITION_IS_EMPTY;
}
}
+
// 3. Street and number
- if (empty($_POST['street_nr1']))
- {
+ if (empty($_POST['street_nr1'])) {
// Street name and house number are empty
$FORM_ERRORS[] = SPONSOR_STREET_NR1_IS_EMPTY;
- }
- elseif ((!empty($_POST['street_nr2'])) && (empty($_POST['street_nr1'])))
- {
+ } elseif ((!empty($_POST['street_nr2'])) && (empty($_POST['street_nr1']))) {
// 1st line for street is empty, but 2nd line not
$FORM_ERRORS[] = SPONSOR_STREET_NR1_IS_EMPTY_2_NOT;
}
+
// 4. Country code
- if (empty($_POST['country']))
- {
+ if (empty($_POST['country'])) {
// Country code is empty
$FORM_ERRORS[] = SPONSOR_COUNTRY_IS_EMPTY;
- }
- elseif (strlen($_POST['country']) != 2)
- {
+ } elseif (strlen($_POST['country']) != 2) {
// Country code is invalid
$FORM_ERRORS[] = SPONSOR_COUNTRY_IS_INVALID;
}
+
// 3. ZIP code
- if (empty($_POST['zip']))
- {
+ if (empty($_POST['zip'])) {
// ZIP code is empty
$FORM_ERRORS[] = SPONSOR_ZIP_IS_EMPTY;
- }
- elseif (bigintval($_POST['zip']) != $_POST['zip'])
- {
+ } elseif (bigintval($_POST['zip']) != $_POST['zip']) {
// ZIP is invalid
$FORM_ERRORS[] = SPONSOR_ZIP_IS_INVALID;
$_POST['zip'] = "";
}
+
// 4. City
- if (empty($_POST['city']))
- {
+ if (empty($_POST['city'])) {
// City is empty
$FORM_ERRORS[] = SPONSOR_CITY_IS_EMPTY;
}
+
// 5. Phone number
- if (empty($_POST['phone']))
- {
+ if (empty($_POST['phone'])) {
// City is empty
$FORM_ERRORS[] = SPONSOR_PHONE_IS_EMPTY;
}
+
// 6. Homepage URL
- if (empty($_POST['url']))
- {
+ if (empty($_POST['url'])) {
// Homepage URL is empty
$FORM_ERRORS[] = SPONSOR_URL_IS_EMPTY;
- }
- elseif (!VALIDATE_URL($_POST['url']))
- {
+ } elseif (!VALIDATE_URL($_POST['url'])) {
// Homepage URL is invalid
$FORM_ERRORS[] = SPONSOR_URL_IS_INVALID;
$_POST['url'] = "";
}
+
// 7. Light validation of email address
- if ((empty($_POST['email'])) || ($_POST['email'] == "@"))
- {
+ if ((empty($_POST['email'])) || ($_POST['email'] == "@")) {
// Email is invalid/empty
$FORM_ERRORS[] = SPONSOR_EMAIL_IS_INVALID;
- }
- elseif (SPONSOR_FOUND_EMAIL_DB($_POST['email']))
- {
+ } elseif (SPONSOR_FOUND_EMAIL_DB($_POST['email'])) {
// Email already found in database!
$FORM_ERRORS[] = SPONSOR_EMAIL_IS_ALREADY_REGISTERED;
$_POST['email'] = "";
}
}
// Is the password long enough?
- elseif (strlen($_POST['pass1']) < $_CONFIG['pass_len'])
+ elseif (strlen($_POST['pass1']) < getConfig('pass_len'))
{
// Too short!
$FORM_ERRORS[] = SPONSOR_PASSWORD_TOO_SHORT;
}
// Check if he has accepted the terms&conditions
- if (empty($_POST['terms']))
- {
+ if (empty($_POST['terms'])) {
// Homepage URL is empty
$FORM_ERRORS[] = SPONSOR_TERMS_NOT_ACCEPTED;
}
if (count($FORM_ERRORS) > 0) unset($_POST['ok']);
}
-if ((isset($_POST['ok'])) && (count($FORM_ERRORS) == 0))
-{
+if ((isset($_POST['ok'])) && (count($FORM_ERRORS) == 0)) {
// Generate message array
$MSGs = array(
'failed' => SPONSOR_REGISTRATION_FAILED,
break;
default:
- if (!IS_ADMIN())
- {
+ DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s detected.", $STATUS));
+ if (!IS_ADMIN()) {
// Message for testing admin
$MSG = ADMIN_SPONSOR_UNKOWN_STATUS_1.$STATUS.ADMIN_SPONSOR_UNKOWN_STATUS_2;
- }
- else
- {
+ } else {
// Message for the guest
$MSG = SPONSOR_UNKOWN_STATUS_1.$STATUS.SPONSOR_UNKOWN_STATUS_2;
}
// Display message
LOAD_TEMPLATE("admin_settings_saved", false, $MSG);
-}
- else
-{
+} else {
// Check for payment types
$result = SQL_QUERY("SELECT id, pay_name, pay_rate, pay_currency, pay_min_count
FROM "._MYSQL_PREFIX."_sponsor_paytypes
ORDER BY pay_name", __FILE__, __LINE__);
- if (SQL_NUMROWS($result) > 0)
- {
+ if (SQL_NUMROWS($result) > 0) {
// Load all types...
$OUT = "<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"300\" class=\"left2 right2 top2\">\n";
$SW = 2;
<STRONG><FONT class=\"guest_failed\">".SPONSOR_REGISTER_SOMETHING_MISSING.":</FONT></STRONG><br />
</P>
<OL>\n";
- foreach ($FORM_ERRORS as $error)
- {
+ foreach ($FORM_ERRORS as $error) {
$OUT .= "<LI>".$error."</LI>\n";
- }
+ } // END - if
+
$OUT .= "</OL><br />\n";
define('__SPONSOR_FORM_ERRORS', $OUT);
define('__SPONSOR_REFID', $_POST['refid']);
- }
- else
- {
+ } else {
// None found, first call
define('__COMPANY' , "");
define('__POSITION' , "");
}
// Prepare referal things
- if (!isset($_GET['refid']))
- {
+ if (!isset($_GET['refid'])) {
// No referal link
define('__SPONSOR_REFID', "0");
- }
- else
- {
+ } else {
// Referal ID transmitted, we don't care here if it is right or not
define('__SPONSOR_REFID', bigintval($_GET['refid']));
}
// Display registration form
LOAD_TEMPLATE("guest_sponsor_reg");
- }
- else
- {
+ } else {
// Nothing added so far
LOAD_TEMPLATE("admin_settings_saved", false, SPONSOR_PAYMENT_LIST_IS_EMPTY);
}