PDA

View Full Version : How to combine two hacks that want to modify the same code?


JJR512
07-13-2002, 01:23 AM
The microstats hack wants to change this code:
while ($var=$DB_site->fetch_array($vars)) {
if ($var['findword']!="") {
$newtext=str_replace($var['findword'],$var['replaceword'],$newtext);
}
}
With this:
$findwords=array(0 => '{getmicrostats}');
$replacewords=array(0 => $microstats);
$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);

The username in post hack wants to replace the same bit of code with this:
$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);
How can I combine those two new bits of code into one bit of code that allows both hacks to function properly?

Admin
07-13-2002, 07:02 AM
$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);

JJR512
07-13-2002, 08:04 AM
Thanks! :)

Boofo
07-13-2002, 09:14 AM
Boy, does this code ever look familiar. :)

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