break; case 'remove_avatar': $current_User->remove_avatar(); break; case 'delete_avatar': $file_ID = param('file_ID', 'integer', NULL); $current_User->delete_avatar($file_ID); break; case 'upload_avatar': // Stop a request from the blocked IP addresses or Domains antispam_block_request(); $current_User->update_avatar_from_upload(); break; case 'redemption': // Change status of user email to 'redemption' $EmailAddressCache =& get_EmailAddressCache(); if (($EmailAddress =& $EmailAddressCache->get_by_name($current_User->get('email'), false, false)) && in_array($EmailAddress->get('status'), array('warning', 'suspicious1', 'suspicious2', 'suspicious3', 'prmerror'))) { // Change to 'redemption' status only if status is 'warning', 'suspicious1', 'suspicious2', 'suspicious3' or 'prmerror' $EmailAddress->set('status', 'redemption'); $EmailAddress->dbupdate(); } break; case 'crop': // crop profile picture $file_ID = param('file_ID', 'integer', NULL); // Check data to crop $image_crop_data = param('image_crop_data', 'string', ''); $image_crop_data = empty($image_crop_data) ? array() : explode(':', $image_crop_data); foreach ($image_crop_data as $image_crop_value) { $image_crop_value = (double) $image_crop_value; if ($image_crop_value < 0 || $image_crop_value > 100) {
/** * Insert/Update the data of email address into DB * * @param array Data of returned email: * 'address' * 'errormsg' * 'message' * 'headers' * 'errtype' */ function dre_save_email_address_data($email_returned) { global $DB; if (empty($email_returned['address'])) { // No emails, Exit here return; } $EmailAddressCache =& get_EmailAddressCache(); // Get an existing email address to update if it exist $EmailAddress =& $EmailAddressCache->get_by_name($email_returned['address'], false); if (!$EmailAddress) { // Insert new email address $EmailAddress = new EmailAddress(); $EmailAddress->set('address', $email_returned['address']); } switch ($email_returned['errtype']) { // Error type of the returned email: case 'P': // Permanent error $EmailAddress->increase_counter('prmerror'); // Update only the adresses with NOT spammer statuses $EmailAddress->set_status('prmerror'); break; case 'T': // Temporary error if (in_array($EmailAddress->get('status'), array('suspicious1', 'suspicious2', 'suspicious3'))) { // If current status already is defined as 'suspicious1', 'suspicious2' or 'suspicious3' if ($EmailAddress->get('sent_last_returnerror') <= 1) { if ($EmailAddress->get('status') == 'suspicious1') { // Increase status from suspicious1 to suspicious2 $EmailAddress->set('status', 'suspicious2'); } elseif ($EmailAddress->get('status') == 'suspicious2') { // Increase status from suspicious2 to suspicious3 $EmailAddress->set('status', 'suspicious3'); } } } elseif ($EmailAddress->get('status') == 'redemption') { // IF current status is 'redemption' we should set it as 'suspicious3' $EmailAddress->set_status('suspicious3'); } else { // Update only the email addresses with level status less then Suspicious 1 $EmailAddress->set_status('suspicious1'); } $EmailAddress->increase_counter('tmperror'); break; case 'S': // Spam suspicion $EmailAddress->increase_counter('spamerror'); // Update only the email addresses with 'unknown' status $EmailAddress->set_status('warning'); break; default: // Other errors $EmailAddress->increase_counter('othererror'); // Update only the email addresses with 'unknown' status $EmailAddress->set_status('warning'); break; } // Insert/Update an email address $EmailAddress->dbsave(); }
/** * Get status of user email * * @return string Status: 'unknown', 'warning', 'suspicious1', 'suspicious2', 'suspicious3', 'prmerror', 'spammer', 'redemption' */ function get_email_status() { $user_email = $this->get('email'); $EmailAddressCache =& get_EmailAddressCache(); if (!empty($user_email) && ($EmailAddress =& $EmailAddressCache->get_by_name($user_email, false, false))) { // The email of this user is located in the DB table return $EmailAddress->get('status'); } else { // There is no email address in the DB table return 'unknown'; } }
/** * Display message depending on user email status * * @param integer User ID */ function display_user_email_status_message($user_ID = 0) { global $Messages, $current_User, $Blog, $disp; if (!is_logged_in() || $user_ID != 0 && $user_ID != $current_User->ID) { // User must be logged in AND only for current User return; } $email_status = $current_User->get_email_status(); if (empty($email_status) || !in_array($email_status, array('redemption', 'warning', 'suspicious1', 'suspicious2', 'suspicious3', 'prmerror'))) { // No message for current email status return; } $EmailAddressCache =& get_EmailAddressCache(); $EmailAddress =& $EmailAddressCache->get_by_name($current_User->get('email'), false, false); $is_admin_page = is_admin_page() || empty($Blog); if (check_user_status('is_validated')) { // Url to user profile page $url_change_email = get_user_settings_url('subs'); } else { // Url to activate email address $url_change_email = get_activate_info_url(NULL, '&'); } // Url to change status if ($is_admin_page) { global $admin_url; $user_tab_param = get_param('user_tab') != '' ? '&user_tab=' . get_param('user_tab') : ''; $url_change_status = $admin_url . '?ctrl=user&action=redemption&user_ID=' . $current_User->ID . $user_tab_param . '&' . url_crumb('user'); } else { $user_tab_param = empty($disp) ? 'profile' : $disp; $url_change_status = get_secure_htsrv_url() . 'profile_update.php?action=redemption&user_tab=' . $user_tab_param . '&blog=' . $Blog->ID . '&' . url_crumb('user'); } // Display info about last error only when such data exists $email_last_sent_ts = empty($EmailAddress) ? '' : $EmailAddress->get('last_sent_ts'); $last_error_info = empty($email_last_sent_ts) ? '' : ' ' . sprintf(T_('(last error was detected on %s)'), mysql2localedatetime_spans($email_last_sent_ts, 'M-d')); switch ($email_status) { case 'warning': case 'suspicious1': case 'suspicious2': case 'suspicious3': $Messages->add(sprintf(T_('We have detected some delivery problems to your email account %s%s. Please add our email: %s to your address book. If you still don\'t receive our emails, try using a different email address instead of %s for your account.<br /><a %s>Click here to use a different email address</a>.<br /><a %s>Click here to discard this message once you receive our emails again</a>.'), '<b>' . $current_User->get('email') . '</b>', $last_error_info, '<b>' . user_get_notification_sender($current_User->ID, 'email') . '</b>', '<b>' . $current_User->get('email') . '</b>', 'href="' . $url_change_email . '"', 'href="' . $url_change_status . '"'), 'error'); break; case 'prmerror': $Messages->add(sprintf(T_('Your email address: %s does not seem to work or is refusing our emails%s. Please check your email address carefully. If it\'s incorrect, <a %s>change your email address</a>. If it\'s correct, please add our email: %s to your address book, then <a %s>click here to try again</a>!'), '<b>' . $current_User->get('email') . '</b>', $last_error_info, 'href="' . $url_change_email . '"', '<b>' . user_get_notification_sender($current_User->ID, 'email') . '</b>', 'href="' . $url_change_status . '"'), 'error'); break; case 'redemption': $Messages->add(sprintf(T_('We are currently trying to send email to your address: %s again.'), '<b>' . $current_User->get('email') . '</b>'), 'note'); break; } }