View Full Version : Username in posts and microstats
Boofo
06-02-2002, 06:47 PM
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.
$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,$new text);
Admin
06-03-2002, 12:17 PM
$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,$new text);
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. :)
Originally posted by FireFly
$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,$new text);
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? :)
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? :)
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.
Boofo
06-03-2002, 01:55 PM
Have any idea what it might be or what I can do to fix it? :)
Originally posted by FireFly
I don't think my hack is causing that.
globalwin
06-18-2002, 01:40 PM
hmm, please help: I have this code, the micostats work, but the bbuserinfo doesnt:
// ###################### Start dovars #######################
function dovars($newtext,$sendheader=1) {
// parses replacement vars
global $DB_site,$replacementsetid,$gzipoutput,$gziplevel, $newpmmsg,$fullpm,$bbuserinfo, $microstats;
static $vars;
if (connection_status()) {
exit;
}
if (!isset($vars)) {
$vars=$DB_site->query("SELECT findword,replaceword FROM replacement WHERE replacementsetid IN(-1,'$replacementsetid') ORDER BY replacementsetid DESC,replacementid DESC");
} else {
$DB_site->data_seek(0,$vars);
}
$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,$new text);
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.