DOWNLOAD Select/Expand with SXBB1.0.2, look inside.
 
 
Post new topic   Reply to topic   printer-friendly view    phpMiX.org Forum Index -> phpBB MODs -> Select Expand BBCodes
View previous topic :: View next topic  
Author Message
class
Starter
Starter


Joined: 05 Jun 2005
Posts: 1

PostPosted: Sun Jun 05, 2005 10:19 pm    Post subject: DOWNLOAD Select/Expand with SXBB1.0.2, look inside. Reply with quote

You can mix SXBB with oxpus.de script and it does

Download/Select/Expand

this is unofficial so do not bother oxpus or markus about this but if you are
interested to add 'Download' near 'Select' etc of SXBB, thats easy with oxpus script , so here are the updated instructions that you should do after installing SXBB 1.0.2 of markus to feat correctly with:

Code:

# Download MOD of oxpus.de with a soft modification to feat with SXBB 1.0.2
# (Select eXpand BBcode)
# You should have SXBB 1.0.2 installed before to apply this.
#
#-----[ OPEN ]-----
#
viewtopic.php

#
#-----[ FIND ]-----
#
include($phpbb_root_path . 'common.'.$phpEx);

#
#-----[ AFTER, ADD ]-----
# // Maybe the line with bbcode can already exists. Then ignore this line.
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include($phpbb_root_path . 'includes/functions_post.'.$phpEx);

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

#
#-----[ AFTER, ADD ]-----
#
if ( isset($HTTP_GET_VARS['dl_code']) )
{
   $dl_code = intval($HTTP_GET_VARS['dl_code']) - 1;

   if ($dl_code >= 0)
   {
      $sql = "SELECT p.forum_id,  pt.post_text, pt.bbcode_uid
         FROM " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt
         WHERE p.post_id = $post_id
            AND pt.post_id = $post_id";
      if ( !($result = $db->sql_query($sql)) )
      {
         message_die(GENERAL_ERROR, "Could not create download stream for code box.", '', __LINE__, __FILE__, $sql);
      }

      $download_file = '';
      $is_auth_dl = array();
      $matches = array();
      $orig_word = array();
      $replacement_word = array();

      $row = $db->sql_fetchrow($result);

      $is_auth_dl = auth(AUTH_ALL, $row['forum_id'], $userdata);

      $bbcode_uid = $row['bbcode_uid'];
      $download_file = $row['post_text'];

      obtain_word_list($orig_word, $replacement_word);

      if (count($orig_word) && ($forum_topic_data['disable_word_censor'] == 0))
      {
         $download_file = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $download_file . '<'), 1, -1));
      }

      $db->sql_freeresult($result);

      $match_count = preg_match_all("#\[code:1:$bbcode_uid\](.*?)\[/code:1:$bbcode_uid\]#si", $download_file, $matches);

      if ($is_auth_dl['auth_read'] && $dl_code <= $match_count)
      {
         $download_file = $matches[1][$dl_code];
         $download_file = strip_tags($download_file);
         $download_file = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", '', $download_file);
         $download_file = preg_replace('/\[url\]|\[\/url\]/si', '', $download_file);
         $download_file = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $download_file);

         $download_file = unprepare_message($download_file);
         $download_file = preg_replace('/(/', '(', $download_file);
         $download_file = preg_replace('/)/', ')', $download_file);
         $download_file = preg_replace('/:/', ':', $download_file);
         $download_file = preg_replace('/[/', '[', $download_file);
         $download_file = preg_replace('/]/', ']', $download_file);
         $download_file = preg_replace('/{/', '{', $download_file);
         $download_file = preg_replace('/}/', '}', $download_file);
         $download_file = str_replace('\n', "\n\r", $download_file);
         $download_file = preg_replace("#\[s=([0-9]+?)\]#", "", $download_file);

         $filename = $board_config['sitename']."_CODE_Post_".$post_id."_".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 ]-----
#
for($i = 0; $i < $total_posts; $i++)
{

#
#-----[ AFTER, ADD ]-----
#
   $post_id = $postrow[$i]['post_id'];

#
#-----[ OPEN ]-----
#
includes/bbcode.php

#
#-----[ FIND ]-----
#
function bbencode_second_pass_code($text, $uid, $bbcode_tpl)
{
   global $lang;

#
#-----[ AFTER, ADD ]-----
#
   global $post_id, $phpEx;

#
#-----[ FIND ]-----
#
   // Now, do all the non-first-level matches. These are simple.
   $text = str_replace("[code:$uid]", $code_start_html, $text);
   $text = str_replace("[/code:$uid]", $code_end_html, $text);

#
#-----[ AFTER, ADD ]-----
#SXBB *update*
   for ($i = 0; $i < $match_count; $i++)
   {
      $j = $i + 1;
      $replacement = '&nbsp;&nbsp;<span class="nav"><a class="genmed" style="text-decoration:none;" href="'.append_sid("viewtopic.$phpEx?".POST_POST_URL."=".$post_id."&amp;dl_code=".$j).'">'.$lang['Download'].'</a></span>&nbsp;';
      $text = preg_replace("/\{L_DOWNLOAD\}/", $replacement, $text, 1);
   }

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

#
#-----[ FIND ]-----
#
$lang['Contract'] = "Contract";

#
#-----[ AFTER, ADD ]-----
#
$lang['Download'] = 'Download';

#
#-----[ OPEN ]-----
#
templates/YourTemplate/bbcode.tpl

#
#-----[ FIND ]-----
#SXBB *update*

      <td class="helpline"><span class="genmed"><b>{L_CODE}:</b>
<script type="text/javascript" src="{U_SXBB_JSLIB}"></script>
<script type="text/javascript">
<!--
   var id = 'SXBB' + (1000 + Math.floor(Math.random() * 5000));
   SXBB[id] = new _SXBB(id);
   SXBB[id].T['select'] = '{L_SELECT}';
   SXBB[id].T['expand'] = '{L_EXPAND}';
   SXBB[id].T['contract'] = '{L_CONTRACT}';
   SXBB[id].writeCmd();
//-->
</script>
      </span></td>
   </tr>
   <tr>
     <td class="code">
<script type="text/javascript">
<!--
   SXBB[id].writeDiv();
//-->
</script><!-- END code_open -->

#
#-----[ REPLACE WITH ]-----
#SXBB *update*

      <td class="helpline"><span class="genmed"><b>{L_CODE}:</b>
{L_DOWNLOAD}
<script type="text/javascript" src="{U_SXBB_JSLIB}"></script>
<script type="text/javascript">
<!--
   var id = 'SXBB' + (1000 + Math.floor(Math.random() * 5000));
   SXBB[id] = new _SXBB(id);
   SXBB[id].T['select'] = '{L_SELECT}';
   SXBB[id].T['expand'] = '{L_EXPAND}';
   SXBB[id].T['contract'] = '{L_CONTRACT}';
   SXBB[id].writeCmd();
//-->
</script>
      </span></td>
   </tr>
   <tr>
     <td class="code">
<script type="text/javascript">
<!--
   SXBB[id].writeDiv();
//-->
</script><!-- END code_open -->

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


all credits to markus and oxpus.
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Sun Jun 05, 2005 11:59 pm    Post subject: Re: DOWNLOAD Select/Expand with SXBB1.0.2, look inside. Reply with quote

Very glad you got it!

Thanks for sharing Wink

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    phpMiX.org Forum Index -> phpBB MODs -> Select Expand BBCodes All times are GMT + 1 Hour
 
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum