<?php
include_once("inc/inc_stri.php");


$result=mysql_query("SELECT * FROM $sweartable WHERE intId != '0'");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    $replace = $a_row->strReplace1;
    if ($a_row->intReplace > 1)
    {
        $choice = rand(1, $a_row->intReplace);

        if ($choice == 1)
        {
            $replace = $a_row->strReplace1;
        }
        if ($choice == 2)
        {
            $replace = $a_row->strReplace2;
        }
        if ($choice == 3)
        {
            $replace = $a_row->strReplace3;
        }
        if ($choice == 4)
        {
            $replace = $a_row->strReplace4;
        }
        if ($choice == 5)
        {
            $replace = $a_row->strReplace5;
        }
    }
    $replace = "[swear]".$replace."[/swear]";

    $cleantext = stri_replace("$a_row->strSwear", "$replace", $cleantext);
}
/*
function stri_replace( $find, $replace, $string )
{
    $parts = explode( strtolower($find), strtolower($string) );

    $pos = 0;

    foreach( $parts as $key=>$part )
    {
    $parts[ $key ] = substr($string, $pos, strlen($part));
    $pos += strlen($part) + strlen($find);
    }

return( join( $replace, $parts ) );
}
*/