vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How to dispay latest threads on homepage? (https://vborg.vbsupport.ru/showthread.php?t=57935)

Bonee70 10-16-2003 12:08 PM

How to dispay latest threads on homepage?
 
Ive already searched the forums for a script but I cant find any help here so far.

Im looking for an oportunity to display the lastest threads on my homepage.

It should look like this:

http://playaz.elitemaddenleagues.com/

I guess even the homepage of this site is using those scripts.

Help or a hint would be very appreciated!

Bonee

paddysplace 10-16-2003 04:10 PM

PHP Code:

<?php
error_reporting
(7);

chdir('/home/USERNAME/public_html/forums');

require(
'./global.php');

###########
## Stats ##
###########

  ////Get number of members
  //$totalmembers
    
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
    
$totalmembers number_format($numbersmembers['users']);

  
////Get total number of posts
  //$totalposts

    
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
    
$totalposts number_format($countposts['posts']);
    
  
////Get total number of threads
  //$totalthreads
    
    
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
    
$totalthreads number_format($countthreads['threads']);
    
  
////Get username and id of newest member
  //$newestuser[user]
  //$newestuser[id]

    
$newestuser=$DB_site->query_first("SELECT userid,username FROM user WHERE userid=$numbersmembers[max]");
    
$newestuser[user] = unhtmlspecialchars($newestuser['username']);
    
$newestuser[id] = unhtmlspecialchars($newestuser['userid']);

  
////Get username, id, post count, and post percent of top poster
  //$top[user]
  //$top[id]
  //$top[count]
    
    
$topposter=$DB_site->query_first('SELECT userid,username,posts FROM user ORDER BY posts DESC LIMIT 10');
    
$top[user] = unhtmlspecialchars($topposter['username']);
    
$top[id] = unhtmlspecialchars($topposter['userid']);
    
$top[count] = number_format($topposter['posts']);

###################
## Testing Stats ##
###################

echo "<font face=arial>";
echo 
"Total Members: "."<b>$totalmembers</b>";
echo 
"<BR>";
echo 
"Total Posts: "."<b>$totalposts</b>";
echo 
"<BR>";
echo 
"Total Threads "."<b>$totalthreads</b>";
echo 
"<p>";
echo 
"Newest User Username: "."<b>$newestuser[user]</b>";
echo 
"<BR>";
echo 
"Newest User ID: "."<b>$newestuser[id]</b>";
echo 
"<p>";
echo 
"Top Poster Username: "."<b>$top[user]</b>";
echo 
"<BR>";
echo 
"Top Poster ID: "."<b>$top[id]</b>";
echo 
"<BR>";
echo 
"Top Poster Count: "."<b>$top[count]</b>";
echo 
"<p><br>";

#########################
## Latest Forum Topics ##
#########################

echo "Last 5 Thread Postings:<p>"//Seperate from Stat Display

$maxthreadchars "30";

$threads=$DB_site->query("SELECT threadid,thread.title,replycount,postusername,postuserid,dateline,views,lastposter,lastpost FROM thread ORDER BY lastpost DESC LIMIT 5");
  while (
$thread=$DB_site->fetch_array($threads)) 
  {
        
$lastposttime vbdate("$timeformat $dateformat",$thread['lastpost']);
        
$title unhtmlspecialchars($thread['title']);

        if (
strlen($thread['title'])>"$maxthreadcharsAND $maxthreadchars!='0'
        {
            
$title substr($thread['title'], 0$maxthreadchars 3) . '...';
        }
            
$thread['date'] = vbdate("$dateformat $timeformat"$thread['dateline']);
    
?>
    <table bordercolor="#000000" border="1" cellspacing="0" cellpadding="3">
    <tr>
    <td>
    <B><? echo $title; ?></B>
    </td>
    </tr>
    <tr>
    <td>
    <font size="-1">
    Reply Count: <B><? echo $thread['replycount']; ?></B><br>
    Thread Starter: <B><? echo $thread['postusername']; ?></B><br>
    Total Views: <B><? echo $thread['views']; ?></B><br>
    Last Poster: <B><? echo $thread['lastposter']; ?></B><br>
    Thread Date: <B><? echo $thread['date']; ?></B><br>
    </font>
    </td>
    </tr>
    </table><p>
 <?
 }
  $DB_site->free_result($threads);
  unset($thread);
?>

Compatible with 2.x, Use whatever you'd like from it.. I was bored, output viewable at http://www.mesopia.com/vbstats.php

Regards,
Patrick

Bonee70 10-17-2003 12:01 PM

Oh greta man, ty! ...but for some reason I cant view the code (liscense reasosn?). Well I have my code here, but what to do now?!

Sylvus 10-17-2003 03:40 PM

This is a great little addition you made Patrick! Any way to make it the last 5 posts per forum category?

Syl...

hypnoticpimp 06-16-2006 02:36 PM

i use vbulletin 3.5.4

and i get ths error

Unable to add cookies, header already sent.
File: /home/wshh/public_html/home1.php
Line: 7

when using that

Marco van Herwaarden 06-17-2006 12:10 PM

Quote:

Originally Posted by hypnoticpimp
i use vbulletin 3.5.4

and i get ths error

Unable to add cookies, header already sent.
File: /home/wshh/public_html/home1.php
Line: 7

when using that

Make sure there is no extra character (or space/newline) in front of the "<?php", or after the final "?>" in any PHP-file.

Make sure you are using an editor that can handle this correct.

hypnoticpimp 06-20-2006 10:57 PM

marco. theres no space betweeen that, and when i access my page. vbstats.php i get this error

Fatal error: Call to a member function query_first() on a non-object in /home/wshh/public_html/vbstats.php on line 14

I just copied and pasted that whole php code to notepad, and changed location of my global file. and uploaded it and i got that error


All times are GMT. The time now is 03:49 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.01231 seconds
  • Memory Usage 1,759KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete