Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Reg Exp Question: Removing Class And Style From Html


i have a little database driven content managment system. people can
load up html-docs. some of them use ms word as their html-editor,
which resultes in loads of "class" and "style" attributes - like this:

<p class="MsoNormal">Some text</p>

now i'd like to remove them (the attributes, not the people, that is).
i know reg exp is the way, but somehow the solution avoids me.




View Complete Forum Thread with Replies

Related Forum Messages:
Wnat To Embed Full HTML Page In Email, But Migrating Style From Css Files To Element Style Attributes
My web pages of course use css files, but Webmail services require
style to be in element style attributes.

How do I convert a standard HTML page to HTML suitable for delivery to
webmail services?

Perhaps another way to ask the question is:

How to I walk the DOM and for every element, for every style, set the
element's style attribute to the values that are looked up in the css
file in normal rendering.

Anyone know of any tools, or examples to do this?

View Replies !
Removing Page Style
I found a great script which turns a HTML page into a PDF, but the problem is it turns the whole page, with layout etc, into the pdf, which looks really bad with all the navigation etc, on it. Code:

View Replies !
Style Class Css Or PHP?
Having had a little experience of HTML and style classes but only a limited
knowledge of PHP perhaps somebody can tell me the pros and cons of the
following.

Surely if I write something in PHP like

$style = "<b><i><font size=&#391;'>"
$endstyle ="</b></i></font>"
$s = array($style,$endstyle)
echo $s[0] . "I want my font in bold italic and size 1" . $s[1]

does this not do the same as style classes? Taking it one step further, if I
write all of the styles in a script called styles.php and include it in all of
my php pages is that not the same as having a .css file?

Why use 2 programming languages when it can be done in 1?

View Replies !
Class File And Including A CSS Style
I have a class file which contains the classes for the frontend of the site. In some of the functions there are links to various different things.

I tried adding a class attribute onto the link but it doesn't work. So I tried including/requiring the class file and that did nothing but spit the code out onto the page. Any idea what I can do to fix this?

View Replies !
Class Definitions In Java Style
When working with many classes in a php code, some classes might have the sam name, in java you can reference classes in different folders by writing foldername.classname, while referencing the classes in current folder with just classname.

View Replies !
Html Page - <style ... > Tag
If i have an html page and i am looking for the <style ... > tag. What would be the best way to look for it? I need to look for a special type, something like

<script language="Javascript" type="text/javascript" >....<script> .

View Replies !
Removing HTML
I have a form that is receiving spam from people, and this is unaceptable. I know that it is impossible to stop all spam, however, I need to stop people from posting links. As of now, I have my function stripping out tags, or anything that resembles tags. ie. <something> That can stop actual links, but now they just type the link. Is there a way to sense if a string has "http://" or "www." etc... to prevent the form from allowing it to procede? I know how to get the prevention to work, I just need to sense it.

View Replies !
Removing Html Tag
in my datbases their is field news & it's dat is shown here it has datatype of text Code:

View Replies !
Removing Html From A Blob Via Php
I'm trying to use php ereg coding to remove all html from a blob so that I can parse it into keywords, any Ideas?

View Replies !
Removing Some HTML With Preg_replace
I need to be able to upload a file (html) to the server and strip away
everything up-to and including the <BODY> tag and everything from
</BODY> down. I have a perl script that does this successfully using
the following 2 lines...
$progress_report =~s/^.*<BODY.*?>//s;
$progress_report =~s/</BODY>.*//s;

I want to be able to do this with php. Can anybody help me with this?
I tried using hte regexp above in the preg_replace() function, but it
did not work.

View Replies !
Removing Attribules From HTML
I just noticed that the firefox bookmarks page in over 500KB, while it displays on 22KB of text on the screen. I carry this file with me on my disk-on-key so it is important for it to be small. I want to parse entrys like this too make them smaller: Code:

View Replies !
Removing HTML Tags
I am using ajax, so I am manipulate the text with either php(prefer) or javascript.
I have a text area where the user enters whatever. They click send and a 'js' function gets called and it calls my sendRequest function and sends over the data to my php file to be insert into my db.

What I want to do is remove any of the html/js tags I can. The only thing I want to keep is the spacing the user enters (line spacing).

My php file - I have tried many different ways, but none of them seem to work

$txt = $_GET['text'];

$stuff = array("","");
$txt = str_replace($stuff, "<br />");
echo strip_tags($txt, '<br />');

So using the code above if I enter:
<b>Test</b>

This is a test

The Results is:
TestThis is a test

I've tried another method using 'preg_match', but i am getting an error b/c of the function.

View Replies !
Removing Attributes From Html Tags
I want to build a class which will return a stripped version of variable containing HTML tags.

In my constructor i will use strip_tags to get rid of the unwanted tags in the variable.

After that i'll call a method cleanup() which has to do the hard work.

Lets say i fill an array with values containing attributes like Onclick Onmouseover Style in my constuctor.

I will allow de <a> tag to be used, but i want to strip the tag from attributes mentioned above.

View Replies !
Removing Empty HTML Tags
Long story short:

Converting word files to readable HTML (approx 1200 docs).

Got it going good, have one problem left:
Due to the difference between hard and soft carriage returns, sometimes end up with <p> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> and I need to get rid of these. There are differring numbers of non-printing characters and spaces between the p tags.

I am convinced that a regular expression will do this but so far have not found one.

So basically what I need is to remove any paragraphs that contain no printable characters.

View Replies !
Removing Word HTML From A File
I have a problem with converting word docs to HTML. As you probably know, when word generates its HTML it has a lot of needless tags. Is there a way I can cut these out and just leave basic formatting tags such as <b>, <br>, <ol>, <li> etc. I found this code to remove Word HTML PHP Code:

View Replies !
Removing HTML Tags From String
I have a bit of code that selects data from a MySQL LONGTEXT field. The data will typically contain some HTML tags.

The PHP then cuts this down to 100 characters, and adds ".....[more]" as a clickable link at the end which loads a new page containing the complete data.

If you like, this will produce a list of snippets of ALL entries in the table and the user can choose which one to read in its entirity.

It works brilliantly, but if there are any HTML tags around the 100 character position then random results occur. Well, not random but difficult to calculate.

My solution is to strip out these HTML tags using a PHP function, and then cutting the data down to 100 chars. Code:

View Replies !
Any Way Of Removing Line Breaks From HTML Code?
I have a big big chunk of HTML code stored inside a variable $myhtml. Is there any way I can possibly remove all line breaks in the HTML?

I tried $myhtml = str_replace('
', '', $myhtml);
but it doesn't work.

View Replies !
Removing Html Anchors From POST'ed Text String
I am having problems with trying to remove some tags using PHP. What I
want is to perform a search and replace on a URL, so if someone tried to
put a URL into a guestbook database, instead of the user inputting a
link as:

<a href="http://whatever.com">visit me</A>

It goes into the database as:

http://whatever.com

I have tried the str_replace() function, but doesn't seem to work. I have
also tried strip_tags() but then that just give the result:

This is the code I've written.

$AmendedComment = str_replace("<a href="", " ", $_POST['Comment']);
$FinalComment = addslashes($AmendedComment);

Checking the database and reading it out again, the first part of the URL
remains intact, so the URL is clickable - not what I want.

I've made an attempt at preg_replace() but it's difficult to get head
around trying to write a pattern.



View Replies !
Cleaning User Input (Removing HTML/stripping Slashes Etc...)
How can I remove HTML and add slashes to a variable?

I know I can add slashes with addslashes($var); but I need to know how to remove all HTML at the same time. Also - Are there any other characters I should strip from the variable (it will be stored in a database and displayed on a web page).

View Replies !
HTML-Form In A PHP-class
i've got the following problem:

I want to code a class for a calendar-month-overview. This means, there is a form, where the user can select a month and a year. Can I just put the form in a function called print_month_overview() or sth. like that? But how can i save/restore the previously selected month/year?

For example, i have a file called test.php, where i'd like to show such a month_overview.
I make a new object of the month_overview.class: Code:

View Replies !
Simple PHP Class To Convert A HTML File To PDF
I need a simple PHP class to convert a HTML file (with texts and images) to PDF. I'm using php4 and can't use php5 on my server.

View Replies !
This Class Returns HTML Content But Fails In Producing Globals, Why?
The following class is supposed to produce a series of HTML dropdowns
and HTML text fields based solely upon variable names for month, day
and year passed into it. Those variable names will correspond to
actual variables with values that are passed into the preSelect()
function inside the methods (that function is called from an outside
parent script included). However, upon careful inspection the global
function does not globalize anything within any method.

// USE THIS CLASS TO GENERATE A SERIES OF DROPDOWNS AND TEXT FIELDS
PERTAINING TO MONTH / DAY / YEAR
class DropdownGenerator {
var $hasMonth, $hasDay, $hasYear,
$monthVar, $dayVar, $yearVar,
$yearFieldLength,
$monthArray;

function DropdownGenerator($monthVar = '', $dayVar = '', $yearVar =
'', $yearFieldLength = 4) {

$this->yearFieldLength = $yearFieldLength;
foreach (array('month', 'day', 'year') as $key => $val) {
$this->{$val . 'Var'} = ${$val . 'Var'};
$this->{'has' . ucfirst($val)} = (strlen($this->{$val . 'Var'}) >
0) ? 1 : 0;
if (strlen($this->{$val . 'Var'}) > 0) global ${$this->{$val .
'Var'}};
}

$this->monthArray = array(&#3901;' => 'January',
&#3902;' => 'February',
&#3903;' => 'March',
&#3904;' => 'April',
&#3905;' => 'May',
&#3906;' => 'June',
&#3907;' => 'July',
&#3908;' => 'August',
&#3909;' => 'September',
&#3910;' => 'October',
&#3911;' => 'November',
&#3912;' => 'December'
);

View Replies !
Defining A Class/instantiating Object Inside A Method Of Another Class
I have a class. Inside the class I have a method that reads a text file.
In the text file I have a class name and a file name where that class is
defined. Now, I need to instantiate an object of that class, the problem
being that at the time I find out the class name and the file name, I'm
inside a method of another class. Well, let me just type up a little
example:

View Replies !
Child Class Member's Iteration By Parent Class
I have a class that has a few private members. Is there a way to create a function in its parent class that can access its (child's) private members.

With the following code I am able to get only the public and protected members.

class parentIter {

function iterateProps ( ) {
foreach ( $this as $propName => $propValue ) {
echo "<br>$propName => $propValue" ;
}
}
}

class childIter extends parentIter {
protected $var1 = 'protected var' ;
private $var2 = 'private var' ;
public $var3 = 'public var' ;

function iterateProps ( ) {
parent::iterateProps () ;
}
}
$obj = new childIter () ;
$obj->iterateProps ( ) ;

View Replies !
PHP5: Can A Class Inherit Initialized Classvariable From Another Class?
I got following problem trying to inherit a variable from another class

class Core
{
public $obj;

function initialize($obj)
{
$this->obj = $obj;
}

}

class test extends Core
{
function test()
{
echo $this->obj;
// or
echo parent::$obj;
// ??
}

}

$core = new Core
$core->initialize('hello');

$test = new test
$test->test();

As far as what I would like to get, I would see 'hello', but instead I
get following error:
Fatal error: Access to undeclared static property: Core::$obj (echo
parent::$obj;)
After declaring $obj as public and static I don't get any result as
well..
Is it possible to inherit already initialized variables from a
different class or are there design patterns who could do something
like that? I hope it is clear where I want to go with this..
I am doing this because I can't give the class test any parameters
because it could be extended (class woow extends test). Also the amount
of variables is not certain and there might be lots of classes needing
to inherit the variables. That would mean that I would have to change
every class if a parameter would change..

View Replies !
Access Class Member Function Without Instantiating Class?
I need to access a class member function from outside the class, and hopefully without having to instantiate the class if possible?

I have an HTML form <select> and each <option> item is being pulled from an array stored in a mysql db.  But I'm doing this independently of the normal purpose of the class itself, I just want to use that member function.

View Replies !
Modify A Function Of A Parent Class From The Child Class ?
How do i modify a function of a parent class from the child class ?

View Replies !
Date :: Class Starts And The Time A Class Ends
I have a registeration system set up. The user registers the time a class starts and the time a class ends. These times are stored in mysql db with time type. How do I prevent double booking in this situation? e.g. If the class starts at 9:00 and ends at 10:30, how do I ensure that no class takes place between those times.

View Replies !
Calling Class Method Of Variable Class.
Yes, it's the week of OO here in c.l.php

If I want to call the method a class (not an object), one normally uses:
classname::method();

which works fine.

However, what if I don't know the classname yet?
$classname::method();
doesn't work, neither does
{$classname}::method();

I've got solved it like this now:
call_user_func(array($classname,'method'));

View Replies !
Syntax? How To Declare A Member Of A Class Which Is Itself A Class
how to declare a member of a class which is itself an object?

class cA
{
private $blah;
public function foo()
{
return blah;
}
}

class cB
{
private cA $a; // I want this to be of type class A
}

View Replies !
Invoke Function From Initiated Class Within A Class
<?php
//clsrecordset.php
class Recordset extends Database{

public function Recordset( ) { }

public function query( ) { }

public function endOfFile ( ) { }

}
?>

<?php
//clssearchindex.php
require_once('clsrecordset.php');

class Searchindex {
private c_rs;

public function Searchindex ( ) {
$this->c_rs = new Recordset( );
}

public function getSQL ( ) { }

public function getData ( ) {
$rs = $this->c_rs->query($this->getSQL()); // error occurred this line
$this->c_rs->query($this->getSQL());
if ( $this->c_rs->endOfFile() ) {
$norecs = true;
}
}
}
?>

Error message: Call to a member function query() on a non-object

Additional, when I type the $this->c_rs-> , there is no intellisense on this case that's why I know there is something wrong and couldn't find the function.

Help: How can I call the function from the initiated class in order to use in other class?

View Replies !
Div Style
I have this line in my script

PHP Code:

<div style="width:310px; margin:24 0 0 2px">

What does each margin 0 stand for? I imagine its for spacing, but which is for which?

View Replies !
Same CSS Style In Php Segments.
I have several seperate individual php segment which make up my website. To
check what each segment actuallt displays I am linking my css style to each
and every segment in a wysiwyg program.

This results in a website with the same css file being called about 20
times. Of course I can delete all but one of these "link css rows" and then
add them again as and when a segment needs to be edited.

This seems to be a round about way of doing things even if it gets the job
done. Is there a more effective way?

View Replies !
Coding Style...
When i write a script, i tend to seperate the differnt functions with differnt files. For example. When i creat a user management script, i create and add_user.php file and a modify_user.php file, and so on. I also see a lot of people who simply write one big 10 meg php file that includes everything in one. (seperated into functions.)

Is there an advantage to this? Or is it just a matter of personal prefrence? I guess it really doesnt matter that much, i just wanted to know.

View Replies !
Perl Style In Php ?
Often I just want to be able to get at a single element from a
function that returns an array. For example, if I just want the
current year I need to write:

$today = getdate();
$year = $today['year'];

Call me lazy but this is two steps to return a single value.
In perl I can nest these two step together into something like:

$year = ( $getdate() )['year'];

I've tried to get several variations of this to work in php but I
don't seem to be having any luck.

Is this style possible in php?

View Replies !
Inline CSS Style
I'm having a problem sending email using php mail. The email is designed with tables so I'm using inline CSS styles. Problem is that the styles do not work. It gets displayed as text. Code:

View Replies !
CSS - Change The Style
how can I change the style of this code to align 10px to the right?

echo " <span class="leftfloat">$artist_name_next[$i] </span>"

I tried adding Style='left:10px;' but that didn't take.

View Replies !
Applying CSS Style
I am having trouble applying the style mytext (from CSS) to the following:

echo "Sizes Possible With ". "$size" ."mm Head Box, and ".$drive." Drive";

Any way I do it, I either get plain text, or the style being applied do the $size and $drive so they appear as that, and not as their values, or I get the correct text with no style applied, or I get a parsing error. The style works fine elsewhere in the script applied to a table. The problem seems to be mixing text and variables together.

View Replies !
Css Style Switcher
trying to make themed website. seenthis in one shop. and i want to do the same.
i came across the problem wich i cant solve. Code:

View Replies !
Using Style Position
I have two tables. If I leave them alone, one will print on the screen, then below it the next, etc. However, I want table one on the left and table two on the right of
the screen. Both are populated by two different queries, so they are not exactly created at the same time. I decided to use styles to position:absolute the second table to the
right of the first table.

I am worried that this is not correct. For example, my text size is set at smaller, but on medium the tables are not lined up right. The blend into each other and when the browser's text size is larger,
well, it looks terrible.

View Replies !
Adding Css Style
This is part of my code how do i put a style sheet on that I can't use the tr tag as I want my headings to be a different colour? usually I would put a class in the tr but I cant because of the php.

echo "<tr>";
echo    "<td>".$row['scan']."</td>";
echo    "<td>".$row['description']."</td>";
echo    "<td>".$row['serialpartno']."</td>";
echo    "<td>".$row['date']."</td>";
echo "</tr>";

View Replies !
Style Date
I was programming a calendar for a website and ran into this:

firstly:
mktime(0,0,0,3,27,2005); ->returns 1111878000
mktime(0,0,0,3,26,2005); ->returns 1111795200

and then:
date("d.m.y",1111878000); ->returns 26.03.2005
date("d.m.y",1111795200); ->returns 26.03.2005

Is this something one should except? Shouldn't the timestamps be
trusted or am I just confused?

View Replies !
CSS Style Output
I query mysql and output to a table:

I have a "text" style in my css style sheet. no matter what I have tried it will just not assign the style to the above.

View Replies !
Style Sheets
I have an external php stylesheet that is included in all my pages like this.

<link rel="stylesheet" type="text/css" href="style.php">

In the stylesheet the below is supposed to set the background color but the expression always evaluates false and I can't figure out.

body { background: <?php echo ($bkColor)?"$bkColor":"#003399"; ?> ; color:white; font-size:12pt; font-weight: bold.

View Replies !
CSS Style Switch
I am trying to create a mechanism which enables me to switch between a screen CSS (where every piece of content is shown) and a print css where images are not displayed. At the moment any new php pages I create are generated using a Dreamweaver template which has in it an editable region Code:

View Replies !
OOP Style Programme
I have just started OOP style programming and have made my first class. The class it self explanatory and simply takes an uploaded file and a name. As it goes through the verifyImage function, it will exit if there is an error. If no error then it carries on.
I have called it this way in my main page: PHP Code:

require_once('newImage.php');

$image = new newImage($_FILES['image']['size'], $_FILES['image']['type'], $_FILES['image']['tmp_name'], $_POST['name']);

if ($image->verifyImage()) {
    $image->moveImage();
}

View Replies !
PHP 4: Does Method_exist Return True If Parent Class Method Even If Child Class Forgot To Call Parent::
My code was dying on the line below where I use method_exists:

if (class_exists($nameOfClassToBeUsed)) {
$object = new $nameOfClassToBeUsed();
$this->arrayOfAllTheObjectsSoFarLoaded[$nameOfClassToBeUsed] = &
$object;
if (method_exists($object, "setCallingCode"))
$object->setCallingCode($nameOfFunctionOrClassCalling);
return $object;
} else {
$this->error("$nameOfClassToBeUsed not found. The code that wants
this class is $nameOfFunctionOrClassCalling ");
}

The method is in the parent class yet I'd forgotten to call parent:: in
the constructor of the child class. It seems to me that method_exists
was testing true, though the method was not truly available, and then
the code died. Adding parent:: to the constructor of the child solved
the problem. Is this a bug in PHP?

View Replies !
Class.phpmailer.php & Class.smtp.php ?
class.phpmailer.php & class.smtp.php ?

Hi friend,

anybody tried class.phpmailer.php & class.smtp.php to
sendmail?

I try to connect to mail.yahoo.com, not working.

<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
// set mailer to use SMTP
$mail->Host = "smtp1.example.com;smtp2.example.com";
// specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP
authentication
$mail->Username = "jswan"; // SMTP username
$mail->Password = "secret"; // SMTP password
$mail->From = "from@...";
$mail->FromName = "Mailer";
$mail->AddAddress("josh@...", "Josh Adams");
$mail->AddAddress("ellen@...");
// name is optional
$mail->AddReplyTo("info@...", "Information");
$mail->WordWrap = 50;
// set word wrap to 50 characters
$mail->AddAttachment("/var/tmp/file.tar.gz");
// add attachments
$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
// optional name
$mail->IsHTML(true);
// set email format to HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in
bold!</b>";
$mail->AltBody = "This is the body in plain text for
non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>

View Replies !
Coding A Class' Function Outside A Class
I still haven't found if there is a way to write functions (methods) that belong to a class, outside of that. Maybe there is not, at least untill now.But I prefered to post a question here about that in case there is and someone knows.

View Replies !
Use External Class In A Static Class
I have a language class with a static method so it can be accesed without instantiation for use all over the shop...

anyway I am using the oop mysqli and wanted to know how to make this available this inside the static method.

View Replies !
Including A Class File In Another Class
Trying to figure out a way that my static field $Source can recognize the Enum class...at present, it doesn;t work with the include statement (where it is located now), when the Enum class is instantiated...any ideas? Code:

View Replies !
Calling An Outer Class From An Inner Class
okay, so i have a class called $superclass

inside superclass, i call and initialize another class called $tpl

($superclass->tpl)

superclass contains a few different classes.

Inside tpl i need to use another class that superclass is including. How do I do this?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved