Jump to content

[SOLVED] Capital Letters error


env3rt

Recommended Posts

I'm making my own htmlEntities thingy because I want certain codes to work and others not to. The problem is that if I ban < br > then you can still do things like < BR > and stuff

<?php 
function htmlfilter($badcodes){

$filout = array(

"<br>","<BR>","<Br>","<bR>","<P>","<p>"

);
$nobadcodes = "<nocode>";
foreach($filout as $replace){
	$badcodes = str_replace($filout,$nobadcodes,$badcodes);
}
return $badcodes;
}
?>

So basically I need something to ignore capital letters, because I don't want to type every possible combination of capital letters and normal letters for each code (like above)

Please help, ask if you need further information.

Link to comment
https://forums.phpfreaks.com/topic/72009-solved-capital-letters-error/
Share on other sites

I'm making my own htmlEntities thingy because I want certain codes to work and others not to.

 

an existing function already provides for this:

 

strip_tags ( string $str [, string $allowable_tags] )

 

$content = strip_tags($content);

 

if you want to allow <UL> and <LI>, for instance,

 

$content = strip_tags($content, '<UL><LI>');

 

 

 

ah, but this doesn't replace does it?? never mind..

[code=]<?php 
function htmlfilter($badcodes){

$filout = array(

"<br>","<p>"

);
$nobadcodes = "<nocode>";
foreach($filout as $ireplace){
	$badcodes = str_ireplace($filout,$nobadcodes,$badcodes);
}
return $badcodes;
}
?>

Would that be what you do just replace the to "replace"'s with ireplace?

Because it's not working

<?php 
function htmlfilter($badcodes){
  $filout = array('<br>','<p>');
  $nobadcodes = '<nocode>';
  $badcodes=str_ireplace($filout,$nobadcodes,$badcodes);
  return $badcodes;
}
?>

 

Try that. I enclosed the text with single quotes instead of double.

remove the for, we're sending the whole array in one shot:

 

function htmlfilter($badcodes){

    $filout = array("<br>","<p>");
     $nobadcodes = "<nocode>";
return str_ireplace($filout,$nobadcodes,$badcodes);
}

That's not working :(

<?php 
function htmlfilter($badcodes){
  $filout = array('<br>','<p>');
  $nobadcodes = '<nocode>';
  $badcodes=str_ireplace($filout,$nobadcodes,$badcodes);
  return $badcodes;
}
?>

 

Try that. I enclosed the text with single quotes instead of double.

not working either

<?php
include("htmlfilter.php");
$sig = $username."sig.html";
$fh = fopen($sig, 'r');
$sigpage = fread($fh, filesize($sig));
fclose($fh);
if($_POST['sigupdate'])
       {
$fh = fopen($sig, 'w');
$filterhtml = htmlfilter($signature);
fwrite($fh, $filterhtml);
fclose($fh);
echo "<script type='text/javascript'>
window.location = '/$username.php'
</script>";
}


echo"
<center>Update your signature!
<form method='post' action='?signature'>
<textarea name='signature'>$sigpage</textarea>
       <input type='submit' value='Submit' name='sigupdate'>
</form>
Your sig is now:<br>
$sigpage
</center></marquee></font>
";
?>

 

I would really like it if you could just switch the replace to ireplace from the original code for me because the original code was working, and I don't know how to do it :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.