Click to See Complete Forum and Search --> : How to strip out certain tags


wvmlt
12-06-2004, 06:33 AM
I have a forum where users can add their signature. I'd like to make it so users can not put images in their signature. How can I remove [ img] and [ /img] tags if a user enters them? Here's my code for that area:

// Start of edit signature
elseif($_GET['area'] == "editsignature") {
update_location('Editing Signature', '', '', '');
eval("\$header = \"".gettmp('header')."\";");
$output .= undoslashes($header);
getemoticons();
// Get signature from database
$query = $db->query("SELECT signature FROM hbb_members WHERE ID='$GLOBALS[userid]'");
$sigarray = $db->fetch_array($query);
$sigarray['signature'] = stripslashes(undoslashes($sigarray['signature']));
$sigarray['length'] = strlen($sigarray['signature']);
eval("\$result = \"".gettmp("editsignature")."\";");
$output .= undoslashes($result);
}

// Start input edit signature
elseif($_POST['editsignature'] == "1") {
$siglength = strlen($_POST['post']);
if($siglength > $configinfo['c_maxsiglength']) {
eval("\$header = \"".gettmp('header')."\";");
$output .= undoslashes($header);
$output .= hbberror('<li>Your signature is too long. The maximum length of a signature can be $configinfo[c_maxsiglength] characters. Your signature was $siglength characters long.</li>');
}
elseif(num_emoticons($_POST['post']) > $configinfo['c_maxemoticons']) {
$output .= hbberror('Your signature has too many emoticons. The total number of emoticons allowed per signature is '.$configinfo['c_maxemoticons'].'.');
}
else {
if(get_magic_quotes_gpc() == 1) {
$_POST['post'] = stripslashes($_POST['post']);
}
$signature = doslashes($_POST['post'], '1');
$db->query("UPDATE hbb_members SET signature='".$signature."' WHERE ID='$GLOBALS[userid]'");
$output .= hbbredirect('Your signature has now been updated. You are now being redirected to your user control panel where you can make further changes.', "usercp.php?area=main&amp;s=$s");
}
}

96turnerri
12-06-2004, 12:09 PM
preg_replace("/(.*?)/", "", $str);