*/ if (!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) . '/../../') . '/'); if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); require_once(DOKU_PLUGIN . 'syntax.php'); require_once(DOKU_INC . 'inc/cache.php'); define('HTML_OK_INVALIDID', 0); define('HTML_OK_NOTSUPPORTED', 1); define('HTML_OK_EXCLUDEDWINDOW', 2); define('HTML_OK_BADCLASSNAME', 3); define('HTML_OK_BADSELECTOR', 4); define('HTML_OK_BADFNNAME', 5); // ini_set('display_errors', "on"); // ini_set('error_reporting', E_ALL); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_htmlOKay extends DokuWiki_Syntax_Plugin { // $access_levels = array('none'=>0, 'strict'=>1, 'medium'=>2, 'lax'=>3, 'su'=>4)); var $access_level = 0; var $client; var $msgs; var $htmlOK_errors; var $cycle = 0; var $open_div = 0; var $closed_div = 0; var $divs_reported = false; var $JS_ErrString = ""; var $helper; function __construct() { $this->htmlOK_errors = array('Invalid ID', 'Element or Attribute not supported', 'Internal Window Elements Not Supported', 'Invalid CSS Class name(s)', 'ID Selectors not supported', 'Invalid Javascript function name(s)'); $this->msgs = ""; } /** * What kind of syntax are we? */ function getType() { return 'protected'; } /** * What about paragraphs? (optional) */ function getPType() { return 'block'; } /** * Where to sort in? */ function getSort() { return 180; } /** * Connect pattern to lexer * $this->Lexer->addPattern('<(?i)\w+\s+.*?ID\s*=.*?>','plugin_htmlOKay'); * $this->Lexer->addPattern('<(?i)\w+\s+.*?CLASS\s*=.*?>','plugin_htmlOKay'); */ function connectTo($mode) { $this->cycle++; $this->Lexer->addEntryPattern('(?=.*?)', $mode, 'plugin_htmlOKay'); $this->Lexer->addPattern('.<(?i)IFRAME.*?/IFRAME\s*>', 'plugin_htmlOKay'); $this->Lexer->addPattern('.<(?i)ILAYER.*?/ILAYER\s*>', 'plugin_htmlOKay'); $this->Lexer->addPattern('<(?i)a.*?javascript.*?', 'plugin_htmlOKay'); $this->Lexer->addPattern('<(?i)FORM.*?', 'plugin_htmlOKay'); $this->Lexer->addPattern('<(?i)DIV.*?>', 'plugin_htmlOKay'); $this->Lexer->addPattern('<(?i)/DIV.*?>', 'plugin_htmlOKay'); $this->Lexer->addPattern('.<(?i)STYLE.*?/STYLE\s*>', 'plugin_htmlOKay'); $this->Lexer->addPattern('<(?i)SCRIPT.*?/script\s*>', 'plugin_htmlOKay'); $this->Lexer->addPattern('<(?i)TABLE.*?', 'plugin_htmlOKay'); $this->Lexer->addPattern('(?i)ID\s*=\s*\W?.*?\W', 'plugin_htmlOKay'); $this->Lexer->addPattern('(?i)class\s*=\s*\W?.*?\W', 'plugin_htmlOKay'); } function postConnect() { $this->Lexer->addExitPattern('', 'plugin_htmlOKay'); } /** * level 2 permissions: guarded access */ function rewrite_match_medium($match) { if (preg_match('//i', $match, $matches)) { if (preg_match('/(action)/i', $matches[1], $action)) { return $this->getError(HTML_OK_NOTSUPPORTED, $match, $action[1]); } elseif (preg_match('/(onsubmit)/i', $matches[1], $onsubmit)) { return $this->getError(HTML_OK_NOTSUPPORTED, $match, $onsubmit[1]); } } elseif (preg_match('/' . "\n"; return $msg; } } function compact_string($string_x) { if ($len = strlen($string_x) > 400) { $string_a = substr($string_x, 0, 200); $string_b = substr($string_x, -200); $string_x = $string_a . '
. . .
' . $string_b; } return $string_x; } ?>