On Tue, 2002-06-04 at 12:26, Marcin Sołtysiak wrote:
> Hi all
Greetings!
> Ages ago some angel soul posted a snippet for MSHTML cleaning.. Can
> anyone fwd it to me, please :-)
I'm not sure if this is the latest version, but this is
what I'm using...
Tarjei, maybe this could be included as a snippet to
the new Nadmin distribution?
--------------------------------------
<h1>Removing MS induced crud</h1>
<?php
function walk_topics_and_articles($id) {
$topic=mgd_get_topic($id);
echo "Debug: Processing topic: $topic->name: ";
$old_description=$topic->description;
$topic->description=nuke_crud($topic->description);
if ($old_description != $topic->description) $update=1;
if ($update==1) {
$topic->update(); echo mgd_errstr(mgd_errno()); echo "<br>\n";
} else { echo "<br>\n"; }
unset ($old_description, $update);
$articlelist=mgd_list_topic_articles($id);
if ($articlelist) {
while ($articlelist->fetch()) {
if ($article->approved) { $approve=1; } else {
$approve=""; }
$article=mgd_get_article($articlelist->id);
echo " Processing article:
$article->title: ";
$old_abstract=$article->abstract;
$article->abstract=nuke_crud($article->abstract);
if ($old_abstract != $article->abstract) $update=1;
$old_content=$article->content;
$article->content=nuke_crud($article->content);
if ($old_content != $article->content) $update=1;
if ($update==1) {
$article->update(); echo mgd_errstr(mgd_errno()); echo
"<br>\n";
} else { echo "<br>\n"; }
if ($approve==1) mgd_approve_article($article->id);
unset ($update, $old_content, $old_abstract);
}
}
$subtopics=mgd_list_topics($id);
if ($subtopics) {
while ($subtopics->fetch()) {
walk_topics_and_articles($subtopics->id);
}
}
}
function nuke_crud($string) {
//Remove all parameters from P,B,DIV,SPAN tags that contain
strings "mso", "navigointipaa1" or "windowtext"
$ret=eregi_replace('<([PB]|DIV|SPAN)[^>]*(mso|navigointipaa1|windowtext)+[^>]*>',
"<\\1>", $string);
//Remove <O:P> and <FONT> tags
$ret=eregi_replace("(</?o:p>)|(</?font[^>]*>)", "", $ret);
return $ret;
}
if ($confirm==1) {
$root_topics=mgd_list_topics(0);
if ($root_topics) {
while ($root_topics->fetch()) {
walk_topics_and_articles($root_topics->id);
}
}
} else { ?>
<p>You need to confirm that you wish to start, set confirm to 1 in the
query parameters</p>
<? } ?>
--------------------------------------------------
> Solt
/Bergie
--
Henri Bergius [EMAIL PROTECTED]
Consultant Partner Tel: +358-20-198 6032
Nemein Oy http://www.nemein.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]