The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
![]() |
|||||||||||||||||||||||||
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"); 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. 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("&","&",$bbcode); $bbcode=str_replace("<","&lt;",$bbcode); $bbcode=str_replace(">","&gt;",$bbcode); $bbcode=str_replace("<","<",$bbcode); $bbcode=str_replace(">",">",$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(">)", "> )", $bbcode); $bbcode=str_replace("<)", "< )", $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); } } } 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'"); 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]; 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')"); Code:
$preformatted = $post[preformatted]; $post[message]=bbcodeparse($post[pagetext],$forum[forumid],$post[allowsmilie]); //highlight words for search engine Show Your Support
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|