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
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..

Link to comment
Share on other sites

[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

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

<?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 :)

Link to comment
Share on other sites

<?php

function htmlfilter($badcodes){

  $filout = array('<br>','<p>');

  $nobadcodes = '<nocode>';

  $badcodes=str_replace($filout,$nobadcodes,$badcodes);

  return $badcodes;

}

?>

 

that works but once I change the replace to ireplace it stops working

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.