function prepare_post(&$mode, &$post_data, &$error_msg, &$username, &$subject, &$message) { global $bb_cfg, $user, $userdata, $lang; // Check username if (!empty($username)) { $username = clean_username($username); if (!$userdata['session_logged_in'] || $userdata['session_logged_in'] && $username != $user->name) { require INC_DIR . 'functions_validate.php'; if ($err = validate_username($username)) { $error_msg .= $err; } } else { $username = ''; } } // Check subject if (!empty($subject)) { $subject = str_replace('&', '&', $subject); } else { if ($mode == 'newtopic' || $mode == 'editpost' && $post_data['first_post']) { $error_msg .= !empty($error_msg) ? '<br />' . $lang['EMPTY_SUBJECT'] : $lang['EMPTY_SUBJECT']; } } // Check message if (!empty($message)) { } else { if ($mode != 'delete') { $error_msg .= !empty($error_msg) ? '<br />' . $lang['EMPTY_MESSAGE'] : $lang['EMPTY_MESSAGE']; } } // Check smilies limit if ($bb_cfg['max_smilies']) { $count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . $bb_cfg['smilies_path']); if ($count_smilies > $bb_cfg['max_smilies']) { $to_many_smilies = sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']); $error_msg .= !empty($error_msg) ? '<br />' . $to_many_smilies : $to_many_smilies; } } if (IS_GUEST && !bb_captcha('check')) { $error_msg .= !empty($error_msg) ? '<br />' . $lang['CAPTCHA_WRONG'] : $lang['CAPTCHA_WRONG']; } }
$emailer->reset(); $message = $lang['PROFILE_UPDATED_INACTIVE']; $user->session_end(); } else { meta_refresh('index.php', 10); $message = $lang['PROFILE_UPDATED']; } $sql_args = DB()->build_array('UPDATE', $db_data); DB()->query("UPDATE " . BB_USERS . " SET {$sql_args} WHERE user_id = {$pr_data['user_id']} LIMIT 1"); if ($pr_data['user_id'] != $userdata['user_id']) { if ($pr_data['user_level'] == MOD && !empty($db_data['username'])) { $datastore->update('moderators'); } } cache_rm_user_sessions($pr_data['user_id']); if ($adm_edit) { bb_die($lang['PROFILE_USER'] . ' <b>' . profile_url($pr_data) . '</b> ' . $lang['GOOD_UPDATE']); } elseif (!$pr_data['user_active']) { bb_die($lang['PROFILE_UPDATED_INACTIVE']); } else { meta_refresh('index.php', 10); bb_die($lang['PROFILE_UPDATED']); } } else { bb_die($lang['NOTHING_HAS_CHANGED']); } } } $template->assign_vars($tp_data); $template->assign_vars(array('PAGE_TITLE' => $mode == 'editprofile' ? $lang['EDIT_PROFILE'] . ($adm_edit ? " :: {$pr_data['username']}" : '') : $lang['REGISTER'], 'SHOW_REG_AGREEMENT' => $mode == 'register' && !IS_ADMIN, 'ERROR_MESSAGE' => $errors ? join('<br />', array_unique($errors)) : '', 'MODE' => $mode, 'EDIT_PROFILE' => $mode == 'editprofile', 'ADM_EDIT' => $adm_edit, 'SHOW_PASS' => $adm_edit || $mode == 'register' && IS_ADMIN, 'CAPTCHA_HTML' => $need_captcha ? bb_captcha('get') : '', 'LANGUAGE_SELECT' => language_select($pr_data['user_lang'], 'user_lang'), 'TIMEZONE_SELECT' => tz_select($pr_data['user_timezone'], 'user_timezone'), 'USER_TIMEZONE' => $pr_data['user_timezone'], 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['avatars']['max_width'], $bb_cfg['avatars']['max_height'], round($bb_cfg['avatars']['max_size'] / 1024)), 'AVATAR_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_avatar'), 'AVATAR_DIS_EXPLAIN' => sprintf($lang['AVATAR_DISABLE'], $bb_cfg['terms_and_conditions_url']), 'AVATAR_IMG' => get_avatar($pr_data['user_id'], $pr_data['avatar_ext_id'], !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar')), 'SIGNATURE_EXPLAIN' => sprintf($lang['SIGNATURE_EXPLAIN'], $bb_cfg['max_sig_chars']), 'SIG_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_sig'), 'PR_USER_ID' => $pr_data['user_id'], 'U_RESET_AUTOLOGIN' => LOGIN_URL . "?logout=1&reset_autologin=1&sid={$userdata['session_id']}")); print_page('usercp_register.tpl');
display_post_attachments($post_id, $postrow[$i]['post_attachment']); } if ($moderation && !defined('SPLIT_FORM_START') && ($start || $post_id == $t_data['topic_first_post_id'])) { define('SPLIT_FORM_START', TRUE); } if ($poster_id != BOT_UID) { $prev_post_time = $postrow[$i]['post_time']; } } set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id, $max_post_time); if (defined('SPLIT_FORM_START')) { $template->assign_vars(array('SPLIT_FORM' => true, 'START' => $start, 'S_SPLIT_ACTION' => "modcp.php", 'POST_FORUM_URL' => POST_FORUM_URL, 'POST_TOPIC_URL' => POST_TOPIC_URL)); } // Quick Reply if ($bb_cfg['show_quick_reply']) { if ($is_auth['auth_reply'] && !($t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED)) { $template->assign_vars(array('QUICK_REPLY' => true, 'QR_POST_ACTION' => POSTING_URL, 'QR_TOPIC_ID' => $topic_id, 'CAPTCHA_HTML' => IS_GUEST ? bb_captcha('get') : '')); if (!IS_GUEST) { $notify_user = bf($userdata['user_opt'], 'user_opt', 'user_notify'); $template->assign_vars(array('QR_NOTIFY_CHECKED' => $notify_user ? $notify_user && $is_watching_topic : $is_watching_topic)); } } } foreach ($is_auth as $name => $is) { $template->assign_vars(array(strtoupper($name) => $is)); } $template->assign_vars(array('PG_ROW_CLASS' => isset($pg_row_class) ? $pg_row_class : 'row1')); if (IS_ADMIN) { $template->assign_vars(array('U_LOGS' => "admin/admin_log.php?sid={$userdata['session_id']}&t={$topic_id}&db=900")); } print_page('viewtopic.tpl');
if (in_array($row['user_level'], array(MOD, ADMIN))) { bb_die($lang['NO_SEND_ACCOUNT']); } $username = $row['username']; $user_id = $row['user_id']; $user_actkey = make_rand_str(12); $user_password = make_rand_str(8); $sql = "UPDATE " . BB_USERS . "\n\t\t\t\tSET user_newpasswd = '{$user_password}', user_actkey = '{$user_actkey}'\n\t\t\t\tWHERE user_id = " . $row['user_id']; if (!DB()->sql_query($sql)) { bb_die('Could not update new password information'); } require CLASS_DIR . 'emailer.php'; $emailer = new emailer($bb_cfg['smtp_delivery']); $emailer->from($bb_cfg['sitename'] . " <{$bb_cfg['board_email']}>"); $emailer->email_address("{$username} <{$row['user_email']}>"); $emailer->use_template('user_activate_passwd', $row['user_lang']); $emailer->assign_vars(array('SITENAME' => $bb_cfg['sitename'], 'USERNAME' => $username, 'PASSWORD' => $user_password, 'U_ACTIVATE' => make_url('profile.php?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey))); $emailer->send(); $emailer->reset(); bb_die($lang['PASSWORD_UPDATED']); } else { bb_die($lang['NO_EMAIL_MATCH']); } } else { bb_die('Could not obtain user information for sendpassword'); } } else { $email = $username = ''; } $template->assign_vars(array('USERNAME' => $username, 'EMAIL' => $email, 'CAPTCHA_HTML' => $need_captcha ? bb_captcha('get') : '', 'S_HIDDEN_FIELDS' => '', 'S_PROFILE_ACTION' => "profile.php?mode=sendpassword")); print_page('usercp_sendpasswd.tpl');
if (!$login_errors) { if ($user->login($_POST, $mod_admin_login)) { $redirect_url = defined('FIRST_LOGON') ? $bb_cfg['first_logon_redirect_url'] : $redirect_url; // Обнуление при введении правильно комбинации логин/пароль CACHE('bb_login_err')->set('l_err_' . USER_IP, 0, 3600); if ($redirect_url == '/' . LOGIN_URL || $redirect_url == LOGIN_URL) { $redirect_url = 'index.php'; } redirect($redirect_url); } $login_errors[] = $lang['ERROR_LOGIN']; if (!$mod_admin_login) { $login_err = CACHE('bb_login_err')->get('l_err_' . USER_IP); if ($login_err > $bb_cfg['invalid_logins']) { $need_captcha = true; } if ($login_err > 50) { // TODO temp ban ip } CACHE('bb_login_err')->set('l_err_' . USER_IP, $login_err + 1, 3600); } else { $need_captcha = false; } } } // Login page if (IS_GUEST || $mod_admin_login) { $template->assign_vars(array('LOGIN_USERNAME' => htmlCHR($login_username), 'LOGIN_PASSWORD' => htmlCHR($login_password), 'ERROR_MESSAGE' => join('<br />', $login_errors), 'ADMIN_LOGIN' => $mod_admin_login, 'REDIRECT_URL' => htmlCHR($redirect_url), 'CAPTCHA_HTML' => $need_captcha && !$bb_cfg['captcha']['disabled'] ? bb_captcha('get') : '', 'PAGE_TITLE' => $lang['LOGIN'], 'S_LOGIN_ACTION' => LOGIN_URL)); print_page('login.tpl'); } redirect($redirect_url);
} // Update download count if (!$thumbnail) { $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET download_count = download_count + 1 WHERE attach_id = ' . (int) $attachment['attach_id']; if (!DB()->sql_query($sql)) { bb_die('Could not update attachment download count'); } } // Determine the 'presenting'-method if ($download_mode == PHYSICAL_LINK) { $url = make_url($upload_dir . '/' . $attachment['physical_filename']); header('Location: ' . $url); exit; } else { if (IS_GUEST && !bb_captcha('check')) { global $template; $redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/'); $message = '<form action="' . DOWNLOAD_URL . $attachment['attach_id'] . '" method="post">'; $message .= $lang['CAPTCHA'] . ':'; $message .= '<div class="mrg_10" align="center">' . bb_captcha('get') . '</div>'; $message .= '<input type="hidden" name="redirect_url" value="' . $redirect_url . '" />'; $message .= '<input type="submit" class="bold" value="' . $lang['SUBMIT'] . '" /> '; $message .= '<input type="button" class="bold" value="' . $lang['GO_BACK'] . '" onclick="document.location.href = \'' . $redirect_url . '\';" />'; $message .= '</form>'; $template->assign_vars(array('ERROR_MESSAGE' => $message)); require PAGE_HEADER; require PAGE_FOOTER; } send_file_to_browser($attachment, $upload_dir); exit; }
$page_title = $lang['POST_A_NEW_TOPIC']; $hidden_form_fields .= '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />'; break; case 'reply': $page_title = $lang['POST_A_REPLY']; $hidden_form_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />'; break; case 'editpost': $page_title = $lang['EDIT_POST']; $hidden_form_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />'; break; } // Generate smilies listing for page output generate_smilies('inline'); $template->set_filenames(array('body' => 'posting.tpl')); // Output the data to the template $template->assign_vars(array('FORUM_NAME' => htmlCHR($forum_name), 'PAGE_TITLE' => $page_title, 'POSTING_TYPE_TITLE' => $page_title, 'POSTING_TOPIC_ID' => $mode != 'newtopic' ? $topic_id : '', 'POSTING_TOPIC_TITLE' => $mode != 'newtopic' ? wbr($post_info['topic_title']) : '', 'U_VIEW_FORUM' => "viewforum.php?" . POST_FORUM_URL . "={$forum_id}", 'USERNAME' => @$username, 'CAPTCHA_HTML' => IS_GUEST ? bb_captcha('get') : '', 'SUBJECT' => $subject, 'MESSAGE' => $message, 'POSTER_RGROUPS' => isset($poster_rgroups) && !empty($poster_rgroups) ? $poster_rgroups : '', 'ATTACH_RG_SIG' => $switch_rg_sig ? $switch_rg_sig : false, 'U_VIEWTOPIC' => $mode == 'reply' ? "viewtopic.php?" . POST_TOPIC_URL . "={$topic_id}&postorder=desc" : '', 'S_NOTIFY_CHECKED' => $notify_user ? 'checked="checked"' : '', 'S_TYPE_TOGGLE' => $topic_type_toggle, 'S_TOPIC_ID' => $topic_id, 'S_POST_ACTION' => POSTING_URL, 'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields)); if ($mode == 'newtopic' || $post_data['first_post']) { $template->assign_var('POSTING_SUBJECT'); } // Update post time if ($mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post']) { $template->assign_vars(array('SHOW_UPDATE_POST_TIME' => $is_auth['auth_mod'] || $post_data['poster_post'] && $post_info['post_time'] + 3600 * 3 > TIMENOW, 'UPDATE_POST_TIME_CHECKED' => $post_data['poster_post'] && $post_info['post_time'] + 3600 * 2 > TIMENOW)); } // Topic review if ($mode == 'reply' && $is_auth['auth_read']) { topic_review($topic_id); } require PAGE_HEADER; $template->pparse('body'); require PAGE_FOOTER;