vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Username in posts and microstats (https://vborg.vbsupport.ru/showthread.php?t=39356)

Boofo 06-02-2002 06:47 PM

Username in posts and microstats
 
Can anyone plaese help me with the following code? I had microstats installed and working and when I installed the username in posts hack, microstats quit working. I know the problem in the code, just not how to fix it so both of them will work. I know it can be done because they both work here.
Code:

$findwords=array(0 => '{getmicrostats}');
  $replacewords=array(0 => $microstats);
  $i=1;

  $findwords=array(0 => '{bbusername}');
  $replacewords=array(0 => "$bbuserinfo[username]<!-- auto name hack -->");
  $i=1;
  while ($var=$DB_site->fetch_array($vars) and $i++) {
    if ($var['findword']!='') {
      $findwords[$i]=$var['findword'];
      $replacewords[$i]=$var['replaceword'];
    }
  }
  $newtext=str_replace($findwords,$replacewords,$newtext);


Admin 06-03-2002 12:17 PM

Code:

  $findwords=array(0 => '{getmicrostats}', 1 => '{bbusername}');
  $replacewords=array(0 => $microstats, 1 => "$bbuserinfo[username]<!-- auto name hack -->");
  $i=1;
  while ($var=$DB_site->fetch_array($vars) and $i++) {
    if ($var['findword']!='') {
      $findwords[$i]=$var['findword'];
      $replacewords[$i]=$var['replaceword'];
    }
  }
  $newtext=str_replace($findwords,$replacewords,$newtext);

Might work.

Boofo 06-03-2002 12:36 PM

That did the trick, Chen. Works great! Thank you very much! :) :) :)

Could you just add more arrays to it as you need to then? This could come in handy. Gives me a few ideas. :)

Quote:

Originally posted by FireFly
Code:

  $findwords=array(0 => '{getmicrostats}', 1 => '{bbusername}');
  $replacewords=array(0 => $microstats, 1 => "$bbuserinfo[username]<!-- auto name hack -->");
  $i=1;
  while ($var=$DB_site->fetch_array($vars) and $i++) {
    if ($var['findword']!='') {
      $findwords[$i]=$var['findword'];
      $replacewords[$i]=$var['replaceword'];
    }
  }
  $newtext=str_replace($findwords,$replacewords,$newtext);

Might work.


Admin 06-03-2002 12:49 PM

Yes you can, but make sure you increment $i every time you add a new variable.

Boofo 06-03-2002 12:52 PM

You mean the $i=1;, right? Ok, I can do that. Just for learning sake here, why didn't you increment it when you put both of them together then? Or does the 0 and 1 basically mean the same? :)

Quote:

Originally posted by FireFly
Yes you can, but make sure you increment $i every time you add a new variable.

Admin 06-03-2002 01:10 PM

It could have been $i=0; before, don't know why it was set to 1.

Boofo 06-03-2002 01:34 PM

You could use something like this for an Easter Egg sort of thing, couldn't you? Like if you do the word {Boofo} it could put almost anything in the message post (from the postbit variables). For instance you could do {location} and have it bring up their location variable. Am I going in the right direction on this or am I way off track again? :)

Boofo 06-03-2002 01:37 PM

I think that might have been from the microstats code and when I added the user name in post hack, it also had the 1 in it. At least I got to the point I knew what piece of code was messing up. :) Maybe I am learning something (although not significant), huh? :)

Quote:

Originally posted by FireFly
It could have been $i=0; before, don't know why it was set to 1.

Boofo 06-03-2002 01:46 PM

I just noticed something that I'm not sure has anything to do with the code you gave me, but if I delete a message with the username in post hack in it, it gives me the errorid message. It goes ahead and deletes it, I just get the error after it says the message was successfully deleted. Any idea what might be causing that? Or how I can fix it?

Admin 06-03-2002 01:52 PM

I don't think my hack is causing that.


All times are GMT. The time now is 08:43 AM.

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.01558 seconds
  • Memory Usage 1,735KB
  • 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
  • (3)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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