/
!!!

## MOD :
##
## : 5-10
## : 4
## viewtopic.php
## language/lang_english/lang_main.php
## language/lang_german/lang_main.php
## templates/subSilver/viewtopic_body.tpl

#-----[ O ]------------------------------------------
#
viewtopic.php

#
#-----[ ]------------------------------------------
#
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);

#
#-----[ ]------------------------------------------
#
include($phpbb_root_path . 'includes/functions_post.'.$phpEx);

#
#-----[ ]------------------------------------------
#
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;

#
#-----[ ]------------------------------------------
#
$download = ( isset($HTTP_GET_VARS['download']) ) ? $HTTP_GET_VARS['download'] : '';

#
#-----[ ]------------------------------------------
#
//
// End session management
//

#
#-----[ ]------------------------------------------
#
if ( $download )
{
$sql_download = ( $download != -1 ) ? " AND p.post_id = " . intval($download) . " " : '';

$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);

$sql = "SELECT u.*, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = $topic_id
$sql_download
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY p.post_time ASC, p.post_id ASC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not create download stream for post.", '', __LINE__, __FILE__, $sql);
}

$download_file = '';

$is_auth_read = array();

while ( $row = $db->sql_fetchrow($result) )
{
$is_auth_read = auth(AUTH_ALL, $row['forum_id'], $userdata);

$poster_id = $row['user_id'];
$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];

$post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);

$post_subject = ( $row['post_subject'] != '' ) ? $row['post_subject'] : '';

$bbcode_uid = $row['bbcode_uid'];
$message = $row['post_text'];
$message = strip_tags($message);
$message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", '', $message);
$message = preg_replace('/\[url\]|\[\/url\]/si', '', $message);
$message = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);

$message = unprepare_message($message);
$message = preg_replace('/(/', '(', $message);
$message = preg_replace('/)/', ')', $message);
$message = preg_replace('/:/', ':', $message);
$message = preg_replace('/[/', '[', $message);
$message = preg_replace('/]/', ']', $message);
$message = preg_replace('/{/', '{', $message);
$message = preg_replace('/}/', '}', $message);

if (count($orig_word))
{
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);

$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
}

$break = "\n\r";
$line = '-----------------------------------';
$download_file .= $break.$line.$break.$poster.$break.$post_date.$break.$break.$post_subject.$break.$line.$break.$message.$break;
}

$disp_folder = ( $download == -1 ) ? 'Topic_'.$topic_id : 'Post_'.$download;

if (!$is_auth_read['auth_read'])
{
$download_file = sprintf($lang['Sorry_auth_read'], $is_auth_read['auth_read_type']);
$disp_folder = 'Download';
}

$filename = $board_config['sitename']."_".$disp_folder."_".date("Ymd",time()).".txt";
header('Content-Type: text/x-delimtext; name="'.$filename.'"');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Content-Transfer-Encoding: plain/text');
header('Content-Length: '.strlen($download_file));
print $download_file;

exit;
}

#
#-----[ ]------------------------------------------
#
//
// Send vars to template
//
$template->assign_vars(array(

#
#-----[ ]------------------------------------------
#
'L_DOWNLOAD_POST' => $lang['Download_post'],
'L_DOWNLOAD_TOPIC' => $lang['Download_topic'],
'DOWNLOAD_TOPIC' => append_sid("viewtopic.$phpEx?download=-1&".POST_TOPIC_URL."=".$topic_id),

#
#-----[ ]------------------------------------------
#
$template->assign_block_vars('postrow', array(

#
#-----[ ]------------------------------------------
#
'DOWNLOAD_POST' => append_sid("viewtopic.$phpEx?download=".$postrow[$i]['post_id']."&".POST_TOPIC_URL."=".$topic_id),

#
#-----[ ]------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ ]------------------------------------------
#
//
// Viewtopic
//

#
#-----[ ]------------------------------------------
#
$lang['Download_post'] = 'Download Post';
$lang['Download_topic'] = 'Download Topic';

#
#-----[ ]------------------------------------------
#
language/lang_german/lang_main.php

#
#-----[ ]------------------------------------------
#
//
// Viewtopic
//

#
#-----[ ]------------------------------------------
#
$lang['Download_post'] = 'Beitrag speichern';
$lang['Download_topic'] = 'Topic speichern';

#
#-----[ O ]------------------------------------------
#
templates/subSilver/viewtopic_body.tpl

#
#-----[ ]------------------------------------------
#
{PAGINATION}

#
#-----[ ]------------------------------------------
#
<br /><a href="{DOWNLOAD_TOPIC}" class="genmed">{L_DOWNLOAD_TOPIC}</a>

#
#-----[ ]------------------------------------------
# // Or find another position
{postrow.POST_DATE}

#
#-----[ ]------------------------------------------
#
 <a href="{postrow.DOWNLOAD_POST}" class="genmed">{L_DOWNLOAD_POST}</a>

#
#-----[ ]------------------------------------------
#
{PAGINATION}

#
#-----[ ]------------------------------------------
#
<br /><a href="{DOWNLOAD_TOPIC}" class="genmed">{L_DOWNLOAD_TOPIC}</a>


#
#-----[ / ]------------------------------------------
#


! :)

/ /