vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Letter counter (https://vborg.vbsupport.ru/showthread.php?t=43729)

Sho 09-19-2002 03:15 PM

Letter counter
 
First of all, I want to apologize for my horrible English.

Now, my request. Alongside the post counter, I want a letter counter for my postbit template. Well, I'm not good at this stuff, that's why I'm posting a request, but I believe it shouldn't be too hard to do. A new column in the post table, one in the user table, some changes to newreply.php, newthread.php, showthread.php and probably member.php. Hm. It's probably hard to count the letters in existing posts, but maybe someone can come up with an addition to the "Update Counters" thingie.

Anyone interested? :)

Xenon 09-19-2002 03:27 PM

you can try that:

open functions.php find:
PHP Code:

    // do posts from ignored users
    
if (($ignore[$post[userid]] and $post[userid] != 0)) {
        eval(
"\$retval = \"".gettemplate("postbit_ignore")."\";"); 

before that add:
PHP Code:

$post[numchars]=strlen($post[pagetext]); 

then add $post[numchars] in your postbit template

Sho 09-19-2002 03:33 PM

Hmm. Haven't tried it yet, but it seems surprisingly simple.

My explanation was probably too inaccurate. I want a letter counter for all posts a member has written, not just the current one.

Well, going to try that now. :)

Sho 09-19-2002 03:37 PM

Nope, that's not what I'm looking for. Amazing nonetheless. :)

Xenon 09-19-2002 03:50 PM

ah ok, missunderstood...

yes you're right then you have to add a field to user-table called letters

then open newreply.php and newthread.php
find:
PHP Code:

          $DB_site->query("UPDATE user SET
          "
.iif ($foruminfo[countposts],"posts=posts+1,","").

change it to:
PHP Code:

          $DB_site->query("UPDATE user SET letters=letters+".strlen($message).",
          "
.iif ($foruminfo[countposts],"posts=posts+1,","").


Sho 09-19-2002 04:06 PM

Hmm ... and editpost.php? :rolleyes:

Xenon 09-19-2002 04:19 PM

that's a bit more complicated...

also if you want to get all old posts involved...

at first open editpost find this:
PHP Code:

  $postinfo[message]=htmlspecialchars($postinfo[pagetext]); 

below add:
PHP Code:

 $postinfo[len]=strlen($postinfo[pagetext]) 

then you have to edit your editpost template add(twice):
Code:

<input type="hidden" name="postlen" value="$postinfo[len]">
Code:

<input type="hidden" name="postid" value="$postid">
then back in editpost.php
after
PHP Code:

    $DB_site->query("UPDATE post SET title='".addslashes(htmlspecialchars($title))."',pagetext='".addslashes($message)."',allowsmilie='$allowsmilie',showsignature='$signature',iconid='$iconid'$editedbysql$attachmentsql WHERE postid='$postid'"); 

add this:
PHP Code:

$DB_site->query("UPDATE user SET letters=".($bbuserinfo[letters]-$postlen+strlen($message))." WHERE userid=".$buserinfo[userid]); 

then find:
PHP Code:

eval("standardredirect(\"".gettemplate("redirect_deletepost")."\",\"showthread.php?s=$session[sessionhash]&threadid=$threadinfo[threadid]\");"); 

before add:
PHP Code:

$DB_site->query("UPDATE user SET letters=".($bbuserinfo[letters]-$postlen)." WHERE userid=".$buserinfo[userid]); 

should be all

Sho 09-19-2002 06:00 PM

*starts implementing*

Dean C 10-01-2002 06:26 PM

this is interesting...

*bookmarks thread*

- miSt

Logician 10-02-2002 08:17 AM

If you are trying to calculate the total number of characters a user posted to your board, maybe you can find this easier to adopt. Basically 1 SQL query can calculate it easily:

SELECT SUM(LENGTH(pagetext)) FROM `post` WHERE userid=X

You can integrate it to vb like:

PHP Code:

$charcount=$DB_site->query_first("SELECT SUM(LENGTH(pagetext)) as char FROM `post` WHERE userid='$bbuserinfo[userid]'");
$bbuserinfo['charcount']=$charcount['char']; 

by adding this at the end of say, global.php. Then you can use the variable $bbuserinfo['charcount'] in any template you want (like getinfo etc.). This might not work for postbit, but there is also a solution for this if you are tying to implement it into postbit..

One obvious advantage of making a dynamic query is that the number returned will be always up to date after message editing, deleting etc.

Enjoy..


All times are GMT. The time now is 09:07 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.01044 seconds
  • Memory Usage 1,761KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (11)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete