vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   /me code Version 3 (https://vborg.vbsupport.ru/showthread.php?t=59698)

buro9 02-02-2005 03:34 PM

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

Erwin 02-02-2005 10:52 PM

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.

MissKalunji 02-02-2005 11:37 PM

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?

buro9 02-03-2005 10:50 AM

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.

sensimilla 02-03-2005 01:09 PM

and whats the use for it ? retrieving forgiven nickname? :p

buro9 02-03-2005 09:12 PM

Quote:

Originally Posted by sensimilla
and whats the use for it ? retrieving forgiven nickname? :p

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.

buro9 02-17-2005 07:35 PM

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 :)

Erwin 02-17-2005 09:37 PM

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...

Erwin 02-17-2005 09:40 PM

Looking at your code, I still need the newreply.php bit... I'll try this out tonight...

buro9 02-17-2005 09:51 PM

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 :)

buro9 02-17-2005 09:58 PM

OK, This version takes care of edits too:
Code:

  // HACK : START : ME
  global $post;
  if ('' == $post[username]) {
    global $reputation;
    if ('' == $reputation[username]) {
      global $pm;
      if ('' == $pm[fromusername]) {
        global $postinfo;
        if ('' == $postinfo[username]) {
          $meUsername = ''; // Can't determine username
        } else {
          $meUsername = $postinfo[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

Remember to strip my formatting :)

I think new replies are already dealt with by the $post one are they not?

I can't find a scenario in which it no longer works on mine.

buro9 02-17-2005 10:11 PM

Oh yeah... I see what you meant about the newreply bit... and yes, I think you do need it still.

In fact... I just tried to work around it... and you really need that bit still.

weaver 02-17-2005 10:39 PM

Is this still ready to update? Or does the newreply bit need to be worked out first?

mholtum 02-17-2005 11:07 PM

/me clicks install worked great

Viktor Kraft 02-18-2005 12:37 AM

Sometimes this doesn't work.
If I do three /me in a row only the first "me" is parsed, the others no.

But I did a test here, and work. Did I do something wrong editing the files?

Diva 02-20-2005 04:18 AM

Hi Erwin! Your hack is working great, except in PMs. I am using your quick PM hack also. When replying it shows "/me" instead of the person's name who sent the first PM. Could you help me with this? Thanks bunches!

Erwin 02-20-2005 08:01 PM

Quote:

Originally Posted by Diva
Hi Erwin! Your hack is working great, except in PMs. I am using your quick PM hack also. When replying it shows "/me" instead of the person's name who sent the first PM. Could you help me with this? Thanks bunches!

Mmm... let me take a look when I find time...

Diva 02-20-2005 08:02 PM

Thank you so much for all of your hard work. :)

zetetic 02-22-2005 07:37 PM

Quote:

Originally Posted by buro9
Remember to strip my formatting :)

I think new replies are already dealt with by the $post one are they not?

I can't find a scenario in which it no longer works on mine.

Good job! :)

I've been using this modification to make this hack work in PM's, message preview, etc. But it doesn't seem to work now with the latest version of this hack. Any idea how to incorporate these fixes? (For example right now if you use "/me" in a PM, when the person replies with quote it shows up as "/me" instead of with the name.)

Stryker[X] 02-28-2005 10:00 PM

]
Quote:

Originally Posted by User_001
Yep, unless there is more than one spot that code is in..

Code:

$pagetext = trim(strip_quotes($pagetext));
                // /me Hack
        $pagetext = preg_replace('#^/me(.*)$#im', "[color=\"red\"]* $originalposter\\1[/color]", $pagetext);
                // /me Hack
                eval('$newpost[\'message\'] = "' . fetch_template('newpost_quote', 1, 0) . '";');

                // fetch the quoted post title



edit: It works when the "/me" code is placed before the quote tags.

And to clarify, this is the only hack i am using. :)

[high] * Stryker[X] starts to think...
[/high]

Lets see here...on my forum, I have a double space after every /me enteree. Any ideas?

Eagle Creek 02-28-2005 11:27 PM

Is it full 3.0.7 compatible?

MissKalunji 03-01-2005 12:00 AM

Quote:

Originally Posted by Eagle Creek
Is it full 3.0.7 compatible?


yeah it works fine with me

MicroLinux? 03-01-2005 03:13 AM

I dont have the time right now to read through this... But this is thehack where like.. you want to greet the user looking so you put "Hello/me," and /me will be their username? If it is... THANKS SO MUCH!

fridayweb 03-01-2005 02:40 PM

I have a problem with the /me code being used within the vB Journal, created by Antonbomb22.

When someone types /me in that, it displays the name of the user VIEWING the journal, not the person who originally posted in their own journal.

Any suggestions on how to change that?

Deaths 03-01-2005 02:48 PM

You should ask AN-net himself, as he coded the journal.

kcadd 03-12-2005 09:55 AM

/me installs the /me hack :P

zetetic 04-13-2005 03:28 PM

Quote:

Originally Posted by tmhall
Good job! :)

I've been using this modification to make this hack work in PM's, message preview, etc. But it doesn't seem to work now with the latest version of this hack. Any idea how to incorporate these fixes? (For example right now if you use "/me" in a PM, when the person replies with quote it shows up as "/me" instead of with the name.)

I'm replying to myself because I figured out what was wrong. All this time I thought Edgewize's solution was a fix for this hack, but it's actually a completely different way of doing it that appears to do everything Erwin's does (even with Buro's mods) but works in quotes and previews too.

I know it's basically a thread hijack but there have been so many twists and turns on this thread it's really confusing. I'd love to know if Erwin or buro9 see anything wrong with doing it Edgewize's way, since it seems to work better...

TwinsForMe 05-10-2005 06:58 PM

I'm having a conflict with the Multiquote hack (not the quick-reply multi-quote).

If I quote someone with multi-quote who has used /me, my username will be inserted. If I quote myself when I had used /me, my username will be replaced with /me.

Here is a screenshot:

TwinsForMe 05-14-2005 02:59 PM

No one can help?

Erwin 05-15-2005 03:59 AM

The /me code hack upgraded to version 3.00 thanks to Edgewize's suggestions - this fixes the parsing problems in quotes and PMs. :)


Just remove the old hack and follow the instructions in the first post.

Getox 05-15-2005 06:51 AM

hey hey new version, might install this on my forum, even though my site is sitting there, useless music forum ;)
is / me install here?

[high]* Getox tests[/high]

zetetic 05-15-2005 02:54 PM

Excellent. Thanks for the update, Erwin. :)

TwinsForMe 05-15-2005 03:12 PM

Thanks. :)

Logikos 05-17-2005 11:32 AM

Erwin. For this to work in vB 3.0.7. You should change your instructions for private.php.

Should Be Find:
PHP Code:

$pagetext trim(htmlspecialchars_uni($pagetext)); 

Copy pasted code below:

Just wanted to let you know. :)

[high]* Logikos rocks[/high]

boo.3 05-17-2005 11:44 AM

/me loves this hack

jesus likes pie 05-30-2005 02:28 PM

I cant find

Code:

$pagetext = trim($pagetext);
in my private.php


:\

Logikos 05-30-2005 02:57 PM

Look 2 post up dude for an update.

jesus likes pie 05-30-2005 03:16 PM

oh thanks.

Erwin 05-31-2005 02:38 AM

Fixed the first post. :)

Logikos 05-31-2005 04:45 AM

Thank you Erwin! :)


All times are GMT. The time now is 11:02 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.01475 seconds
  • Memory Usage 1,840KB
  • 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
  • (8)bbcode_code_printable
  • (1)bbcode_php_printable
  • (12)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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