1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-28 10:20:45 +02:00

Bugtracker #2827, #3576, #3577 - stop linkwords appearing in places they shouldn't (code now has to explicitly enable them in various areas), match complete word/phrase only (no partials), fully case-insensitive match and display case exactly as found, don't process on admin pages

This commit is contained in:
e107steved
2007-01-17 21:29:28 +00:00
parent 89f0002765
commit 3733a94ce9
13 changed files with 273 additions and 122 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/download.php,v $ | $Source: /cvs_backup/e107_0.8/download.php,v $
| $Revision: 1.7 $ - with modifications | $Revision: 1.8 $ - with modifications
| $Date: 2007-01-17 13:39:28 $ | $Date: 2007-01-17 21:29:28 $
| $Author: mrpete $ | $Author: e107steved $
| |
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -277,7 +277,7 @@ if ($action == "list") {
$DOWNLOAD_CATEGORY_ICON = ($download_category_icon ? "<img src='".e_IMAGE."icons/".$download_category_icon."' alt='' style='float: left' />" : "&nbsp;"); $DOWNLOAD_CATEGORY_ICON = ($download_category_icon ? "<img src='".e_IMAGE."icons/".$download_category_icon."' alt='' style='float: left' />" : "&nbsp;");
$DOWNLOAD_CATEGORY = $tp->toHTML($download_category_name,FALSE,"emotes_off, no_make_clickable"); $DOWNLOAD_CATEGORY = $tp->toHTML($download_category_name,FALSE,"emotes_off, no_make_clickable");
$DOWNLOAD_CATEGORY_DESCRIPTION = $tp -> toHTML($download_category_description, TRUE); $DOWNLOAD_CATEGORY_DESCRIPTION = $tp -> toHTML($download_category_description, TRUE,'hook=description');
if (!$DOWNLOAD_LIST_TABLE) { if (!$DOWNLOAD_LIST_TABLE) {
if (file_exists(THEME."download_template.php")) { if (file_exists(THEME."download_template.php")) {
@@ -653,7 +653,7 @@ function parse_download_cat_child_table($row)
$dcatname=$tp->toHTML($row['download_category_name'],FALSE,"emotes_off, no_make_clickable"); $dcatname=$tp->toHTML($row['download_category_name'],FALSE,"emotes_off, no_make_clickable");
$DOWNLOAD_CAT_SUB_NAME = ($row['d_count'] ? "<a href='".e_BASE."download.php?list.".$row['download_category_id']."'>".$dcatname."</a>" : $dcatname); $DOWNLOAD_CAT_SUB_NAME = ($row['d_count'] ? "<a href='".e_BASE."download.php?list.".$row['download_category_id']."'>".$dcatname."</a>" : $dcatname);
$DOWNLOAD_CAT_SUB_NAME_LINKED = "<a href='".e_BASE."download.php?list.".$row['download_category_id']."'>".$dcatname."</a>"; $DOWNLOAD_CAT_SUB_NAME_LINKED = "<a href='".e_BASE."download.php?list.".$row['download_category_id']."'>".$dcatname."</a>";
$DOWNLOAD_CAT_SUB_DESCRIPTION = $tp->toHTML($row['download_category_description']); $DOWNLOAD_CAT_SUB_DESCRIPTION = $tp->toHTML($row['download_category_description'],TRUE,'hook=description');
$DOWNLOAD_CAT_SUB_COUNT = $row['d_count']; $DOWNLOAD_CAT_SUB_COUNT = $row['d_count'];
$DOWNLOAD_CAT_SUB_SIZE = parsesize( $row['d_size']); $DOWNLOAD_CAT_SUB_SIZE = parsesize( $row['d_size']);
$DOWNLOAD_CAT_SUB_DOWNLOADED = intval( $row['d_requests']); $DOWNLOAD_CAT_SUB_DOWNLOADED = intval( $row['d_requests']);
@@ -662,7 +662,7 @@ function parse_download_cat_child_table($row)
foreach($row['subsubcats'] as $subrow) foreach($row['subsubcats'] as $subrow)
{ {
$DOWNLOAD_CAT_SUBSUB_ICON = get_cat_icons($subrow['download_category_icon'],$subrow['d_count']); $DOWNLOAD_CAT_SUBSUB_ICON = get_cat_icons($subrow['download_category_icon'],$subrow['d_count']);
$DOWNLOAD_CAT_SUBSUB_DESCRIPTION = $tp->toHTML($subrow['download_category_description']); $DOWNLOAD_CAT_SUBSUB_DESCRIPTION = $tp->toHTML($subrow['download_category_description'],TRUE,'hook=description');
$DOWNLOAD_CAT_SUBSUB_COUNT = intval($subrow['d_count']); $DOWNLOAD_CAT_SUBSUB_COUNT = intval($subrow['d_count']);
$DOWNLOAD_CAT_SUBSUB_SIZE = parsesize($subrow['d_size']); $DOWNLOAD_CAT_SUBSUB_SIZE = parsesize($subrow['d_size']);
$DOWNLOAD_CAT_SUBSUB_DOWNLOADED = intval($subrow['d_requests']); $DOWNLOAD_CAT_SUBSUB_DOWNLOADED = intval($subrow['d_requests']);

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/download_shortcodes.php,v $ | $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/download_shortcodes.php,v $
| $Revision: 1.6 $ | $Revision: 1.7 $
| $Date: 2007-01-07 15:59:42 $ | $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -155,7 +155,7 @@ SC_END
SC_BEGIN DOWNLOAD_CATEGORY_DESCRIPTION SC_BEGIN DOWNLOAD_CATEGORY_DESCRIPTION
global $tp,$dl; global $tp,$dl;
$text = $tp -> toHTML($dl['download_category_description'], TRUE); $text = $tp -> toHTML($dl['download_category_description'], TRUE,'hook=description');
if($parm){ if($parm){
return substr($text,0,$parm); return substr($text,0,$parm);
}else{ }else{
@@ -204,7 +204,7 @@ SC_END
SC_BEGIN DOWNLOAD_VIEW_DESCRIPTION SC_BEGIN DOWNLOAD_VIEW_DESCRIPTION
global $tp, $dl; global $tp, $dl;
$maxlen = ($parm ? intval($parm) : 0); $maxlen = ($parm ? intval($parm) : 0);
$text = ($dl['download_description'] ? $tp->toHTML($dl['download_description'], TRUE) : ""); $text = ($dl['download_description'] ? $tp->toHTML($dl['download_description'], TRUE, 'hook=description') : "");
if($maxlen){ if($maxlen){
return substr($text, 0, $maxlen); return substr($text, 0, $maxlen);
}else{ }else{

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/news_shortcodes.php,v $ | $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/news_shortcodes.php,v $
| $Revision: 1.2 $ | $Revision: 1.3 $
| $Date: 2006-12-07 15:41:50 $ | $Date: 2007-01-17 21:29:28 $
| $Author: sweetas $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
@@ -24,16 +24,16 @@ SC_BEGIN NEWSTITLE
global $tp; global $tp;
$news_item = getcachedvars('current_news_item'); $news_item = getcachedvars('current_news_item');
$param = getcachedvars('current_news_param'); $param = getcachedvars('current_news_param');
return $tp -> toHTML($news_item['news_title'], TRUE, 'parse_sc,no_hook,emotes_off, no_make_clickable'); return $tp -> toHTML($news_item['news_title'], TRUE, 'parse_sc,no_hook,emotes_off, no_make_clickable,hook=title');
SC_END SC_END
SC_BEGIN NEWSBODY SC_BEGIN NEWSBODY
global $tp; global $tp;
$news_item = getcachedvars('current_news_item'); $news_item = getcachedvars('current_news_item');
$param = getcachedvars('current_news_param'); $param = getcachedvars('current_news_param');
$news_body = $tp -> toHTML($news_item['news_body'], TRUE, 'parse_sc, fromadmin', $news_item['news_author']); $news_body = $tp -> toHTML($news_item['news_body'], TRUE, 'parse_sc, fromadmin,hook=content', $news_item['news_author']);
if($news_item['news_extended'] && (isset($_POST['preview']) || strpos(e_QUERY, 'extend') !== FALSE)) { if($news_item['news_extended'] && (isset($_POST['preview']) || strpos(e_QUERY, 'extend') !== FALSE)) {
$news_extended = $tp -> toHTML($news_item['news_extended'], TRUE, 'parse_sc, fromadmin', $news_item['news_author']); $news_extended = $tp -> toHTML($news_item['news_extended'], TRUE, 'parse_sc, fromadmin,hook=content', $news_item['news_author']);
$news_body .= "<br /><br />".$news_extended; $news_body .= "<br /><br />".$news_extended;
} }
return $news_body; return $news_body;

View File

@@ -1,4 +1,4 @@
// $Id: wmessage.sc,v 1.2 2007-01-07 15:59:42 e107steved Exp $ // $Id: wmessage.sc,v 1.3 2007-01-17 21:29:28 e107steved Exp $
$prefwmsc = isset($pref['wmessage_sc']) && $pref['wmessage_sc']; $prefwmsc = isset($pref['wmessage_sc']) && $pref['wmessage_sc'];
if (($prefwmsc && $parm == "header") || (!$prefwmsc && ($parm !='header')) ){ if (($prefwmsc && $parm == "header") || (!$prefwmsc && ($parm !='header')) ){
return; return;
@@ -59,9 +59,9 @@ if (($prefwmsc && $parm == "header") || (!$prefwmsc && ($parm !='header')) ){
{ {
while ($row = $sql->db_Fetch()) while ($row = $sql->db_Fetch())
{ {
$wmessage .= $tp->toHTML($row['gen_chardata'], TRUE, 'parse_sc, defs', 'admin')."<br />"; $wmessage .= $tp->toHTML($row['gen_chardata'], TRUE, 'parse_sc, defs, hook=content', 'admin')."<br />";
if(!$wmcaption){ if(!$wmcaption){
$wmcaption = $tp->toHTML($row['gen_ip'], TRUE, 'defs'); $wmcaption = $tp->toHTML($row['gen_ip'], TRUE, 'defs, hook=title');
} }
} }
} }

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
| $Revision: 1.3 $ | $Revision: 1.4 $
| $Date: 2007-01-15 22:06:18 $ | $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -301,33 +301,75 @@ class e_parse
} }
global $pref, $fromadmin; global $pref, $fromadmin;
$fromadmin = strpos($modifiers, "fromadmin"); // Set defaults for options
//$text = str_replace(array("&#092;&quot;", "&#092;&#039;", "&#092;&#092;"), array("&quot;", "&#039;", "&#092;"), $text); $opts = array(
'fromadmin' => FALSE,
'defs' => FALSE, // support for converting defines(constants) within text.
'constants' => FALSE, // replace all {e_XXX} constants with their e107 value
'nobreak' => FALSE, // Line break compression - TRUE removes multiple line breaks
'retain_nl' => FALSE, // Retain newlines - wraps to \n instead of <br /> if TRUE
'no_make_clickable' => FALSE, // URLs etc are clickable - TRUE disables
'no_replace' => FALSE, // Replace clickable links - TRUE disables (only if no_make_clickable not set)
'do_hook' => FALSE, // Tentative option to force hooking when TRUE (area is null string)
'no_hook' => FALSE, // Deprecated - TRUE disables hooked parsers
'hook' => '', // Generic 'set text area for hooked parser' option
'emotes_off' => FALSE, // Convert emoticons to graphical icons - TRUE disables conversion
'emotes_on' => FALSE, // Force conversion to emotes if TRUE (overridden by 'emotes_off')
'value' => FALSE, // Restore entity form of quotes and such to single characters - TRUE disables
'parse_sc' => FALSE // Parse shortcodes - TRUE enables parsing
);
// Now decode options from any modifiers set
foreach (explode(',',$modifiers) as $t)
{
$t = trim($t); // Allow for spaces after commas in the list
$tval = TRUE;
if (strpos($t,'=') !== FALSE) list($t,$tval) = explode('=',$t,2);
if (array_key_exists($t,$opts)) $opts[$t] = $tval;
}
// $fromadmin = strpos($modifiers, "fromadmin");
$fromadmin = $opts['fromadmin'];
// support for converting defines(constants) within text. eg. Lan_XXXX - must be the entire text string (i.e. not embedded) // support for converting defines(constants) within text. eg. Lan_XXXX - must be the entire text string (i.e. not embedded)
if(strpos($modifiers,"defs") !== FALSE && strlen($text) < 25 && defined(trim($text))){ // if(strpos($modifiers,"defs") !== FALSE && strlen($text) < 25 && defined(trim($text)))
if ($opts['defs'] && (strlen($text) < 25) && defined(trim($text)))
{
// echo "Modifiers: ".$modifiers."<br />";
return constant(trim($text)); return constant(trim($text));
} }
// replace all {e_XXX} constants with their e107 value // replace all {e_XXX} constants with their e107 value
if(strpos($modifiers, "constants") !== FALSE) // if(strpos($modifiers, "constants") !== FALSE)
if ($opts['constants'])
{ {
$text = $this->replaceConstants($text); $text = $this->replaceConstants($text);
} }
if(!$wrap && $pref['main_wordwrap']) $wrap = $pref['main_wordwrap']; if(!$wrap && $pref['main_wordwrap']) $wrap = $pref['main_wordwrap'];
$text = " ".$text; $text = " ".$text;
// Prepare for line-break compression. Avoid compressing newlines in embedded scripts and CSS // Prepare for line-break compression. Avoid compressing newlines in embedded scripts and CSS
if (strpos($modifiers, 'nobreak') === FALSE) { // if (strpos($modifiers, 'nobreak') === FALSE)
if (!$opts['nobreak'])
{
$text = preg_replace("#>\s*[\r]*\n[\r]*#", ">", $text); $text = preg_replace("#>\s*[\r]*\n[\r]*#", ">", $text);
preg_match_all("#<(script|style)[^>]+>.*?</(script|style)>#is", $text, $embeds); preg_match_all("#<(script|style)[^>]+>.*?</(script|style)>#is", $text, $embeds);
$text = preg_replace("#<(script|style)[^>]+>.*?</(script|style)>#is", "<|>", $text); $text = preg_replace("#<(script|style)[^>]+>.*?</(script|style)>#is", "<|>", $text);
} }
// Convert URL's to clickable links, unless modifiers or prefs override // Convert URL's to clickable links, unless modifiers or prefs override
if($pref['make_clickable'] && strpos($modifiers, 'no_make_clickable') === FALSE) { // if($pref['make_clickable'] && strpos($modifiers, 'no_make_clickable') === FALSE)
if($pref['link_replace'] && strpos($modifiers, 'no_replace') === FALSE) { if ($pref['make_clickable'] && !$opts['no_make_clickable'])
{
// if($pref['link_replace'] && strpos($modifiers, 'no_replace') === FALSE)
if ($pref['link_replace'] && !$opts['no_replace'])
{
$_ext = ($pref['links_new_window'] ? " rel=\"external\"" : ""); $_ext = ($pref['links_new_window'] ? " rel=\"external\"" : "");
$text = preg_replace("#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\" {$_ext}>".$pref['link_text']."</a>", $text); $text = preg_replace("#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\" {$_ext}>".$pref['link_text']."</a>", $text);
$text = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#is", "\\1<a href=\"http://\\2\" {$_ext}>".$pref['link_text']."</a>", $text); $text = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#is", "\\1<a href=\"http://\\2\" {$_ext}>".$pref['link_text']."</a>", $text);
@@ -337,16 +379,23 @@ class e_parse
$email_text = ($pref['email_text']) ? $this->replaceConstants($pref['email_text']) : "\\1\\\\3"; $email_text = ($pref['email_text']) ? $this->replaceConstants($pref['email_text']) : "\\1\\\\3";
} }
$text = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a rel='external' href='javascript:window.location=\"mai\"+\"lto:\"+\"\\2\"+\"@\"+\"\\3\";self.close();' onmouseover='window.status=\"mai\"+\"lto:\"+\"\\2\"+\"@\"+\"\\3\"; return true;' onmouseout='window.status=\"\";return true;'>".$email_text."</a>", $text); $text = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a rel='external' href='javascript:window.location=\"mai\"+\"lto:\"+\"\\2\"+\"@\"+\"\\3\";self.close();' onmouseover='window.status=\"mai\"+\"lto:\"+\"\\2\"+\"@\"+\"\\3\"; return true;' onmouseout='window.status=\"\";return true;'>".$email_text."</a>", $text);
} else { }
else
{
$text = preg_replace("#(^|[\n ])([\w]+?://[^ \"\n\r\t<,]*)#is", "\\1<a href=\"\\2\" rel=\"external\">\\2</a>", $text); $text = preg_replace("#(^|[\n ])([\w]+?://[^ \"\n\r\t<,]*)#is", "\\1<a href=\"\\2\" rel=\"external\">\\2</a>", $text);
$text = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<,]*)#is", "\\1<a href=\"http://\\2\" rel=\"external\">\\2</a>", $text); $text = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<,]*)#is", "\\1<a href=\"http://\\2\" rel=\"external\">\\2</a>", $text);
$text = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a rel='external' href='javascript:window.location=\"mai\"+\"lto:\"+\"\\2\"+\"@\"+\"\\3\";self.close();' onmouseover='window.status=\"mai\"+\"lto:\"+\"\\2\"+\"@\"+\"\\3\"; return true;' onmouseout='window.status=\"\";return true;'>-email-</a>", $text); $text = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a rel='external' href='javascript:window.location=\"mai\"+\"lto:\"+\"\\2\"+\"@\"+\"\\3\";self.close();' onmouseover='window.status=\"mai\"+\"lto:\"+\"\\2\"+\"@\"+\"\\3\"; return true;' onmouseout='window.status=\"\";return true;'>-email-</a>", $text);
} }
} }
// Convert emoticons to graphical icons, unless modifiers override // Convert emoticons to graphical icons, unless modifiers override
if (strpos($modifiers, 'emotes_off') === FALSE) { // if (strpos($modifiers, 'emotes_off') === FALSE) {
if ($pref['smiley_activate'] || strpos($modifiers,'emotes_on') !== FALSE) { if (!$opts['emotes_off'])
{
// if ($pref['smiley_activate'] || strpos($modifiers,'emotes_on') !== FALSE) {
if ($pref['smiley_activate'] || $opts['emotes_on'])
{
if (!is_object($this->e_emote)) { if (!is_object($this->e_emote)) {
require_once(e_HANDLER.'emote_filter.php'); require_once(e_HANDLER.'emote_filter.php');
$this->e_emote = new e_emoteFilter; $this->e_emote = new e_emoteFilter;
@@ -355,23 +404,33 @@ class e_parse
} }
} }
// Reduce multiple newlines in all forms to a single newline character, except for embedded scripts and CSS // Reduce multiple newlines in all forms to a single newline character, except for embedded scripts and CSS
if (strpos($modifiers, 'nobreak') === FALSE) { // if (strpos($modifiers, 'nobreak') === FALSE) {
if (!$opts['nobreak'])
{
$text = preg_replace("#[\r]*\n[\r]*#", E_NL, $text); $text = preg_replace("#[\r]*\n[\r]*#", E_NL, $text);
foreach ($embeds[0] as $embed) { foreach ($embeds[0] as $embed) {
$text = preg_replace("#<\|>#", $embed, $text, 1); $text = preg_replace("#<\|>#", $embed, $text, 1);
} }
} }
// Restore entity form of quotes and such to single characters, except for text destined for tag attributes or JS. // Restore entity form of quotes and such to single characters, except for text destined for tag attributes or JS.
if (strpos($modifiers, 'value') === FALSE) { // output not used for attribute values. // if (strpos($modifiers, 'value') === FALSE) { // output not used for attribute values.
if (!$opts['value'])
{ // output not used for attribute values.
$text = str_replace($this -> search, $this -> replace, $text); $text = str_replace($this -> search, $this -> replace, $text);
}else{ // output used for attribute values. }
else
{ // output used for attribute values.
$text = str_replace($this -> replace, $this -> search, $text); $text = str_replace($this -> replace, $this -> search, $text);
} }
// Start parse [bb][/bb] codes // Start parse [bb][/bb] codes
if ($parseBB === TRUE) { if ($parseBB === TRUE)
{
if (!is_object($this->e_bb)) { if (!is_object($this->e_bb)) {
require_once(e_HANDLER.'bbcode_handler.php'); require_once(e_HANDLER.'bbcode_handler.php');
$this->e_bb = new e_bbcode; $this->e_bb = new e_bbcode;
@@ -380,6 +439,7 @@ class e_parse
} }
// End parse [bb][/bb] codes // End parse [bb][/bb] codes
// profanity filter // profanity filter
if ($pref['profanity_filter']) { if ($pref['profanity_filter']) {
if (!is_object($this->e_pf)) { if (!is_object($this->e_pf)) {
@@ -389,18 +449,19 @@ class e_parse
$text = $this->e_pf->filterProfanities($text); $text = $this->e_pf->filterProfanities($text);
} }
// Optional short-code conversion // Optional short-code conversion
if (strpos($modifiers,'parse_sc') !== FALSE) // if (strpos($modifiers,'parse_sc') !== FALSE)
if ($opts['parse_sc'])
{ {
$text = $this->parseTemplate($text, TRUE); $text = $this->parseTemplate($text, TRUE);
} }
//Run any hooked in parsers //Run any hooked in parsers
if(isset($pref['tohtml_hook']) && $pref['tohtml_hook']) if ((($opts['hook'] != '') || $opts['do_hook']) && !$opts['no_hook'] && isset($pref['tohtml_hook']) && $pref['tohtml_hook'])
{ {
foreach(explode(",",$pref['tohtml_hook']) as $hook) foreach(explode(",",$pref['tohtml_hook']) as $hook)
{
if (strpos($modifiers, 'no_hook') === FALSE)
{ {
if (!is_object($this->e_hook[$hook])) if (!is_object($this->e_hook[$hook]))
{ {
@@ -408,29 +469,37 @@ class e_parse
$hook_class = "e_".$hook; $hook_class = "e_".$hook;
$this->e_hook[$hook] = new $hook_class; $this->e_hook[$hook] = new $hook_class;
} }
$text = $this->e_hook[$hook]->$hook($text); $text = $this->e_hook[$hook]->$hook($text,$opts['hook']);
}
} }
} }
if (strpos($modifiers, 'nobreak') === FALSE) {
// if (strpos($modifiers, 'nobreak') === FALSE)
if (!$opts['nobreak'])
{
$text = $this -> textclean($text, $wrap); $text = $this -> textclean($text, $wrap);
} }
// Search Highlight // Search Highlight
if (strpos($modifiers, 'emotes_off') === FALSE) { // if (strpos($modifiers, 'emotes_off') === FALSE)
if (!$opts['emotes_off'])
{
if ($this->checkHighlighting()) if ($this->checkHighlighting())
{ {
$text = $this -> e_highlight($text, $this -> e_query); $text = $this -> e_highlight($text, $this -> e_query);
} }
} }
$nl_replace = "<br />"; $nl_replace = "<br />";
if (strpos($modifiers, 'nobreak') !== FALSE) // if (strpos($modifiers, 'nobreak') !== FALSE)
if ($opts['nobreak'])
{ {
$nl_replace = ''; $nl_replace = '';
} }
elseif (strpos($modifiers, 'retain_nl') !== FALSE) // elseif (strpos($modifiers, 'retain_nl') !== FALSE)
elseif ($opts['retain_nl'])
{ {
$nl_replace = "\n"; $nl_replace = "\n";
} }
@@ -439,6 +508,7 @@ class e_parse
return trim($text); return trim($text);
} }
function toAttribute($text) { function toAttribute($text) {
$text = str_replace("&amp;","&",$text); // URLs posted without HTML access may have an &amp; in them. $text = str_replace("&amp;","&",$text); // URLs posted without HTML access may have an &amp; in them.
$text = htmlspecialchars($text); // Xhtml compliance. $text = htmlspecialchars($text); // Xhtml compliance.

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/chat.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/chat.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:34:51 $ | $Date: 2007-01-17 21:29:28 $
| $Author: mcfly_e107 $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
require_once("../../class2.php"); require_once("../../class2.php");
@@ -111,7 +111,7 @@ foreach ($chatList as $row)
{ {
$CHAT_TABLE_DATESTAMP = $obj2->convert_date($row['cb_datestamp'], "long"); $CHAT_TABLE_DATESTAMP = $obj2->convert_date($row['cb_datestamp'], "long");
$CHAT_TABLE_NICK = preg_replace("/[0-9]+\./", "", $row['cb_nick']); $CHAT_TABLE_NICK = preg_replace("/[0-9]+\./", "", $row['cb_nick']);
$cb_message = $tp->toHTML($row['cb_message']); $cb_message = $tp->toHTML($row['cb_message'], TRUE,'hook=content');
if($row['cb_blocked']) if($row['cb_blocked'])
{ {
$cb_message .= "<br />".CHATBOX_L25; $cb_message .= "<br />".CHATBOX_L25;

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/chatbox_menu.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/chatbox_menu.php,v $
| $Revision: 1.3 $ | $Revision: 1.4 $
| $Date: 2007-01-17 13:41:01 $ | $Date: 2007-01-17 21:29:28 $
| $Author: mrpete $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -196,7 +196,7 @@ if(!$text = $e107cache->retrieve("nq_chatbox"))
$datestamp = $obj2->convert_date($cb['cb_datestamp'], "short"); $datestamp = $obj2->convert_date($cb['cb_datestamp'], "short");
if(!$pref['cb_wordwrap']) { $pref['cb_wordwrap'] = 30; } if(!$pref['cb_wordwrap']) { $pref['cb_wordwrap'] = 30; }
$emotes_active = $pref['cb_emote'] ? 'emotes_on' : 'emotes_off'; $emotes_active = $pref['cb_emote'] ? 'emotes_on, hook=content' : 'emotes_off, hook=content';
$cb_message = $tp -> toHTML($cb['cb_message'], FALSE, $emotes_active, $cb_uid, $pref['menu_wordwrap']); $cb_message = $tp -> toHTML($cb['cb_message'], FALSE, $emotes_active, $cb_uid, $pref['menu_wordwrap']);

View File

@@ -12,9 +12,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/content/content.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/content/content.php,v $
| $Revision: 1.4 $ | $Revision: 1.5 $
| $Date: 2007-01-04 13:11:52 $ | $Date: 2007-01-17 21:29:28 $
| $Author: lisa_ $ | $Author: e107steved $
+---------------------------------------------------------------+ +---------------------------------------------------------------+
*/ */
@@ -1282,7 +1282,7 @@ function show_content_item(){
} }
if($idp==1){ if($idp==1){
$CONTENT_CONTENT_TABLE_SUMMARY = (isset($content_pref["content_content_summary"]) && $content_pref["content_content_summary"] && $row['content_summary'] ? $tp -> toHTML($row['content_summary'], TRUE, "") : ""); $CONTENT_CONTENT_TABLE_SUMMARY = (isset($content_pref["content_content_summary"]) && $content_pref["content_content_summary"] && $row['content_summary'] ? $tp -> toHTML($row['content_summary'], TRUE, "hook=summary") : "");
$CONTENT_CONTENT_TABLE_SUMMARY = $tp -> replaceConstants($CONTENT_CONTENT_TABLE_SUMMARY); $CONTENT_CONTENT_TABLE_SUMMARY = $tp -> replaceConstants($CONTENT_CONTENT_TABLE_SUMMARY);
}else{ }else{
$CONTENT_CONTENT_TABLE_SUMMARY = ""; $CONTENT_CONTENT_TABLE_SUMMARY = "";
@@ -1307,13 +1307,13 @@ function show_content_item(){
} }
}else{ }else{
$CONTENT_CONTENT_TABLE_SUMMARY = (isset($content_pref["content_content_summary"]) && $content_pref["content_content_summary"] && $row['content_summary'] ? $tp -> toHTML($row['content_summary'], TRUE, "") : ""); $CONTENT_CONTENT_TABLE_SUMMARY = (isset($content_pref["content_content_summary"]) && $content_pref["content_content_summary"] && $row['content_summary'] ? $tp -> toHTML($row['content_summary'], TRUE, "hook=summary") : "");
$CONTENT_CONTENT_TABLE_SUMMARY = $tp -> replaceConstants($CONTENT_CONTENT_TABLE_SUMMARY); $CONTENT_CONTENT_TABLE_SUMMARY = $tp -> replaceConstants($CONTENT_CONTENT_TABLE_SUMMARY);
$lastpage = TRUE; $lastpage = TRUE;
} }
$CONTENT_CONTENT_TABLE_TEXT = $tp -> replaceConstants($CONTENT_CONTENT_TABLE_TEXT); $CONTENT_CONTENT_TABLE_TEXT = $tp -> replaceConstants($CONTENT_CONTENT_TABLE_TEXT);
$CONTENT_CONTENT_TABLE_TEXT = $tp -> toHTML($CONTENT_CONTENT_TABLE_TEXT, TRUE, ""); $CONTENT_CONTENT_TABLE_TEXT = $tp -> toHTML($CONTENT_CONTENT_TABLE_TEXT, TRUE, "hook=content");
$custom = $eArrayStorage->ReadArray($row['content_pref']); $custom = $eArrayStorage->ReadArray($row['content_pref']);

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/featurebox.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/featurebox.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:35:10 $ | $Date: 2007-01-17 21:29:28 $
| $Author: mcfly_e107 $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -50,8 +50,8 @@ else
} }
$fbcc = $fb_title; $fbcc = $fb_title;
$fb_title = $tp -> toHTML($fb_title, TRUE); $fb_title = $tp -> toHTML($fb_title, TRUE,'hook=title');
$fb_text = $tp -> toHTML($fb_text, TRUE); $fb_text = $tp -> toHTML($fb_text, TRUE,'hook=content');
if(!$fb_rendertype) if(!$fb_rendertype)
{ {
$ns -> tablerender($fb_title, $fb_text, 'featurebox'); $ns -> tablerender($fb_title, $fb_text, 'featurebox');

View File

@@ -22,7 +22,7 @@ SC_END
SC_BEGIN POST SC_BEGIN POST
global $post_info, $tp, $iphost; global $post_info, $tp, $iphost;
$ret = ""; $ret = "";
$ret = $tp->toHTML($post_info["thread_thread"], TRUE, "", 'class:'.$post_info["user_class"]); $ret = $tp->toHTML($post_info["thread_thread"], TRUE, "hook=content", 'class:'.$post_info["user_class"]);
if (ADMIN && $iphost) { if (ADMIN && $iphost) {
$ret .= "<br />".$iphost; $ret .= "<br />".$iphost;
} }

View File

@@ -163,7 +163,7 @@ SC_END
SC_BEGIN LINK_MAIN_DESC SC_BEGIN LINK_MAIN_DESC
global $LINK_MAIN_DESC, $rowl, $linkspage_pref, $tp; global $LINK_MAIN_DESC, $rowl, $linkspage_pref, $tp;
return (isset($linkspage_pref['link_cat_desc']) && $linkspage_pref['link_cat_desc'] ? $tp->toHTML($rowl['link_category_description'], TRUE) : ""); return (isset($linkspage_pref['link_cat_desc']) && $linkspage_pref['link_cat_desc'] ? $tp->toHTML($rowl['link_category_description'], TRUE,'hook=description') : "");
SC_END SC_END
SC_BEGIN LINK_MAIN_NUMBER SC_BEGIN LINK_MAIN_NUMBER
@@ -308,7 +308,7 @@ SC_END
SC_BEGIN LINK_DESC SC_BEGIN LINK_DESC
global $LINK_DESC, $linkspage_pref, $tp, $rowl; global $LINK_DESC, $linkspage_pref, $tp, $rowl;
return (isset($linkspage_pref['link_desc']) && $linkspage_pref['link_desc'] ? $tp->toHTML($rowl['link_description'], TRUE) : ""); return (isset($linkspage_pref['link_desc']) && $linkspage_pref['link_desc'] ? $tp->toHTML($rowl['link_description'], TRUE,'hook=content') : "");
SC_END SC_END
SC_BEGIN LINK_RATING SC_BEGIN LINK_RATING

View File

@@ -11,61 +11,142 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/linkwords.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/linkwords.php,v $
| $Revision: 1.2 $ | $Revision: 1.3 $
| $Date: 2007-01-03 20:50:47 $ | $Date: 2007-01-17 21:29:28 $
| $Author: e107steved $ | $Author: e107steved $
|
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
class e_linkwords class e_linkwords
{ {
var $linkwords = array(); var $word_list = array(); // List of link words/phrases
var $linkhold = array(); // Placeholders in case url's contain linkwords var $link_list = array(); // Corresponding list of links to apply
var $linkurls = array(); var $tip_list = array();
var $area_opts = array(
'title' => FALSE,
'summary' => FALSE,
'content' => TRUE,
'description' => TRUE
); // We can set this from prefs later
var $block_list = array(
// 'page.php?3',
// 'page.php?31!'
);
function e_linkwords() function e_linkwords()
{ {
/* constructor */ /* constructor */
$sql = new db; $link_sql = new db;
if($sql -> db_Select("linkwords", "*", "linkword_active=0")) if($link_sql -> db_Select("linkwords", "*", "linkword_active=0"))
{ {
$linkWords = $sql -> db_getList(); while ($row = $link_sql->db_Fetch())
$placeprefix="|*#!|"; // A highly unusual string
$iPlace = 1;
foreach($linkWords as $words)
{ {
$word = $words['linkword_word']; $lw = trim(strtolower($row['linkword_word']));
$this -> linkwords[] = $word; if (strpos($lw,','))
$this -> linkurls[] = " <a href='".$words['linkword_link']."' rel='external'>$word</a>"; { // Several words to same link
$this -> linkhold[] = $placeprefix.$iPlace++.$placeprefix; $lwlist = explode(',',$lw);
$word2 = substr_replace($word, strtoupper($word[0]), 0, 1); foreach ($lwlist as $lw)
$this -> linkwords[] = $word2; {
$this -> linkhold[] = $placeprefix.$iPlace++.$placeprefix; $this->word_list[] = trim($lw);
$this -> linkurls[] = " <a href='".$words['linkword_link']."' rel='external'>$word2</a>"; $this->link_list[] = $row['linkword_link'];
}
}
else
{
$this->word_list[] = $lw;
$this->link_list[] = $row['linkword_link'];
}
} }
} }
} }
function linkwords($text)
function linkwords($text,$area = '')
{ {
$content = preg_split('#(<.*?>)#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); if ((strpos(e_SELF, ADMINDIR) !== FALSE) || (strpos(e_PAGE, "admin_") !== FALSE)) return $text; // No linkwords on admin directories
if (($area != '') && (!array_key_exists($area,$this->area_opts) || !$this->area_opts[$area])) return $text; // No linkwords in disabled areas
// Now see if disabled on specific pages
$check_url = e_SELF.(e_QUERY ? "?".e_QUERY : '');
foreach ($this->block_list as $p)
{
if(substr($p, -1) == '!')
{
$p = substr($p, 0, -1);
if(substr($check_url, strlen($p)*-1) == $p) return $text;
}
else
{
if(strpos($check_url, $p) !== FALSE) return $text;
}
}
// Split up by HTML tags and process the odd bits here
$ptext = ""; $ptext = "";
$lflag = FALSE;
$content = preg_split('#(<.*?>)#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
foreach($content as $cont) foreach($content as $cont)
{ {
if (strstr($cont, "<")) if (strpos($cont, "<") !== FALSE)
{ // Its some HTML
$ptext .= $cont;
if (strpos($cont,"<a") !== FALSE) $lflag = TRUE;
if (strpos($cont,"</a") !== FALSE) $lflag = FALSE;
}
else
{ // Its the text in between
if ($lflag)
{ // Its probably within a link - leave unchanged
$ptext .= $cont;
}
else
{
if (trim($cont))
{ // Some non-white space - worth word matching
$ptext .= $this->linksproc($cont,0,count($this->word_list));
}
else
{ {
$ptext .= $cont; $ptext .= $cont;
} else { }
$cont2=str_replace($this -> linkwords, $this -> linkhold, $cont); }
$cont2=str_replace($this -> linkhold, $this -> linkurls, $cont2);
$ptext .= $cont2;
} }
} }
return $ptext; return $ptext;
} }
function linksproc($text,$first,$limit)
{ // This function is called recursively - it splits the text up into blocks - some containing a particular linkword
while (($first < $limit) && (stripos($text,$this->word_list[$first]) === FALSE)) { $first++; };
if ($first == $limit) return $text; // Return if no linkword found
// There's at least one occurrence of the linkword in the text
$ret = '';
$lw = $this->word_list[$first];
// This splits the text into blocks, some of which will precisely contain a linkword
$split_line = preg_split('#\b('.$lw.')\b#i', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
foreach ($split_line AS $sl)
{
if (strcasecmp($sl,$lw) == 0)
{ // Do linkword replace
$ret .= " <a href='".$this->link_list[$first]."' rel='external'>{$sl}</a>";
}
elseif (trim($sl))
{ // Something worthwhile left - look for more linkwords in it
$ret .= $this->linksproc($sl,$first+1,$limit);
}
else
{
$ret .= $sl; // Probably just some white space
}
}
return $ret;
}
} }
?> ?>

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/page.php,v $ | $Source: /cvs_backup/e107_0.8/page.php,v $
| $Revision: 1.7 $ | $Revision: 1.8 $
| $Date: 2007-01-17 13:36:57 $ | $Date: 2007-01-17 21:29:28 $
| $Author: mrpete $ | $Author: e107steved $
| |
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -229,7 +229,7 @@ class pageClass
} }
else else
{ {
$this -> pageToRender = $tp -> toHTML($this -> pageText, TRUE, 'parse_sc, constants'); $this -> pageToRender = $tp -> toHTML($this -> pageText, TRUE, 'parse_sc, constants,hook=content');
return; return;
} }
@@ -265,11 +265,11 @@ class pageClass
foreach($this -> pageTitles as $title) foreach($this -> pageTitles as $title)
{ {
$titlep = preg_replace("/\[newpage=(.*?)\]/", "\\1", $title); $titlep = preg_replace("/\[newpage=(.*?)\]/", "\\1", $title);
$this -> pageTitles[$count] = ($titlep == "[newpage]" ? LAN_PAGE_13." ".($count+1)."&nbsp;" : $tp -> toHTML($titlep, TRUE, 'parse_sc, constants,emotes_off,no_make_clickable')); $this -> pageTitles[$count] = ($titlep == "[newpage]" ? LAN_PAGE_13." ".($count+1)."&nbsp;" : $tp -> toHTML($titlep, TRUE, 'parse_sc, constants,emotes_off,no_make_clickable,hook=title'));
$count++; $count++;
} }
$this -> pageToRender = $tp -> toHTML($pages[$this -> pageSelected], TRUE, 'parse_sc, constants'); $this -> pageToRender = $tp -> toHTML($pages[$this -> pageSelected], TRUE, 'parse_sc,constants,hook=content');
$this -> title = (substr($this -> pageTitles[$this -> pageSelected], -1) == ";" ? "" : $this -> pageTitles[$this -> pageSelected]); $this -> title = (substr($this -> pageTitles[$this -> pageSelected], -1) == ";" ? "" : $this -> pageTitles[$this -> pageSelected]);
if($this -> debug) if($this -> debug)