<?php
/***************************************************************************
 *                              quick_reply.php
 *                            -------------------
 *   begin                : Tuesday, May 4, 2004
 *   copyright            : Xpert
 *   contact              : <xpert@phpbbguru.net> http://www.phpbbguru.net
 *
 *   $Id: quick_reply.php,v 3.0.5 2007/02/24 22:38 xpert Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   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($phpbb_root_path . 'includes/functions_post.'.$phpEx);

$template->set_filenames(array('quick_reply_output' => 'quick_reply.tpl'));

$attach_sig = ( $userdata['session_logged_in'] && $userdata['user_attachsig'] ) ? "checked='checked'" : '';
$notify_user = ( $can_watch_topic && ($is_watching_topic || $userdata['user_notify']) ) ? "checked='checked'" : '';
$bbcode = ( !$userdata['session_logged_in'] ) ? $board_config['allow_bbcode'] : $board_config['allow_bbcode'] && $userdata['user_allowbbcode'];
$smilies = ( !$userdata['session_logged_in'] ) ? $board_config['allow_smilies'] : $board_config['allow_smilies'] && $userdata['user_allowsmile'];
$secretkey = 't' . $topic_id;

// Generate a signature to validate this page
$authkey = md5("nana" . $secretkey . "foofoo");
$authval = md5($HTTP_SERVER_VARS['HTTP_USER_AGENT'] . $secretkey . $HTTP_SERVER_VARS['REMOTE_ADDR']);  
$timekey = md5("time" . $secretkey);
$timepad = preg_replace('/[^0-9]/', '', $HTTP_SERVER_VARS['REMOTE_ADDR']) + 0;
$timeval = time() ^ $timepad;

$hidden_form_fields = '<input type="hidden" name="mode" value="reply" />';
$hidden_form_fields .= '<input type="hidden" name="disable_bbcode" value="' . (!$bbcode) . '" />';
$hidden_form_fields .= '<input type="hidden" name="disable_smilies" value="' . (!$smilies) . '" />';
$hidden_form_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
$hidden_form_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
// Insert our signature into the form
$hidden_form_fields .= '<input type="hidden" name="' . $authkey . '" value="' . $authval . '">';
$hidden_form_fields .= '<input type="hidden" name="' . $timekey . '" value="' . $timeval . '">';

$template->assign_vars(array(
'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_QUICK_REPLY' => $lang['QR'],
	'L_USERNAME' => $lang['Username'],
	'L_MESSAGE_BODY' => $lang['Message_body'],
	'L_ATTACH_SIGNATURE' => $lang['Attach_signature'],
	'L_NOTIFY' => $lang['Notify'],
	'L_PREVIEW' => $lang['Preview'],
	'L_SUBMIT' => $lang['Submit'],
	// [begin] Post Is Sending	
	'L_TRANSLIT' => $lang['Translit'], 
	// [end] Post Is Sending
	'L_NO_TEXT_SELECTED' => $lang['QR_no_text_selected'],
	'L_EMPTY_MESSAGE' => $lang['Empty_message'],
	'S_QUICK_REPLY_ACTION' => append_sid('posting.'.$phpEx),
	'S_ATTACH_SIGNATURE' => $attach_sig,
	'S_NOTIFY' => $notify_user,
	'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields
	)
);

generate_smilies('inline', PAGE_POSTING);

$template->assign_var_from_handle('QUICK_REPLY', 'quick_reply_output');

?>