vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Probably very easy: total # of posts today (https://vborg.vbsupport.ru/showthread.php?t=26682)

futureal 08-28-2001 06:30 AM

Hi,

I am hoping I could add a little tidbit of info on my Forum Home display that, similar to "Total Posts: xx" and "Total Threads: xx" says something to the effect of "Total Posts Today: xx"

In an ideal world, it would only count posts on that particular day, thus resetting to zero at the midnight hour. It seems like something that should be pretty easy...

(but also makes me wonder, from an efficiency standpoint, if it's a good idea to be counting and re-counting all of the posts that day each time somebody loads the page...)

Also, I did do a search for this and only came up with a thread from almost a year ago where somebody asked a similar question but got no response.

So if anybody has a simple solution, thanks in advance! As you can see I am a PHP/MySQL newbie... learning a bit here and there... thanks!

Admin 08-29-2001 04:24 PM

Add this code:
PHP Code:

// get number of posts today
$datecut=time()-(86400);
$getpoststoday=$DB_site->query_first("SELECT count(*) AS count FROM post WHERE dateline>='$datecut'");
$poststoday=$getpoststoday[count]; 

in index.php, right before
PHP Code:

// get newest member 

Now you can use $poststoday anywhere in your forumhome template to show the number of posts today.

futureal 08-29-2001 10:21 PM

Thanks FireFly, works great!

futureal 08-29-2001 11:04 PM

I actually changed it a little bit. After some poking around on php.net I came up with this line:

PHP Code:

$datecut mktime(0,0,0,date("m"), date("d"), date("y")); 

That will reset it at midnight of each day, according to the system time. The other version works for the past 24 hours.

Now that I've actually modified a line of PHP code all by myself, I feel quite special :) Thanks again!

Admin 08-30-2001 03:47 AM

No problem mate. :)

FWC 08-30-2001 05:01 AM

Quote:

Now you can use $poststoday anywhere in your forumhome template to show the number of posts today.
Another cool one, FireFly. I am going to be in trouble when the next upgrade comes out. I can't stop myself! :D

Admin 08-30-2001 05:14 AM

Yeah I know what you mean.
Unless the next version is a major one (2.1.0), I don't think I'm gonna upgrade.
I have so many hacks installed, it's really tough! :(

But I'm glad you like this. :)


All times are GMT. The time now is 01:48 AM.

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.02252 seconds
  • Memory Usage 1,727KB
  • 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
  • (3)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