Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
  #1  
Old 10-16-2001, 12:42 AM
dirgotronix dirgotronix is offline
 
Join Date: Oct 2001
Posts: 61
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd like to have a feature in people's profiles that show the average words per post for that user. Our forums top posters pride themselves in long, meaningful posts, yet we still have people who have yet to post more than a sentance per post. Is there a way one could code in an averageing system that counts the words per post and display that in their profile? The math is easy enough, it's just finding out how many words are in each post that comes as a challenge to me.

Anyone want to help out here? It would be greatly appretiated!
Reply With Quote
  #2  
Old 10-16-2001, 01:48 AM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You might look at this function:

http://www.php.net/manual/en/function.strtok.php

This would help you get the count of the number of words in the message field.

Then, you would need a new field in your database for total number of words posted.

The problem is, users who already have a lot of posts aren't going to have accurate averages unless you create two new fields in the database. One for total words, one for number of posts made since the hack was installed.

Hope that helps you get started.

Amy
Reply With Quote
  #3  
Old 10-16-2001, 05:56 AM
dirgotronix dirgotronix is offline
 
Join Date: Oct 2001
Posts: 61
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, my idea was this:

Find some way of taking a users post count, and then going in the post database and for userid=$userid tossing the posts into an array, and then for each post find the wordcount, += it to a var, and then divide by total posts.

I'm not sure how intensive that would be on the database, probably equal to or worse than a search is.

It would be ideal I suppose if it automatically added a field to post for each post, but that would require far more hacking, and scripting something for their previous posts.
Reply With Quote
  #4  
Old 10-16-2001, 06:31 AM
dirgotronix dirgotronix is offline
 
Join Date: Oct 2001
Posts: 61
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's the quick script I wrote up, works pretty well from what I can tell, although it is somewhat slow for users with high post counts (although my server is only a P200, it's slow in its old age)

PHP Code:
<?
require("config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);

$result = mysql_query("SELECT pagetext FROM post WHERE userid = $userid ORDER BY dateline ASC");
$number = mysql_num_rows($result);
$i = "0";
$totalcount = "0";
    while($number > $i) {
        $results = mysql_fetch_row($result);
        $string = $results[0];

        $tok = strtok($string," ");
        $count = "0";
        while(!($tok === FALSE)){
            //echo "Word=$tok<br>";
            $count ++;
            $totalcount ++;
            $tok = strtok(" ");

        }
    //echo $i . " " . $count . "<br>";
    $i++;
    }
$average = $totalcount / $number;
$average = number_format($average,3);
echo "Userid $userid has $average Words per post.";
mysql_close($db);
?>
Reply With Quote
  #5  
Old 10-23-2002, 04:00 PM
cgwillis cgwillis is offline
 
Join Date: Feb 2002
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where do you put this code? I'm really interested in implementing this into my board. I wanted to add this to the postbit under the number of posts for the user. Would that be to server intensive?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:09 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06684 seconds
  • Memory Usage 2,197KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete