sparks wrote:
LS97 wrote:
sparks wrote:
There is a way to do it without passwords on the current forum system, but it's slow, time consuming and the ST would have the creator's head on a silver platter cos it would be calling their site all the time. It would involve using an external program to run through every thread in all the forums, adding new users to an array or incrementing their count every time it finds a post by them. I could probably do it but won't and encourage you not to
According to the topic count on the home page of the forums, the forums would have to be accessed at least 87556 times, though probably more since it's not one-topic-per-page.
Do you think that is an easier way to do it, also from a code performance point of view, rather than searching the user and getting their post in less than 10 seconds?
And how do you get the post count of another user?
Are you talking about doing something like http://scratch.mit.edu/forums/search.ph … r_id=32786?
Offline
sparks wrote:
LS97 wrote:
sparks wrote:
There is a way to do it without passwords on the current forum system, but it's slow, time consuming and the ST would have the creator's head on a silver platter cos it would be calling their site all the time. It would involve using an external program to run through every thread in all the forums, adding new users to an array or incrementing their count every time it finds a post by them. I could probably do it but won't and encourage you not to
According to the topic count on the home page of the forums, the forums would have to be accessed at least 87556 times, though probably more since it's not one-topic-per-page.
Do you think that is an easier way to do it, also from a code performance point of view, rather than searching the user and getting their post in less than 10 seconds?
And how do you get the post count of another user?
You search for their posts using search.php and count the results.
Offline
Wow! I've never used that search feature before! Okay, so a PHP script SHOULD be able to work it out just fine! If you know the PPP (posts-per-page) you should be able to just read the last page in the lists and count the posts there.
((numberOfPages - 1)*numberOfPostsPerPage) + numberOfPostsOnLastPage
Offline
Hmm... I'd be willing to do this if anyone could figure out a way...
Offline
If you can get at the mysql database (or even just select, order, and possibly limit priveleges to speed things up,) you could use this code:
<?php
function get_users_by_post_count() {
// return an array containing the top 5 posters.
}
// load the background image
$img = imagecreatefrompng("http://img651.imageshack.us/img651/637/top5posters.png");
// everything white will be transparent
$white = imagecolorallocate($img, 255, 255, 255);
imagecolortransparent($img, $white);
// set our text color
$black = imagecolorallocate($img, 0, 0, 0);
// get users ordered by post count
$p = get_users_by_post_count();
// write our top five
imagestring($img, 5, 22, 63, $p[0], $black);
imagestring($img, 5, 23, 103, $p[1], $black);
imagestring($img, 5, 25, 135, $p[2], $black);
imagestring($img, 5, 24, 161, $p[3], $black);
imagestring($img, 5, 25, 186, $p[4], $black);
// output
header("Content-type: image/png");
imagepng($img);
die();
?>Offline
Also, using that, I made one for my forums.
http://geonotron.net84.net/forums/posts.php
Offline
GeonoTRON2000 wrote:
function get_users_by_post_count() {
// return an array containing the top 5 posters.
}
That function would be the only part actually involved in counting comments, the rest of the code is just for displaying the result as text but you've left this function empty but for a comment?
Offline
sparks wrote:
GeonoTRON2000 wrote:
function get_users_by_post_count() {
// return an array containing the top 5 posters.
}That function would be the only part actually involved in counting comments, the rest of the code is just for displaying the result as text but you've left this function empty but for a comment?
Because we aren't sure how we're going to do it yet.
If mysql:
function get_users_by_post_count() {
mysql_connect("sql.scratch.mit.edu", "postcounter", "********");
mysql_select_db("scratch_forums");
$q = mysql_query("SELECT * FROM forum_users ORDER BY -user_posts LIMIT 5") or die(mysql_error());
$a = array();
$i = 0;
while ($arr = mysql_fetch_assoc($q)) {
$a[$i] = $arr["username"];
$i++;
}
return $a;
}Last edited by GeonoTRON2000 (2012-05-02 10:06:17)
Offline