content_length = strlen($lf);
} }
class filter_downcase extends pfilter {
function filter_func(&$lf, $args) {
$lf = preg_replace('/<([-_\/:.\w\d]+)(.*?)>/me',
'"<" . strtolower("\\1").
$this->downcase_attrs("\\2") . ">"', $lf);
$this->content_length = strlen($lf);
}
function downcase_attrs($string) {
return(
preg_replace('/(\s[a-zA-Z]+)(?:(=)([^"\'][^\s]*|"[^">]*?"|\'[^\'>]*?\'))?/me',
'preg_replace("/\s+/m", " ", strtolower("\\1\\2")) .
$this->addquotes("\\3")', $string)
);
}
function addquotes($string) {
if (($string[0] != '"') && ($string[0] != "'")) {
return('"' . htmlentities($string) . '"');
}
else {
return($string);
}
} }
class filter_wap extends pfilter {
function filter_func(&$wml, $args) {
global $out_contenttype, $out_add_headers, $htreq_headers;
if (strpos($out_contenttype, 'html') !== false)
if ( (strpos($htreq_headers['ACCEPT'], 'application/vnd.wap.wml') !== false)
|| (strpos($htreq_headers['ACCEPT'], 'text/wml') !== false))
{
preg_match('#^(.*)]*>(.*)]*>(.+)<#i', $uu[1], $uu)) {
$title = $uu[1];
} else { $title = "untitled document"; }
$from_orig = array('br', '/tr', 't[dfh]', '[h]', '/[h]', 'li', '/li',
'[fcdgjklmnoqrvwxyz]', '/[fcdgjklmnoqrvwxyz]',
'/*t\w+', '/*img', '/*table', '/*[uo]l', '/*input');
$to_wml = array("
", " |
", " | ", "", "
", '* ', '
',
"", "");
foreach ($from_orig as $value) {
$from_html[] = '#<' . $value . '[^>]*>#ims';
}
if (preg_match('#]*>(.+)<#i', $wml, $uu)) {
$title = $uu[1];
} else { $title = "untitled document"; }
$wml = preg_replace('#^.{0,4096} ]*?>#is', '', $wml);
$wml = preg_replace('#", " |
", " | ", "", "
", '* ', '
',
"", "");
foreach ($from_orig as $value) {
$from_html[] = '#<' . $value . '[^>]*>#ims';
}
$wml = preg_replace($from_html, $to_wml, $wml);
$wml = preg_replace(
array('/ /', '/ä/', '/ö/', '/ü/', '/Ä/', '/Ö/', '/Ü/', '/ß/', '//', '/&[#a-z0-9]+;/'),
array(' ', 'ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß', ' ', '?'), $wml);
$wml = preg_replace('/(]+>)(.+?)(<\/a>)/imse', '"\\1" . strip_tags("\\2") . "\\3"', $wml);
# filter_downcase::filter_func($wml, "");
$wml =
'' .
'' .
''.
' ' .
' ' .
'' .
"$wml";
'
';
$out_add_headers["Content-Type"] = "application/vnd.wap.wml";
$this->content_length = strlen($wml);
}
} }
class filter_garbage extends pfilter {
function filter_func(&$lf, $args) {
$lf = strtr($lf, '<>', '()');
} }
?>