* $Author:: $ *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team *
* For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
$ret = TRUE;
foreach ($array as $key => $value) {
// Check all fields that must register
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_must_register` WHERE `field_name`='%s' AND `field_required`='Y' LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_must_register` WHERE `field_name`='%s' AND `field_required`='Y' LIMIT 1",
array($key), __FUNCTION__, __LINE__);
// Entry found?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Check if extension country is not found (you have to enter the 2-chars long country code) or
// if extensions is present check if country code was selected
// 01 2 21 12 3 32 234 5 54 4 43 34 4 4 5 5432 2 3 3210
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - foreach
// Return result
} // END - if
// Look for categories
- $result = SQL_QUERY('SELECT
+ $result = sqlQuery('SELECT
`id`,
`cat`,
`visible`
`sort` ASC',
__FUNCTION__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNums($result)) {
// List alle visible modules (or all to the admin)
$OUT .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Prepare array for the template
$content['default_yes'] = '';
$content['default_no'] = '';
$OUT .= '</table>';
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No categories setted up so far...
$OUT .= displayMessage('{--NO_CATEGORIES_VISIBLE--}', TRUE);
// Checks whether the registration data is complete
function isRegistrationDataComplete () {
// Init elements
- $GLOBALS['registration_ip_timeout'] = FALSE;
- $GLOBALS['registration_short_password'] = FALSE;
- $GLOBALS['registration_selected_cats'] = '0';
+ $GLOBALS['registration_ip_timeout'] = FALSE;
+ $GLOBALS['registration_weak_password'] = FALSE;
+ $GLOBALS['registration_selected_cats'] = '0';
// Default is okay
$isOkay = TRUE;
+ $isRandom = FALSE;
// First we only check the submitted data then we continue... :)
//
setPostRequestArray($postArray);
// Are both passwords zero length?
- if ((strlen(postRequestElement('pass1')) == 0) && (strlen(postRequestElement('pass2')) == 0) && ($isOkay === TRUE)) {
+ if ((strlen(postRequestElement('password1')) == 0) && (strlen(postRequestElement('password2')) == 0) && ($isOkay === TRUE)) {
// Is the extension 'register' newer or equal 0.5.5?
if ((isExtensionInstalledAndNewer('register', '0.5.5')) && (isRegisterGeneratePasswordEmptyEnabled())) {
// Generate a random password
$randomPassword = generatePassword();
+ $isRandom = TRUE;
// Set it in both entries
- setPostRequestElement('pass1', $randomPassword);
- setPostRequestElement('pass2', $randomPassword);
+ setPostRequestElement('password1', $randomPassword);
+ setPostRequestElement('password2', $randomPassword);
} else {
// Not allowed or no recent extension version
- setPostRequestElement('pass1', '!');
- setPostRequestElement('pass2', '!');
+ setPostRequestElement('password1', '!');
+ setPostRequestElement('password2', '!');
// ... which is both not okay
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Random password generation not possible, isExtensionInstalledAndNewer(register, 0.5.5)=' . intval(isExtensionInstalledAndNewer('register', '0.5.5')) . ',isRegisterGeneratePasswordEmptyEnabled()=' . intval(isRegisterGeneratePasswordEmptyEnabled()));
} // END - if
// Did he enter his password twice?
- if (((!isPostRequestElementSet('pass1')) || (!isPostRequestElementSet('pass2'))) || ((postRequestElement('pass1') != postRequestElement('pass2')) && (isPostRequestElementSet('pass1')) && (isPostRequestElementSet('pass2')))) {
- if ((postRequestElement('pass1') != postRequestElement('pass2')) && (isPostRequestElementSet('pass1')) && (isPostRequestElementSet('pass2'))) {
+ if (((!isPostRequestElementSet('password1')) || (!isPostRequestElementSet('password2'))) || ((postRequestElement('password1') != postRequestElement('password2')) && (isPostRequestElementSet('password1')) && (isPostRequestElementSet('password2')))) {
+ if ((postRequestElement('password1') != postRequestElement('password2')) && (isPostRequestElementSet('password1')) && (isPostRequestElementSet('password2'))) {
// Both passwords did not match
- setPostRequestElement('pass1', '!');
- setPostRequestElement('pass2', '!');
+ setPostRequestElement('password1', '!');
+ setPostRequestElement('password2', '!');
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter same passwords.');
} else {
- if (!isPostRequestElementSet('pass1')) {
+ if (!isPostRequestElementSet('password1')) {
// Password 1 is empty
- setPostRequestElement('pass1', '!');
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter pass1.');
+ setPostRequestElement('password1', '!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter password1.');
} else {
// Password 2 is empty
- setPostRequestElement('pass1', '');
+ setPostRequestElement('password1', '');
}
- if (!isPostRequestElementSet('pass2')) {
+ if (!isPostRequestElementSet('password2')) {
// Password 2 is empty
- setPostRequestElement('pass2', '!');
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter pass2.');
+ setPostRequestElement('password2', '!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did not enter password2.');
} else {
// Password 1 is empty
- setPostRequestElement('pass2', '');
+ setPostRequestElement('password2', '');
}
}
$isOkay = FALSE;
} // END - if
- // Is the password long enouth?
- if ((strlen(postRequestElement('pass1')) < getPassLen()) && ($isOkay === TRUE)) {
- $GLOBALS['registration_short_password'] = TRUE;
+ // Is the password strong enough?
+ if (($isRandom === FALSE) && (!isStrongPassword(postRequestElement('password1')))) {
+ $GLOBALS['registration_weak_password'] = TRUE;
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did enter a short password.');
$isOkay = FALSE;
} // END - if
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isOkay=' . intval($isOkay) . ',selected=' . $GLOBALS['registration_selected_cats'] . '/' . getLeastCats());
$isOkay = (($isOkay) && ($GLOBALS['registration_selected_cats'] >= getLeastCats()));
- if ((postRequestElement('email') != '!') && (isCheckDoubleEmailEnabled())) {
- // Does the email address already exists in our database?
- if ((isEmailTaken(postRequestElement('email'))) && (!isAdmin())) {
- setPostRequestElement('email', '?');
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did enter a already used email address.');
- $isOkay = FALSE;
- } // END - if
+ // Check if email is taken, if configured
+ if ((isExtensionInstalledAndNewer('other', '0.3.0')) && (isCheckDoubleEmailEnabled()) && (postRequestElement('email') != '!') && (isEmailTaken(postRequestElement('email'))) && (!isAdmin())) {
+ // Is already used
+ setPostRequestElement('email', '?');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'User did enter a already used email address.');
+ $isOkay = FALSE;
} // END - if
// Check for IP timeout?
reportBug(__FUNCTION__, __LINE__, 'Tried to register a user account without ext-user installed.');
} // END - if
+ // Init extra SQL data
+ initExtraRegistrationSql();
+
// Init filter data
$filterData = array(
// Initialization not done by default
- 'init_done' => FALSE
+ 'init_done' => FALSE,
+ 'post_data' => postRequestArray(),
+ 'blacklisted' => '',
+ 'message' => '{--PRE_USER_REGISTRATION_FAILED--}',
);
- // Init extra SQL data
- initExtraRegistrationSql();
-
// Run the pre-registration chain
$filterData = runFilterChain('pre_user_registration', $filterData);
// Did the initialization work?
if ($filterData['init_done'] === FALSE) {
// Something bad happened!
- displayMessage('{--PRE_USER_REGISTRATION_FAILED--}');
+ displayMessage($filterData['message']);
// Stop here
return FALSE;
} // END - if
// Create user's account...
- SQL_QUERY_ESC("INSERT INTO
+ sqlQueryEscaped("INSERT INTO
`{?_MYSQL_PREFIX?}_user_data`
(
`gender`,
bigintval(postRequestElement('day')),
bigintval(postRequestElement('month')),
bigintval(postRequestElement('year')),
- generateHash(postRequestElement('pass1')),
+ generateHash(postRequestElement('password1')),
bigintval(postRequestElement('max_mails')),
bigintval(postRequestElement('max_mails')),
convertZeroToNull(postRequestElement('refid')),
), __FUNCTION__, __LINE__);
// Get his userid
- $filterData['register_insert_id'] = bigintval(SQL_INSERTID());
+ $filterData['register_insert_id'] = getSqlInsertId();
// Did this work?
- if (!isValidUserId($filterData['register_insert_id'])) {
+ if (!isValidId($filterData['register_insert_id'])) {
// Something bad happened!
displayMessage('{--USER_NOT_REGISTERED--}');
// Shall we reset random refid? Only possible with latest ext-user
if (isExtensionInstalledAndNewer('user', '0.3.4')) {
// Reset all accounts, registration is done
- SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0', __FUNCTION__, __LINE__);
+ sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0', __FUNCTION__, __LINE__);
} // END - if
// Update referral table
addPointsThroughReferralSystem(
// Subject
'register_welcome',
- // New user's id
+ // User's id number
$filterData['register_insert_id'],
- // Points
+ // Points to add
getPointsRegister(),
// Referral id (or NULL if none set)
convertZeroToNull(postRequestElement('refid'))
// Write catgories
if (ifPostContainsSelections('cat')) {
+ // Init SQL
+ $sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_user_cats` (`userid`, `cat_id`) VALUES';
+
// Write all entries
foreach (postRequestElement('cat') as $categoryId => $joined) {
// "Join" this group?
if ($joined == 'Y') {
// Insert category entry
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_cats` (`userid`, `cat_id`) VALUES (%s, %s)",
- array(
- $filterData['register_insert_id'],
- bigintval($categoryId)
- ), __FUNCTION__, __LINE__);
+ $sql .= ' (' . $filterData['register_insert_id'] . ', ' . bigintval($categoryId) . '),';
} // END - if
} // END - foreach
+
+ // Run SQL without last commata
+ sqlQuery(substr($sql, 0, -1), __FUNCTION__, __LINE__);
} // END - if
// Registration phase is done here, so for tester accounts we end here
} // END - if
// ... rewrite a zero referral id to the main title
- if (!isValidUserId(postRequestElement('refid'))) {
+ if (!isValidId(postRequestElement('refid'))) {
setPostRequestElement('refid', getMainTitle());
} // END - if
// Is ZIP code set?
if (isPostRequestElementSet('zip')) {
// Prepare data array for the email template
- // Start with the gender...
$content = array(
'hash' => $GLOBALS['register_confirm_hash'],
'userid' => $filterData['register_insert_id'],
- 'gender' => SQL_ESCAPE(postRequestElement('gender')),
- 'surname' => SQL_ESCAPE(postRequestElement('surname')),
- 'family' => SQL_ESCAPE(postRequestElement('family')),
- 'email' => SQL_ESCAPE(postRequestElement('email')),
- 'street' => SQL_ESCAPE(postRequestElement('street_nr')),
- 'city' => SQL_ESCAPE(postRequestElement('city')),
+ 'gender' => sqlEscapeString(postRequestElement('gender')),
+ 'surname' => sqlEscapeString(postRequestElement('surname')),
+ 'family' => sqlEscapeString(postRequestElement('family')),
+ 'email' => sqlEscapeString(postRequestElement('email')),
+ 'street' => sqlEscapeString(postRequestElement('street_nr')),
+ 'city' => sqlEscapeString(postRequestElement('city')),
'zip' => bigintval(postRequestElement('zip')),
'country' => $GLOBALS['register_country_data'],
- 'refid' => SQL_ESCAPE(postRequestElement('refid')),
- 'password' => SQL_ESCAPE(postRequestElement('pass1')),
+ 'refid' => sqlEscapeString(postRequestElement('refid')),
+ 'password' => sqlEscapeString(postRequestElement('password1')),
);
} else {
// No ZIP code entered
$content = array(
'hash' => $GLOBALS['register_confirm_hash'],
'userid' => $filterData['register_insert_id'],
- 'gender' => SQL_ESCAPE(postRequestElement('gender')),
- 'surname' => SQL_ESCAPE(postRequestElement('surname')),
- 'family' => SQL_ESCAPE(postRequestElement('family')),
- 'email' => SQL_ESCAPE(postRequestElement('email')),
- 'street' => SQL_ESCAPE(postRequestElement('street_nr')),
- 'city' => SQL_ESCAPE(postRequestElement('city')),
+ 'gender' => sqlEscapeString(postRequestElement('gender')),
+ 'surname' => sqlEscapeString(postRequestElement('surname')),
+ 'family' => sqlEscapeString(postRequestElement('family')),
+ 'email' => sqlEscapeString(postRequestElement('email')),
+ 'street' => sqlEscapeString(postRequestElement('street_nr')),
+ 'city' => sqlEscapeString(postRequestElement('city')),
'zip' => '',
'country' => $GLOBALS['register_country_data'],
- 'refid' => SQL_ESCAPE(postRequestElement('refid')),
- 'password' => SQL_ESCAPE(postRequestElement('pass1')),
+ 'refid' => sqlEscapeString(postRequestElement('refid')),
+ 'password' => sqlEscapeString(postRequestElement('password1')),
);
}
return $GLOBALS[__FUNCTION__];
}
-// Checks whether 'display_refid' is "YES"
+// Checks whether 'display_refid' is "Y"
function isDisplayRefidEnabled () {
// Is the cache entry set?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
+// "Getter" for least_cats
+function getLeastCats () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('least_cats');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
// ----------------------------------------------------------------------------
// Template helper functions
// ----------------------------------------------------------------------------