mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 11:50:30 +02:00
Consolidate parsing classes into single file.
This commit is contained in:
@@ -4,16 +4,12 @@
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2001-2002 Steve Dunstan (jalist@e107.org)
|
||||
| Copyright (C) 2008-2010 e107 Inc (e107.org)
|
||||
| Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.7/e107_handlers/emote.php $
|
||||
| $Revision: 11678 $
|
||||
| $Id: emote.php 11678 2010-08-22 00:43:45Z e107coders $
|
||||
| $Author: e107coders $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
@@ -3,13 +3,15 @@ $class = e107::getBB()->getClass('code');
|
||||
|
||||
|
||||
|
||||
global $pref, $e107cache, $tp;
|
||||
global $pref, $e107cache;
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
if($pref['smiley_activate'])
|
||||
{
|
||||
if (!is_object($tp->e_emote))
|
||||
{
|
||||
require_once(e_HANDLER.'emote_filter.php');
|
||||
// require_once(e_HANDLER.'emote_filter.php');
|
||||
$tp->e_emote = new e_emoteFilter;
|
||||
}
|
||||
$code_text = $tp->e_emote->filterEmotesRev($code_text);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/*
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
@@ -7,11 +7,7 @@
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Administration UI handlers, admin helper functions
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/admin_handler.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* @DEPRECATED FILE
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/*
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
@@ -9,19 +9,23 @@
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
* @DEPRECATED FILE
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @DEPRECATED
|
||||
* Use e107::getParser()->parseTemplate("{USER_AVATAR=".$avatar."}",true); instead.
|
||||
*/
|
||||
function avatar($avatar)
|
||||
{
|
||||
|
||||
return e107::getParser()->parseTemplate("{USER_AVATAR=".$avatar."}",true);
|
||||
|
||||
|
||||
/*
|
||||
global $tp;
|
||||
if (stristr($avatar, '-upload-') !== false)
|
||||
{
|
||||
@@ -43,6 +47,7 @@ function avatar($avatar)
|
||||
{
|
||||
return $avatar;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
?>
|
@@ -260,6 +260,44 @@ if (!function_exists('asortbyindex'))
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('r_emote'))
|
||||
{
|
||||
/**
|
||||
* @DEPRECATED
|
||||
*/
|
||||
function r_emote()
|
||||
{
|
||||
global $sysprefs, $pref;
|
||||
$tp = e107::getParser();
|
||||
|
||||
if (!is_object($tp->e_emote))
|
||||
{
|
||||
// require_once(e_HANDLER.'emote_filter.php');
|
||||
$tp->e_emote = new e_emoteFilter;
|
||||
}
|
||||
|
||||
$str = '';
|
||||
foreach($tp->e_emote->emotes as $key => $value) // filename => text code
|
||||
{
|
||||
$key = str_replace("!", ".", $key); // Usually '.' was replaced by '!' when saving
|
||||
$key = preg_replace("#_(\w{3})$#", ".\\1", $key); // '_' followed by exactly 3 chars is file extension
|
||||
$key = e_IMAGE."emotes/" . $pref['emotepack'] . "/" .$key; // Add in the file path
|
||||
|
||||
$value2 = substr($value, 0, strpos($value, " "));
|
||||
$value = ($value2 ? $value2 : $value);
|
||||
$value = ($value == '&|') ? ':((' : $value;
|
||||
$value = " ".$value." ";
|
||||
//TODO CSS class
|
||||
$str .= "\n<a href=\"javascript:addtext('$value',true)\"><img src='$key' alt='' /></a> ";
|
||||
}
|
||||
|
||||
return "<div class='spacer'>".$str."</div>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!function_exists('multiarray_sort'))
|
||||
{
|
||||
|
||||
|
@@ -1272,8 +1272,10 @@ class e_parse extends e_parser
|
||||
{
|
||||
return $text;
|
||||
}
|
||||
|
||||
$pref = e107::getPref();
|
||||
|
||||
global $pref, $fromadmin;
|
||||
global $fromadmin;
|
||||
|
||||
// Set default modifiers to start
|
||||
$opts = $this->e_optDefault;
|
||||
@@ -1570,7 +1572,7 @@ class e_parse extends e_parser
|
||||
{
|
||||
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;
|
||||
}
|
||||
$sub_blk = $this->e_emote->filterEmotes($sub_blk);
|
||||
@@ -1655,7 +1657,7 @@ class e_parse extends e_parser
|
||||
{
|
||||
if (!is_object($this->e_pf))
|
||||
{
|
||||
require_once(e_HANDLER."profanity_filter.php");
|
||||
// require_once(e_HANDLER."profanity_filter.php");
|
||||
$this->e_pf = new e_profanityFilter;
|
||||
}
|
||||
$sub_blk = $this->e_pf->filterProfanities($sub_blk);
|
||||
@@ -2901,3 +2903,151 @@ return $html;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class e_emotefilter {
|
||||
var $search;
|
||||
var $replace;
|
||||
var $emotes;
|
||||
|
||||
function e_emotefilter() /* constructor */
|
||||
{
|
||||
$pref = e107::getPref();
|
||||
|
||||
if(!$pref['emotepack'])
|
||||
{
|
||||
$pref['emotepack'] = "default";
|
||||
save_prefs();
|
||||
}
|
||||
|
||||
$this->emotes = e107::getConfig("emote")->getPref();
|
||||
|
||||
if(!vartrue($this->emotes))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($this->emotes as $key => $value)
|
||||
{
|
||||
$value = trim($value);
|
||||
|
||||
if ($value)
|
||||
{ // Only 'activate' emote if there's a substitution string set
|
||||
$key = preg_replace("#!(\w{3,}?)$#si", ".\\1", $key);
|
||||
// Next two probably to sort out legacy issues - may not be required any more
|
||||
$key = preg_replace("#_(\w{3})$#", ".\\1", $key);
|
||||
$key = str_replace("!", "_", $key);
|
||||
|
||||
$filename = e_IMAGE."emotes/" . $pref['emotepack'] . "/" . $key;
|
||||
|
||||
$fileloc = SITEURLBASE.e_IMAGE_ABS."emotes/" . $pref['emotepack'] . "/" . $key;
|
||||
|
||||
if(file_exists($filename))
|
||||
{
|
||||
if(strstr($value, " "))
|
||||
{
|
||||
$tmp = explode(" ", $value);
|
||||
foreach($tmp as $code)
|
||||
{
|
||||
$this->search[] = " ".$code;
|
||||
$this->search[] = "\n".$code;
|
||||
//TODO CSS class?
|
||||
$this->replace[] = " <img src='".$fileloc."' alt='' style='vertical-align:middle; border:0' /> ";
|
||||
$this->replace[] = "\n <img src='".$fileloc."' alt='' style='vertical-align:middle; border:0' /> ";
|
||||
}
|
||||
unset($tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
if($value)
|
||||
{
|
||||
$this->search[] = " ".$value;
|
||||
$this->search[] = "\n".$value;
|
||||
//TODO CSS class?
|
||||
$this->replace[] = " <img src='".$filename."' alt='' style='vertical-align:middle; border:0' /> ";
|
||||
$this->replace[] = "\n <img src='".$filename."' alt='' style='vertical-align:middle; border:0' /> ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($this->emotes[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function filterEmotes($text)
|
||||
{
|
||||
$text = str_replace($this->search, $this->replace, $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
function filterEmotesRev($text)
|
||||
{
|
||||
$text = str_replace($this->replace, $this->search, $text);
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class e_profanityFilter
|
||||
{
|
||||
var $profanityList;
|
||||
|
||||
function e_profanityFilter()
|
||||
{
|
||||
global $pref;
|
||||
|
||||
$words = explode(",", $pref['profanity_words']);
|
||||
$word_array = array();
|
||||
foreach($words as $word)
|
||||
{
|
||||
$word = trim($word);
|
||||
if($word != "")
|
||||
{
|
||||
$word_array[] = $word;
|
||||
if (strpos($word, '$') !== FALSE)
|
||||
{
|
||||
$word_array[] = str_replace('$', '\$', $word); // Special case - '$' may be 'in clear' or as entity
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count($word_array))
|
||||
{
|
||||
$this->profanityList = str_replace('#','\#',implode("\b|\b", $word_array)); // We can get entities in the string - confuse the regex delimiters
|
||||
}
|
||||
unset($words);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function filterProfanities($text)
|
||||
{
|
||||
global $pref;
|
||||
if (!$this->profanityList)
|
||||
{
|
||||
return $text;
|
||||
}
|
||||
if ($pref['profanity_replace'])
|
||||
{
|
||||
return preg_replace("#\b".$this->profanityList."\b#is", $pref['profanity_replace'], $text);
|
||||
}
|
||||
else
|
||||
{
|
||||
return preg_replace_callback("#\b".$this->profanityList."\b#is", array($this, 'replaceProfanities'), $text);
|
||||
}
|
||||
}
|
||||
|
||||
function replaceProfanities($matches)
|
||||
{
|
||||
/*!
|
||||
@function replaceProfanities callback
|
||||
@abstract replaces vowels in profanity words with stars
|
||||
@param text string - text string to be filtered
|
||||
@result filtered text
|
||||
*/
|
||||
|
||||
return preg_replace("#a|e|i|o|u#i", "*" , $matches[0]);
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/emote.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* @DEPRECATED FILE
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
/*
|
||||
function r_emote()
|
||||
{
|
||||
global $sysprefs, $pref, $tp;
|
||||
@@ -43,5 +38,5 @@ function r_emote()
|
||||
|
||||
return "<div class='spacer'>".$str."</div>";
|
||||
}
|
||||
|
||||
*/
|
||||
?>
|
@@ -1,27 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/emote_filter.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* @DEPRECATED FILE
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
/*
|
||||
|
||||
class e_emotefilter {
|
||||
var $search;
|
||||
var $replace;
|
||||
var $emotes;
|
||||
|
||||
function e_emotefilter() /* constructor */
|
||||
function e_emotefilter()
|
||||
{
|
||||
$pref = e107::getPref();
|
||||
|
||||
@@ -100,6 +96,9 @@ class e_emotefilter {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,20 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*
|
||||
*
|
||||
* $URL$
|
||||
* $Revision$
|
||||
* $Id$
|
||||
* @DEPRECATED FILE
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
/*
|
||||
class e_profanityFilter
|
||||
{
|
||||
var $profanityList;
|
||||
@@ -61,18 +58,21 @@ class e_profanityFilter
|
||||
return preg_replace_callback("#\b".$this->profanityList."\b#is", array($this, 'replaceProfanities'), $text);
|
||||
}
|
||||
}
|
||||
|
||||
function replaceProfanities($matches)
|
||||
{
|
||||
/*!
|
||||
@function replaceProfanities callback
|
||||
*
|
||||
*
|
||||
// @function replaceProfanities callback
|
||||
@abstract replaces vowels in profanity words with stars
|
||||
@param text string - text string to be filtered
|
||||
@result filtered text
|
||||
*/
|
||||
|
||||
function replaceProfanities($matches)
|
||||
{
|
||||
|
||||
|
||||
return preg_replace("#a|e|i|o|u#i", "*" , $matches[0]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -314,7 +314,7 @@ function PreFile_Select($formid='prefile_selector')
|
||||
}
|
||||
|
||||
function Emoticon_Select($formid='emoticon_selector') {
|
||||
require_once(e_HANDLER."emote.php");
|
||||
// require_once(e_HANDLER."emote.php");
|
||||
$text ="<!-- Start of Emoticon selector -->
|
||||
<div style='margin-left:0px;margin-right:0px; position:relative;z-index:1000;float:right;display:none' id='{$formid}' onclick=\"this.style.display='none'\" >
|
||||
<div style='position:absolute; bottom:30px; right:75px; width:221px; height:133px; overflow:auto;'>
|
||||
|
@@ -54,7 +54,7 @@ if(($pref['cb_layer']==2) || isset($_POST['chatbox_ajax']))
|
||||
*/
|
||||
|
||||
// if(!defined('e_HANDLER')){ exit; }
|
||||
require_once(e_HANDLER.'emote.php');
|
||||
// require_once(e_HANDLER.'emote.php');
|
||||
|
||||
$emessage='';
|
||||
|
||||
|
@@ -571,7 +571,7 @@ class listclass
|
||||
$tp = e107::getParser();
|
||||
if (!is_object($parser->e_pf))
|
||||
{
|
||||
require_once(e_HANDLER.'profanity_filter.php');
|
||||
// require_once(e_HANDLER.'profanity_filter.php');
|
||||
$parser->e_pf = new e_profanityFilter;
|
||||
}
|
||||
foreach ($listArray as $k => $v)
|
||||
|
@@ -174,7 +174,7 @@ class pm_shortcodes extends e_shortcode
|
||||
|
||||
public function sc_pm_emotes()
|
||||
{
|
||||
require_once(e_HANDLER.'emote.php');
|
||||
// require_once(e_HANDLER.'emote.php');
|
||||
return r_emote();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user