Download Topics and Posts

Eklentiler ile ilgili gelişmeler. Yeni modlar, güncellemeler.

Download Topics and Posts

İleti IcEman 21.03.2007, 23:11

Basit ama benim hoşuma giden bir mod paylaşmak istedim.


Kod: Tümünü seç
##############################################################
## MOD Title:      Download Topics and Posts
## MOD Author: OXPUS < webmaster@oxpus.de > (Karsten Ude) http://www.oxpus.de
## MOD Description:   Insert links on viewtopic to save the whole topic or one post of it in a textfile
## MOD Version:      1.0.6
##
## Installation Level:   Easy
## Installation Time:   5-10 Minutes
## Files To Edit:   4
##         viewtopic.php
##         language/lang_english/lang_main.php
##         language/lang_german/lang_main.php
##         templates/subSilver/viewtopic_body.tpl
##
## Included Files:   n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
##############################################################
## MOD History:
##
##   2005-04-11 - Version 1.0.6
##      - Fix security issue to prevent downloading not allowed topics or posts
##     For update replace in viewtopic.php all after "if ( $download )"
##
##   2005-04-09 - Version 1.0.5
##      - Fix security issue
##     For update replace in viewtopic.php all after "if ( $download )"
##
##   2005-03-18 - Version 1.0.4
##      - Fix filename for downloading textfile
##     For update replace in viewtopic.php all after "if ( $download )"
##
##   2005-01-12 - Version 1.0.3
##      - Fix HTML-Chars on saved Text
##     For update replace in viewtopic.php all after "if ( $download )"
##
##   2004-06-13 - Version 1.0.2
##      - Fix missing include in viewtopic.php
##     For update insert after
##      include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
##     this line:
##      include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
##
##   2004-05-29 - Version 1.0.1
##      - Remove BBCodes and HTML-Chars from saved Text.
##     For update replace in viewtopic.php all after "if ( $download )"
##
##   2004-05-27 - Version 1.0.0
##      - First release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php

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

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

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

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

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

#
#-----[ AFTER, ADD ]------------------------------------------
#
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;
}

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

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

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

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

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

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

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

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

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

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

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

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

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
<br /><a href="{DOWNLOAD_TOPIC}" class="genmed">{L_DOWNLOAD_TOPIC}</a>

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

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
&nbsp;<a href="{postrow.DOWNLOAD_POST}" class="genmed">{L_DOWNLOAD_POST}</a>

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

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
<br /><a href="{DOWNLOAD_TOPIC}" class="genmed">{L_DOWNLOAD_TOPIC}</a>


#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM



En son IcEman tarafından, 22.03.2007, 21:56 tarihinde değiştirildi, toplamda 1 değişiklik yapıldı.
Kullanıcı avatarı
IcEman
Üye
Üye
 
İleti: 239
Kayıt: 04.12.2005, 13:43
Konum: İstanbul

Cvp: Download Topics and Posts

İleti

ALEXIS
22.03.2007, 14:26

Test ettiysen, enter ile verilen boşluklarda ve Türkçe karakterler de sorun çıkıp çıkmadığüı hakkında yorum yazar mısın ? Geçen sene arızalıydılar.
Kullanıcı avatarı
ALEXIS
Site Yöneticisi
Site Yöneticisi
 
İleti: 2563
Kayıt: 30.06.2005, 09:08

Cvp: Download Topics and Posts

İleti IcEman 22.03.2007, 21:55

şu an sitemizde kurulu bu mod ve türkçe karkterlerde bir sorun yaşamadım ve boşluklarda da örneğin bir üye tarafından yazılmış dörtlükler halinde bir şiirde denedim sorun çıkmadı :?
Kullanıcı avatarı
IcEman
Üye
Üye
 
İleti: 239
Kayıt: 04.12.2005, 13:43
Konum: İstanbul


Duyurular & Güncellemeler



Kimler çevrimiçi

Bu forumu görüntüleyenler: Kayıtlı kullanıcı yok ve 0 misafir

cron