PDA

View Full Version : question about a small snippet of code


Sarge
05-27-2001, 09:32 AM
$curTime = localtime();
$uts = time() - ($curTime[2]*566401 + $curTime[1]*60 + $curTime[0]);
$lts = $uts - (566401);
unset($curTime);

IS this time set for the past 7 days?
If not... what would it read?

Sarge
05-27-2001, 02:27 PM
anyone know?

Sarge
05-28-2001, 02:03 AM
bump

Sarge
05-28-2001, 08:13 AM
I am upping my postcount on this one

the_sisko
05-28-2001, 08:41 AM
Don't know what you are looking for but maybe:

$pastweek = time()-(60*60*24*7);

This is the timestamp from last week...but tell me what your are looking for!

Sarge
05-28-2001, 09:13 AM
<?php

$templatesused = "highpost2,highpostbit2";
require ("global.php");

$numberHighPostPerPage = 20; //set for this paste of the script
$curTime = localtime();
$uts = time() - ($curTime[2]*566401 + $curTime[1]*60 + $curTime[0]);
$lts = $uts - (566401); // 3600 * 24 + 1 (to be completely honest about "yesterday")
unset($curTime);

$users = $DB_site->query("
SELECT post.userid, user.username, COUNT(post.userid) AS count
FROM post
LEFT JOIN user ON post.userid=user.userid
WHERE dateline >= $lts AND dateline <= $uts
GROUP BY post.userid
ORDER BY count DESC
LIMIT $numberHighPostPerPage"
);

while ($user = $DB_site->fetch_array( $users ) )
{
eval( "\$highpostbits2 .= \"".gettemplate("highpostbit2")."\";");
$numhp++;
}
for ( ; $numhp < $numberHighPostPerPage; $numhp++ )
{
$user[userid] = "-1"; $user[username] = "Unclaimed"; $user[count] = "0";
eval( "\$highpostbits2 .= \"".gettemplate("highpostbit2")."\";");
}
eval("dooutput(\"".gettemplate('highpost2')."\");");

?>

Thanks... trying to change this so it lists top posters from the past 7 days
Sarge

the_sisko
05-28-2001, 09:45 PM
Try this one.
<?php

$templatesused = "highpost2,highpostbit2";
require ("global.php");

$numberHighPostPerPage = 20; //set for this paste of the script
$uts = time() - (604800);
$lts = time() - (86401);
unset($curTime);


$users = $DB_site->query("
SELECT post.userid, user.username, COUNT(post.userid) AS count
FROM post
LEFT JOIN user ON post.userid=user.userid
WHERE dateline >= $lts AND dateline <= $uts
GROUP BY post.userid
ORDER BY count DESC
LIMIT $numberHighPostPerPage"
);

while ($user = $DB_site->fetch_array( $users ) )
{
eval( "\$highpostbits2 .= \"".gettemplate("highpostbit2")."\";");
$numhp++;
}
for ( ; $numhp < $numberHighPostPerPage; $numhp++ )
{
$user[userid] = "-1"; $user[username] = "Unclaimed"; $user[count] = "0";
eval( "\$highpostbits2 .= \"".gettemplate("highpostbit2")."\";");
}
eval("dooutput(\"".gettemplate('highpost2')."\");");

?>