PDA

View Full Version : A simple hack that YOU can help me with.


Gutspiller
04-13-2002, 05:35 PM
I have looked all over and it can't be found, but it's pretty simple. All I want is a hack that will count the number of threads in the forums id's I specify for the last 24 hours. But, it has to be able to work on a non-vb page. I don't think this would be that hard, but it would really come in handy. I don't want the final number to be seperate numbers, I want it to add all the new threads in the certain forums together to make a final number. Again, 1 single number of all the new threads created in the forums that I specify and it will reset to zero when the 24 hours is up, and it needs to work on a non-vb page.

It would be nice if I could adjust the time of the 24 hour reset though, but is not nessasary for me to still use the hack.

Please can somebody help me with this? :(

Thanks for any help or redirection you can offer.

N!ck
04-13-2002, 06:41 PM
something like:


<?
require("/path/to/forums/global.php");
$last24 = time() - 86400;
$threads = $DB_site->fetch_array($DB_site->query("SELECT COUNT(*) as total FROM thread WHERE lastpost > $last24 AND (forumid = 'FORUMID1' OR forumid = 'FORUMID2')"));
echo $threads[total];
?>


that SHOULD work, but i'm no expert and i didn't test this code so...:D

Chris M
04-13-2002, 07:15 PM
Listen...

If he says it works, trust him...

He found a way to stop admins editing my profile, so for that I thank him tremendously...

Satan

Gutspiller
04-13-2002, 08:22 PM
OK, so if I want to add more forums to the hack so that adds them to the total would I just add

forumid = '12'

to the end of the line where you say:

forumid = 'FORUMID1' and forumid = 'FORUMID2'?

And how do I change the time for the hack?

BTW thanks for such a fast reply. :)

EDIT: I test it and it was off, it was only saying 32 and it should of either been over 100 or 0, depending on where the 24 hours mark lies.

I changed the "OR"s to "AND"s and it just stays 0 even when a new thread is created.

Can you please help?

N!ck
04-14-2002, 03:08 PM
first, the OR needs to stay "OR".

second, you are correct in changing the "FORUMID1" and "FORUMID2" parts (and you can add more with the same syntax).

third (and i might have misunderstood), what this script does is counts how many threads were posted to in the past 24 hours in the forums you specify.

fourth, the 86400 part is the number of seconds in 24 hours. if you want to change the 24 hours, just do 3600 times the number of hours you desire and replace 86400 with the result.

if i misunderstood what you're looking for, let me know

Gutspiller
04-15-2002, 04:43 AM
Nope, still isn't working.

I have all my forum set and it still says there have been 6 posts in the last 24 hours.

And when does the 24 hours start? If you are doing it in seconds, when does it start over? That's what I was asking. I want to change when it started, because for what I am using it for I don't want the 24 hour period to restart right when I am posting my stuff that I want it to track. Right now I need it to start and end at 4:00 AM MDT

I double checked that all the forums I want included in it for the hack to track are in the hack and there id's are correct and it all checks out, so it must be something with the hack. :(

Any ideas?

mr e
04-15-2002, 06:06 AM
My forums are down so this I'm kind of guessing here, but would this work? If you want this on your main page, put this in you index.php, I don't THINK it matters where, but I could be wrong.

$thisdate = date('Y-m-d');
$getthreadtotal = $DB_site->query_first("SELECT COUNT(*) as total FROM thread WHERE dateline = $thisdate AND forumid = 'FORUMID1' OR forumid = 'FORUMID2'");
$threadtotal = $getthreads[total];

eval("\$threadtotal = \"".gettemplate('forumhome')."\";");

Then put $threadtotal somewhere in your forumhome template.

Gutspiller
04-15-2002, 06:27 PM
mr e I need this to work on a none vb page and I don't exactly know how to change that code so that it would work.

The date in that code looks like it's static. It looks like if I put in a date that it will always be that date, it wont change. So the first day I used it it would show the last 24 hours, but the next day it would show 48 and so on and so forth. I need something that will only show the latest posts since the last 24 hours and I need to be able to change when the 24 hour period restarts. I don't nessasarly want it to be the 12:00 of the server, or whatnot.

More help please. :(

mr e
04-15-2002, 09:33 PM
It's not a static time because everytime you load the page it checkes the date('Y-m-d'); so today it would equal 2002-05-15 and tomorrow it would equal 2002-05-16. Got it? I'll try to see if I can figure out how to get this on a non-vB page.

Gutspiller
04-15-2002, 09:43 PM
Originally posted by mr e
It's not a static time because everytime you load the page it checkes the date('Y-m-d'); so today it would equal 2002-05-15 and tomorrow it would equal 2002-05-16. Got it? I'll try to see if I can figure out how to get this on a non-vB page.

So what happens if the threads that I am trying to track, somebody comes to the page for the first time in the middle of the chunk of posts that I am trying to track? I don't want it to say 50 posts today and tomorrow it has the other 50, when it should really be reading 100.

How does it track it?

Andy Z
04-15-2002, 10:47 PM
Every time the page loads it will execute that query, every day the date() part will change with the server's clock. So the next day for your server it would return different results. With nicksaunders code it would pull the threads from the last 24 hours from the time the person called the page from his/her browser. To get this on a non-vB page, it still has to be a php-processed page (usually only .php like extensions). On the non-vB page put:
<?php
require('/home/username/public_html/forums/global.php');
?>
and replace that path with the paths to your forums (on most linux hosts that should be pretty close).

Gutspiller
04-16-2002, 02:31 AM
Originally posted by andypotter
Every time the page loads it will execute that query, every day the date() part will change with the server's clock. So the next day for your server it would return different results. With nicksaunders code it would pull the threads from the last 24 hours from the time the person called the page from his/her browser. To get this on a non-vB page, it still has to be a php-processed page (usually only .php like extensions). On the non-vB page put:
<?php
require('/home/username/public_html/forums/global.php');
?>
and replace that path with the paths to your forums (on most linux hosts that should be pretty close).

Like I said, I want to be able to adjust the time. I said that in my first post. I don't want it specific on page loads, server time, or users time. I want to set the when the 24 hour block restarts. THAT is what I want the code for. Can somebody please provide the code for that? :(

N!ck
04-17-2002, 01:22 AM
the 24 hours is always 24 hours before you loaded the page. it never starts over.

once again, this is the number of THREADS affected, and the script doesn't lie ;). if you want to change it to show posts, i'll have to do a left join which is a pain in the butt (actually, i'm lazy and don't want to do it unnecessarily)

Gutspiller
04-17-2002, 02:44 AM
Originally posted by nicksaunders
the 24 hours is always 24 hours before you loaded the page. it never starts over.

once again, this is the number of THREADS affected, and the script doesn't lie ;). if you want to change it to show posts, i'll have to do a left join which is a pain in the butt (actually, i'm lazy and don't want to do it unnecessarily)

I am a little confused as to what you mean. Also, it still doesn't show the posts in the right forum. I have included everything that you said and it still will show a number of posts that haven't been posted in the forums that I have specified to watch. I didn't think this hack would be this hard? :ermm:

I just want it to work. :( (and so far it hasn't worked once) :disappointed:

Can you fix it? I mean if you haven't even tested it, I don't see how you can be so sure you know exactly what it's doing.

N!ck
04-18-2002, 01:06 AM
i don't think i'm advanced enough to do this then :P

firefly, assistance please. thanks

Gutspiller
04-18-2002, 02:19 AM
Originally posted by nicksaunders
i don't think i'm advanced enough to do this then :P

firefly, assistance please. thanks

OK, thanks for all your help anyhow. :)