mirror of
https://github.com/e107inc/e107.git
synced 2025-08-29 17:19:56 +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:
@@ -11,9 +11,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/chat.php,v $
|
||||
| $Revision: 1.1.1.1 $
|
||||
| $Date: 2006-12-02 04:34:51 $
|
||||
| $Author: mcfly_e107 $
|
||||
| $Revision: 1.2 $
|
||||
| $Date: 2007-01-17 21:29:28 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
require_once("../../class2.php");
|
||||
@@ -111,7 +111,7 @@ foreach ($chatList as $row)
|
||||
{
|
||||
$CHAT_TABLE_DATESTAMP = $obj2->convert_date($row['cb_datestamp'], "long");
|
||||
$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'])
|
||||
{
|
||||
$cb_message .= "<br />".CHATBOX_L25;
|
||||
|
@@ -11,9 +11,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/chatbox_menu/chatbox_menu.php,v $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2007-01-17 13:41:01 $
|
||||
| $Author: mrpete $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2007-01-17 21:29:28 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@@ -196,7 +196,7 @@ if(!$text = $e107cache->retrieve("nq_chatbox"))
|
||||
|
||||
$datestamp = $obj2->convert_date($cb['cb_datestamp'], "short");
|
||||
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']);
|
||||
|
||||
|
@@ -12,9 +12,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/content/content.php,v $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2007-01-04 13:11:52 $
|
||||
| $Author: lisa_ $
|
||||
| $Revision: 1.5 $
|
||||
| $Date: 2007-01-17 21:29:28 $
|
||||
| $Author: e107steved $
|
||||
+---------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@@ -1282,7 +1282,7 @@ function show_content_item(){
|
||||
}
|
||||
|
||||
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);
|
||||
}else{
|
||||
$CONTENT_CONTENT_TABLE_SUMMARY = "";
|
||||
@@ -1307,13 +1307,13 @@ function show_content_item(){
|
||||
}
|
||||
|
||||
}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);
|
||||
$lastpage = TRUE;
|
||||
}
|
||||
|
||||
$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']);
|
||||
|
||||
@@ -1466,4 +1466,4 @@ function show_content_item(){
|
||||
|
||||
require_once(FOOTERF);
|
||||
|
||||
?>
|
||||
?>
|
@@ -11,9 +11,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/featurebox.php,v $
|
||||
| $Revision: 1.1.1.1 $
|
||||
| $Date: 2006-12-02 04:35:10 $
|
||||
| $Author: mcfly_e107 $
|
||||
| $Revision: 1.2 $
|
||||
| $Date: 2007-01-17 21:29:28 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@@ -50,8 +50,8 @@ else
|
||||
}
|
||||
|
||||
$fbcc = $fb_title;
|
||||
$fb_title = $tp -> toHTML($fb_title, TRUE);
|
||||
$fb_text = $tp -> toHTML($fb_text, TRUE);
|
||||
$fb_title = $tp -> toHTML($fb_title, TRUE,'hook=title');
|
||||
$fb_text = $tp -> toHTML($fb_text, TRUE,'hook=content');
|
||||
if(!$fb_rendertype)
|
||||
{
|
||||
$ns -> tablerender($fb_title, $fb_text, 'featurebox');
|
||||
|
@@ -22,7 +22,7 @@ SC_END
|
||||
SC_BEGIN POST
|
||||
global $post_info, $tp, $iphost;
|
||||
$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) {
|
||||
$ret .= "<br />".$iphost;
|
||||
}
|
||||
|
@@ -163,7 +163,7 @@ SC_END
|
||||
|
||||
SC_BEGIN LINK_MAIN_DESC
|
||||
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_BEGIN LINK_MAIN_NUMBER
|
||||
@@ -308,7 +308,7 @@ SC_END
|
||||
|
||||
SC_BEGIN LINK_DESC
|
||||
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_BEGIN LINK_RATING
|
||||
|
@@ -11,60 +11,141 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/linkwords.php,v $
|
||||
| $Revision: 1.2 $
|
||||
| $Date: 2007-01-03 20:50:47 $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2007-01-17 21:29:28 $
|
||||
| $Author: e107steved $
|
||||
|
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
|
||||
class e_linkwords
|
||||
{
|
||||
var $linkwords = array();
|
||||
var $linkhold = array(); // Placeholders in case url's contain linkwords
|
||||
var $linkurls = array();
|
||||
|
||||
var $word_list = array(); // List of link words/phrases
|
||||
var $link_list = array(); // Corresponding list of links to apply
|
||||
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()
|
||||
{
|
||||
/* constructor */
|
||||
$sql = new db;
|
||||
if($sql -> db_Select("linkwords", "*", "linkword_active=0"))
|
||||
$link_sql = new db;
|
||||
if($link_sql -> db_Select("linkwords", "*", "linkword_active=0"))
|
||||
{
|
||||
$linkWords = $sql -> db_getList();
|
||||
$placeprefix="|*#!|"; // A highly unusual string
|
||||
$iPlace = 1;
|
||||
foreach($linkWords as $words)
|
||||
{
|
||||
$word = $words['linkword_word'];
|
||||
$this -> linkwords[] = $word;
|
||||
$this -> linkurls[] = " <a href='".$words['linkword_link']."' rel='external'>$word</a>";
|
||||
$this -> linkhold[] = $placeprefix.$iPlace++.$placeprefix;
|
||||
$word2 = substr_replace($word, strtoupper($word[0]), 0, 1);
|
||||
$this -> linkwords[] = $word2;
|
||||
$this -> linkhold[] = $placeprefix.$iPlace++.$placeprefix;
|
||||
$this -> linkurls[] = " <a href='".$words['linkword_link']."' rel='external'>$word2</a>";
|
||||
|
||||
while ($row = $link_sql->db_Fetch())
|
||||
{
|
||||
$lw = trim(strtolower($row['linkword_word']));
|
||||
if (strpos($lw,','))
|
||||
{ // Several words to same link
|
||||
$lwlist = explode(',',$lw);
|
||||
foreach ($lwlist as $lw)
|
||||
{
|
||||
$this->word_list[] = trim($lw);
|
||||
$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 );
|
||||
$ptext = "";
|
||||
foreach($content as $cont)
|
||||
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) == '!')
|
||||
{
|
||||
if (strstr($cont, "<"))
|
||||
{
|
||||
$ptext .= $cont;
|
||||
} else {
|
||||
$cont2=str_replace($this -> linkwords, $this -> linkhold, $cont);
|
||||
$cont2=str_replace($this -> linkhold, $this -> linkurls, $cont2);
|
||||
$ptext .= $cont2;
|
||||
}
|
||||
$p = substr($p, 0, -1);
|
||||
if(substr($check_url, strlen($p)*-1) == $p) return $text;
|
||||
}
|
||||
return $ptext;
|
||||
else
|
||||
{
|
||||
if(strpos($check_url, $p) !== FALSE) return $text;
|
||||
}
|
||||
}
|
||||
|
||||
// Split up by HTML tags and process the odd bits here
|
||||
$ptext = "";
|
||||
$lflag = FALSE;
|
||||
|
||||
$content = preg_split('#(<.*?>)#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
|
||||
foreach($content as $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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user