<?
function spmwform()
{
global $photos_path, $html_header, $html_footer, $bwscflinfo;


$fll_path=$photos_path."spamwrd.dat";
$spwstring="";

if (file_exists("$fll_path")){
$arr_wrds=file("$fll_path");
foreach ($arr_wrds as $arrwrd)
{
$spwstring=$spwstring.$arrwrd;
}
}

echo $html_header; 
echo "
<center>
<table width='500'   border=0 cellspacing=0 cellpadding=1>
<tr><td bgcolor='#eeeeee'> 
<font FACE='ARIAL, HELVETICA'   color='#000099'><b>
Edit Spam Words
</b></font>
</td></tr><tr><td>
<font FACE='ARIAL, HELVETICA' size='-1' color='#000099'>
<form action='admin.php?md=spmwsave' method='post'>

$bwscflinfo

Input spam words or phrases, e-mails, IP addresses separated by commas:
<textarea name='spwstring'   rows='10' cols='60'>$spwstring</textarea>
<br>
<input type='submit' value='Submit Spam Words'>
</form>
</font>
</td></tr></table>
</center>
";
echo $html_footer;
exit;
}

function spmwsave()
{
global $photos_path, $html_header, $html_footer, $HTTP_POST_VARS, $bwscflinfo;

$spwstring=$HTTP_POST_VARS['spwstring'];

$fll_path=$photos_path."spamwrd.dat";
$flnm=fopen("$fll_path","w");
fwrite($flnm, $spwstring);
fclose($flnm);

$bwscflinfo="
 
<font FACE='ARIAL, HELVETICA' size='+1'  color='#009900'> <b>
Spam words has been saved successfully !
</b>
</font>
<p>
 
";

spmwform();
}

function spamadsdel()
{
global $cat_fields, $table_ads, $exp_period, $html_footer, $html_header ;
 
 
$sql_query="select idnum from $table_ads where visible=4";
$sql_res=mysql_query("$sql_query");
while ($row = mysql_fetch_array ($sql_res))
{
$del_id=$row['idnum'];
$sql_query="delete from $table_ads where idnum=$del_id";
mysql_query("$sql_query");
delete_photos($del_id);
}

echo $html_header; 
echo "
<center>
<table width='500'   border=0 cellspacing=0 cellpadding=1>
<tr><td > 
<font FACE='ARIAL, HELVETICA'   color='#000099'><b>
Spam ads have been deleted succesfully 
</b></font>
</td></tr></table>
";
echo $html_footer;
exit;

}

function check_spamw()
{
global $photos_path, $HTTP_POST_VARS, $REMOTE_ADDR;

$fll_path=$photos_path."spamwrd.dat";
$spwstring="";

if (file_exists("$fll_path")){
$arr_wrds=file("$fll_path");
foreach ($arr_wrds as $arrwrd)
{
chop($arrwrd);
$spwstring=$spwstring.$arrwrd;
}
}
$spwstring=ereg_replace("\n", '', $spwstring);
$spwstring=ereg_replace("\r", '', $spwstring);
$dllmmt=',';
$arrswds=split($dllmmt,$spwstring);

$spamres="0";

foreach ($arrswds as $spmwrd)
{
$spmwrd1=ereg_replace(" ", '', $spmwrd);
if ($spmwrd1 !="")
{
$fldsch=$HTTP_POST_VARS['title'];
if (preg_match("/$spmwrd/sU",$fldsch)){$spamres="1";}
$fldsch=$HTTP_POST_VARS['brief'];
if (preg_match("/$spmwrd/sU",$fldsch)){$spamres="1";}
$fldsch=$HTTP_POST_VARS['email'];
if ($spmwrd==$fldsch){$spamres="1";}

if (($REMOTE_ADDR!="") and ($REMOTE_ADDR==$spmwrd)){$spamres="1";}


}
}

return $spamres;
}
?>