X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fguest%2Fwhat-sponsor_reg.php;h=7060952e9d3e3b83ec031c873712d41ee5ad4fac;hb=22a33b87f9894a94efb71de7630f12129e34f83b;hp=44f99a4ffb02cf4bbf179a49d932561d214fbf95;hpb=524c58a61b0a074fed8d7c9dc2f9ddab7f653595;p=mailer.git diff --git a/inc/modules/guest/what-sponsor_reg.php b/inc/modules/guest/what-sponsor_reg.php index 44f99a4ffb..7060952e9d 100644 --- a/inc/modules/guest/what-sponsor_reg.php +++ b/inc/modules/guest/what-sponsor_reg.php @@ -34,10 +34,17 @@ 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 -ADD_DESCR("guest", basename(__FILE__)); +ADD_DESCR("guest", __FILE__); // Create array for form errors (= missing data) $FORM_ERRORS = array(); @@ -47,107 +54,93 @@ if (isset($_POST['ok'])) { // 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'] = ""; @@ -193,15 +186,14 @@ if (isset($_POST['ok'])) { } } // 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; } @@ -210,8 +202,7 @@ if (isset($_POST['ok'])) { 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, @@ -279,13 +270,11 @@ WHERE id='%s' LIMIT 1", array($_POST['pay_type']), __FILE__, __LINE__); 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; } @@ -294,15 +283,12 @@ WHERE id='%s' LIMIT 1", array($_POST['pay_type']), __FILE__, __LINE__); // 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 = "\n"; $SW = 2; @@ -381,16 +367,14 @@ ORDER BY pay_name", __FILE__, __LINE__); ".SPONSOR_REGISTER_SOMETHING_MISSING.":

    \n"; - foreach ($FORM_ERRORS as $error) - { + foreach ($FORM_ERRORS as $error) { $OUT .= "
  1. ".$error."
  2. \n"; - } + } // END - if + $OUT .= "

\n"; define('__SPONSOR_FORM_ERRORS', $OUT); define('__SPONSOR_REFID', $_POST['refid']); - } - else - { + } else { // None found, first call define('__COMPANY' , ""); define('__POSITION' , ""); @@ -418,22 +402,17 @@ ORDER BY pay_name", __FILE__, __LINE__); } // 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); }