Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
  #1  
Old 05-07-2005, 10:27 PM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default News Fetch Hack Help

Basically the hack fetches news directly from a specific forum(s) and then outputs it to a non-vb page.

You can see the hack in action here: www.totalbf2.com

Now the problem im having is if you look at the bottom of the page, you see a list of errors. I had someone already try to take a look at it, but he was unable to complete the task.

Here is what he had come up with, http://forums.totalbf2.com/news4.php ...
Now as you can see there, everything is showing up properly, and the errors are gone, although no news text is showing up!

I have attached the news4.php file which is the nearly fixed version, but along with it i have included news.php which is the current one being used that contains the errors.

I would be greatful is anyone is able to resolve this issue.
Attached Files
File Type: php news4.php (3.0 KB, 15 views)
File Type: php news.php (5.1 KB, 11 views)
Reply With Quote
  #2  
Old 05-09-2005, 09:53 PM
risestar risestar is offline
 
Join Date: Oct 2001
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is the one I have been using on my front page for awhile, it works quite well and you can customize the look and feel easily. It is the news out script by RAFE

See it in action here

http://www.digitalinsurrection.com



PHP Code:
<?php
// See bottom for more instructions.
 
// We need vB global for bbcode parsing.
// This scripts needs to be in the forums directory or you need to uncomment the chdir
// lines (and edit them).
 
// chdir("/path/to/forums/"); 
 
require_once("./global.php"); 
 
// chdir("/path/to/this/script"); 
 
 
 
// VARIABLES TO SET
 
// hostname or ip of server
$servername="localhost";
 
// username and password to log onto db server
$dbusername="dbusername";
$dbpassword="dbpassword";
 
// name of database
$dbname="forumname";
 
//path to your forums
$forumspath "http/path/to/your/forums";
 
 
function 
writenews($cats$filetw$newsitems=7){ 
global 
$servername;
global 
$dbusername;
global 
$dbpassword;
global 
$dbname;
global 
$forumspath;
 
 
//Connect to the database
$connection mysql_connect("$servername","$dbusername","$dbpassword") or die ("Cannot connect to server.");
$db mysql_select_db("$dbname"$connection) or die ("Could not select database.");
 
//Create SQL statement this gets the title poster and other bits
$sql "SELECT threadid, title, forumid, replycount, postusername, postuserid, lastposter, dateline, iconid FROM thread WHERE forumid IN ($cats) AND sticky = '0' ORDER BY threadid DESC LIMIT $newsitems";
 
 
//execute sql query
$sql_result mysql_query($sql$connection) or die ("Could not execute query.");
 
if (!
$sql_result) { 
echo 
"Could not get news.";

 
while (
$row mysql_fetch_array($sql_result)) {
$threadid $row["threadid"];
$title $row["title"]; 
$forumid $row["forumid"];
$replycount $row["replycount"];
$postusername $row["postusername"];
$postuserid $row["postuserid"];
$lastposter $row["lastposter"];
$iconid $row["iconid"];
$dateline $row["dateline"];
 
//create the second SQL statement to pull the post from the thread it resides in
$sql2 "SELECT postid, threadid, username, userid, title, dateline, pagetext, iconid FROM post WHERE threadid = \"$threadid\" ORDER BY postid ASC LIMIT 1";
 
//This gets the text of the post
$sql_result2 mysql_query($sql2$connection) or die ("Could not execute query in second sql statement.");
if (!
$sql_result2) { 
echo 
"Could not get news.";

while (
$row2 mysql_fetch_array($sql_result2)) {
$ptext $row2["pagetext"];
 
 
//Convert time
$dateposted date("D j M Y, g:i A",$dateline);
 
//Comments or comment depending on number of replies
if ($replycount==1) {
$commenttext "Comment";
}
else {
$commenttext "Comments";
}
 
 
// This parses the bbcode
require_once("./includes/functions_bbcodeparse.php");
$outxt=parse_bbcode2($ptext,"1","1","1","1","1");
 
// Uncomment next 4 lines if you want to limit the amount of text displayed to the first paragraph.
// $trimmed = explode("<br />", $outxt);
//$outxt=$trimmed[0];
//$trimmed = explode("</p>", $outxt);
//$outxt=$trimmed[0];
 
$outxt=substr($outxt,0,350);
 
// This is optional. It strips out unecessary tags if you wish and leaves those specified behind
// $outxt = strip_tags($outxt, '<a>,<b>,<strong>,<i>,<em>,<br />,<br>,<p>');
 
// This sql gets the title of the forum
$sql3 "SELECT title FROM forum WHERE forumid = \"$forumid\" LIMIT 1";
$sql_result3 mysql_query($sql3$connection) or die ("Could not execute query in second sql statement.");
$row3 mysql_fetch_array($sql_result3);
$forumname $row3["title"];
 
//EDIT the HTML OUTPUT HERE
 
$towrite .= "
 
<table border=0 width=100% cellpadding=0 class=tborder>
<!-- Overall Table -->
<td bgcolor=#7A7A7A>
 
<table border=0 width=100% cellpadding=0>
<td bgcolor=#E6E8FA>
 
<div>
<table border=0 width=100% bgcolor=#869BBF><td bgcolor=#869BBF>
Posted on <i><font color=#FFFFCC>
$dateposted</i></font> 
</td>
 
<td align=right bgcolor=#869BBF>
 
Posted by <a href=\"
$forumspath/member.php?s=&amp;action=getinfo&amp;userid=$postuserid\"><b><font color=#FFFFCC>$postusername</b></FONT></a> 
</td></table> 
 
<table border=0>
<td bgcolor=#E6E8FA>
 
<br>
<P>
<div>
<h4><a href=\"
$forumspath/showthread.php?s=&amp;threadid=$threadid\">$title</a></h4>
</div>
<P>
 
<div>
$outxt <b>...</b></div>
<P>
<a href=\"
$forumspath/showthread.php?s=&amp;threadid=$threadid\">Read complete Article</a><P><br><BR>
 
</td></table>
 
 
 
 
<table border=0 width=100% bgcolor=#869BBF>
<td align=left bgcolor=#869BBF>
<a class=newsout href=\"
$forumspath/showthread.php?s=&amp;threadid=$threadid\">$replycount $commenttext</a></div>&nbsp;
</td>
<td align=center bgcolor=#869BBF>
<A class=newsout HREF=\"http://forums.digitalinsurrection.com/forum/forumdisplay.php?f=186\">&raquo;View complete Article Archive</a></td>
 
<td align=right bgcolor=#869BBF>
&nbsp;<a href=\"
$forumspath/newreply.php?do=newreply&t=$threadid\"><img src=\"$forumspath/images/reply_small.gif\" title=\"Post a reply to this article\" border=\"0\"></a>
</td></table>
 
</div>
 
 
 
</td></table>
 
</td><!-- End Overall Table --></table><P><br>
"
;
// END HTML EDIT
}
}
 
 
 
//disconnect
//mysql_free_result($sql_result);
//mysql_close($connection);
 
 
// If you want to wite out to a file - good idea to reduce db load
// Then uncomment this section and edit appropriately. You need
// to have a folder to stores the output file and they need to writeable (chmod 666)
// $filetw is name of output file.
// You may then want to call this file by cron so thing update reguarly.
 
//$tmpfile = fopen("/path/to/storafe/folder/".$filetw."","w+"); 
//$fp = fwrite($tmpfile,$towrite); 
//fclose($tmpfile); 
//flush (); 
 
// If you are writing to a file comment the line below out.
echo $towrite;
}
 
 
// This calls the writenews function. Done as a function so can be called multiple times.
// First variable is forum id to get news from. One forum is like 1 and multiple forums
// like 1,2,3. Output file onyl applies if you are outputting a file (see just above)
// The last variable is the number of news itmes to grab / display. Deafults to 10.
 
@writenews("231,232,233,234,235""outputfile.txt","7");
 
// Want another write out (useful for files etc?) just call function again as below
// @writenews("16,17", "outputfile.txt","10");
?>
Reply With Quote
  #3  
Old 05-09-2005, 09:56 PM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, thanks a bunch... ill test it out and see how it works.
Reply With Quote
  #4  
Old 05-10-2005, 07:33 PM
GSX-Racing GSX-Racing is offline
 
Join Date: May 2005
Posts: 69
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Risestar

What file does that code go into and where in the forum structure does it go? Just the root folder of the forum?
Reply With Quote
  #5  
Old 05-10-2005, 10:04 PM
GameWizard's Avatar
GameWizard GameWizard is offline
 
Join Date: Apr 2004
Location: Vancouver, BC
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks a bunch dude! Works like a charm.

Quote:
Originally Posted by GSX-Racing
Risestar

What file does that code go into and where in the forum structure does it go? Just the root folder of the forum?
Well you put it whereever you want, as long as you point the file to whever the forums are.

The code can go into its own file if you like, then included into the page you want, which is what i do.
Reply With Quote
  #6  
Old 05-13-2005, 09:25 PM
risestar risestar is offline
 
Join Date: Oct 2001
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you just create a new php file, for example forumposts.php and put it in it

and then just call that with an include into your non-vb page.

the new file needs to either be in the same directory as the forum root or you need to uncomment the 2 chdir lines and specify the absolute path to your forums directory

most of the variables there are customizable. You can also add the $forumtitle if you want the name of the forum called into the query

Quote:
Originally Posted by GSX-Racing
Risestar

What file does that code go into and where in the forum structure does it go? Just the root folder of the forum?
Reply With Quote
  #7  
Old 05-18-2005, 08:40 PM
risestar risestar is offline
 
Join Date: Oct 2001
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you so choose, you can also add 1 additional query and called up post attachments into your front page.

This would give you a real phpnuke feel to the news postings.
Reply With Quote
Reply

Thread Tools
Display Modes

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 04:02 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.04118 seconds
  • Memory Usage 2,282KB
  • Queries Executed 14 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (2)postbit_attachment
  • (7)postbit_onlinestatus
  • (7)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_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete