Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Beta Releases
FAQ Community Calendar Today's Posts Search

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
  #2  
Old 09-20-2005, 12:01 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Screenshots please?
Reply With Quote
  #3  
Old 09-20-2005, 12:25 PM
dcncdrew dcncdrew is offline
 
Join Date: Sep 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dont have any.
Reply With Quote
  #4  
Old 09-20-2005, 02:34 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Then get a few one.
Reply With Quote
  #5  
Old 09-20-2005, 10:17 PM
dcncdrew dcncdrew is offline
 
Join Date: Sep 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you can figure it out
Reply With Quote
  #6  
Old 09-20-2005, 11:25 PM
G-Unot G-Unot is offline
 
Join Date: Sep 2005
Location: Brooklyn, New York
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Argh, I rather seeing a screenshot first, then installing, you know why? what if I install it and I don't like it =/ I don't like wasting time.
Reply With Quote
  #7  
Old 09-20-2005, 11:57 PM
dcncdrew dcncdrew is offline
 
Join Date: Sep 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

me either
Reply With Quote
  #8  
Old 09-21-2005, 04:42 AM
Dreamgun Dreamgun is offline
 
Join Date: Mar 2002
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

dcncdrew, mind posting some or getting a demo link...? I mean it'll take you 5 minutes tops and oh yeah, you made the hack.
Reply With Quote
  #9  
Old 09-21-2005, 10:24 AM
tcs's Avatar
tcs tcs is offline
 
Join Date: Jun 2002
Posts: 130
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Using the add on.
Really cool for pulling content from the forums mysql to display on another site.

Can you have it pull the 1st image attachment too?
Reply With Quote
  #10  
Old 09-21-2005, 10:47 AM
dcncdrew dcncdrew is offline
 
Join Date: Sep 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^ I guess we can try to do that.

I'll get some screens for the lazy later today

Quote:
and oh yeah, you made the hack.
I know and I also know that it works to an extent and thats why I am tracking it here.
Also, I am not trying to be rude. I just am working on making changes so thats all. And if you cant understand the layout by looking at the html then thats a whole nother problem all together.

The html template means you have the option to have it displayed any way you want. So what I deem a good and logical layout to me is different to you.

That is why it's called a template.
Reply With Quote
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 08:42 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04221 seconds
  • Memory Usage 2,306KB
  • Queries Executed 24 (?)
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
  • (1)bbcode_quote
  • (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
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • 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