...

View Full Version : word filter



ycpc55
01-03-2007, 11:38 PM
hi
i have this word filter in php witch works fine but my site is using php with html templates so when i try to use this word filter in my site it wont work any idea how i can get this to work in my site?

word filter code:

<?
$badword = $_POST['badword'];

function filter($string){
$badwords = array("@yahoo.com", "@hotmail.com");
$filtered = str_replace($badwords, "****", $string);
return $filtered;
}

$filteredtext = filter($badword);
if (!$filteredtext) {
echo "You did not enter a sentence";
}else{
echo"$filteredtext";
}
?>

php code for my site:

<?php
/************************************************************************
* @Author: Tinu Coman *
************************************************************************/

$ft = new ft(ADMIN_PATH.MODULE."templates/");
$ft->define( array(main => "members_list.html"));
$ft->define_dynamic('member_row','main');
$l_r=ROW_PER_PAGE;

$time_stamp = mktime ( date("H"), date("i")-ONLINE_TIMEOUT, date("s"), date("m"), date("d"), date("Y") );

if(($glob['ofs']) || (is_numeric($glob['ofs'])))
{
$glob['offset']=$glob['ofs'];
}
if((!$glob['offset']) || (!is_numeric($glob['offset'])))
{
$offset=0;
}
else
{
$offset=$glob['offset'];
}
$arguments="";
$filter='';

if($glob['imageField_x'])
{
$_SESSION['s_g']=$glob['s_g'];
$_SESSION['ssy']=$glob['ssy'];
$_SESSION['esy']=$glob['esy'];
$_SESSION['country']=$glob['country'];
$_SESSION['photo']=$glob['photo'];
$_SESSION['st_online']=$glob['st_online'];
}

if($glob['s_g'])
{
$filter.=" and gender='".$glob['s_g']."'";
}

if($glob['ssy'])
{
$year=date("Y")-$glob['ssy'];
$filter.=" and birthdate <= '".$year."-1-1"."'";
}

if($glob['esy'])
{
$year=date("Y")-$glob['esy'];
$filter.=" and birthdate >= '".$year."-12-31"."' ";
}

if($glob['country'])
{
$filter.=" and country = '".$glob['country']."'";
}

if($glob['photo'])
{
$filter.=" and picture != 'NULL'";
}

if($glob['st_online'])
{
$filter.=" and action >= '".$time_stamp."'";
}


$dbu=new mysql_db;

$dbu->query("SELECT distinct
action, username, gender, thumb, member_id, city, country, headline, birthdate, publish_photo, password_protect
FROM member WHERE active1='1' AND active2='1' AND visible='2' ".$filter." ORDER BY username");

$max_rows=$dbu->records_count();
$ft->assign("ROWS", $max_rows);
$dbu->move_to($offset);
$i=0;
while($dbu->move_next()&&$i<$l_r)
{
if($dbu->f('member_id')==$_SESSION[U_ID])
{
$me=true;
}
else
{
$me=false;
}

list($b_year,$b_month,$b_day )=split("-",$dbu->f('birthdate'));
$age=get_age($b_month,$b_day,$b_year);

$description=$dbu->f('headline');
$ft->assign('DESCRIPTION', get_safe_text($description));
$ft->assign('THUMBNAIL_WIDTH', THUMBNAIL_WIDTH);

$ft->assign('USERNAME',$dbu->f('username'));
$ft->assign('COUNTRY',$dbu->f('country'));
$ft->assign('CITY',$dbu->f('city'));
$ft->assign('AGE',$age);

$ft->assign('READ_LINK',"index.php?pag=member_profile&pagold=members_list&member_id=".$dbu->f('member_id'));

//********begin get thumbnail code****
$picture = get_thumbnail($dbu->f('thumb'),$dbu->f('password_protect'), $dbu->f('publish_photo'), $dbu->f('member_id'), $_SESSION[U_ID], $me );
$ft->assign('PICTURE', $script_path.UPLOAD_PATH.$picture);
//********end get thumbnail code****


if($dbu->f('action') > $time_stamp )
{
$st=1;
$ft->assign('ST','<font color="#ff0000">online</font>');
}
else
{
$st=0;
$ft->assign('ST',"offline");
}

if($st)
{
$ft->assign("IM_LINK",'<a href="'."javascript:po13('../chat/index_blank.php?pag=chat&member_id=".$dbu->f('member_id')."', '".$dbu->f('member_id')."')".'" class="LinkStyle1"> Invite For Chat </a>');
$ft->assign('S_IM',"");
$ft->assign('E_IM',"");

}
else
{
$ft->assign('IM_LINK','#');
$ft->assign('S_IM',"<!--");
$ft->assign('E_IM',"-->");

}

if($dbu->f('member_id')==$_SESSION[U_ID])
{
$ft->assign('S_IM',"<!--");
$ft->assign('E_IM',"-->");
}

if($dbu->f('member_id') == $_SESSION[U_ID])
{
$ft->assign('MESSAGE_LINK',"index.php?pag=view_profile");
}
else
{
$ft->assign('MESSAGE_LINK',"index.php?pag=message_add&pagold=members_list&receiver_id=".$dbu->f('member_id'));
}
$i++;
if($i % 2 == 1)
{
$ft->assign('BG_COLOR',"#EEEEEE");
}
else
{
$ft->assign('BG_COLOR',"#FFFFFF");
}

$ft->parse('member_ROW_OUT','.member_row');

}
if($offset>=$l_r)
{
$ft->assign('BACKLINK',"<a class=\"LinkStyle1\" href=\"index.php?pag=members_list&offset=".($offset-$l_r).$arguments."\">Prev ".ROW_PER_PAGE."</a>");
}
else
{
$ft->assign('BACKLINK','');
}
if($offset+$l_r<$max_rows)
{
$ft->assign('NEXTLINK',"<a class=\"LinkStyle1\" href=\"index.php?pag=members_list&offset=".($offset+$l_r).$arguments."\">Next ".ROW_PER_PAGE."</a>");
}
else
{
$ft->assign('NEXTLINK','');
}

if(!$i)
{
unset($ft);
return get_error_message("There are no Profiles that match your search criteria.");
}

$ft->assign('PAG_DD',get_pagination_dd($offset, $max_rows, $l_r));

$ft->assign('PAGE_TITLE',"List Of Members");
$ft->assign('MESSAGE',$glob['error']);
$ft->parse('content','main');
$ft->clear_dynamic('content','member_row');
//$ft->fastprint(content);
return $ft->fetch('content');

?>

template code:

</head>
<table width="520" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12"><img src="../images/bul_arrow_g.gif" border="0"></td>
<td class=WhiteSlim12> <b>&nbsp;&nbsp;Search Results - {ROWS} Members</b> </td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="3">
<p align="center">&nbsp;</td>
</tr>
<tr>
<td width="10"><img src="../img/spacer.gif" border="0" width="1" height="1"></td>
<td width="500"> <table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><font color="red" size=-1>{MESSAGE}</font></td>
</tr>
</table>
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan=2><img src="../img/spacer.gif" border="0" width="1" height="10"></td>
</tr>
<tr>
<td colspan=2> <table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="4" background="../img/line_spacer.jpg"><img src="../img/spacer.gif" width="1" height="1"></td>
</tr>
<!-- BEGIN DYNAMIC BLOCK: member_row -->
<tr>
<td height="18" width="1" bgcolor="{BG_COLOR}">&nbsp;</td>
<td class="BlackSlim11" bgcolor="{BG_COLOR}" colspan="3"> <table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80" align="center" class=GraySlim11><a href="{READ_LINK}"><img src="{PICTURE}" width="{THUMBNAIL_WIDTH}" border="1" vspace="3" hspace="3" style="border-color: #000000"></a><br>
{ST}</td>
<td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class=BlackSlim11><b> {USERNAME}</b> </td>
</tr>
<tr>
<td class=BlackSlim11><b>Age</b> : {AGE}</td>
</tr>
<tr>
<td class=BlackSlim11><b>Location:</b> {COUNTRY} / {CITY}</td>
</tr>
<tr>
<td class=BlackSlim11>{DESCRIPTION} &nbsp;</td>
</tr>
<tr>
<td class=BlackSlim11><a href="{READ_LINK}" class=LinkStyle1>View Profile</a></td>
</tr>
<tr>
<td class=BlackSlim11><a href="{MESSAGE_LINK}" class=LinkStyle1>Send Private Message</a></td>
</tr>
{S_IM}
<tr>
<td class=BlackSlim11>{IM_LINK}</td>
</tr>
{E_IM}
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="4" background="../img/line_spacer.jpg"><img src="../img/spacer.gif" width="1" height="1"></td>
</tr>
<!-- END DYNAMIC BLOCK: member_row -->
</table></td>
</tr>
<tr>
<td colspan=2><img src="../img/spacer.gif" border="0" width="1" height="8"></td>
</tr>
<tr>
<td class="BlackSlim11" colspan=2>
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="180" align="right" valign="top">{BACKLINK}</td>
<td width="140" align="center" valign="top" class="BlackSlim11">
<form name="pagination" method="post" action="index.php">
<input type="hidden" name="pag" value="members_list">
{PAG_DD}
</form></td>
<td width="180" align="left" valign="top">{NEXTLINK}</td>
</tr>
</table></td>
</tr>
</table></td>
<td width="10"><img src="../img/spacer.gif" border="0" width="1" height="1"></td>
</tr>
</table>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum