This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#26 2012-05-01 14:54:50

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Hello, AT. I have a challenge for you.

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  tongue  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?


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#27 2012-05-01 15:38:57

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Hello, AT. I have a challenge for you.

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  tongue  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

 

#28 2012-05-01 16:15:08

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Hello, AT. I have a challenge for you.

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


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#29 2012-05-01 18:53:02

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: Hello, AT. I have a challenge for you.

Hmm... I'd be willing to do this if anyone could figure out a way...


http://i.imgur.com/BAEgGDL.png

Offline

 

#30 2012-05-01 19:58:09

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Hello, AT. I have a challenge for you.

I tried writing a PHP script to find the number of posts that someone has, but it gave me a redirect screen, (stupid cURL).


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#31 2012-05-01 20:25:55

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: Hello, AT. I have a challenge for you.

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:

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();
?>

http://i.imgur.com/BAEgGDL.png

Offline

 

#32 2012-05-01 20:33:21

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: Hello, AT. I have a challenge for you.

Also, using that, I made one for my forums.
http://geonotron.net84.net/forums/posts.php


http://i.imgur.com/BAEgGDL.png

Offline

 

#33 2012-05-02 04:16:47

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Hello, AT. I have a challenge for you.

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?


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#34 2012-05-02 10:05:54

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: Hello, AT. I have a challenge for you.

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:

Code:

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)


http://i.imgur.com/BAEgGDL.png

Offline

 

Board footer