drop tagwall from trunk

master
Andrew Dolgov 17 years ago
parent e0579c6d4f
commit 7e1265ede7

@ -163,13 +163,6 @@
// These two options enable SMTP authentication when sending
// digests. Require DIGEST_SMTP_HOST.
define('ENABLE_TAGWALL', true);
// Disable this if you are having troubles with Tagwall library which
// is used to strip potentially unsafe content from RSS articles. When
// disabled, simpler version of processing will be used when needed.
// Try disabling when having problems with showing articles and/or
// loading feeds.
define('CONFIG_VERSION', 10);
// Expected config version. Please update this option in config.php
// if necessary (after migrating all new options from this file).

@ -73,14 +73,6 @@
require_once 'magpierss/rss_utils.inc';
}
if (ENABLE_TAGWALL) {
include_once "tw/tw-config.php";
include_once "tw/tw.php";
include_once TW_SETUP . "paranoya.php";
$tw_parser = new twParser();
}
function _debug($msg) {
$ts = strftime("%H:%M:%S", time());
print "[$ts] $msg\n";
@ -3172,16 +3164,8 @@
if (get_pref($link, "STRIP_UNSAFE_TAGS") || $force_strip_tags) {
if (ENABLE_TAGWALL) {
global $tw_parser;
global $tw_paranoya_setup;
$res = $tw_parser->strip_tags($res, $tw_paranoya_setup);
} else {
$res = strip_tags_long($res, "<p><a><i><em><b><strong><blockquote><br><img><div><span>");
}
$res = strip_tags_long($res,
"<p><a><i><em><b><strong><blockquote><br><img><div><span><ul><ol><li>");
// $res = preg_replace("/\r\n|\n|\r/", "", $res);
// $res = strip_tags_long($res, "<p><a><i><em><b><strong><blockquote><br><img><div><span>");

@ -1,19 +0,0 @@
Universal (X)HTML Tag Filter
--------------------------------------------
<Idea,Code>
Juraj 'HVGE' Durech
hvge@cauldron.sk
minimal-huge.host.sk
<ThanxTo,Support,Respect>
www.designia.sk
www.martincohen.info
www.fczbkk.com
--------------------------------------------

@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

@ -1,43 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter|
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 www.designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* tag|wall error module
*
* description:
* - this is default error module.
*/
class FOO_error extends TW_errors
{
function FOO_error($options = 0)
{
$this->TW_errors($options);
}
function add($errval, $position, $show_code, $param1=null, $param2=null )
{
$this->ErrorArray["TW_err_".$this->identifier++] = array($errval, $param1, $param2, $position, $show_code);
if($errval & 0xff00) $this->IsError = 1;
return null;
}
}
?>

@ -1,94 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter|
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 www.designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* tag|wall error module
*
* description:
* - this module appending automatic links and colored piece of bad code.
*
* - Module using following CSS classes (you must define it in your CSS stylesheet)
*
* .tw-err-int - internal error (in output string)
* .tw-err-err - standard error
* .tw-err-war - warning
* .tw-err-com - comment
*
* .tw-err-int-l - internal error (in error list)
* .tw-err-err-l - standard error
* .tw-err-war-l - warning
* .tw-err-com-l - comment
*/
class LINK_error extends TW_errors
{
function LINK_error($options = 0)
{
$this->TW_errors($options);
}
function add($errval, $position, $show_code, $param1=null, $param2=null )
{
$err_id = "TW_err_".$this->identifier++;
$this->ErrorArray[$err_id] = array($errval, $param1, $param2, $position, $show_code);
if($errval & 0xff00) $this->IsError = 1;
// append errors and warnings
if(($errval & 0x0ff0) && $show_code != null )
return '<a name="'.$err_id.'"><span class="'.$this->get_error_class($errval).'">'.$show_code.'</span></a>';
return null;
}
// You can call this method from your project and create nice list of errors.
//
// $lang - error string pack
// $mask - any combination of following masks:
// 0xf000 - internal,
// 0x0f00 - errors,
// 0x00f0 - warnings,
// 0x000f - comments
//
function create_list (&$lang, $mask = 0x0ff0)
{
$errors = $this->get_by_mask($mask);
$out = "<ul>";
foreach($errors as $key => $value)
{
$errno = $value[TWE_ERRNO];
$piece = '<span class="'.$this->get_error_class($errno).'">'.$value[TWE_CODE].'</span>';
$list ='<a href="#'.$key.'">'.$this->get_error_text($key,$lang).$piece.'</a>';
$out .= '<li class="'.$this->get_error_class($errno).'-l">'.$list.'</li>';
}
return $out."</ul>";
}
function get_error_class ($error)
{
if($error&0xf000) return "tw-err-int";
if($error&0x0f00) return "tw-err-err";
if($error&0x00f0) return "tw-err-war";
return "tw-err-com";
}
}
?>

@ -1,69 +0,0 @@
<?php
/*
* tag|wall ver 0.1.0 | PHP Tag Filter|
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 www.designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* tag|wall error module
*
* description:
* - TODO: add module description
*
* output modifications:
* - TODO: add your output modifications here
*/
class ???_error extends TW_errors
{
// TODO: add module depended variables here
// Class constructor
// NOTE: parser calling this with his options. See twParser constructor.
//
function ???_error($options = 0)
{
// call parent class constructor
$this->TW_errors($options);
// TODO: add your own module initializations here
}
// You must implement your own add method.
function add($errval, $position, $show_code, $param1=null, $param2=null )
{
$err_id = "TW_err_".$this->identifier++;
//
// This is basic error implementation. Modify this code only if you really need it.
//
$this->ErrorArray[$err_id] = array($errval, $param1, $param2, $position, $show_code);
if($errval & 0xff00) $this->IsError = 1;
// TODO: create your output additions here, and return it as string
return null;
}
// TODO:
// You can implement ohther methods here.
// For example: special error filters, post-parsing functions for generating
// error lists, etc...
}
?>

@ -1,60 +0,0 @@
<?php
// WARNING:
//
// All tags used in configuration must be defined in tw/tw-tags.php file too.
//
$tw_paranoya_setup = array(
"a" => array(
"href" => array( TW_RQ_URL ), // value is required url
"name" => array( TW_RQ_LINK ), // value is link (link+href combination must be fixed in base)
"title" => null,
"target" => null,
),
"hr" => null, // without attributes
"br" => null,
"img" => array(
"width" => array( TW_NUM ), // 80 - default, number must be in range <60,120>
"height"=> array( TW_NUM ),
"src" => array( TW_RQ_URL ),
"title" => null,
"border"=> array( TW_RQ_NUM, 0, 0, 0),
),
"p" => array(
// null - default value (null = remove attr if value not found in case array)
"class" => array( TW_CASE, null, array("par1","par2","par3") ),
),
"b" => "strong", // tag substitution <b> -> <strong>
"strong" => null, // new tag must be configured too
"i" => null,
"u" => null,
"div" => array(
"title" => null,
),
"span" => array(
"class" => array( TW_CASE, null, array("my-class1","my-class2","my-class3") ),
),
"blockquote" => null,
"h1" => null,
"h2" => null,
"h3" => null,
"table" => null,
"td" => null,
"tr" => null,
"th" => null,
"ul" => null,
"ol" => null,
"li" => null,
"dl" => null,
"dt" => null,
"dd" => null,
);
?>

@ -1,471 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter |
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 www.designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
*/
/*
* $this->pt text
* $this->pti text index
*/
class TW_base // TW_lang extends this class
{
var $error; // error module object
var $output; // output module object
var $out; // output string
var $content_off;
var $tags; // relationships between tags
var $config; // current configuration (twParser::strip_tags())
var $config_tags; // tags in current configuration
var $config_attr; // attributes in current configuration
var $config_req_attr; // required attributes
var $TAG;
var $is_attributes;
var $ATTRIBUTES; // index => array("atr","value")
var $ATTR; // array(atr,value)
var $VALUE;
/********************************************************************************************
* BASE CONSTRUCTOR
*/
function TW_base()
{
global $tw_tag_relations;
$this->stack();
$this->tags = &$tw_tag_relations;
$this->content_off = 0;
}
/*
* BASE "DESTRUCTOR" (parser call this function if end of string is rached)
*/
function base_end()
{
while( $tag = $this->stack_pop() )
{
$this->out .= $this->output->close( $tag );
}
return null;
}
/********************************************************************************************
* TAG STACK implementation
*/
var $Tstack;
function stack() { $this->Tstack[0] = null; }
function stack_push( $tag ) { array_unshift( $this->Tstack, $tag ); }
function stack_pop() { return array_shift( $this->Tstack ); }
function stack_search( $tag ) { return in_array( $tag, $this->Tstack ); }
function stack_top( $tag = null )
{
if( $tag ) return $this->Tstack[0] == $tag;
return $this->Tstack[0];
}
/********************************************************************************************
* S T A R T _ T A G _ f i l t e r <tag atr=value>
*
*/
function START_TAG_filter()
{
$tag = $this->TAG;
if( $tag == null )
{
//###### syntax error
return;
}
if( in_array($tag,$this->config_tags) )
{
//enabled tag
if(is_string($this->config_attr[$tag]))
{
$this->TAG = $tag = $this->config_attr[$tag];
//tag substitution warning
}
// ------- perform attribute check -----------
if($this->is_attributes)
{
if(!$this->config_attr[$tag])
{
$this->ATTRIBUTES = null;
// remove attribute warning
}
else
{
foreach( $this->ATTRIBUTES as $key => $attr )
{
if( ! in_array($attr[0], $this->config_attr[$tag] ) )
{
$this->ATTRIBUTES[$key][1] = null;
// remove attribute warning
continue;
}
// --------- perform value check -----------
if(($val = $attr[1])==null) continue;
if(($cmda = &$this->config[$tag][$attr[0]])==null) continue; //null - accept all values
switch($cmda[0] & 7)
{
case TW_URL:
// V0.1.2: fixed some fatal bugs, big thanx to fczbkk
//
// TODO: make better url check with parse_url()
// $val = strtolower($val);
if(stripos($val, "http://") === false)
{
if(stripos($val, "ftp://") === false)
if(stripos($val, "email:") === false)
if(stripos($val, "https://") === false)
if(stripos($val, "./") === false) // local relative url
$val = "http://".$val;
}
$this->ATTRIBUTES[$key][1] = $val;
break;
case TW_LINK:
//TODO: add link separator check here.
// Do not use this attribute in config!
break;
case TW_NUM:
if( $val >= $cmda[2] && $val <= $cmda[3] ) break;
$this->ATTRIBUTES[$key][1] = $cmda[1];
break;
case TW_CASE:
if( !in_array($val, $cmda[2]) ) $this->ATTRIBUTES[$key][1] = $cmda[1];
break;
}
}
}
}
// check required attributes
if($this->config_req_attr[$tag])
{
if( $this->is_attributes )
foreach( $this->config_req_attr[$tag] as $required )
{
$req_found = 0;
foreach( $this->ATTRIBUTES as $val)
if( $val[0] == $required )
{
$req_found = 1;
break;
}
if($req_found) continue;
switch( $this->config[$tag][$required][0] & 7 )
{
case TW_LINK:
case TW_URL:
// error
break;
default:
$this->ATTRIBUTES[$required] = array($required, $this->config[$tag][$required][1]);
break;
}
}
else
{
foreach( $this->config_req_attr[$tag] as $required )
{
switch( $this->config[$tag][$required][0] & 7 )
{
case TW_LINK:
case TW_URL:
// required tag error
break;
default:
$this->ATTRIBUTES[$required] = array($required, $this->config[$tag][$required][1]);
break;
}
}
}
}
// cross tag removal algorithm
$flag = $this->tags[$tag];
$top = $this->stack_top();
if( $flag[2] != null ) // check if tag before is specified
{
// yes, tag before is specified, check relationship
if(! in_array($top, $flag[2]) )
{
if( $flag[0] & TW_OPT )
{
if( $top == $tag )
{
// End Tag is optional and current tag is the same as last tag (on stack).
// Close previos for XHTML compatibility and open new the same tag.
// Return, because no manipulation with stack is required.
$this->out .= $this->output->close( $tag );
$this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );
return;
}
if( $this->stack_search($tag) )
{
// repair stack
while(($top = $this->stack_pop() ) != $tag )
{
/*if( !($this->tags[$top][0] & TW_OPT ) )
{
// auto close warning
}*/
$this->out .= $this->output->close( $top );
}
$this->stack_push($tag);
$this->out .= $this->output->close( $tag );
$this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );
return;
}
}
// <th>...<td> =>> <th>...</th><td>... (<th> & <td> they have common parent tag (<tr>) )
if( $this->tags[$top][0] & TW_OPT )
{
if( $this->tags[$top][2] == $flag[2] )
{
$this->out .= $this->output->close( $this->stack_pop() );
$this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );
$this->stack_push( $tag );
return;
}
}
// invalid relation between tags #######
return;
}
// valid relationship
}
if( $flag[0] & TW_NOP )
{
//tag without End Tag <br />
$this->out .= $this->output->single( $tag, $this->ATTRIBUTES );
}
else
{
//Tag with End Tag, push to stack
if( ($top == $tag) && ($flag[0] & TW_OPT) )
{
// '<p><p>' => '<p></p><p>'
$this->out .= $this->output->close( $tag );
$this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );
return;
}
$this->out .= $this->output->pair( $tag, $this->ATTRIBUTES );
$this->stack_push( $tag );
}
return;
}
else
{
//disabled tag (or not supported) ######
return;
}
}
/********************************************************************************************
* E N D _ T A G _ f i l t e r </tag>
*
*/
function END_TAG_filter()
{
$tag = $this->TAG;
if( $tag == null )
{
// </>
if ($tag = $this->stack_pop() )
{
$this->out .= $this->output->close($tag);
return;
}
else
{
// kunda underflow :)
return;
}
}
if(in_array($tag,$this->config_tags))
{
// enabled tag
if(is_string($this->config_attr[$tag]))
{
$this->TAG = $tag = $this->config_attr[$tag];
//tag substitution warning
}
$top = $this->stack_top( $tag );
if( $top )
{
$this->out .= $this->output->close( $tag );
$this->stack_pop();
return;
}
if( $this->stack_search($tag) )
{
// closing cross tags
while( ($top = $this->stack_pop()) != $tag )
{
/*if( !($this->tags[$top][0] & TW_OPT ) )
{
// auto close warning
}*/
$this->out .= $this->output->close( $top );
}
$this->out .= $this->output->close( $tag );
}
else
{
// ###### cross tag error
return;
}
}
// drop out warning
}
/*
* THERE ARE STATE IN, OUT & NEW FUNCTIONS
*
*/
/********************************************************************************************
* STATE T_begin '<'
*/
function T_begin_in()
{
$this->tag_position = $this->pti;
$this->TAG = null;
}
// --- MAIN TAG-FILTER FUNCTION ---
function T_begin_out($word)
{
$this->START_TAG_filter();
}
/********************************************************************************************
* STATE TC_begin '</'
*/
function T_Cbegin_in()
{
$this->tag_position = $this->pti;
$this->TAG = null;
}
// TAG CLOSE function
//
function T_Cbegin_out($word)
{
$this->END_TAG_filter();
}
/********************************************************************************************
* STATE T_gettag 'tagname'
*/
function T_gettag_in()
{
$this->is_attributes = 0;
$this->ATTRIBUTES = null;
return;
}
function T_gettag_new($word) { $this->TAG = strtolower($word); }
function T_gettag_out($word) { return; }
/********************************************************************************************
* STATE A_begin '__atr...'
*/
function A_begin_in() { $this->ATTR = null; }
function A_begin_new($word) { $this->ATTR[0] = strtolower($word); }
function A_begin_out($word)
{
if( $this->is_attributes )
{
foreach( $this->ATTRIBUTES as $akey => $aval )
{
if($this->ATTR[0] == $aval[0])
{
// duplicate warning
$this->ATTRIBUTES[$akey] = $aval;
return;
}
}
}
else
{
$this->is_attributes = 1;
}
$this->ATTRIBUTES[] = $this->ATTR;
}
/********************************************************************************************
* STATE V_begin 'atr...'
*/
function V_begin_in() { $this->VALUE = null; }
function V_begin_out($word) { $this->ATTR[1] = $this->VALUE; }
/********************************************************************************************
* STATE VALUE1
*/
function VALUE1_in() { return; }
function VALUE1_out($word) { $this->VALUE = substr($word,0,strlen($word)-1); }
/********************************************************************************************
* STATE VALUE2
*/
function VALUE2_in() { return; }
function VALUE2_out($word)
{
$this->VALUE = str_replace("\"", "&#34", substr($word, 0, strlen($word)-1) );
}
/********************************************************************************************
* STATE VALUE3
*/
function VALUE3_in() { return; }
function VALUE3_out($word) { $this->VALUE = $word; }
} // END class TW_base
?>

@ -1,183 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter |
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 www.designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* TW - based on SHL Language File
*
* Spolocne so SHL
* - kompatibilita s FSHL generatorom 0.4.x
* - zakladna kostra stavoveho diagramu je spolocna
*
* Rozdiely voci SHL
* - polia maju iny vyznam pretoze spracuva iny stavovy automat
* - vsetky stavy sa volaju rekurentne
*
* function STATE_in() - vola sa pri vstupe do stavu (Ovplyvnuje flag PF_XIO)
* function STATE_out() - vola sa pri opusteni stavu (_RET) (Ovplyvnuje flag PF_XIO)
* tiez hned po navrate z rekurzie flag PF_XDONE sposobi zavolanie
* STATE_out() a opustenie aktualneho stavu (simulovany _RET)
* function STATE_new() - vola sa pri zmene stavu (Ovplyvnuje flag PF_XNEW)
*/
class TW_lang
{
var $states;
var $initial_state;
var $keywords;
var $version;
var $signature;
function TW_lang()
{
$this->signature = "TW";
$this->version = "1.0";
$this->initial_state="OUT";
$this->states =
array
(
"OUT" => array (
array(
"<" => array("T_tagWall",0),
//"&" => array("VChar",0), // validate char (currently not implemented in base)
),
PF_CLEAN, // PF_CLEAN - znaky sa forwarduju na vystup
0,0
),
"T_tagWall" => array (
array(
"ALPHA" => array("T_begin",1), // normal tag
"/" => array("T_Cbegin",0), // close tag
"<" => array("T_tagWall",1), // '<<<<<<<<' fix (faster than _RET)
"!--" => array("HTML_comment",0),
"_ALL" => array("_RET",0), // '<?' other fixes
),
PF_XDONE,
0,0
),
"T_Cbegin" => array (
array(
"ALPHA" => array("T_gettag",1),
"_ALL" => array("_RET",0),
),
PF_XIO | PF_XDONE, 0,0
),
"T_begin" => array (
array(
"ALPHA" => array("T_gettag",1),
"_ALL" => array("_RET",0),
),
PF_XIO | PF_XDONE, 0,0
),
"T_gettag" => array (
array(
"!ALNUM"=> array("T_in",1),
),
PF_XIO | PF_XDONE | PF_XNEW, 0,0
),
"T_in" => array(
array(
"ALPHA" => array("A_begin",1), // char back to stream
">" => array("_RET",0),
"/>" => array("_RET",0), // pozor na spracovanie v T_begin
),
0,0,0
),
"A_begin" => array (
array(
"!ALPHA"=> array("V_begin",1),
">" => array("_RET",1), // vracia string do streamu
"/>" => array("_RET",1), // pozor na spracovanie v TAGbegin
),
PF_XIO | PF_XDONE | PF_XNEW , 0,0
),
// this is wide attribute=value implementation
"V_begin" => array (
array(
'"' => array("VALUE1",0),
"'" => array("VALUE2",0),
"ALNUM" => array("VALUE3",1),
">" => array("_RET",1),
"/>" => array("_RET",1),
),
PF_XIO | PF_XDONE, 0,0
),
// "DOUBLEQUOTED VALUE"
"VALUE1" => array(
array(
'"' => array("_RET",0),
),
PF_XIO, 0,0
),
// 'SINGLEQUOTED VALUE'
"VALUE2" => array(
array(
"'" => array("_RET",0),
),
PF_XIO, 0,0
),
// UNQUOTEDVALUE99
"VALUE3" => array(
array(
/* "_" => array ("VALUE3",0), //Uncomment for better HTML4 compatibility (not recommended)
"." => array ("VALUE3",0),
*/
"-" => array ("VALUE3",0),
"!ALNUM"=> array("_RET",1),
),
PF_XIO, 0,0
),
// all comment content will be removed
"HTML_comment" => array(
array(
"-->" => array("_RET",0),
),
0,0,0
),
);
$this->keywords=null;
}
}
?>

@ -1,57 +0,0 @@
<?
/*
* tag|wall | PHP Tag Filter|
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 www.designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* tag|wall error strings
*
* NOTE:
* TW not using this file directly. You can include it to your project
* at your opinion. Then you can use method TW_errors::get_error_text()
* for getting error texts.
*
* Please correct my stupid english :)
*/
$tw_error_strings = array(
// comments & tips
TWE_OK => null,
TWE_VERSION => "Versions: parser V %s, language V%s",
TWE_CREDITS => "tag|wall: code Juraj Durech (hvge@cauldron.sk).",
TWE_NOTE => "%s",
// warnings
TWE_STACK_UNDERFLOW => "Stack underflow, tag '%s' was dropped out.",
TWE_STACK_NOT_EMPTY => "There are some unclosed tags on stack.",
TWE_UNEXPECTED_EOST => "Unexpected end of stream.",
TWE_UNEXPECTED_QUOTE => "Unexpected quote.",
// errors
TWE_SYNTAX => "HTML syntax error.",
TWE_TOO_MANY_ATTRS => "Too many attributes in tag '%s'.",
// internal errors
TWE_FILE_NOT_FOUND => "File '%s' not found.",
TWE_BAD_SIGNATURE => "Language '%s' have bad signature '%s'.",
TWE_LANG_NOT_FOUND => "Language '%s' not found.",
);
?>

@ -1,74 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter |
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* HL_DEBUG_output.php xhtml debug output module (highlight tags)
*/
class HL_DEBUG_output
{
function HL_DEBUG_output() { return; }
// input: string, array()
function pair ($tag, &$attributes)
{
if($attributes == null)
return $this->highlight( "<$tag>" );
$attr = null;
foreach ($attributes as $value)
{
if($value[1]) $attr .= ' '.$value[0].'="'.$value[1].'"';
}
return $this->highlight( "<$tag$attr>" );
}
function single ($tag, &$attributes)
{
if($attributes == null)
return $this->highlight( "<$tag />" );
$attr = null;
foreach ($attributes as $value)
{
if($value[1]) $attr .= $value[0].'="'.$value[1].'" ';
}
return $this->highlight( "<$tag $attr/>" );
}
// template for end tags
function close ($tag)
{
return $this->highlight( "</$tag>" );
}
function template_end() { return null; }
function highlight($string)
{
$string = str_replace("&","&amp",$string);
return '<span style="background-color:yellow">'.str_replace("<","&lt;",$string).'</span>';
}
} //END class HTML_output
?>

@ -1,67 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter |
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* HTML_output.php html output module
*/
class HTML_output
{
function HTML_output() { return; }
// input: string, array()
function pair ($tag, &$attributes)
{
if($attributes == null)
return "<$tag>";
$attr = null;
foreach ($attributes as $value)
{
if($value[1]) $attr .= ' '.$value[0].'="'.$value[1].'"';
}
return "<$tag$attr>";
}
function single ($tag, &$attributes)
{
if($attributes == null)
return "<$tag>";
$attr = null;
foreach ($attributes as $value)
{
if($value[1]) $attr .= ' '.$value[0].'="'.$value[1].'"';
}
return "<$tag$attr>";
}
// template for end tags
function close ($tag)
{
return "</$tag>";
}
function template_end() { return null; }
} //END class HTML_output
?>

@ -1,67 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter |
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* XHTML_output.php xhtml output module
*/
class XHTML_output
{
function XHTML_output() { return; }
// input: string, array()
function pair ($tag, &$attributes)
{
if($attributes == null)
return "<$tag>";
$attr = null;
foreach ($attributes as $value)
{
if($value[1]) $attr .= ' '.$value[0].'="'.$value[1].'"';
}
return "<$tag$attr>";
}
function single ($tag, &$attributes)
{
if($attributes == null)
return "<$tag />";
$attr = null;
foreach ($attributes as $value)
{
if($value[1]) $attr .= $value[0].'="'.$value[1].'" ';
}
return "<$tag $attr/>";
}
// template for end tags
function close ($tag)
{
return "</$tag>";
}
function template_end() { return null; }
} //END class XHTML_output
?>

@ -1,117 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter|
* ---------------------------------------------------------------------
Copyright (C) 2002 designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* tw-config.php
*
*/
// paths
define ('TW_PATH', 'tw/');
define ('TW_LANG', TW_PATH.'lang/');
define ('TW_CACHE', TW_PATH.'tw_cache/');
define ('TW_SETUP', TW_PATH.'filter-setup/');
define ('TW_ERRMODULE', TW_PATH.'error/');
define ('TW_OUTMODULE', TW_PATH.'output/');
// tag flags
define ('TW_NOP', 0x0001);
define ('TW_OPT', 0x0002);
define ('TW_OVR', 0x0004);
define ('TW_DUP', 0x0008);
// attr filter commands
define ('TW_ALL', 0);
define ('TW_URL', 1); // value is url
define ('TW_LINK', 2); // value is link
define ('TW_NUM', 3); // value must be between
define ('TW_CASE', 4); // value must be in case of..
define ('TW_REQ', 8); // required attribute
define ('TW_RQ_ALL', TW_REQ);
define ('TW_RQ_URL', 1 | TW_REQ);
define ('TW_RQ_LINK', 2 | TW_REQ);
define ('TW_RQ_NUM', 3 | TW_REQ);
define ('TW_RQ_CASE', 4 | TW_REQ);
if(!defined('FSHL_WITH_TW_DEFINED'))
{
define ('FSHL_WITH_TW_DEFINED', 1);
// debug modes (on - 1, off - 0)
// only shlParser supports DEBUG modes
define ('DEBUG_STATE', 0); // enable debug states
define ('DEBUG_REPORT', 0); // enable parser error reports and infos
// fshlParser() 'option' flags (not used at this time)
define ('P_DISABLE_RECURSION', 0x0001);
define ('P_DISABLE_NEWLANG', 0x0002);
define ('P_DISABLE_EXECUTE', 0x0004);
define ('P_DISABLE_EXIT', 0x0008);
define ('P_DEFAULT', 0x0000);
// F/SHL state flags
define ('PF_VOID', 0x0000);
define ('PF_KEYWORD', 0x0001);
define ('PF_RECURSION', 0x0004);
define ('PF_NEWLANG', 0x0008);
define ('PF_EXECUTE', 0x0010); // not used
// TW state flags
define ('PF_CLEAN', 0x0100);
define ('PF_XIO', 0x0200);
define ('PF_XDONE', 0x0400);
define ('PF_XNEW', 0x0800);
// state field indexes
define ('XL_DIAGR', 0);
define ('XL_FLAGS', 1);
define ('XL_CLASS', 2);
define ('XL_DATA', 3);
define ('XL_DSTATE', 0);
define ('XL_DTYPE', 1);
// internal and special states
define ('P_RET_STATE', '_RET');
define ('P_QUIT_STATE', '_QUIT');
// group delimiters
$group_delimiters=array(
"SPACE", "!SPACE",
"NUMBER", "!NUMBER",
"ALPHA", "!ALPHA",
"ALNUM", "!ALNUM",
"HEXNUM", "!HEXNUM",
"_ALL",
// TODO: Add special language depended groups here.
// See function shlParser::isdelimiter()
// and fshlGenerator::make_isdx(). You must
// implement your new delimiters...
"PHP_DELIM",
);
$fshl_signatures=array("SHL","TW");
} //end if(!defined())
?>

@ -1,118 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter|
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 www.designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* tw-errors.php
*
* This file containing basic error definitions and basic error handling class.
*
*/
// comments
define('TWE_OK', 0x0000); // null
define('TWE_VERSION', 0x0001); // param1=parser_version, param2=lang_version
define('TWE_NOTE', 0x0002); // param2=note / tips / etc...
define('TWE_CREDITS', 0x0003); // null
// warnings
define('TWE_STACK_UNDERFLOW', 0x0010); // param1=tag_name
define('TWE_STACK_NOT_EMPTY', 0x0020); // param1=tags, stack not empty
define('TWE_UNEXPECTED_EOST', 0x0030); // unexpected end of stream (tag completed automatically)
define('TWE_UNEXPECTED_QUOTE', 0x0040); // atr="value>...
// errors
define('TWE_SYNTAX', 0x0100); // null, HTML syntax error (for future strict bases)
define('TWE_TOO_MANY_ATTRS', 0x0200); // tag_name, too many attrs in tag ..
// internal errors
define('TWE_FILE_NOT_FOUND', 0x1000); // param1 = file
define('TWE_BAD_SIGNATURE', 0x2000); // param1 = language, param2 = signature
define('TWE_LANG_NOT_FOUND', 0x3000); // param1 = language
// indexes to ErrorArray
define('TWE_ERRNO', 0); // error value
define('TWE_PARAM1', 1); // parameter 1
define('TWE_PARAM2', 2); // parameter 2
define('TWE_POSIT', 3); // position in source
define('TWE_CODE', 4); // piece of bad code
class TW_errors
{
var $IsError;
var $ErrorArray;
var $identifier;
/* class constructor
*/
function TW_errors($options = 0)
{
$this->IsError = 0;
$this->ErrorArray = null;
$this->identifier = 0;
}
function is_error() { return $this->IsError; }
function get_err_array() { return $this->ErrorArray; }
function get_comments() { return $this->get_by_mask(0x000f); }
function get_warnings() { return $this->get_by_mask(0x00f0); }
function get_errors() { return $this->get_by_mask(0x0f00); }
function get_internal() { return $this->get_by_mask(0xf000); }
function get_by_mask($mask)
{
$ErrTemp = null;
foreach($this->ErrorArray as $key => $value)
{
if($value[TWE_ERRNO] & $mask) $ErrTemp[$key] = $value;
}
return $ErrTemp;
}
/* Input:
* id: error id,
* lang: error_language_array
*
* Outupt:
* error text or null
*/
function get_error_text ( $id, &$lang )
{
if( in_array($id, $this->ErrorArray) )
{
$errno = $this->ErrorArray[$id][TWE_ERRNO];
if( in_array($errno,$lang) )
return sprintf( $lang[$errno],
$this->ErrorArray[$id][TWE_PARAM1],
$this->ErrorArray[$id][TWE_PARAM2] );
else
return sprintf( "Please translate errno 0x%x.",$errno );
}
return null;
}
} // END class TW_errors
?>

@ -1,97 +0,0 @@
<?php
/*
* tag|wall | PHP Tag Filter|
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 www.designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* tw-tags.php - this file contains common tag definitions and
* relationships
*
* WARNING: This is not filter configuration. Relationships are used
* for correct cross tag fixing.
* ---------------------------------------------------------------------
* Tag flags:
*
* TW_DUP - remove duplicates ( not implemented )
* <i>...<i>:::</i></i> => <i>...:::</i>
*
* TW_NOP - tag without end tag
* <br /><hr /> etc..
*
* TW_OPT - tag have optional end tag ( optional end tag is closed automatically )
* <li>line1<li>line2 => <li>line1</li><li>line2</li>
*
* CONT.OFF - content off ( not implemented )
* <tag>content-off<tag2>content-on</tag1></tag> => <tag><tag2>content-on</tag1></tag>
*
* REQ.TAG - required tag in stack
* <ul><li>... this is correct
* <p><li>... this is not correct, result is <p>...
*/
$tw_tag_relations = array(
// TAG FLAG CONT.OFF REQ. TAG
"a" => array(0, 0, null),
"b" => array(0, 0, null),
"blockquote"=> array(0, 0, null),
"big" => array(0, 0, null),
"br" => array(TW_NOP, 0, null),
"code" => array(0, 0, null),
"dl" => array(0, 0, null),
"dt" => array(TW_OPT, 0, array("dl")),
"dd" => array(TW_OPT, 0, array("dl")),
"div" => array(0, 0, null),
"em" => array(0, 0, null),
"h1" => array(0, 0, null),
"h2" => array(0, 0, null),
"h3" => array(0, 0, null),
"h4" => array(0, 0, null),
"h5" => array(0, 0, null),
"h6" => array(0, 0, null),
"hr" => array(TW_NOP, 0, null),
"i" => array(0, 0, null),
"img" => array(TW_NOP, 0, null),
"ul" => array(0, 1, null),
"ol" => array(0, 1, null),
"li" => array(TW_OPT, 0, array("ul","ol")),
"object" => array(0, 1, null),
"p" => array(TW_OPT, 0, null),
"pre" => array(0, 0, null),
"small" => array(0, 0, null),
"span" => array(0, 0, null),
"strong" => array(0, 0, null),
"style" => array(0, 1, null),
"sub" => array(0, 0, null),
"sup" => array(0, 0, null),
"table" => array(0, 1, null),
"caption" => array(0, 0, array("table")),
"tbody" => array(0, 0, array("table")),
"tfoot" => array(0, 0, array("table")),
"thead" => array(0, 0, array("table")),
"tr" => array(TW_OPT, 1, array("table","tbody")),
"td" => array(TW_OPT, 0, array("tr")),
"th" => array(TW_OPT, 0, array("tr")),
"u" => array(0, 0, null),
// TODO: add your specific tags here...
);
?>

@ -1,291 +0,0 @@
<?php
/*
* tag|wall ver 0.1.4 | PHP Tag Filter |
* ---------------------------------------------------------------------
Copyright (C) 2002 Juraj 'HVGE' Durech
Copyright (C) 2002 designia.sk
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------
* tw.php
*
* main tag|wall parser core
* ---------------------------------------------------------------------
*
*/
define ("TW_PARSER_VERSION", "0.1.4");
require_once(TW_PATH."tw-tags.php");
require_once(TW_PATH."tw-errors.php");
class twParser
{
// class variables
var $text, $textlen, $textpos;
var $lang, $options;
var $output, $err, $content_off;
var $out;
var $_trans, $_flags, $_data, $_delim, $_class, $_keywords;
var $_ret,$_quit;
var $base, $_names;
// -----------------------------------------------------------------------
// USER LEVEL functions
//
/* twParser CLASS CONSTRUCTOR
*
* input:
* string $language - TW language class name ( see directory tw/lang/ )
* int $options - parser options (not used)
*/
function twParser(
$language = "TW",
$options = P_DEFAULT
)
{
$_lang = $language."_lang";
$_base = $language."_base";
require_once (TW_LANG."$_base.php");
require_once (TW_CACHE."$_lang.php");
$this->lang = new $_lang;
$this->base = $_base;
$this->options = $options;
$this->_trans = &$this->lang->trans;
$this->_flags = &$this->lang->flags;
$this->_delim = &$this->lang->delim;
$this->_ret = &$this->lang->ret;
$this->_quit = &$this->lang->quit;
$this->_names = &$this->lang->names;
$this->content_off = &$this->lang->content_off;
}
/* STRIP TAGS
*
* input:
* string $text - input string
* array $configuration - filter configuration array ( see files in directory tw/filter-setup/ )
* string $output_module - output module name ( tw/output )
* string $error_module - error module name ( tw/error )
* int $offset - offset in $text
*
* output:
* parsed string
*/
function strip_tags (
$text,
&$configuration,
$output_module = "XHTML",
$error_module = "FOO",
$offset = 0
)
{
// open modules
$_err = $error_module."_error";
require_once (TW_ERRMODULE."$_err.php");
$this->err = new $_err( $this->options );
$_out = $output_module."_output";
require_once (TW_OUTMODULE."$_out.php");
$this->output = new $_out;
// parser init
$this->text = &$text;
$this->textlen = strlen($text);
$this->text .= "IMNOTREALLYOPTIMISTIC";
$this->textpos = $offset;
$this->out = null;
// FSHL pointers init
$this->lang->pt = &$this->text;
$this->lang->pti = &$this->textpos;
$this->lang->out = &$this->out;
$this->lang->err = &$this->err;
$this->lang->output = &$this->output;
// base init
$base = &$this->base;
$this->lang->$base();
$this->lang->config_tags = array_keys($configuration);
// load initial configuration
foreach($configuration as $tag => $attributes)
{
$this->lang->config_req_attr[$tag] = null;
if(is_array($attributes))
{
$this->lang->config_attr[$tag] = array_keys($configuration[$tag]);
foreach($attributes as $attr => $command)
{
if( $command )
if( $command[0] & TW_REQ ) $this->lang->config_req_attr[$tag][] = $attr;
}
}
else
{
$this->lang->config_attr[$tag] = $attributes;
}
}
$this->lang->config = &$configuration;
// start parser
$this->parse_string ( $this->lang->initial_state );
$this->out .= $this->lang->base_end();
$this->out .= $this->output->template_end();
return $this->out;
}
function get_position() { return $this->textpos; }
function get_out() { return $this->out; }
// error wrapper
function is_error() { return $this->err->is_error(); }
function get_err_array() { return $this->err->get_err_array(); }
function get_comments() { return $this->err->get_by_mask(0x000f); }
function get_warnings() { return $this->err->get_by_mask(0x00f0); }
function get_errors() { return $this->err->get_by_mask(0x0f00); }
function get_internal() { return $this->err->get_by_mask(0xf000); }
function get_by_mask($mask) { return $this->err->get_by_mask($mask); }
function get_error_text ( $id, &$lang ) { return $this->err->get_error_text ( $id, $lang ); }
// ---------------------------------------------------------------------------------
// LOW LEVEL functions
//
// main parser function
//
function parse_string ($state)
{
$flags = $this->_flags[$state];
$statename_n = $this->_names[$state]."_new";
// perform IN function if required
if( $flags & PF_XIO )
{
$statename_i = $this->_names[$state]."_in";
$statename_o = $this->_names[$state]."_out";
$this->lang->$statename_i();
}
$stateword = null;
while( ($word = $this->getword("isd$state")) != null )
{
if(is_array($word))
{
// word is delimiter
$newstate = $this->_trans[$state][$word[0]][XL_DSTATE];
// char back to stream (CB2S) if required
if( $this->_trans[$state][$word[0]][XL_DTYPE] )
{
if( $newstate == $state )
{
// If it is the same state, CB2S flag have different significance
// re-initialize state (call IN function)
$stateword = null;
if( $flags & PF_XIO ) $this->lang->$statename_i();
continue;
}
$this->textpos -= strlen($word[1]);
}
else
{
$stateword .= $word[1]; // add new parsed word to stateword
}
if( $newstate == $this->_ret ) // newstate is _RET from recursion
{
// perform NEW function if required
if( $flags & PF_XNEW ) $this->lang->$statename_n($stateword);
// perform OUT function if required
if( $flags & PF_XIO ) $this->lang->$statename_o($stateword);
// return from recursion
return;
}
if( $state != $newstate ) // recursion - only if it is really new state
{
// perform NEW function if required
if( $flags & PF_XNEW ) $this->lang->$statename_n($stateword);
// recursion
$this->parse_string($newstate);
// perform OUT function if required and return.
if( $flags & PF_XDONE )
{
if( $flags & PF_XIO ) $this->lang->$statename_o(null);
return;
}
continue;
}
}
else
{
// word is not delimiter
if( $flags & PF_CLEAN )
{
if(!$this->content_off)
$this->out .= str_replace("<","&gt",$word);
}
else
{
$stateword .= $word;
}
}
} //END while()
// TODO: check this OUT
// perform NEW function if required
if( $flags & PF_XNEW ) $this->lang->$statename_n($stateword);
// perform OUT function if required and return.
if( $flags & PF_XIO ) $this->lang->$statename_o($stateword);
}
// get word from stream
//
function getword ($state)
{
$result = null;
if($this->textpos < $this->textlen)
{
$del = $this->lang->$state(); // call "is delimiter" isdX function
if($del != false)
{
// actual char (or sub-string) is delimiter
$this->textpos += strlen($del[1]);
return $del;
}
else
{
// Actual char/string is not delimiter.
// Result word is between current position and first delimiter in stream
$result = $this->text[$this->textpos++];
while(($this->textpos < $this->textlen) && !$this->lang->$state())
$result .= $this->text[$this->textpos++];
}
}
return $result;
}
} // END class twParser
?>

@ -1,177 +0,0 @@
<?php
/* --------------------------------------------------------------- *
* WARNING: ALL CHANGES IN THIS FILE WILL BE LOST
*
* Source language file: tw/lang/TW_lang.php
* Language version: 1.0 (Sign:TW)
*
* Target file: tw/tw_cache/TW_lang.php
* Build date: Wed 20.11.2002 00:29:40
*
* Generator version: 0.4.1
* --------------------------------------------------------------- */
class TW_lang extends TW_base
{
var $trans,$flags,$data,$delim,$class,$keywords;
var $version,$signature,$initial_state,$ret,$quit;
var $pt,$pti,$generator_version;
var $names;
function TW_lang ()
{
$this->version="1.0";
$this->signature="TW";
$this->generator_version="0.4.1";
$this->initial_state=0;
$this->trans=array(0=>array("<"=>array(0=>1,1=>0,),),1=>array("ALPHA"=>array(0=>3,1=>1,),"/"=>array(0=>2,1=>0,),"<"=>array(0=>1,1=>1,),"!--"=>array(0=>11,1=>0,),"_ALL"=>array(0=>12,1=>0,),),2=>array("ALPHA"=>array(0=>4,1=>1,),"_ALL"=>array(0=>12,1=>0,),),3=>array("ALPHA"=>array(0=>4,1=>1,),"_ALL"=>array(0=>12,1=>0,),),4=>array("!ALNUM"=>array(0=>5,1=>1,),),5=>array("ALPHA"=>array(0=>6,1=>1,),">"=>array(0=>12,1=>0,),"/>"=>array(0=>12,1=>0,),),6=>array("!ALPHA"=>array(0=>7,1=>1,),">"=>array(0=>12,1=>1,),"/>"=>array(0=>12,1=>1,),),7=>array("\""=>array(0=>8,1=>0,),"'"=>array(0=>9,1=>0,),"ALNUM"=>array(0=>10,1=>1,),">"=>array(0=>12,1=>1,),"/>"=>array(0=>12,1=>1,),),8=>array("\""=>array(0=>12,1=>0,),),9=>array("'"=>array(0=>12,1=>0,),),10=>array("-"=>array(0=>10,1=>0,),"!ALNUM"=>array(0=>12,1=>1,),),11=>array("-->"=>array(0=>12,1=>0,),),);
$this->flags=array(0=>256,1=>1024,2=>1536,3=>1536,4=>3584,5=>0,6=>3584,7=>1536,8=>512,9=>512,10=>512,11=>0,);
$this->delim=array(0=>array(0=>"<",),1=>array(0=>"ALPHA",1=>"/",2=>"<",3=>"!--",4=>"_ALL",),2=>array(0=>"ALPHA",1=>"_ALL",),3=>array(0=>"ALPHA",1=>"_ALL",),4=>array(0=>"!ALNUM",),5=>array(0=>"ALPHA",1=>">",2=>"/>",),6=>array(0=>"!ALPHA",1=>">",2=>"/>",),7=>array(0=>"\"",1=>"'",2=>"ALNUM",3=>">",4=>"/>",),8=>array(0=>"\"",),9=>array(0=>"'",),10=>array(0=>"-",1=>"!ALNUM",),11=>array(0=>"-->",),);
$this->ret=12;
$this->quit=13;
$this->names=array(0=>"OUT",1=>"T_tagWall",2=>"T_Cbegin",3=>"T_begin",4=>"T_gettag",5=>"T_in",6=>"A_begin",7=>"V_begin",8=>"VALUE1",9=>"VALUE2",10=>"VALUE3",11=>"HTML_comment",12=>"_RET",13=>"_QUIT",);
}
/* OUT */
function isd0 ()
{
$c1=$this->pt[$this->pti];
if($c1=="<")
return array("<","<");
return false;
}
/* T_tagWall */
function isd1 ()
{
$p=$this->pti;
$c1=$this->pt[$p++];
$c2=$c1.$this->pt[$p++];
$c3=$c2.$this->pt[$p];
if(stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
return array("ALPHA",$c1);
if($c1=="/")
return array("/","/");
if($c1=="<")
return array("<","<");
if($c3=="!--")
return array("!--","!--");
return array("_ALL",$c1);
}
/* T_Cbegin */
function isd2 ()
{
$c1=$this->pt[$this->pti];
if(stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
return array("ALPHA",$c1);
return array("_ALL",$c1);
}
/* T_begin */
function isd3 ()
{
$c1=$this->pt[$this->pti];
if(stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
return array("ALPHA",$c1);
return array("_ALL",$c1);
}
/* T_gettag */
function isd4 ()
{
$c1=$this->pt[$this->pti];
if(!stristr("eaoinltsrvdukzmcpyhjbfgxwq0123456789",$c1))
return array("!ALNUM",$c1);
return false;
}
/* T_in */
function isd5 ()
{
$p=$this->pti;
$c1=$this->pt[$p++];
$c2=$c1.$this->pt[$p];
if(stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
return array("ALPHA",$c1);
if($c1==">")
return array(">",">");
if($c2=="/>")
return array("/>","/>");
return false;
}
/* A_begin */
function isd6 ()
{
$p=$this->pti;
$c1=$this->pt[$p++];
$c2=$c1.$this->pt[$p];
if(!stristr("eaoinltsrvdukzmcpyhjbfgxwq",$c1))
return array("!ALPHA",$c1);
if($c1==">")
return array(">",">");
if($c2=="/>")
return array("/>","/>");
return false;
}
/* V_begin */
function isd7 ()
{
$p=$this->pti;
$c1=$this->pt[$p++];
$c2=$c1.$this->pt[$p];
if($c1=="\"")
return array("\"","\"");
if($c1=="'")
return array("'","'");
if(stristr("eaoinltsrvdukzmcpyhjbfgxwq0123456789",$c1))
return array("ALNUM",$c1);
if($c1==">")
return array(">",">");
if($c2=="/>")
return array("/>","/>");
return false;
}
/* VALUE1 */
function isd8 ()
{
$c1=$this->pt[$this->pti];
if($c1=="\"")
return array("\"","\"");
return false;
}
/* VALUE2 */
function isd9 ()
{
$c1=$this->pt[$this->pti];
if($c1=="'")
return array("'","'");
return false;
}
/* VALUE3 */
function isd10 ()
{
$c1=$this->pt[$this->pti];
if($c1=="-")
return array("-","-");
if(!stristr("eaoinltsrvdukzmcpyhjbfgxwq0123456789",$c1))
return array("!ALNUM",$c1);
return false;
}
/* HTML_comment */
function isd11 ()
{
$p=$this->pti;
$c3=$this->pt[$p++].$this->pt[$p++].$this->pt[$p];
if($c3=="-->")
return array("-->","-->");
return false;
}
}
?>
Loading…
Cancel
Save