Ciao a tutti, ho un problema strano che non riesco a risolvere.
Devo "pulire" del codice html eliminando le varie classi dei
<td> ecc, e per fare questo ho usato queste due funzioni
Codice PHP:
function removeEvilTags($source){
$allowedTags='<a>
[b]<h1><h2><h3><h4>[i]' .
'<img>[*][list=1]
[b]<table>' .
'<tr><td><th><u><ul>';
$source = strip_tags($source, $allowedTags);
return preg_replace('/<(.*?)>/ie', "'<'.removeEvilAttributes('\\1').'>'", $source);
}
function removeEvilAttributes($tagSource){
$stripAttrib = "' (style|class)=\"(.*?)\"'i";
$tagSource = stripslashes($tagSource);
$tagSource = preg_replace($stripAttrib, '', $tagSource);
echo $tagSource;
return $tagSource;
}
e fin qui tutto a posto, ottengo il risultato voluto. Il problema nasce quando cerco di inglobare il tutto in un oggetto...ecco la classe:
Codice PHP:
class ClearHtml{
var $text = '';
function ClearHtml($text=''){
$this->text = $text;
}
function clear(){
if($this->text != '')
return $this->removeEvilTags($this->text);
}
function removeEvilTags($source){
$allowedTags='<a>
[b]<h1><h2><h3><h4>[i]' .
'<img>[*][list=1]
[b]<table>' .
'<tr><td><th><u><ul>';
$source = strip_tags($source, $allowedTags);
return preg_replace('/<(.*?)>/ie', "'<'.$this->removeEvilAttributes('\\1').'>'", $source);
}
function removeEvilAttributes($tagSource){
$stripAttrib = "' (style|class)=\"(.*?)\"'i";
$tagSource = stripslashes($tagSource);
$tagSource = preg_replace($stripAttrib, '', $tagSource);
echo "DENTRO";
return $tagSource;
}
function setText($text){
$this->text = $text;
}
}
alla riga di removeEvilTags
Codice PHP:
return preg_replace('/<(.*?)>/ie', "'<'.$this->removeEvilAttributes('\\1').'>'", $source);
la funzione removeEvilAttributes non viene mai richiamata....come mai? qualche idea? cosa mi sfugge? 
grazie!! roby.
ps: vedo che mi toglie uno slash... la chiamata è
removeEvilAttributes('\\1') con due slash!