|
PHP |
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39
PHP
<?php
// RU:
// вырезает куски текста, например
// скрипты от "<SCRIPT" до "</SCRIPT>"
// комментарии от "<!--" до "-->"
// $del=1 УДАЛЯТЬ ВЫБРАННЫЕ КУСКИ
// $del=0 УДАЛЯТЬ ОСТАЛЬНЫЕ КУСКИ
// $imp по какому символу имплодить
// $exp по какому символу эксплодить
-
// EN:
// cuts out pieces of text, for example
// scripts from "<SCRIPT" to "</ SCRIPT>"
// comments from "<! -" to "->"
// $del=1 DELETE SELECTED CUSKS
// $del=0 REMOVE THE OTHER CUSKS
// $imp on which character to implode()
// $exp by which character to explode()
-
function cut_tag ($cont, $imp=' ', $exp=' ', $del=1, $cutstart='<script', $cutend='</script>') {
-
$cont = str_replace( $exp, ' ', $cont);
$cont = str_replace($cutstart, $exp.$cutstart, $cont);
$cont = str_replace($cutend, $cutend.$exp, $cont);
$arr= explode($exp, $cont);
$i=0; $new=array();
// echo "\n<table>";
while ($i<count($arr)) {
$cc=0;
//echo "\n<tr><td>". $i . "</td><td><textarea> " . $arr[$i]."</textarea></td></tr>";
if (substr($arr[$i], 0, strlen($cutstart))==$cutstart) $cc=1;
//if( $del==1 AND $cc==1) НИЧЕГО !!!!!
if( $del==1 AND $cc==0) $new[] = $arr[$i];
if( $del<>1 AND $cc==1) $new[] = $arr[$i];
$i++;
}
//echo "\n</table>";
$cont2 = implode($imp, $new);
return $cont2;
}
-
-
-
function cut_many_tags ($cont, $imp=' ', $exp=' ', $del=1, $tags=array('script', 'a'), $striptags=1 ) {
-
$cont = str_replace( $exp, ' ', $cont);
-
// ДОБАВЛЯЮ МЕТКИ ДЛЯ ТЭГОВ ОКРЫВАЮЩИХ
//$cont = str_replace( '>', '>'.$exp, $cont);
$cont = str_replace( '<', $exp.'<', $cont);
$cont = str_replace( $exp.'</', '</', $cont);
$cont = str_replace( $exp.$exp, $exp, $cont);
// $cont = str_replace($cutstart, $exp.$cutstart, $cont);
// $cont = str_replace($cutend, $cutend.$exp, $cont);
-
$arr= explode($exp, $cont);
$i=0; $new=array();
// echo "\n<table>";
echo "<br> count($"."tags)=".count($tags);
while ($i<count($arr)) {
echo "<br>".$i."<textarea rows='1' cols='70'>".$arr[$i]."</textarea>";
$cc=0;
$j=0;
while ($j<count($tags)) {
//echo "\n<tr><td>". $i . "</td><td><textarea> " . $arr[$i]."</textarea></td></tr>";
if (substr($arr[$i], 0, strlen('<'.$tags[$j].' ')) == '<'.$tags[$j].' '
OR
substr($arr[$i], 0, strlen('<'.$tags[$j].'>')) == '<'.$tags[$j].'>' ) { $cc=1; echo " <br> +"; }
echo "<br>".$j." ".$tags[$j]." ". strlen('<'.$tags[$j].' ') . " " . strlen('<'.$tags[$j].'>') ;
echo " <textarea rows='1' cols='7'>".substr($arr[$i], 0, strlen('<'.$tags[$j].' ')) ."</textarea>";
-
//if( $del==1 AND $cc==1) НИЧЕГО !!!!!
$j++;
}
if ($striptags==1) $arr[$i] = strip_tags($arr[$i]);
if( $del==1 AND $cc==0) $new[] = $arr[$i];
if( $del<>1 AND $cc==1) $new[] = $arr[$i];
echo "<hr> <textarea rows='1' cols='70'>".$arr[$i] ."</textarea>";
$i++;
}
//echo "\n</table>";
$cont2 = implode($imp, $new);
return $cont2;
}
-
-
-
// вырезает script, style, comments
// cuts script, style, comments
function cut_script_style_comments ($text ) {
$text = str_replace(
array('<SCRIPT', '</SCRIPT', '<STYLE', '</STYLE'),
array('<script', '</script', '<style', '</style' ),
$text);
-
$text = cut_tag ($text, $imp=' ', $exp=' ', $del=1, $cutstart='<script', $cutend='</script>');
$text = cut_tag ($text, $imp=' ', $exp=' ', $del=1, $cutstart='<style', $cutend='</style>');
$text = cut_tag ($text, $imp=' ', $exp=' ', $del=1, $cutstart='<-- ', $cutend='-->');
$text = cut_tag ($text, $imp=' ', $exp=' ', $del=1, $cutstart='<!-- ', $cutend='-->');
return $text;
}
-
?>
|
Добавить комментарий |
Добавить комментарий Пожалуйста, залогиньтесь для добавления комментария.
|
HTML-code and BB-code for blogs and forums |
<a href="https://php-fusion.vveb.ws/php-fusion.php?id=67">cut_many_tags() PHP-Функция вырезает из HTML ненужные тэги, или другие куски текста, например скрипты от "<SCRIPT" до "</SCRIPT>"</a>
[url=https://php-fusion.vveb.ws/php-fusion.php?id=67]cut_many_tags() PHP-Функция вырезает из HTML ненужные тэги, или другие куски текста, например скрипты от "<SCRIPT" до "</SCRIPT>"[/url]
|
|