Пример #1
0
function send_feedback($sender_name, $sender_email, $message, $preview = false)
{
    global $_CLASS, $_CORE_CONFIG;
    $_CLASS['core_template']->assign_array(array('SENT_FROM' => $sender_name, 'SENDER_NAME' => $sender_name, 'SENDER_EMAIL' => $sender_email, 'SENDER_IP' => $_CLASS['core_user']->ip, 'MESSAGE' => $message));
    $body = trim($_CLASS['core_template']->display('modules/Contact/email/index.html', true));
    if ($preview) {
        $_CLASS['core_template']->assign('PREVIEW', $body);
        return;
    }
    require_once $site_file_root . 'includes/mailer.php';
    $mailer = new core_mailer();
    $mailer->to($_CORE_CONFIG['email']['site_mail'], false);
    $mailer->subject($_CLASS['core_user']->get_lang('SITE_FEEDBACK'));
    $mailer->message = $body;
    trigger_error($mailer->send() ? 'SEND_SUCCESSFULL' : $mailer->error);
}
Пример #2
0
 function send_feedback()
 {
     global $_CLASS, $_CORE_CONFIG;
     $_CLASS['core_template']->assign_array(array('SENT_FROM' => $this->data['NAME'], 'SENDER_NAME' => $this->data['NAME'], 'SENDER_EMAIL' => $this->data['EMAIL'], 'SENDER_IP' => $_CLASS['core_user']->ip, 'MESSAGE' => $this->data['MESSAGE']));
     $body = trim($_CLASS['core_template']->display('email/contact/index.txt', true));
     if ($this->preview) {
         $_CLASS['core_template']->assign('PREVIEW', modify_lines($body, '<br/>'));
         return;
     }
     require_once SITE_FILE_ROOT . 'includes/mailer.php';
     $mailer = new core_mailer();
     $mailer->to($_CORE_CONFIG['email']['site_mail'], $_CORE_CONFIG['global']['site_name']);
     $mailer->subject($_CLASS['core_user']->get_lang('SITE_FEEDBACK'));
     $mailer->message = $body;
     trigger_error($mailer->send() ? 'SEND_SUCCESSFULL' : $mailer->error);
 }
function pm_notification($mode, $author, $recipients, $subject, $message)
{
    global $_CLASS, $_CORE_CONFIG, $config;
    if (empty($recipients)) {
        return;
    }
    $subject = censor_text($subject);
    $recipient_list = implode(', ', array_unique(array_keys($recipients)));
    $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type
		FROM ' . USERS_TABLE . "\n\t\tWHERE user_id IN ({$recipient_list})";
    $result = $_CLASS['core_db']->query($sql);
    $user_list = array();
    // add lang support
    while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
        if ($row['user_notify_pm']) {
            $user_list[] = $row;
        }
    }
    $_CLASS['core_db']->free_result($result);
    if (empty($user_list)) {
        return;
    }
    $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
    require_once SITE_FILE_ROOT . 'includes/mailer.php';
    $mailer = new core_mailer();
    $count = count($user_list);
    for ($i = 0; $i < $count; $i++) {
        $mailer->to($user_list[$i]['user_email'], $user_list[$i]['username']);
    }
    $mailer->subject('New Private Message has arrived');
    $_CLASS['core_template']->assign_array(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $_CORE_CONFIG['global']['site_name'], 'SUBJECT' => $subject, 'AUTHOR_NAME' => $author, 'LINK_INBOX' => generate_link('Control_Panel&i=pm&mode=unread', array('full' => true, 'sid' => true))));
    $mailer->message = trim($_CLASS['core_template']->display('email/control_panel/pm_notify.txt', true));
    if (!$mailer->send()) {
        //echo $mailer->error;
    }
}
function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id)
{
    global $config, $_CORE_CONFIG, $_CLASS;
    $titles = array('notify_topic' => 'Topic Reply Notification - ' . $topic_title, 'notify_newtopic' => 'New Topic Notification - ' . $topic_title, 'notify_forum' => 'Forum Post Notification - ' . $forum_name);
    if ($mode == 'reply' || $mode == 'quote') {
        $topic_title = $subject;
        $notify_type = 'topic';
        $template = 'notify_topic';
        //notify_forum
        $where = "(w.forum_id = {$forum_id} OR w.topic_id = {$topic_id})";
    } else {
        $topic_title = $topic_title;
        $notify_type = 'forum';
        $template = 'notify_newtopic';
        $where = 'w.forum_id = ' . $forum_id;
    }
    $topic_title = censor_text($topic_title);
    $holding = array();
    // Add use of notification type
    // Lets get all the users that are set to be notified
    $sql = 'SELECT w.notify_type, w.forum_id, u.user_id, u.username, u.user_email, u.user_lang
		FROM ' . FORUMS_WATCH_TABLE . ' w, ' . USERS_TABLE . " u\n\t\tWHERE {$where}\n\t\t\tAND w.notify_status = 0\n\t\t\tAND u.user_status = " . STATUS_ACTIVE . '
			AND u.user_id = w.user_id';
    $result = $_CLASS['core_db']->query($sql);
    while ($user = $_CLASS['core_db']->fetch_row_assoc($result)) {
        $ignore_array[$user['user_id']] = $user['user_id'];
        $holding[$user['user_id']] = $user;
        $holding[$user['user_id']]['template'] = $notify_type == 'topic' && $user['forum_id'] ? 'notify_forum' : $template;
        if ($notify_type == 'topic' && $user['forum_id']) {
            $holding[$user['user_id']]['template'] = 'notify_forum';
            $holding[$user['user_id']]['update'] = 'forum';
        } else {
            $holding[$user['user_id']]['template'] = $template;
            $holding[$user['user_id']]['update'] = $notify_type;
        }
    }
    $_CLASS['core_db']->free_result($result);
    if (empty($holding)) {
        return;
    }
    // Now we remove the users that aren't allowed to read the forum
    $acl_list = $_CLASS['auth']->acl_get_list(array_keys($ignore_array), 'f_read', $forum_id);
    if (!empty($acl_list)) {
        foreach ($acl_list[$forum_id]['f_read'] as $user_id) {
            unset($ignore_array[$user_id]);
        }
    }
    $processed = $delete_array = $update_array = array();
    foreach ($holding as $user) {
        if (!in_array($user['user_id'], $ignore_array)) {
            $processed[$user['template']][] = $user;
            $update_array[$user['update']][] = $user['user_id'];
        } else {
            $delete_array[$user['update']] = $user['user_id'];
        }
    }
    unset($holding, $ignore_array);
    // Now delete the user_ids not authorized to receive notifications on this topic/forum
    if (!empty($delete_array['topic'])) {
        $_CLASS['core_db']->query('DELETE FROM ' . FORUMS_WATCH_TABLE . "\n\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\tAND user_id IN (" . implode(', ', $delete_array['topic']) . ")");
    }
    if (!empty($delete_array['forum'])) {
        $_CLASS['core_db']->query('DELETE FROM ' . FORUMS_WATCH_TABLE . "\n\t\t\tWHERE forum_id = {$forum_id}\n\t\t\t\tAND user_id IN (" . implode(', ', $delete_array['forum']) . ")");
    }
    if (empty($processed)) {
        return;
    }
    $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
    require_once SITE_FILE_ROOT . 'includes/mailer.php';
    foreach ($processed as $template => $user_list) {
        $mailer = new core_mailer();
        $count = count($user_list);
        for ($i = 0; $i < $count; $i++) {
            $mailer->to($user_list[$i]['user_email'], $user_list[$i]['username']);
        }
        $mailer->subject($titles[$template]);
        $_CLASS['core_template']->assign_array(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $_CORE_CONFIG['global']['site_name'], 'TOPIC_TITLE' => $topic_title, 'FORUM_NAME' => $forum_name, 'U_FORUM' => generate_link("Forums&file=viewforum&f={$forum_id}&e=0", array('sid' => false, 'full' => true)), 'U_TOPIC' => generate_link("Forums&file=viewtopic&t={$topic_id}&e=0", array('sid' => false, 'full' => true)), 'U_NEWEST_POST' => generate_link("Forums&file=viewtopic&t={$topic_id}&p={$post_id}&e={$post_id}", array('sid' => false, 'full' => true)), 'U_STOP_WATCHING_TOPIC' => generate_link("Forums&file=viewtopic&t={$topic_id}&unwatch=topic", array('sid' => false, 'full' => true)), 'U_STOP_WATCHING_FORUM' => generate_link("Forums&file=viewforum&f={$forum_id}&unwatch=forum", array('sid' => false, 'full' => true))));
        $mailer->message = trim($_CLASS['core_template']->display("email/forums/{$template}.txt", true));
        if (!$mailer->send()) {
            //echo $mailer->error;
        }
    }
    $_CLASS['core_db']->transaction();
    if (!empty($update_array['topic'])) {
        $_CLASS['core_db']->query('UPDATE ' . FORUMS_WATCH_TABLE . "\n\t\t\tSET notify_status = 1\n\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\tAND user_id IN (" . implode(', ', $update_array['topic']) . ")");
    }
    if (!empty($update_array['forum'])) {
        $_CLASS['core_db']->query('UPDATE ' . FORUMS_WATCH_TABLE . "\n\t\t\tSET notify_status = 1\n\t\t\tWHERE forum_id = {$forum_id}\n\t\t\t\tAND user_id IN (" . implode(', ', $update_array['forum']) . ")");
    }
    $_CLASS['core_db']->transaction('commit');
}
 function ucp_register($id, $mode)
 {
     global $site_file_root, $config, $_CLASS, $_CORE_CONFIG;
     $coppa = isset($_REQUEST['coppa']) ? (int) $_REQUEST['coppa'] : null;
     $submit = isset($_POST['submit']);
     if ($_CORE_CONFIG['user']['activation'] == USER_ACTIVATION_DISABLE || ($coppa || $_CORE_CONFIG['user']['activation'] == USER_ACTIVATION_SELF || $_CORE_CONFIG['user']['activation'] == USER_ACTIVATION_ADMIN) && !$_CORE_CONFIG['email']['email_enable']) {
         trigger_error('UCP_REGISTER_DISABLE');
     }
     $_CLASS['core_template']->assign('S_UCP_ACTION', generate_link('Control_Panel&amp;mode=register'));
     $error = $data = array();
     $s_hidden_fields = '';
     if (!isset($_POST['agreed'])) {
         if ($_CORE_CONFIG['user']['coppa_enable'] && is_null($coppa)) {
             $now = explode(':', gmdate('m:j:Y'));
             $coppa_birthday = $_CLASS['core_user']->format_date(mktime(12, 0, 0, $now[0], $now[1], $now[2] - 13), 'D M d, Y');
             $_CLASS['core_template']->assign_array(array('L_COPPA_NO' => sprintf($_CLASS['core_user']->lang['UCP_COPPA_BEFORE'], $coppa_birthday), 'L_COPPA_YES' => sprintf($_CLASS['core_user']->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday), 'U_COPPA_NO' => generate_link('Control_Panel&amp;mode=register&amp;coppa=0'), 'U_COPPA_YES' => generate_link('Control_Panel&amp;mode=register&amp;coppa=1'), 'S_SHOW_COPPA' => true, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_REGISTER_ACTION' => generate_link('Control_Panel&amp;mode=register')));
         } else {
             $s_hidden_fields .= '<input type="hidden" name="coppa" value="' . $coppa . '" />';
             $_CLASS['core_template']->assign_array(array('S_SHOW_COPPA' => false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_REGISTER_ACTION' => generate_link('Control_Panel&amp;mode=register')));
         }
         $this->display($_CLASS['core_user']->lang['REGISTER'], 'ucp_agreement.html');
         script_close();
     }
     if ($submit) {
         require_once $site_file_root . 'includes/functions_user.php';
         $error = array();
         $username = get_variable('username', 'POST', false);
         $password = get_variable('password', 'POST', false);
         $email = get_variable('email', 'POST', false);
         $email_confirm = get_variable('email_confirm', 'POST', '');
         //when we add this make sure to confirm that it's one of the installed langs
         $lang = $_CORE_CONFIG['global']['default_lang'];
         $tz = get_variable('tz', 'POST', false);
         if (strpos($username, "\n")) {
             die;
         }
         $username_validate = validate_username($username);
         if ($username_validate !== true) {
             $error[] = $_CLASS['core_user']->get_lang($username_validate);
         }
         if (!$password || $password !== get_variable('password_confirm', 'POST', '')) {
             $error[] = $_CLASS['core_user']->get_lang('PASSWORD_ERROR');
         }
         if (!$email || $email !== $email_confirm) {
             $error[] = $_CLASS['core_user']->get_lang('EMAIL_ERROR');
         } elseif (!check_email($email)) {
             $error[] = $_CLASS['core_user']->get_lang('EMAIL_INVALID');
         }
         if (!$tz || !in_array($tz, tz_array())) {
             $tz = null;
         }
         if ($_CORE_CONFIG['user']['enable_confirm']) {
             $confirmation_code = $_CLASS['core_user']->session_data_get('confirmation_code');
             $confirm_code = trim(get_variable('confirm_code', 'POST', false));
             if (!$confirm_code || !$confirmation_code || $confirm_code != $confirmation_code) {
                 $error[] = $_CLASS['core_user']->get_lang('CONFIRM_CODE_WRONG');
             }
             // we don't need this any more
             $_CLASS['core_user']->user_data_kill('confirmation_code');
         }
         if (empty($error)) {
             $password = encode_password($password, $_CORE_CONFIG['user']['password_encoding']);
             if (!$password) {
                 //do some admin contact thing here
                 die('Activation disabled: Passwaord encoding problem');
             }
             if ($coppa || $_CORE_CONFIG['user']['activation'] == USER_ACTIVATION_SELF || $_CORE_CONFIG['user']['activation'] == USER_ACTIVATION_ADMIN) {
                 if (!$_CORE_CONFIG['email']['email_enable']) {
                     //do some admin contact thing here
                     die('Activation disabled: Email Disabled');
                 }
                 $user_status = STATUS_PENDING;
                 $user_act_key = generate_string(10);
                 if ($coppa) {
                     $message = $_CLASS['core_user']->lang['ACCOUNT_COPPA'];
                     $email_template = 'coppa_welcome_inactive';
                 } elseif ($_CORE_CONFIG['user']['activation'] == USER_ACTIVATION_SELF) {
                     $message = $_CLASS['core_user']->lang['ACCOUNT_INACTIVE'];
                     $email_template = 'user_welcome_inactive';
                 } elseif ($_CORE_CONFIG['user']['activation'] == USER_ACTIVATION_ADMIN) {
                     $message = $_CLASS['core_user']->lang['ACCOUNT_INACTIVE_ADMIN'];
                     $email_template = 'admin_welcome_inactive';
                 }
             } else {
                 $user_status = STATUS_ACTIVE;
                 $user_act_key = null;
                 $email_template = 'user_welcome';
                 $message = $_CLASS['core_user']->lang['ACCOUNT_ADDED'];
             }
             $data = array('username' => (string) $username, 'user_email' => (string) $email, 'user_group' => $coppa ? 3 : 2, 'user_reg_date' => (int) $_CLASS['core_user']->time, 'user_timezone' => (string) $tz, 'user_password' => (string) $password, 'user_password_encoding' => (string) $_CORE_CONFIG['user']['password_encoding'], 'user_lang' => $lang ? (string) $lang : null, 'user_type' => USER_NORMAL, 'user_status' => (int) $user_status, 'user_act_key' => (string) $user_act_key, 'user_ip' => (string) $_CLASS['core_user']->ip);
             user_add($data);
             if ($data['user_status'] === STATUS_ACTIVE) {
                 set_core_config('user', 'newest_user_id', $data['user_id'], false);
                 set_core_config('user', 'newest_username', $data['username'], false);
                 set_core_config('user', 'total_users', $_CORE_CONFIG['user']['total_users'] + 1, false);
             }
             require_once $site_file_root . 'includes/mailer.php';
             $mailer = new core_mailer();
             $mailer->to($email, $username);
             $mailer->subject($subject);
             $_CLASS['core_template']->assign_array(array('SITENAME' => $_CORE_CONFIG['global']['site_name'], 'WELCOME_MSG' => sprintf($_CLASS['core_user']->lang['WELCOME_SUBJECT'], $_CORE_CONFIG['global']['site_name']), 'USERNAME' => $username, 'PASSWORD' => $password, 'EMAIL_SIG' => '', 'U_ACTIVATE' => generate_link('system&amp;mode=activate&user_id=' . $data['user_id'] . '&key=' . $user_act_key, array('sid' => false, 'full' => true))));
             if ($coppa) {
                 $_CLASS['core_template']->assign_array(array('FAX_INFO' => $_CORE_CONFIG['user']['coppa_fax'], 'MAIL_INFO' => $_CORE_CONFIG['user']['coppa_mail'], 'EMAIL_ADDRESS' => $email, 'SITENAME' => $_CORE_CONFIG['global']['site_name']));
             }
             $mailer->message = trim($_CLASS['core_template']->display('modules/Control_Panel/email/' . $email_template, true));
             $mailer->send();
             $message = $message . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_INDEX'], '<a href="' . generate_link() . '">', '</a>');
             trigger_error($message);
         }
     }
     $s_hidden_fields .= '<input type="hidden" name="coppa" value="' . $coppa . '" />';
     $s_hidden_fields .= '<input type="hidden" name="agreed" value="true" />';
     if ($_CORE_CONFIG['user']['enable_confirm']) {
         $_CLASS['core_user']->session_data_set('confirmation_code', generate_string(6));
         $confirm_image = '<img src="' . generate_link('system&amp;mode=confirmation_image') . '" alt="" title="" />';
     } else {
         $confirm_image = false;
     }
     if ($submit) {
         if ($_CORE_CONFIG['user']['max_reg_attempts']) {
             $attempts = (int) $_CLASS['core_user']->session_data_get('reg_attempts', 0);
             if ($attempts > $_CORE_CONFIG['user']['max_reg_attempts']) {
                 trigger_error($_CLASS['core_user']->lang['TOO_MANY_REGISTERS']);
             }
             $_CLASS['core_user']->session_data_get('reg_attempts', $attempts + 1);
         }
     }
     switch ($_CORE_CONFIG['user']['activation']) {
         case USER_ACTIVATION_SELF:
             $l_reg_cond = $_CLASS['core_user']->lang['UCP_EMAIL_ACTIVATE'];
             break;
         case USER_ACTIVATION_ADMIN:
             $l_reg_cond = $_CLASS['core_user']->lang['UCP_ADMIN_ACTIVATE'];
             break;
         default:
             $l_reg_cond = '';
             break;
     }
     $user_char_ary = array('.*' => 'USERNAME_CHARS_ANY', '[\\w]+' => 'USERNAME_ALPHA_ONLY', '[\\w_\\+\\. \\-\\[\\]]+' => 'USERNAME_ALPHA_SPACERS');
     $_CLASS['core_template']->assign_array(array('ERROR' => empty($error) ? false : implode('<br />', $error), 'USERNAME' => isset($username) ? $username : '', 'PASSWORD' => isset($password) ? $password : '', 'EMAIL' => isset($email) ? $email : '', 'EMAIL_CONFIRM' => isset($email_confirm) ? $email_confirm : '', 'CONFIRM_IMG' => $confirm_image, 'SELECT_TZ' => select_tz(isset($tz) ? $tz : $_CORE_CONFIG['global']['default_timezone']), 'L_CONFIRM_EXPLAIN' => sprintf($_CLASS['core_user']->lang['CONFIRM_EXPLAIN'], '<a href="mailto:' . htmlentities($config['board_contact']) . '">', '</a>'), 'L_ITEMS_REQUIRED' => $l_reg_cond, 'L_USERNAME_EXPLAIN' => sprintf($_CLASS['core_user']->lang[$user_char_ary[$_CORE_CONFIG['user']['allow_name_chars']] . '_EXPLAIN'], $_CORE_CONFIG['user']['min_name_chars'], $_CORE_CONFIG['user']['max_name_chars']), 'L_NEW_PASSWORD_EXPLAIN' => sprintf($_CLASS['core_user']->lang['NEW_PASSWORD_EXPLAIN'], $_CORE_CONFIG['user']['min_pass_chars'], $_CORE_CONFIG['user']['max_pass_chars']), 'S_COPPA' => $coppa, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_UCP_ACTION' => generate_link("Control_Panel&amp;mode=register")));
     $this->display($_CLASS['core_user']->lang['REGISTER'], 'ucp_register.html');
 }
Пример #6
0
                 $name = $row['username'];
                 $subject .= 'Email a friend';
             }
             $mailer->to($email, $name);
             $mailer->reply_to($_CLASS['core_user']->data['user_email'], $_CLASS['core_user']->data['username']);
             $mailer->subject($subject);
             if ($cc) {
                 $mailer->cc($_CLASS['core_user']->data['user_email'], $_CLASS['core_user']->data['username']);
             }
             //$mailer->extra_header('X-AntiAbuse: Board servername - ' . $config['server_name']);
             $mailer->extra_header('X-AntiAbuse: User_id - ' . $_CLASS['core_user']->data['user_id']);
             $mailer->extra_header('X-AntiAbuse: Username - ' . $_CLASS['core_user']->data['username']);
             $mailer->extra_header('X-AntiAbuse: User IP - ' . $_CLASS['core_user']->ip);
             $_CLASS['core_template']->assign_array(array('SITENAME' => $_CORE_CONFIG['global']['site_name'], 'BOARD_EMAIL' => $config['board_contact'], 'FROM_USERNAME' => $_CLASS['core_user']->data['username'], 'TO_USERNAME' => $topic_id ? $name : $row['username'], 'MESSAGE' => $message, 'TOPIC_NAME' => $topic_id ? strtr($row['topic_title'], array_flip(get_html_translation_table(HTML_ENTITIES))) : '', 'U_TOPIC' => $topic_id ? generate_link('Forums&amp;file=viewforum&amp;f=' . $row['forum_id'] . "&t={$topic_id}", array('full' => true, 'sid' => false)) : ''));
             $mailer->message = trim($_CLASS['core_template']->display('email/members_list/' . $template, true));
             $mailer->send();
             $_CLASS['core_display']->meta_refresh(3, generate_link());
             $message = !$topic_id ? sprintf($_CLASS['core_user']->lang['RETURN_INDEX'], '<a href="' . generate_link() . '">', '</a>') : sprintf($_CLASS['core_user']->lang['RETURN_TOPIC'], '<a href="' . generate_link("Forums&amp;file=viewtopic&amp;f={$forum_id}&amp;t=" . $row['topic_id']) . '">', '</a>');
             trigger_error($_CLASS['core_user']->lang['EMAIL_SENT'] . '<br /><br />' . $message);
         }
     }
     if ($topic_id) {
         $_CLASS['core_template']->assign_array(array('EMAIL' => htmlspecialchars($email), 'NAME' => htmlspecialchars($name), 'TOPIC_TITLE' => $row['topic_title'], 'U_TOPIC' => generate_link("Forums&amp;file=viewtopic&amp;f={$row['forum_id']}&amp;t={$topic_id}"), 'S_LANG_OPTIONS' => $topic_id ? language_select($email_lang) : ''));
     }
     $_CLASS['core_template']->assign_array(array('USERNAME' => !$topic_id ? $row['username'] : '', 'ERROR_MESSAGE' => empty($error) ? '' : implode('<br />', $error), 'L_EMAIL_BODY_EXPLAIN' => $_CLASS['core_user']->get_lang(!$topic_id ? 'EMAIL_BODY_EXPLAIN' : 'EMAIL_TOPIC_EXPLAIN'), 'S_POST_ACTION' => !$topic_id ? generate_link('Members_List&amp;mode=email&amp;u=' . $user_id, array('full' => true)) : generate_link("Members_List&amp;mode=email&amp;f={$row['forum_id']}&amp;t={$topic_id}", array('full' => true)), 'S_SEND_USER' => !$topic_id));
     break;
 case 'group':
     $_CLASS['core_user']->add_lang('groups', 'Forums');
 default:
     // The basic memberlist
     $page_title = $_CLASS['core_user']->lang['MEMBERLIST'];
Пример #7
0
/**
* Disapprove Post/Topic
*/
function disapprove_post($post_id_list, $mode)
{
    global $_CLASS, $_CORE_CONFIG, $config;
    $forum_id = request_var('f', 0);
    if (!check_ids($post_id_list, FORUMS_POSTS_TABLE, 'post_id', 'm_approve')) {
        trigger_error('NOT_AUTHORIZED');
    }
    $redirect = request_var('redirect', $_CLASS['core_user']->data['session_page']);
    $reason = request_var('reason', '', true);
    $reason_id = request_var('reason_id', 0);
    $success_msg = $additional_msg = '';
    $s_hidden_fields = build_hidden_fields(array('i' => 'queue', 'f' => $forum_id, 'mode' => $mode, 'post_id_list' => $post_id_list, 'mode' => 'disapprove', 'redirect' => $redirect));
    $notify_poster = isset($_REQUEST['notify_poster']);
    $disapprove_reason = '';
    if ($reason_id) {
        $sql = 'SELECT reason_title, reason_description
			FROM ' . FORUMS_REPORTS_REASONS_TABLE . " \n\t\t\tWHERE reason_id = {$reason_id}";
        $result = $_CLASS['core_db']->query($sql);
        $row = $_CLASS['core_db']->fetch_row_assoc($result);
        $_CLASS['core_db']->free_result($result);
        if (!$row || !$reason && $row['reason_name'] === 'other') {
            $additional_msg = $_CLASS['core_user']->lang['NO_REASON_DISAPPROVAL'];
            unset($_POST['confirm']);
        } else {
            $disapprove_reason = $row['reason_title'] != 'other' ? isset($_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]) ? $_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description'] : '';
            $disapprove_reason .= $reason ? "\n\n" . $reason : '';
            unset($reason);
        }
    }
    require_once SITE_FILE_ROOT . 'includes/forums/functions_display.php';
    $reason = display_reasons($reason_id);
    $_CLASS['core_template']->assign_array(array('S_NOTIFY_POSTER' => true, 'S_APPROVE' => false, 'REASON' => $reason, 'ADDITIONAL_MSG' => $additional_msg));
    if (display_confirmation($_CLASS['core_user']->get_lang('DISAPPROVE_POST' . (sizeof($post_id_list) == 1 ? '' : 'S')), $s_hidden_fields, 'modules/forums/mcp_approve.html')) {
        $post_info = get_post_data($post_id_list, 'm_approve');
        // If Topic -> forum_topics_real -= 1
        // If Post -> topic_replies_real -= 1
        $forum_topics_real = 0;
        $topic_replies_real_sql = $post_disapprove_sql = $topic_id_list = array();
        foreach ($post_info as $post_id => $post_data) {
            $topic_id_list[$post_data['topic_id']] = 1;
            // Topic or Post. ;)
            if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
                if ($post_data['forum_id']) {
                    $forum_topics_real++;
                }
            } else {
                if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
                    $topic_replies_real_sql[$post_data['topic_id']] = 1;
                } else {
                    $topic_replies_real_sql[$post_data['topic_id']]++;
                }
            }
            $post_disapprove_sql[] = $post_id;
        }
        if ($forum_topics_real) {
            $sql = 'UPDATE ' . FORUMS_FORUMS_TABLE . "\n\t\t\t\tSET forum_topics_real = forum_topics_real - {$forum_topics_real}\n\t\t\t\tWHERE forum_id = {$forum_id}";
            $_CLASS['core_db']->query($sql);
        }
        if (!empty($topic_replies_real_sql)) {
            foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
                $sql = 'UPDATE ' . FORUMS_TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
                $_CLASS['core_db']->query($sql);
            }
        }
        if (sizeof($post_disapprove_sql)) {
            if (!function_exists('delete_posts')) {
                require_once SITE_FILE_ROOT . 'includes/forums/functions_admin.php';
            }
            // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
            delete_posts('post_id', $post_disapprove_sql);
        }
        unset($post_disapprove_sql, $topic_replies_real_sql);
        update_post_information('topic', array_keys($topic_id_list));
        update_post_information('forum', $forum_id);
        unset($topic_id_list);
        // Notify Poster?
        if ($notify_poster) {
            require_once SITE_FILE_ROOT . 'includes/mailer.php';
            $mailer = new core_mailer();
            foreach ($post_info as $post_id => $post_data) {
                if ($post_data['poster_id'] == ANONYMOUS) {
                    continue;
                }
                $post_data['post_subject'] = censor_text($post_data['post_subject'], true);
                $post_data['topic_title'] = censor_text($post_data['topic_title'], true);
                if ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) {
                    $email_template = 'topic_disapproved.txt';
                    $subject = 'Topic Disapproved - ' . $post_data['topic_title'];
                } else {
                    $email_template = 'post_disapproved.txt';
                    $subject = 'Post Disapproved - ' . $post_data['post_subject'];
                }
                $mailer->to($post_data['user_email'], $post_data['username']);
                //$mailer->reply_to($_CORE_CONFIG['email']['site_email']);
                $mailer->subject($subject);
                //$messenger->im($post_data['user_jabber'], $post_data['username']);
                $_CLASS['core_template']->assign_array(array('SITENAME' => $_CORE_CONFIG['global']['site_name'], 'USERNAME' => $post_data['username'], 'REASON' => stripslashes($disapprove_reason), 'POST_SUBJECT' => $post_data['post_subject'], 'TOPIC_TITLE' => $post_data['topic_title']));
                $mailer->message = trim($_CLASS['core_template']->display('email/forums/' . $email_template, true));
                $mailer->send();
            }
        }
        unset($post_info, $disapprove_reason);
        if ($forum_topics_real) {
            $success_msg = $forum_topics_real == 1 ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
        } else {
            $success_msg = sizeof($post_id_list) == 1 ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
        }
    }
    $redirect = request_var('redirect', generate_link('forums'));
    if (!$success_msg) {
        redirect($redirect);
    } else {
        $_CLASS['core_display']->meta_refresh(3, generate_link("forums&amp;file=viewforum&amp;f={$forum_id}"));
        trigger_error($_CLASS['core_user']->lang[$success_msg] . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_FORUM'], '<a href="' . generate_link('forums&amp;file=viewforum&amp;f=' . $forum_id) . '">', '</a>'));
    }
}