News:

Wondering if this will always be free?  See why free is better.

Main Menu

letter count

Started by Acf, January 01, 2004, 07:11:47 AM

Previous topic - Next topic

Acf

It would be fun to have total count of al the letters typed by a person on a forum :P
Sigh...

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

klumy

Cool option
Just for us 3 ;)

Owdy

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Shadow

Just do it, go Charter! [Unknown] offered me a spot on the dev team! I swear it!

"Sup foos'! I'm Marshie! Capital M and then arshie! I'm going this way!!!"

Owdy

Quote from: Shadow on January 01, 2004, 06:13:14 PM
http://www.simplemachines.org/community/index.php?topic=4304.0

QuoteThis counts the number of char in your postbox

We ment total chars in whole forum, not just post box. This would be stats feature somekind ;)
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Shadow

Ohhhhh... me and my trying to decode non-perfect English. :P

Seems like it would take a lot to count all of that :-/
*doesn't really know*
Just do it, go Charter! [Unknown] offered me a spot on the dev team! I swear it!

"Sup foos'! I'm Marshie! Capital M and then arshie! I'm going this way!!!"

Anguz

it'd just require an extra field for the member information, where you save the char total... every time he posts/edits/deletes a message, that total gets modified... or something like that
Cristián Lávaque http://cristianlavaque.com

Tyris

omg, how did I miss this topic!!?!?!?!

This is something I am DEFINATELY going to write as a mod unless I figure out a way to do a good word-count mod...
I have many members who care about post counts yet feel ripped off coz they only do -meaningful- posts etc... ie: they dont spam... hence they have less posts... if I had a word or letter count instead... this would fix the problem ^.^

Any idea of how to do a good word counter...? I guess any group of letters with a space, new line, full stop etc arround it...?


Grudge

#10
If you *really* want I have my own word count/letter count MOD I use on my boards. I can give it out when SMF is released. It's pretty basic though, just counts letters/words in posts and tries to get it right when pots are edited etc. Puts the amount in the profile. I say *really* because the problem is you should have some kind of "recount" function - but that is VERY time consuming on the server (ie rebuild stats). I decided to set an average number and use that to calculate stats up till the point the MOD was installed instead... anyawy - if you want it I'll make it available after 1.0

EDIT: Removed reference to above :)
I'm only a half geek really...

Tyris

heheheh... useful looking functions ^.^
I'll probably end up writing it myself... I'd like to do a complete count... we dont have -that- many members... soo...

Grudge

Well - a complete count function would be:

$result = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members");
while ($member = mysql_fetch_row($result))
{
$wordCount = 0;
$letterCount = 0;
$messages = db_query("
SELECT body
FROM {$db_prefix}messages
WHERE ID_MEMBER = $member[ID_MEMBER]");
while ($message = mysql_fetch_row($messages))
{
$wordCount += count(preg_split('/\W+/', $message['body'], -1, PREG_SPLIT_NO_EMPTY));
$letterCount += strlen($message['body']);
}
mysql_free_result($messages);
db_query("
UPDATE {$db_prefix}members
SET wordCount = $wordCount, letterCount = $letterCount
WHERE ID_MEMBER = $member[ID_MEMBER]");
}
mysql_free_result($result);


But I warn you that you will need a timeout function in here to stop the script timing out. Also - count-chars shouldn't be used for characters - strlen is much better :)

also - although I used str-word-count in my MOD I found out that the pref_replace method is apparantly much faster and more efficient
I'm only a half geek really...

Tyris

heheheh, cool :)
I know little about stopping timeouts... so a link would be nice ;)

thanks for the code and info :) (and do you mean preg_replace...? I dont know much about em... but use the preg one... dont know anything about 'pref_replace')

Grudge

eek. I meant preg_split actually but preg not pref :D

I don't want to go too much into timeouts but I believe that in SMF the rebuild stats function probably already has timeout protection so you'd be best off just putting this function in there. Basically... you just have a little function that compares the current time to the time the script started and if it's too high you stop the script, provide a little button saying "Press to continue" and repost the data starting from where the script ended. It sounds more complicated than it is (I admidt I got this from Unknowns code :D )

To do this right you basically want a function like I posted to recount the stats (which you'd run every week or so) and a couple of lines in post2 to update the memebers stats every time they post. That way the stats are pretty accurate and you only need to rebuild every so often.
I'm only a half geek really...

pulpitfire

Quote from: Tyris on January 01, 2004, 10:20:01 PM
omg, how did I miss this topic!!?!?!?!

This is something I am DEFINATELY going to write as a mod unless I figure out a way to do a good word-count mod...
I have many members who care about post counts yet feel ripped off coz they only do -meaningful- posts etc... ie: they dont spam... hence they have less posts... if I had a word or letter count instead... this would fix the problem ^.^...

yeah, until they come out with the new and improved wordier spam.

Chris Cromer

Or they could just type the same letter over and over and over... etc...
Chris Cromer

"I was here, here I was, was I here, sure I was" - The little voice in my head.

Owdy

Quote from: Chris Cromer on January 02, 2004, 09:16:33 AM
Or they could just type the same letter over and over and over... etc...

...or start WAG
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Acf

letters divided by the number posts :P hehe letter whores :P
Sigh...

pulpitfire

i made my karma into a "post rating", with thumbs up and thumbs down.  that way, users can rate a person's post quality.

Advertisement: