Code: Alles auswählen
<?
/***************************************************************************
* gb_post.php
* -----------
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
if ( !defined('IN_PHPBB') )
{
die("Hacking attempt");
}
include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include_once($phpbb_root_path . 'includes/functions_post.'.$phpEx);
$profiledata = get_userdata(intval($id));
if ( isset($HTTP_GET_VARS['id']) || isset($HTTP_POST_VARS['id']) )
{
$id = ( isset($HTTP_GET_VARS['id']) ) ? intval($HTTP_GET_VARS['id']) : intval($HTTP_POST_VARS['id']);
}
if ( isset($HTTP_GET_VARS['cid']) || isset($HTTP_POST_VARS['cid']) )
{
$cid = ( isset($HTTP_GET_VARS['cid']) ) ? intval($HTTP_GET_VARS['cid']) : intval($HTTP_POST_VARS['cid']);
}
$allowhtml = $board_config['allow_html'];
$allowbbcode = $board_config['allow_bbcode'];
$allowsmilies = $board_config['allow_smilies'];
if(!isset($HTTP_POST_VARS['submit']))
{
// Generate smilies
generate_smilies('inline', PAGE_POSTING);
//
// Include page header
//
$template->set_filenames(array(
'comment_post_output' => 'gb_comment_posting.tpl')
);
$html_status = ( $userdata['user_allowhtml'] && $board_config['allow_html'] ) ? $lang['HTML_is_ON'] : $lang['HTML_is_OFF'];
$bbcode_status = ( $userdata['user_allowbbcode'] && $board_config['allow_bbcode'] ) ? $lang['BBCode_is_ON'] : $lang['BBCode_is_OFF'];
$smilies_status = ( $userdata['user_allowsmile'] && $board_config['allow_smilies'] ) ? $lang['Smilies_are_ON'] : $lang['Smilies_are_OFF'];
$links_status = ( $board_config['allow_comment_links'] ) ? $lang['Links_are_ON'] : $lang['Links_are_OFF'];
$images_status = ( $board_config['allow_comment_images'] ) ? $lang['Images_are_ON'] : $lang['Images_are_OFF'];
$hidden_form_fields = '<input type="hidden" name="action" value="file">
<input type="hidden" name="id" value="' . $id . '">
<input type="hidden" name="comment" value="post">';
//
// Output the data to the template
//
$template->assign_vars(array(
'HTML_STATUS' => $html_status,
'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'),
'SMILIES_STATUS' => $smilies_status,
'LINKS_STATUS' => $links_status,
'IMAGES_STATUS' => $images_status,
'L_COMMENT_ADD' => $lang['Comment_add'],
'L_COMMENT' => $lang['Message_body'],
'L_COMMENT_TITLE' => $lang['Subject'],
'L_OPTIONS' => $lang['Options'],
'L_COMMENT_EXPLAIN' => sprintf($lang['Comment_explain'], $board_config['max_comment_chars']),
'L_PREVIEW' => $lang['Preview'],
'L_SUBMIT' => $lang['Submit'],
'L_USER_PROFILE'=> $lang['gb_sign'],
'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
'L_BBCODE_B_HELP' => $lang['bbcode_b_help'],
'L_BBCODE_I_HELP' => $lang['bbcode_i_help'],
'L_BBCODE_U_HELP' => $lang['bbcode_u_help'],
'L_BBCODE_Q_HELP' => $lang['bbcode_q_help'],
'L_BBCODE_C_HELP' => $lang['bbcode_c_help'],
'L_BBCODE_L_HELP' => $lang['bbcode_l_help'],
'L_BBCODE_O_HELP' => $lang['bbcode_o_help'],
'L_BBCODE_P_HELP' => $lang['bbcode_p_help'],
'L_BBCODE_W_HELP' => $lang['bbcode_w_help'],
'L_BBCODE_A_HELP' => $lang['bbcode_a_help'],
'L_BBCODE_S_HELP' => $lang['bbcode_s_help'],
'L_BBCODE_F_HELP' => $lang['bbcode_f_help'],
'L_EMPTY_MESSAGE' => $lang['Empty_message'],
'L_FONT_COLOR' => $lang['Font_color'],
'L_COLOR_DEFAULT' => $lang['color_default'],
'L_COLOR_DARK_RED' => $lang['color_dark_red'],
'L_COLOR_RED' => $lang['color_red'],
'L_COLOR_ORANGE' => $lang['color_orange'],
'L_COLOR_BROWN' => $lang['color_brown'],
'L_COLOR_YELLOW' => $lang['color_yellow'],
'L_COLOR_GREEN' => $lang['color_green'],
'L_COLOR_OLIVE' => $lang['color_olive'],
'L_COLOR_CYAN' => $lang['color_cyan'],
'L_COLOR_BLUE' => $lang['color_blue'],
'L_COLOR_DARK_BLUE' => $lang['color_dark_blue'],
'L_COLOR_INDIGO' => $lang['color_indigo'],
'L_COLOR_VIOLET' => $lang['color_violet'],
'L_COLOR_WHITE' => $lang['color_white'],
'L_COLOR_BLACK' => $lang['color_black'],
'L_FONT_SIZE' => $lang['Font_size'],
'L_FONT_TINY' => $lang['font_tiny'],
'L_FONT_SMALL' => $lang['font_small'],
'L_FONT_NORMAL' => $lang['font_normal'],
'L_FONT_LARGE' => $lang['font_large'],
'L_FONT_HUGE' => $lang['font_huge'],
'L_BBCODE_CLOSE_TAGS' => $lang['Close_Tags'],
'L_STYLES_TIP' => $lang['Styles_tip'],
'U_USER_PROFILE' => append_sid("profile.$phpEx?mode=viewprofile&u=$id#gb"),
'U_INDEX' => append_sid('index.'.$phpEx),
'S_POST_ACTION' => append_sid("profile.$phpEx?mode=viewprofile&u=$id&action=post"),
'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields)
);
//
// Show preview stuff if user clicked preview
//
if(isset($HTTP_POST_VARS['preview']))
{
$comments_text = stripslashes($HTTP_POST_VARS['message']);
$title = stripslashes($HTTP_POST_VARS['subject']);
$comment_bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : '';
$comments_text = bbencode_first_pass($comments_text, $comment_bbcode_uid);
if ( !$board_config['allow_html'] && $userdata['user_allowhtml'] )
{
$comments_text = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $comments_text);
}
if ( $board_config['allow_bbcode'])
{
$comments_text = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($comments_text, $comment_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $comments_text);
}
//
// Parse smilies
//
if ( $board_config['allow_smilies'] )
{
$comments_text = smilies_pass($comments_text);
}
$comments_text = make_clickable($comments_text);
$comments_text = str_replace("\n", "\n<br />\n", $comments_text);
//
// Replace naughty words
//
if (!$profiledata['user_allowswearywords'])
{
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
$comments_text = preg_replace($orig_word, $replacement_word, $comments_text);
}
$template->assign_block_vars('preview', array());
$template->assign_vars(array(
'COMMENT' => stripslashes($HTTP_POST_VARS['message']),
'SUBJECT' => stripslashes($HTTP_POST_VARS['subject']),
'PRE_COMMENT' => $comments_text)
);
}
$template->assign_var_from_handle("ACTION_INCLUDE", "comment_post_output");
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->pparse('comment_post_output');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
if(isset($HTTP_POST_VARS['submit']))
{
if (!$userdata['session_logged_in'])
{
message_die(GENERAL_MESSAGE, 'oooops ...Logged out... timeout?');
}
$length = strlen($HTTP_POST_VARS['message']);
$comments_text = str_replace('<br />', "\n", $HTTP_POST_VARS['message']);
$comment_bbcode_uid = make_bbcode_uid();
$comments_text = prepare_message($comments_text, $allowhtml, $allowbbcode, $allowsmilies, $comment_bbcode_uid);
$comments_text = bbencode_first_pass($comments_text, $comment_bbcode_uid);
$poster_id = $userdata['user_id'];
$title = $HTTP_POST_VARS['subject'];
$time = time();
$sql = "INSERT INTO " . PROFILE_GB_TABLE . " VALUES('','" . $id . "','" . str_replace("\'", "''", $comments_text) . "','" . str_replace("\'", "''", $title) . "','" . $time . "', '" . $comment_bbcode_uid . "','" . $poster_id . "')";
if ( !($db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldnt insert comments', '', __LINE__, __FILE__, $sql);
}
$usertodata = get_userdata(intval($HTTP_GET_VARS[POST_USERS_URL]));
// now send email if all the usual conditions & $send_email is set
if ( $usertodata['user_notify_pm'] && !empty($usertodata['user_email']) && $usertodata['user_active'] )
{
$gblang = $usertodata['user_lang'];
$script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/profile.'.$phpEx : 'profile.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->use_template('gb_notify', $usertodata['user_lang']);
$emailer->email_address($usertodata['user_email']);
$emailer->set_subject(); //$lang['Notification_subject']
$emailer->assign_vars(array(
'USERNAME' => $usertodata['username'],
'SITENAME' => $board_config['sitename'],
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),
'U_GBOOK' => $server_protocol . $server_name . $server_port . $script_name . '?mode=viewprofile&u='.$usertodata['user_id'].'#gb')
);
$emailer->send();
$emailer->reset();
}
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("profile.$phpEx?mode=viewprofile&u=" . $id) . '#gb">')
);
$message = $lang['Comment_posted'] . "<br /><br />" . sprintf($lang['Click_return'], "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&u=" . $id) . "#gb\">", "</a>");
message_die(GENERAL_MESSAGE, $message);
}
?>