Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Beta Releases

Reply
 
Thread Tools
VBulletin News Hack Details »»
VBulletin News Hack
Version: 1.00, by dcncdrew dcncdrew is offline
Developer Last Online: Dec 2008 Show Printable Version Email this Page

Version: 3.0.9 Rating:
Released: 09-19-2005 Last Update: 09-19-2005 Installs: 4
Is in Beta Stage  
No support by the author.

This is something I want to implement on my site. It pulls all first posts from a specific forum you specify in descending order by post date. The only issue is that it does not take into account permissions at this point. This is a work in progress. I just wanted something simple but it's looking like it might be more trouble to do so. I had issues with VB's RSS so this is why I started this. I put it together using a few know scripts out there.

The below template.html and include.php file need to be in a folder called "news" in your forum directory.

To implment just write a simple include into a php page outside of your forums using the include.php file.



include.php
Code:
<?php
//config//
$includepath = "/path/to/forum/news/";   //path where the news folder resides
$mainurl = "http://www.yoursite.com";
$forumurl = "http://www.yoursite.com/forum/";
$includeurl = "http://www.yoursite.com/forum/news/"; //URL where the news folder resides
$newstemp = "template.html";

// Database Information
$dbserver = 'localhost';
$dbuser = 'username';
$dbpass = 'password';
$dbase = 'your_database';

$db = mysql_connect($dbserver, $dbuser, $dbpass) or die('Could not connect to DB server!');
mysql_select_db($dbase) or die("Could not connect to database: ".mysql_error());


function replace_bb_code($text) {
	$text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $text);
	$text = preg_replace( "#\[b\](.+?)\[/b\]#is", "<b>\\1</b>", $text );
	$text = preg_replace( "#\[i\](.+?)\[/i\]#is", "<i>\\1</i>", $text );
	$text = preg_replace( "#\[u\](.+?)\[/u\]#is", "<u>\\1</u>", $text );
	$text = preg_replace( "#\[s\](.+?)\[/s\]#is", "<s>\\1</s>", $text );
    $text = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=\"_blank\">\\1</a>",$text);
    $text = eregi_replace("\\[url=([^\\[]+)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=\"_blank\">\\2</a>",$text);
    $text = eregi_replace("\\[img\\]([^\\[]*)\\[/img\\]","<img src=\"\\1\" border=0>",$text);
	$text = eregi_replace("\\[color=([^\\[]+)\\]([^\\[]*)\\[/color\\]","<font color=\"\\1\">\\2</font>",$text);
    $text = eregi_replace("\\[quote\\]([^\\[]*)\\[/quote\\]","<br><br><strong>Quote:</strong><table width='80%' border='0' cellspacing='0' cellpadding='3'><tr><td bgcolor='#EFEFEF'><font color='#000000' size='-2'>\\1</font></td></tr></table><br>",$text);
    $text = eregi_replace("\\[code\\]([^\\[]*)\\[/code\\]","<br><br><strong>Code:</strong><table width='80%' border='0' cellpadding='3' cellspacing='0' bgcolor='#FFFFFF' style='border:1px solid gray;'><tr><td bgcolor='#FFFFFF'><font color='#009900' size='-2'>\\1</font></td></tr></table><br>",$text);
	$text = eregi_replace("\\[size=([^\\[]+)\\]([^\\[]*)\\[/size\\]","<font size='2'>\\2</font>",$text);
	return $text;
	}

$forumid = '12';  // You can set your forum ID here to pull the posts from the forum you want
$post_count = $_REQUEST['postcount'];

if (!$post_count) { $post_count = 3; }  // You may Change the amount of posts that are returned here by changing the number
$changetemplate = $_REQUEST['template'];
if ($changetemplate == "") { } else { $newstemp = $changetemplate; }
$truncate = $_REQUEST['truncate'];
if (!$truncate) { $truncate = 100000; }

if($_REQUEST['reverse']==1) {   ////you may need to change your database prefix from vbforum_ to what yours is
$query = "SELECT * FROM vbforum_post p, vbforum_thread t WHERE p.threadid = t.threadid AND t.forumid ='".$forumid."' ORDER BY p.threadid ASC, p.postid;";
} else {
$query = "SELECT * FROM vbforum_post p, vbforum_thread t WHERE p.threadid = t.threadid AND t.forumid ='".$forumid."' ORDER BY p.threadid DESC, p.postid;";
}

$result = mysql_query($query);
$num = mysql_num_rows($result);
$post = 0;

while($post < $post_count) {
$row = mysql_fetch_object($result);
	if($row=="") { break; }
	if ($previous_topic == $row->threadid) {  // do nothing.
	}
	else {
	$previous_topic = $row->threadid;
	$post++;
		
	$posttextquery = "SELECT * FROM vbforum_post WHERE postid='".$row->postid."';";
	$posttextresult = mysql_query($posttextquery);
	$posttextrow = mysql_fetch_object($posttextresult);
	
	$useridquery = "SELECT * FROM vbforum_user WHERE userid='".$row->userid."';";
	$useridresults = mysql_query($useridquery);
	$useridrow = mysql_fetch_object($useridresults);
	
	$responsesquery = "SELECT * FROM vbforum_post WHERE threadid='".$row->threadid."';";
	$responsesresults = mysql_query($responsesquery);
	$num_responses = mysql_num_rows($responsesresults)-1;
		
	$fileopen = fopen($includeurl.$newstemp, "r");
	$newsstring = fread($fileopen, filesize($includepath.$newstemp));
	
	
	$subject = $posttextrow->title;
    
	$newsstring = str_replace("((post_date))", date("F j, Y", $row->dateline), $newsstring);
	$newsstring = str_replace("((post_time))", date("g:i a", $row->dateline), $newsstring);
	$newsstring = str_replace("((poster_name))", "<a href='".$forumurl."member.php?u=".$row->userid."' target='_blank'>".$useridrow->username."</a>", $newsstring);
	$newsstring = str_replace("((post_subject))", $subject, $newsstring);
	if (strlen($newsstring) > $truncate) {
	$newsstring = str_replace("((post_text))", substr(nl2br($posttextrow->pagetext),0,$truncate)."... <a href='".$forumurl."showthread.php?t=".$row->postid."' target='_blank'>READ MORE</a>", $newsstring);
	} else {
	$newsstring = str_replace("((post_text))", nl2br($posttextrow->pagetext), $newsstring);
	}
	$newsstring = str_replace("((comment))", "<a href='".$forumurl."showthread.php?t=".$row->threadid."' target='_blank'>Comments</a>", $newsstring);
	$newsstring = str_replace("((responses))", $num_responses, $newsstring);
   

	
	$newsstring = replace_bb_code($newsstring);
	$newsstring = replace_bb_code($newsstring);
	
	echo $newsstring;
	}
}


?>
template.html

Code:
<table width='535' border='0' align="center" cellpadding='4' cellspacing='1' style='font-family:Verdana;font-size:11px'>
  <tr>
    <td align='left' bgcolor='#8A8A8A' background="images/header_news.jpg" height="32">
	
	<table width="300" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="286" valign="middle" style='font-family:Verdana;font-size:9px;padding-left:3px'><span class="style1">
		  Posted By: <strong><font color="#FFFFFF"></font>((poster_name))</font></strong><br>
          Posted On: ((post_date)) | ((post_time))</span></td>
        </tr>
      </table>
	
	</td>
  </tr>
  <tr>
    <td align='left' bgcolor='#BFBBBA'>
 <strong><font color="#343434" size="2" face="Verdana, Arial, Helvetica, sans-serif">
      ((post_subject))</font></strong><font face="Verdana, Arial, Helvetica, sans-serif"><br>
      <br>

      <table style='border:1px dotted gray;width:100%;font-family:Verdana;font-size:10px'>
        <tr>
          <td>
<script language="javascript" type="text/javascript"> 
<!-- 
function pointercursor(){document.body.style.cursor = "move";}
function unpointercursor(){document.body.style.cursor="";}
//--> 
</script>((post_text))

</td>
        </tr>
      </table>
      </font>  <p>
((comment)) - ((responses))</p></td>
  </tr>
</table>
<div align="center"><br>
</div>

Supporters / CoAuthors

Show Your Support

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

Comments
  #12  
Old 09-21-2005, 02:05 PM
Dreamgun Dreamgun is offline
 
Join Date: Mar 2002
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem, just thought you may like to support your mod a little. Thanks for new friendly post.
Reply With Quote
  #13  
Old 09-25-2005, 10:42 PM
dcncdrew dcncdrew is offline
 
Join Date: Sep 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reply With Quote
  #14  
Old 09-26-2005, 07:59 PM
Zidane007nl's Avatar
Zidane007nl Zidane007nl is offline
 
Join Date: Jul 2004
Location: The Netherlands
Posts: 102
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice hack you've made, but I've found a bug in your code. The links posted doesn't work. I've fixed it.

This:
PHP Code:
$text eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=\"_blank\">\\1</a>",$text); 
should be:
PHP Code:
$text eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\\1 target=\"_blank\">\\1</a>",$text); 
And:
PHP Code:
$text eregi_replace("\\[url=([^\\[]+)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=\"_blank\">\\2</a>",$text); 
should be
PHP Code:
$text eregi_replace("\\[url=([^\\[]+)\\]([^\\[]*)\\[/url\\]","<a href=\\1 target=\"_blank\">\\2</a>",$text); 
Reply With Quote
  #15  
Old 10-12-2005, 04:38 PM
cedced cedced is offline
 
Join Date: Sep 2005
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

link demo ?
Reply With Quote
  #16  
Old 10-13-2005, 03:27 PM
dcncdrew dcncdrew is offline
 
Join Date: Sep 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Link is teh picture
Reply With Quote
Reply

Thread Tools

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 05:17 PM.


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.08459 seconds
  • Memory Usage 2,271KB
  • Queries Executed 23 (?)
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
  • (2)bbcode_code
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)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_postinfo_query
  • fetch_postinfo
  • 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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete