View Single Post
  #1  
Old 08-12-2006, 04:46 AM
Hobokin Hobokin is offline
 
Join Date: Sep 2003
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Looking for a news script.

I want to find a lightweight script (can be included in a non-vb page) that can pull the first post out of x number of threads from a specific forum (or two) then can count the number of additional posts (for a Comments (12)) type thing.

I don't want to use a CMS / Portal whatever as they are bloated and tend to use VB styles.


I have searched and searched but cant find anything.

Thanks in advance

Edit: I looked into vbExternal, it is pretty close to what I want. The only problem is it operates from inside the vb folder. So it can only be used to include from one forum. I want similar functionality but I also would like for different news to be pulled from a different forum for say subdomains or addon domains. for instance www.site1.com pulls news from forum 2 while hosted.site1.com pulles from forum 5 and www.site2.com pulls from forum 12

Thanks

Well. I looked some more, checked out VbExternal again. waited for a response. And came up with this.

It works, but i'm not an expert coder at all. A lot of it is ripped from vbExternal I was not impressed with the limitations of it. So please someone, anyone read over the code and tell me if there are any obvious flaws or any improvements.

PHP Code:
<?php
// Vb news test. Note: a lot of this is reworked vbexternal code. 
// Actually all of it is :P Thanks to Zero Tolerance.
// ob_start();

// I saw this in vbExternal, thought it looked cool
error_reporting(E_ALL & ~E_NOTICE);
define('THIS_SCRIPT''news');

$news_number '5'// Amount of news to pull
$news_forum '3'// From which forum?

// Change over to vb's directory so we can include global.php
$old_dir getcwd(); // used later maybe.
chdir('path/to/forum');
require_once(
'./global.php');

// Check to make sure the chdir took.
if( !file_exists('./includes/config.php'))
{
    echo 
"includes/config.php does not exist. Cannot continue.";
    exit;
}

function 
RunError($message ""){
    echo 
"<font size='1' face='verdana'>There was an error while processing vBExternal:<br />{$message}</font>";
    exit;
}

// Include some shit I think is important :P
require_once('./includes/class_core.php');
require_once(
'./includes/config.php');
require_once(
'./includes/class_bbcode.php');

// Test to make sure a forum was set.
if (!$news_forum) {
  
RunError("No Specified Forum to pull news from, Edit the script you bum");
}

// The actual Query WOOT!
$pulled_news $db->query("
            select t.*,p.pagetext
            from "
.TABLE_PREFIX."thread t
            left join "
.TABLE_PREFIX."post p on(p.postid=t.firstpostid)
            where t.forumid = 
$news_forum
            order by dateline desc
            limit 0,
$news_number");
      
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
      
        while(
$News $db->fetch_array($pulled_news)){
      
$thread_id $News['threadid'];
      
$thread_title $News['title'];
      
$post_userid $News['postuserid'];
      
$post_username $News['postusername'];
      
$post $bbcode_parser->parse(unhtmlspecialchars($News['pagetext']), $f);
      
$comments vb_number_format($News['replycount']);
      
      echo 
"<a href=\"http://www.mysite/forum/showthread.php?p=$thread_id\">$thread_title</a>";
      echo 
"Posted by <a href=\"http://www.mysite.com/forum/member.php?u=$post_userid\">$post_username</a>";
      echo 
"$post";
      echo 
"Comments: <a href=\"http://www.mysite.com/forum/showthread.php?p=$thread_id\">$comments</a>";
    }
    
chdir($old_dir);
?>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01307 seconds
  • Memory Usage 1,807KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)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
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete