-//
-function sendModeMails ($mod, $modes) {
- global $DATA;
-
- // Load hash
- $result_main = SQL_QUERY_ESC("SELECT password FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1",
- array(getUserId()), __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result_main) == 1) {
- // Load hash from database
- list($hashDB) = SQL_FETCHROW($result_main);
-
- // Extract salt from cookie
- $salt = substr(getSession('u_hash'), 0, -40);
-
- // Now let's compare passwords
- $hash = generatePassString($hashDB);
- if (($hash == getSession('u_hash')) || (REQUEST_POST('pass1') == REQUEST_POST('pass2'))) {
- // Load user's data
- $result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND password='%s' LIMIT 1",
- array(getUserId(), $hashDB), __FUNCTION__, __LINE__);
- if (SQL_NUMROWS($result) == 1) {
- // Load the data
- $DATA = SQL_FETCHROW($result);
-
- // Free result
- SQL_FREERESULT($result);
-
- // Translate gender
- $DATA[0] = translateGender($DATA[0]);
-
- // Clear/init the content variable
- $content = '';
- $DATA['info'] = '';
-
- switch ($mod)
- {
- case 'mydata':
- foreach ($modes as $mode) {
- switch ($mode)
- {
- case 'normal': break; // Do not add any special lines
-
- case 'email': // Email was changed!
- $content = getMessage('MEMBER_CHANGED_EMAIL').": ".REQUEST_POST('old_addy')."\n";
- break;
-
- case 'pass': // Password was changed
- $content = getMessage('MEMBER_CHANGED_PASS')."\n";
- break;
-
- default:
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown mode %s detected.", $mode));
- $content = getMessage('MEMBER_UNKNOWN_MODE').": ".$mode."\n\n";
- break;
- } // END - switch
- } // END - if
-
- if (EXT_IS_ACTIVE('country')) {
- // Replace code with description
- $DATA[4] = COUNTRY_GENERATE_INFO(REQUEST_POST('country_code'));
- } // END - if
-
- // Merge content with data from POST
- $content = merge_array($content, REQUEST_POST_ARRAY());
-
- // Load template
- $msg = LOAD_EMAIL_TEMPLATE('member_mydata_notify', $content, getUserId());
-
- if (getConfig('admin_notify') == 'Y') {
- // The admin needs to be notified about a profile change
- $msg_admin = 'admin_mydata_notify';
- $sub_adm = getMessage('ADMIN_CHANGED_DATA');
- } else {
- // No mail to admin
- $msg_admin = '';
- $sub_adm = '';
- }
-
- // Set subject lines
- $sub_mem = getMessage('MEMBER_CHANGED_DATA');
-
- // Output success message
- $content = "<span class=\"member_done\">{--MYDATA_MAIL_SENT--}</span>";
- break;
-
- default: // Unsupported module!
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unsupported module %s detected.", $mod));
- $content = "<span class=\"member_failed\">{--UNKNOWN_MODULE--}</span>";
- break;
- } // END - switch
- } else {
- // Could not load profile data
- $content = "<span class=\"member_failed\">{--MEMBER_CANNOT_LOAD_PROFILE--}</span>";
- }
- } else {
- // Passwords mismatch
- $content = "<span class=\"member_failed\">{--MEMBER_PASSWORD_ERROR--}</span>";
- }
- } else {
- // Could not load profile
- $content = "<span class=\"member_failed\">{--MEMBER_CANNOT_LOAD_PROFILE--}</span>";
- }
-
- // Send email to user if required
- if ((!empty($sub_mem)) && (!empty($msg))) {
- // Send member mail
- sendEmail($DATA[7], $sub_mem, $msg);
- } // END - if
-
- // Send only if no other error has occured
- if (empty($content)) {
- if ((!empty($sub_adm)) && (!empty($msg_admin))) {
- // Send admin mail
- sendAdminNotification($sub_adm, $msg_admin, $content, getUserId());
- } elseif (getConfig('admin_notify') == 'Y') {
- // Cannot send mails to admin!
- $content = getMessage('CANNOT_SEND_ADMIN_MAILS');
- } else {
- // No mail to admin
- $content = "<span class=\"member_done\">{--MYDATA_MAIL_SENT--}</span>";
- }
- } // END - if
-
- // Load template
- LOAD_TEMPLATE('admin_settings_saved', false, $content);
-}
-
-// Update module counter
-function countModuleHit($mod) {
- if ($mod != "css") {
- // Do count all other modules but not accesses on CSS file css.php!
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET clicks=clicks+1 WHERE `module`='%s' LIMIT 1",
- array($mod), __FUNCTION__, __LINE__);
- } // END - if
-}
-