Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-19-2002, 03:15 PM
Sho Sho is offline
 
Join Date: Nov 2001
Location: Berlin, Germany
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 09-19-2002, 03:27 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #3  
Old 09-19-2002, 03:33 PM
Sho Sho is offline
 
Join Date: Nov 2001
Location: Berlin, Germany
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 09-19-2002, 03:37 PM
Sho Sho is offline
 
Join Date: Nov 2001
Location: Berlin, Germany
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nope, that's not what I'm looking for. Amazing nonetheless.
Reply With Quote
  #5  
Old 09-19-2002, 03:50 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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,","").
Reply With Quote
  #6  
Old 09-19-2002, 04:06 PM
Sho Sho is offline
 
Join Date: Nov 2001
Location: Berlin, Germany
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm ... and editpost.php?
Reply With Quote
  #7  
Old 09-19-2002, 04:19 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 09-19-2002, 06:00 PM
Sho Sho is offline
 
Join Date: Nov 2001
Location: Berlin, Germany
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*starts implementing*
Reply With Quote
  #9  
Old 10-01-2002, 06:26 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is interesting...

*bookmarks thread*

- miSt
Reply With Quote
  #10  
Old 10-02-2002, 08:17 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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..
Reply With Quote
Reply


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 08:06 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04287 seconds
  • Memory Usage 2,280KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_code
  • (11)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete