X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fguest%2Fwhat-sponsor_reg.php;h=cb67895a30157393c094c35beb8c9adbac6eef4b;hb=3daede4c904e23905c3e48dd6749019deca0a0e0;hp=3d54c25b2ccd7a10c185248537d53b5bcf73bb53;hpb=d18075f375db1b9db40773cdf80a5d6f2c36cd3a;p=mailer.git diff --git a/inc/modules/guest/what-sponsor_reg.php b/inc/modules/guest/what-sponsor_reg.php index 3d54c25b2c..cb67895a30 100644 --- a/inc/modules/guest/what-sponsor_reg.php +++ b/inc/modules/guest/what-sponsor_reg.php @@ -31,13 +31,20 @@ ************************************************************************/ // Some security stuff... -if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) { +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()) { + addFatalMessage(sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "sponsor")); + } else { + addFatalMessage(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['salut'])) - { + if (empty($_POST['gender'])) { // Surname is empty - $FORM_ERRORS[] = SPONSOR_NO_SALUT_SELECTED; + $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, @@ -254,7 +245,7 @@ WHERE id='%s' LIMIT 1", array($_POST['pay_type']), __FILE__, __LINE__); define('__EMAIL' , $_POST['email']); define('__SURNAME' , $_POST['surname']); define('__FAMILY' , $_POST['family']); - define('__SALUT' , TRANSLATE_SEX($_POST['salut'])); + define('__GENDER' , TRANSLATE_GENDER($_POST['gender'])); define('__TIMESTAMP', MAKE_DATETIME(time(), 0)); define('__PASSWORD' , $_POST['pass1']); @@ -263,17 +254,7 @@ WHERE id='%s' LIMIT 1", array($_POST['pay_type']), __FILE__, __LINE__); SEND_EMAIL($_POST['email'], SPONSOR_PLEASE_CONFIRM_SUBJ, $EMAIL_MSG); // Send mail to admin - if (GET_EXT_VERSION("admins") >= "0.4.1") - { - // Use new system - SEND_ADMIN_EMAILS_PRO(ADMIN_NEW_SPONSOR, "admin_sponsor_reg", $hash); - } - else - { - // Send over old system - $msg_admin = LOAD_EMAIL_TEMPLATE("admin_sponsor_reg", $hash); - SEND_ADMIN_EMAILS (ADMIN_NEW_SPONSOR, $msg_admin); - } + SEND_ADMIN_NOTIFICATION(ADMIN_NEW_SPONSOR, "admin_sponsor_reg", $hash); // Output message: DONE $MSG = $MSGs['added']; @@ -289,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; } @@ -304,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; @@ -320,7 +296,7 @@ ORDER BY pay_name", __FILE__, __LINE__); { $OUT .= "\n"; @@ -350,25 +326,25 @@ ORDER BY pay_name", __FILE__, __LINE__); define('__EMAIL' , COMPILE_CODE($_POST['email'])); define('__URL' , COMPILE_CODE($_POST['url'])); - // Check for salutation selection - switch ($_POST['salut']) + // Check for gender selection + switch ($_POST['gender']) { case "M": // Male - define('__SALUT_M' , " selected"); - define('__SALUT_F' , ""); - define('__SALUT_C' , ""); + define('__GENDER_M' , " selected=\"selected\""); + define('__GENDER_F' , ""); + define('__GENDER_C' , ""); break; case "F": // Female - define('__SALUT_M' , ""); - define('__SALUT_F' , " selected"); - define('__SALUT_C' , ""); + define('__GENDER_M' , ""); + define('__GENDER_F' , " selected=\"selected\""); + define('__GENDER_C' , ""); break; case "C": // Company - define('__SALUT_M' , ""); - define('__SALUT_F' , ""); - define('__SALUT_C' , " selected"); + define('__GENDER_M' , ""); + define('__GENDER_F' , ""); + define('__GENDER_C' , " selected=\"selected\""); break; } @@ -376,38 +352,36 @@ ORDER BY pay_name", __FILE__, __LINE__); switch ($_POST['receive_warnings']) { case "Y": - define('__REC_Y' , " selected"); + define('__REC_Y' , " selected=\"selected\""); define('__REC_N' , ""); break; case "N": define('__REC_Y' , ""); - define('__REC_N' , " selected"); + define('__REC_N' , " selected=\"selected\""); break; } // Errors found $OUT = "

- ".SPONSOR_REGISTER_SOMETHING_MISSING.":
+ ".SPONSOR_REGISTER_SOMETHING_MISSING.":

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

\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' , ""); define('__TAX_IDENT', ""); - define('__SALUT_M' , ""); - define('__SALUT_F' , ""); - define('__SALUT_C' , ""); + define('__GENDER_M' , ""); + define('__GENDER_F' , ""); + define('__GENDER_C' , ""); define('__SURNAME' , ""); define('__FAMILY' , ""); define('__STREET1' , ""); @@ -427,23 +401,18 @@ ORDER BY pay_name", __FILE__, __LINE__); define('__SPONSOR_FORM_ERRORS', ""); } - // Prepare referral things - if (!isset($_GET['refid'])) - { - // No referral link + // Prepare referal things + if (!isset($_GET['refid'])) { + // No referal link define('__SPONSOR_REFID', "0"); - } - else - { - // Referral ID transmitted, we don't care here if it is right or not + } 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); }
-  ".$name."
+  ".$name."
(".$min." ".$curr." = ".TRANSLATE_COMMA($rate * $min)." ".POINTS.")