Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
/me code Version 3 Details »»
/me code Version 3
Version: 3.00, by Erwin Erwin is offline
Developer Last Online: May 2013 Show Printable Version Email this Page

Version: 3.0.7 Rating:
Released: 01-04-2004 Last Update: Never Installs: 200
 
No support by the author.

Updated version 2.00 thanks to buro9!

Updated version 3.00 thanks to Edgewize!

New in version 3.00:
Correct parsing in quotes, private messages etc.

Okay, this is the famous /me code first created by Chen. All credits go to him. I'm just putting up instructions on how to do this in vB3. It's very easy.

Typing "/me is great!" gives you this:

* Erwin is great!


You make changes to THREE php files only.

1. Copy this piece of code:

Change "red" to whatever color you want.

PHP Code:
// /me hack
if (THIS_SCRIPT == 'newreply' && !isset($bbcode) && isset($pagetext))
        
$pagetext preg_replace('#^(([ \t]|\[[a-z]+[^\]]*\])*)/me[ \t](.*)$#Uim''$1* '.$postinfo['username'].' $3'$pagetext);
elseif (
THIS_SCRIPT == 'private' && !isset($bbcode) && isset($pagetext))
        
$pagetext preg_replace('#^(([ \t]|\[[a-z]+[^\]]*\])*)/me[ \t](.*)$#Uim''$1* '.$pm['fromusername'].' $3'$pagetext);
elseif (isset(
$bbcode) && $dobbcode && is_array($GLOBALS['post']))
        
$bbcode preg_replace('#^(([ \t]|\[[a-z]+[^\]]*\])*)/me[ \t](.*)$#Uim''$1* '.$GLOBALS['post']['username'].' $3'$bbcode);
elseif (isset(
$bbcode) && $dobbcode && $GLOBALS['previewpost'])
        
$bbcode preg_replace('#^(([ \t]|\[[a-z]+[^\]]*\])*)/me[ \t](.*)$#Uim''$1* '.$GLOBALS['bbuserinfo']['username'].' $3'$bbcode);
elseif (isset(
$bbcode) && $dobbcode && isset($GLOBALS['fromuserinfo']))
        
$bbcode preg_replace('#^(([ \t]|\[[a-z]+[^\]]*\])*)/me[ \t](.*)$#Uim''$1* '.$GLOBALS['fromuserinfo']['username'].' $3'$bbcode);
// /me hack 
2. Open functions_bbcodeparse.php:

Find:

PHP Code:
// end smilies 
PASTE code copied BELOW.

3. Open newreply.php

Find:

In 3.0.6 or less:
PHP Code:
$pagetext trim(strip_quotes($pagetext)); 
In 3.0.7:
PHP Code:
$pagetext trim(htmlspecialchars_uni($pagetext)); 
PASTE code copied BELOW.

4. Lastly, open private.php

Find:

PHP Code:
$pagetext trim($pagetext); 
PASTE code copied BELOW.

Done!

Supporters / CoAuthors

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #242  
Old 02-02-2005, 03:34 PM
buro9 buro9 is offline
 
Join Date: Feb 2002
Location: London, UK
Posts: 585
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It was doing weird things when a user edits a post... so I've created this work around for the bit of text that goes into functions_bbcode.php
Code:
  // HACK : START : ME
  global $post;
  if ('' == $post[username]) {
    $meUsername = $bbuserinfo[username];
  } else {
    $meUsername = $post[username];
  }
  $bbcode = preg_replace('#^/me (.*)$#im', "<font color=\"red\">* $meUsername \\1</font>", $bbcode);
  // HACK : END : ME
Essentially if you are editing a post the $post array does not exist, as another context is used instead. So you lose the username.

I've added a switch that tests for this, and if $post doesn't exist, it uses the name of the current poster... fine for my forum as I only allow post owners to edit their messages... but this is a crude hack and it will break when an admin or mod edits their post... so not good.

Does anyone know a better context that I can use? How to find out the equivalent of an $editpost array or the post id so that I can get the proper name.

Cheers

David K
Reply With Quote
  #243  
Old 02-02-2005, 10:52 PM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by buro9
It was doing weird things when a user edits a post... so I've created this work around for the bit of text that goes into functions_bbcode.php
Code:
  // HACK : START : ME
  global $post;
  if ('' == $post[username]) {
    $meUsername = $bbuserinfo[username];
  } else {
    $meUsername = $post[username];
  }
  $bbcode = preg_replace('#^/me (.*)$#im', "<font color=\"red\">* $meUsername \\1</font>", $bbcode);
  // HACK : END : ME
Essentially if you are editing a post the $post array does not exist, as another context is used instead. So you lose the username.

I've added a switch that tests for this, and if $post doesn't exist, it uses the name of the current poster... fine for my forum as I only allow post owners to edit their messages... but this is a crude hack and it will break when an admin or mod edits their post... so not good.

Does anyone know a better context that I can use? How to find out the equivalent of an $editpost array or the post id so that I can get the proper name.

Cheers

David K
Good idea. I've been essentially too lazy to fix this as this hack is basically not that important on my site.
Reply With Quote
  #244  
Old 02-02-2005, 11:37 PM
MissKalunji's Avatar
MissKalunji MissKalunji is offline
 
Join Date: Aug 2003
Location: Canada
Posts: 2,845
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by buro9
It was doing weird things when a user edits a post... so I've created this work around for the bit of text that goes into functions_bbcode.php
Code:
  // HACK : START : ME
  global $post;
  if ('' == $post[username]) {
    $meUsername = $bbuserinfo[username];
  } else {
    $meUsername = $post[username];
  }
  $bbcode = preg_replace('#^/me (.*)$#im', "<font color=\"red\">* $meUsername \\1</font>", $bbcode);
  // HACK : END : ME
Essentially if you are editing a post the $post array does not exist, as another context is used instead. So you lose the username.

I've added a switch that tests for this, and if $post doesn't exist, it uses the name of the current poster... fine for my forum as I only allow post owners to edit their messages... but this is a crude hack and it will break when an admin or mod edits their post... so not good.

Does anyone know a better context that I can use? How to find out the equivalent of an $editpost array or the post id so that I can get the proper name.

Cheers

David K

Whats that fix for?
Reply With Quote
  #245  
Old 02-03-2005, 10:50 AM
buro9 buro9 is offline
 
Join Date: Feb 2002
Location: London, UK
Posts: 585
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MissKalunji
Whats that fix for?
As I said: Essentially if you are editing a post the $post array does not exist, as another context is used instead. So you lose the username

So... when posts with /me in are being edited... the edited version no longer contains the username... so /me might have been "* buro9" in the original, but after edit it was "* " and no username... the fix above presumes the person editing is the person who performs the action and inserts their username.

It's a minor thing, but one that was noticed immediately on my board... so I put this hack to this hack in there.

Though a better solution is desirable.
Reply With Quote
  #246  
Old 02-03-2005, 01:09 PM
sensimilla sensimilla is offline
 
Join Date: Dec 2004
Location: Poland
Posts: 555
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

and whats the use for it ? retrieving forgiven nickname?
Reply With Quote
  #247  
Old 02-03-2005, 09:12 PM
buro9 buro9 is offline
 
Join Date: Feb 2002
Location: London, UK
Posts: 585
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by sensimilla
and whats the use for it ? retrieving forgiven nickname?
Look... if you haven't seen the bug, or experienced it... cool

But if you've seen it, and it nags you... then a workaround is above.

You don't have to use it.
Reply With Quote
  #248  
Old 02-17-2005, 07:35 PM
buro9 buro9 is offline
 
Join Date: Feb 2002
Location: London, UK
Posts: 585
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by buro9
Look... if you haven't seen the bug, or experienced it... cool

But if you've seen it, and it nags you... then a workaround is above.

You don't have to use it.
Erwin! I've got it!

Could you update your hack?

Code:
  // HACK : START : ME
  global $post;
  if ('' == $post[username]) {
    global $reputation;
    if ('' == $reputation[username]) {
      global $pm;
      if ('' == $pm[fromusername]) {
        $meUsername = $bbuserinfo[username];
      } else {
        $meUsername = $pm[fromusername];
      }
    } else {
      $meUsername = $reputation[username];
    }
  } else {
    $meUsername = $post[username];
  }
  $bbcode = preg_replace('#^/me (.*)$#im', "<span class=\"postAction\">* $meUsername \\1 *</span>", $bbcode);
  // HACK : END : ME
Note I've changed one thing regards the formatting that you might not want to change... I use a stylesheet for it so that I can use different colours according to style in use.

But it's the nested if's that is important... solves /me for PM's and reputation bits
Reply With Quote
  #249  
Old 02-17-2005, 09:37 PM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by buro9
Erwin! I've got it!

Could you update your hack?

Code:
  // HACK : START : ME
  global $post;
  if ('' == $post[username]) {
    global $reputation;
    if ('' == $reputation[username]) {
      global $pm;
      if ('' == $pm[fromusername]) {
        $meUsername = $bbuserinfo[username];
      } else {
        $meUsername = $pm[fromusername];
      }
    } else {
      $meUsername = $reputation[username];
    }
  } else {
    $meUsername = $post[username];
  }
  $bbcode = preg_replace('#^/me (.*)$#im', "<span class=\"postAction\">* $meUsername \\1 *</span>", $bbcode);
  // HACK : END : ME
Note I've changed one thing regards the formatting that you might not want to change... I use a stylesheet for it so that I can use different colours according to style in use.

But it's the nested if's that is important... solves /me for PM's and reputation bits
Awesome! I sure will...
Reply With Quote
  #250  
Old 02-17-2005, 09:40 PM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looking at your code, I still need the newreply.php bit... I'll try this out tonight...
Reply With Quote
  #251  
Old 02-17-2005, 09:51 PM
buro9 buro9 is offline
 
Join Date: Feb 2002
Location: London, UK
Posts: 585
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Erwin
Looking at your code, I still need the newreply.php bit... I'll try this out tonight...
It doesn't fix the edit bug!

It's just the lack of username in reputation comments and private messages.

I'll look at the edit one now though
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 04:17 AM.


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.06796 seconds
  • Memory Usage 2,345KB
  • Queries Executed 26 (?)
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
  • (5)bbcode_code
  • (5)bbcode_php
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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