Hallo, all
I have used this function.
$string = strip_tags($p1, '<i><b><u><br>< p><font>');
The problem is that the title will be printed as well, but i dont allow the
title tag.
How to i exclude this ?
Thanks
Danny 3 4065
Danny wrote: I have used this function. $string = strip_tags($p1, '<i><b><u><br>< p><font>');
The problem is that the title will be printed as well, but i dont allow the title tag.
How to i exclude this ?
remove the title and its contents before applying strip_tags.
<?php
$p1 = '<html><head><t itle>title</title></head><body><p>< a>link with<b>embedded bold</b></a></p></body></html>';
if ((substr_count( $p1, '<title>') < 2) && (substr_count($ p1, '</title>') < 2)) {
$t1 = strpos($p1, '<title>');
$t2 = strpos($p1, '</title>');
if ($t2 > $t1) {
if ((substr_count( $p1, '<head>') < 2) && (substr_count($ p1, '</head>') < 2)) {
$h1 = strpos($p1, '<head>');
$h2 = strpos($p1, '</head>');
if (($h2 > $h1) && ($t1 > $h1) && ($t2 < $h2)) {
$p1 = substr($p1, 0, $t1) . substr($p1, $t2+strlen('</title>'));
}
}
}
}
$string = strip_tags($p1, '<i><b><u><br>< p><font>');
?>
--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Hello,
Yes i know i can do that, but the problem is, that the customer cant. The
customer works from a word file and saves it as an html file. Word always
puts the title in it. Why the strip tag allows title standard?
Danny Danny wrote: I have used this function. $string = strip_tags($p1, '<i><b><u><br>< p><font>');
The problem is that the title will be printed as well, but i dont allow the title tag.
How to i exclude this ?
remove the title and its contents before applying strip_tags.
<?php $p1 = '<html><head><t itle>title</title></head><body><p>< a>link with<b>embedded bold</b></a></p></body></html>';
if ((substr_count( $p1, '<title>') < 2) && (substr_count($ p1, '</title>') < 2)) { $t1 = strpos($p1, '<title>'); $t2 = strpos($p1, '</title>'); if ($t2 > $t1) { if ((substr_count( $p1, '<head>') < 2) && (substr_count($ p1, '</head>') < 2)) { $h1 = strpos($p1, '<head>'); $h2 = strpos($p1, '</head>'); if (($h2 > $h1) && ($t1 > $h1) && ($t2 < $h2)) { $p1 = substr($p1, 0, $t1) . substr($p1, $t2+strlen('</title>')); } } } }
$string = strip_tags($p1, '<i><b><u><br>< p><font>'); ?> -- Mail to my "From:" address is readable by all at http://www.dodgeit.com/ == ** ## !! ------------------------------------------------ !! ## ** == TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>) may bypass my spam filter. If it does, I may reply from another address!
Danny top-posted (reformatted) and failed to attribute (corrected): Pedro Graca wrote: Danny wrote: I have used this function. $string = strip_tags($p1, '<i><b><u><br>< p><font>');
The problem is that the title will be printed as well, but i dont allow the title tag.
How to i exclude this ?
remove the title and its contents before applying strip_tags. Yes i know i can do that, but the problem is, that the customer cant. The customer works from a word file and saves it as an html file. Word always puts the title in it. Why the strip tag allows title standard?
strip_tags removes the <title> tag, just like it removes the <b> or <a>
tags. What it doesn't do is remove the text between the tags.
<?php
echo strip_tags('out er <title>inner <a href="x">link</a> content</title> content');
?>
will output "outer inner link content content"
______^^^^_____ ___
Maybe you can try to replace <title> with "<!-- " and </title> with " -->"
if you don't want to check everything like I did on my last post.
--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fazer |
last post by:
Hello,
I was wondering what would be the easiest way to strip away HTML tags from a string?
Or how would I remove everything between < and > also the < , > as well using regex?
Thanks for any help!
|
by: AdamD |
last post by:
Does anyone have an example of how to strip HTML tags from an laready existing text file
Thanks
|
by: John Grandy |
last post by:
Let's say I'm writing an app where various 3rd parties provide content.
In code, I store their content in strings.
The content typically is plain text , but some providers add-in snippets of
HTML to the text, and sometimes these snippets are HTML encoded.
Example 1 : "This new widget by <b>Whacko Corp</b> is so cool you'll be
hoarding them from the public in no time."
|
by: localhost |
last post by:
I have these in all of my pages:
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
And I am wondering if it is safe to remove them after I compile the
ASP.NET application, or if it is possible to have VS.NET 2003 not put
|
by: Daniel M. Hendricks |
last post by:
I'm looking for a function/regex in C# to strip unwanted HTML tags from
comments posted to my web site. Previously, it was written in PHP and
I used this function to strip unwanted tags:
function removeEvilTags($source)
{
$allowedTags='<b><i><blockquote><ul><ol><li><br><a>';
$source = strip_tags($source, $allowedTags);
return preg_replace('/<(.*?)>/ie',
"'<'.removeEvilAttributes('\\1').'>'", $source);
| |
by: tshad |
last post by:
Is there an easy way to strip HTML tags from Text to get just the plain
text?
I am using a program called FreeTextBox that lets you format Text in a
TextBox. It does this by adding HTML tags (<b>, <u>,<span> etc) to the
code.
The problem is that it is a problem since I am putting the text in a
varChar(8000). The HTML adds a lot characters to the text. I can change
this to a Text field in Sql, but you can do a FullText search on a...
|
by: Nathan Sokalski |
last post by:
I have two asp:ImageMaps in a table cell as follows:
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td align="center">
<asp:ImageMap ID="mapBanner" runat="server" BorderWidth="0px"
Height="82px" ImageUrl="../images/top_banner.jpg" Width="1000px"
style="margin:0px;padding:0px;">
<asp:RectangleHotSpot Left="125" Top="5" Right="200" Bottom="22"
|
by: Steve |
last post by:
Hi,
I'm a complete PHP n00b slowly finding my way around
I'm using the following function that I found on php.net to strip
out html and return only the text. It works well except for when
you find styles embedded within the tags
eg: <h3 id="pageName">Have a great day!! </h3>
This throws an error, whereas
<h3 >Thank you for your purchase! </h3works like a charm.
It also falls over when crappy code has <h3> </h3between
the tags.
|
by: george |
last post by:
hello,
which is the best way to strip jscript/vbscript from user input? Is
there any module I could reuse?
thanks in advance
george
P.S. the solution must allow users to enter html code.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |