Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: , by alhatali (Guest)
Developer Last Online: Jan 1970 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 05-28-2001 Last Update: Never Installs: 0
 
No support by the author.

I wrote before a question on how to disable line breaks in posts. However, I didn't get a working answer for it. You can look at the discussion through the following thread:

http://www.vbulletin.com/forum/showt...threadid=16605

So, I decided to do some hacking, though I don't know anything about PHP. Luckily, I was able to get it working correctly. I admit that what I did could be not the right way to do it. This is why I ask everyone to give comments about it and enhance it, if they wish. You will not be able to add this feature unless you enabled HTML in your forums.

The solution:
[list=1][*]Adding a new column to the POST table:

Since, I don't know how to add a column to a table, I decided to stick the following statement somewhere in any of the PHP files that get executed frequently such as index.php or global.php. You can remove the line once you know it got executed for at least one time. If you know some other way to do it, then don't add the following line.

Code:
  $DB_site->query("ALTER TABLE post ADD preformatted SMALLINT DEFAULT '0' not null");
[*]In editpost, newreply, and newthread templates, add the code in red in the the following lines:

Code:
<tr>
	<td bgcolor="#F1F1F1" valign="top"><normalfont><b>Options:</b></normalfont></td>
	<td bgcolor="#F1F1F1" valign="top"><smallfont>
		<input type="checkbox" name="preformatted" value="yes" $preformattedchecked> <b>Pre-Formatted Post:</b> (Don't add any extra formatting code).<br>
		<input type="checkbox" name="parseurl" value="yes" $parseurlchecked> <b>Automatically parse URLs:</b> automatically adds  and  around internet addresses.
[*]In admin/functions.php, add the code in red in the the following lines:

Code:
function bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmilies,$dobbcode)
{ // parses text for vB code, smilies and censoring

  global $DB_site,$wordwrap, $bbuserinfo,$preformatted;

  static $smilies,$bbcodes;
  global $regexcreated,$searcharray,$replacearray,$phpversionnum;

  if($wordwrap!=0) {
    $bbcode=dowordwrap($bbcode);
  }

  if(!$dohtml)  { // kill any rogue html code
    // $bbcode=str_replace("&","&amp;",$bbcode);
    $bbcode=str_replace("&lt;","&amp;lt;",$bbcode);
    $bbcode=str_replace("&gt;","&amp;gt;",$bbcode);
    $bbcode=str_replace("<","&lt;",$bbcode);
    $bbcode=str_replace(">","&gt;",$bbcode);
  }

  if (!$preformatted) { // if message is preformatted using HTML, do nothing.  Otherwise, change newlines to <br>
    $bbcode=nl2br($bbcode);
  }

  //smilies
  if($dosmilies) {
    $bbcode=str_replace("&gt;)", "&gt; )", $bbcode);
    $bbcode=str_replace("&lt;)", "&lt; )", $bbcode);
    if(!isset($smilies)) {
      $smilies=$DB_site->query("SELECT smilietext,smiliepath FROM smilie");
    } else {
      $DB_site->data_seek(0,$smilies);
    }

    while ($smilie=$DB_site->fetch_array($smilies)) {
      if(trim($smilie[smilietext])!="") {
        $bbcode=str_replace(trim($smilie[smilietext]),"<img src=\"$smilie[smiliepath]\" border=\"0\" alt=\"$smilie[smilietext]\">",$bbcode);
      }
    }
  }
[*]In editpost.php, add the code in red in the the following lines (please, notice the extra [/ color] that I added because vB one end tag was not enough to end the red color):

Code:
  $parseurlchecked="CHECKED";

  $preformattedchecked=iif($postinfo[preformatted],"CHECKED","");
  $disablesmilieschecked=iif($postinfo[allowsmilie],"","CHECKED");
  $signaturechecked=iif($postinfo[showsignature],"CHECKED","");
========

Code:
// ############################### start update post ###############################
if ($action=="updatepost") {

  // check for message
  if ($message=="") {
    eval("standarderror(\"".gettemplate("error_nosubject")."\");");
    exit;
  }

  // decode check boxes
  $preformatted=iif(trim($preformatted)=="yes",1,0);
  $parseurl=iif($parseurl=="yes",1,0);
  $email=iif($email=="yes",1,0);
  $allowsmilie=iif($disablesmilies=="yes",0,1);
  $signature=iif($signature=="yes",1,0);
=======

Code:
  $DB_site->query("UPDATE post SET title='".addslashes(htmlspecialchars($newtitle))."',pagetext='".addslashes($message)."',preformatted='$preformatted'[/color],allowsmilie='$allowsmilie',showsignature='$signature',iconid='$iconid'$editedbysql$attachmentsql WHERE postid='$postid'");
[*]In newreply.php, add the code in red in the the following lines (please, notice the extra [/ color] that I added because vB one end tag was not enough to end the red color):

Code:
// ############################### start post reply ###############################
if ($action=="postreply") {

  // check for subject and message
  if ($message=="") {
    eval("standarderror(\"".gettemplate("error_nosubject")."\");");
    exit;
  }

  // decode check boxes
  $preformatted=iif(trim($preformatted)=="yes",1,0);
  $parseurl=iif(trim($parseurl)=="yes",1,0);
  $email=iif(trim($email)=="yes",1,0);
  $allowsmilie=iif(trim($disablesmilies)=="yes",0,1);
  $signature=iif(trim($signature)=="yes",1,0);
  $preview=iif(trim($preview)!="",1,0);
============

Code:
    eval("\$postpreview=\"".gettemplate("newpost_postpreview")."\";");

    $preformattedchecked=iif($preformatted,"checked","");
    $parseurlchecked=iif($parseurl,"checked","");
    $emailchecked=iif($email,"checked","");
    $disablesmilieschecked=iif(!$allowsmilie,"checked","");
    $signaturechecked=iif($signature,"checked","");
    $previewchecked=0;

    $title = htmlspecialchars($title);
====================

Code:
      $DB_site->query("UPDATE post SET title='".addslashes(htmlspecialchars($newtitle))."',pagetext='".addslashes($message)."',preformatted='$preformatted'[/color],allowsmilie='$allowsmilie',showsignature='$signature',iconid='$iconid',attachmentid='$attachmentid' WHERE postid='$postid'");
================

Code:
      $DB_site->query("INSERT INTO post (postid,threadid,title,username,userid,dateline,attachmentid,pagetext,preformatted[/color],allowsmilie,showsignature,ipaddress,iconid,visible) VALUES (NULL,'$threadid','".addslashes(htmlspecialchars($title))."','".addslashes(htmlspecialchars($postusername))."','$bbuserinfo[userid]','".time()."','$attachmentid','".addslashes($message)."','$preformatted','$allowsmilie','$signature','$ipaddress','$iconid','$visible')");
===================

Code:
  $posts=$DB_site->query("
  	SELECT IF(post.userid=0,post.username,user.username) AS username,
	post.pagetext,post.preformatted,post.allowsmilie FROM post
	LEFT JOIN user ON user.userid=post.userid
	WHERE post.visible=1 AND post.threadid='$threadid' $ignoreusers
	ORDER BY dateline DESC");
  if (($bbuserinfo[maxposts] != -1) and ($bbuserinfo[maxposts] != 0)) {
    $maxposts = $bbuserinfo[maxposts];
  }
  while ($post=$DB_site->fetch_array($posts)) {
    if ($postcounter++ < $maxposts) {
	  if ($postcounter%2 == 0) {
	    $backcolor = "#F1F1F1";
	  } else {
	    $backcolor = "#DFDFDF";
	  }
          $preformatted=$post[preformatted];
	  $username=$post[username];
[*]In newthread.php, add the code in red in the the following lines (please, notice the extra [/ color] that I added because vB one end tag was not enough to end the red color):

Code:
// ############################### start post thread ###############################
if ($action=="postthread") {

  // decode check boxes
  $preformatted=iif(trim($preformatted)=="yes",1,0);
  $parseurl=iif(trim($parseurl)=="yes",1,0);
  $email=iif(trim($email)=="yes",1,0);
  $allowsmilie=iif(trim($disablesmilies)=="yes",0,1);
  $signature=iif(trim($signature)=="yes",1,0);
  $preview=iif(trim($preview)!="",1,0);
  $postpoll=iif(trim($postpoll)=="yes",1,0);
==============

Code:
    eval("\$postpreview=\"".gettemplate("newpost_postpreview")."\";");

    $preformattedchecked=iif($preformatted,"checked","");
    $parseurlchecked=iif($parseurl,"checked","");
    $emailchecked=iif($email,"checked","");
    $disablesmilieschecked=iif(!$allowsmilie,"checked","");
    $signaturechecked=iif($signature,"checked","");
    $previewchecked=0;
================

Code:
      $DB_site->query("UPDATE post SET pagetext='".addslashes($message)."',preformatted='$preformatted'[/color],allowsmilie='$allowsmilie',showsignature='$signature',iconid='$iconid',attachmentid='$attachmentid' WHERE postid='$posts[minpost]'");
===============

Code:
      // create first post
      $DB_site->query("INSERT INTO post (postid,threadid,title,username,userid,dateline,attachmentid,pagetext,preformatted,allowsmilie,showsignature,ipaddress,iconid,visible) VALUES (NULL,'$threadid','','".addslashes($postusername)."','$bbuserinfo[userid]','".time()."','$attachmentid','".addslashes($message)."','$preformatted','$allowsmilie','$signature','$ipaddress','$iconid','1')");
[*]In showthread.php, add the code in red in the the following lines:

Code:
  $preformatted = $post[preformatted];
  $post[message]=bbcodeparse($post[pagetext],$forum[forumid],$post[allowsmilie]);

  //highlight words for search engine
[/list=1]

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:29 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06187 seconds
  • Memory Usage 2,218KB
  • Queries Executed 16 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (16)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete