1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 04:40:44 +02:00

More handling of plugin.xml reformat, handle 'special' chars in profanity filter

This commit is contained in:
e107steved
2008-12-05 19:56:51 +00:00
parent b2b15d5542
commit c7bd61a87f
3 changed files with 55 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
/* /*
* e107 website system (c) 2001-2008 Steve Dunstan (e107.org) * e107 website system (c) 2001-2008 Steve Dunstan (e107.org)
* $Id: admin_alt_nav.sc,v 1.4 2008-08-25 13:34:45 e107steved Exp $ * $Id: admin_alt_nav.sc,v 1.5 2008-12-05 19:56:45 e107steved Exp $
*/ */
if (ADMIN) if (ADMIN)
@@ -43,21 +43,26 @@ if (ADMIN)
$text .= adnav_cat(ADLAN_151, e_ADMIN.'admin.php', E_16_NAV_MAIN); $text .= adnav_cat(ADLAN_151, e_ADMIN.'admin.php', E_16_NAV_MAIN);
for ($i = 1; $i < 5; $i++) { for ($i = 1; $i < 5; $i++)
{
$ad_tmpi = 0; $ad_tmpi = 0;
$ad_links_array = asortbyindex($array_functions, 1); $ad_links_array = asortbyindex($array_functions, 1);
$nav_main = adnav_cat($admin_cat['title'][$i], '', $admin_cat['img'][$i], $admin_cat['id'][$i]); $nav_main = adnav_cat($admin_cat['title'][$i], '', $admin_cat['img'][$i], $admin_cat['id'][$i]);
$ad_texti = "<div id='".$admin_cat['id'][$i]."' class='menu' onmouseover=\"menuMouseover(event)\">"; $ad_texti = "<div id='".$admin_cat['id'][$i]."' class='menu' onmouseover=\"menuMouseover(event)\">";
while(list($key, $nav_extract) = each($ad_links_array)){ while(list($key, $nav_extract) = each($ad_links_array))
if($nav_extract[4]==$i){ {
if(getperms($nav_extract[3])){ if($nav_extract[4]==$i)
{
if(getperms($nav_extract[3]))
{
$ad_texti .= adnav_main($nav_extract[1], $nav_extract[0], $nav_extract[5]); $ad_texti .= adnav_main($nav_extract[1], $nav_extract[0], $nav_extract[5]);
$ad_tmpi = 1; $ad_tmpi = 1;
} }
} }
} }
$ad_texti .= "</div>"; $ad_texti .= "</div>";
if ($ad_tmpi == 1) { if ($ad_tmpi == 1)
{
$text .= $nav_main; $text .= $nav_main;
$text .= $ad_texti; $text .= $ad_texti;
} }
@@ -78,10 +83,10 @@ if (ADMIN)
$plug_vars = $plug->plug_vars; $plug_vars = $plug->plug_vars;
if($plug_vars['administration']['configFile']) if($plug_vars['administration']['configFile'])
{ {
$plug_vars['name'] = $tp->toHTML($plug_vars['name'], FALSE, "defs"); $plug_vars['@attributes']['name'] = $tp->toHTML($plug_vars['@attributes']['name'], FALSE, "defs");
$icon_src = (isset($plug_vars['plugin_php']) ? e_PLUGIN_ABS : e_PLUGIN_ABS.$row['plugin_path'].'/') .$plug_vars['administration']['iconSmall']; $icon_src = (isset($plug_vars['plugin_php']) ? e_PLUGIN_ABS : e_PLUGIN_ABS.$row['plugin_path'].'/') .$plug_vars['administration']['iconSmall'];
$plugin_icon = $plug_vars['administration']['iconSmall'] ? "<img src='{$icon_src}' alt='".$plug_vars['administration']['caption']."' style='border:0px; vertical-align:bottom; width: 16px; height: 16px' />" : E_16_PLUGIN; $plugin_icon = $plug_vars['administration']['iconSmall'] ? "<img src='{$icon_src}' alt='".$plug_vars['administration']['caption']."' style='border:0px; vertical-align:bottom; width: 16px; height: 16px' />" : E_16_PLUGIN;
$plugin_array[ucfirst($plug_vars['name'])] = adnav_main($plug_vars['name'], e_PLUGIN.$row['plugin_path']."/".$plug_vars['administration']['configFile'], $plugin_icon); $plugin_array[ucfirst($plug_vars['@attributes']['name'])] = adnav_main($plug_vars['@attributes']['name'], e_PLUGIN.$row['plugin_path']."/".$plug_vars['administration']['configFile'], $plugin_icon);
} }
$render_plugins = TRUE; $render_plugins = TRUE;
$active_plugs = TRUE; $active_plugs = TRUE;
@@ -90,12 +95,14 @@ if (ADMIN)
} }
ksort($plugin_array, SORT_STRING); ksort($plugin_array, SORT_STRING);
$plugs_text = ''; $plugs_text = '';
foreach ($plugin_array as $plugin_compile) { foreach ($plugin_array as $plugin_compile)
{
$plugs_text .= $plugin_compile; $plugs_text .= $plugin_compile;
} }
} }
if (getperms('Z')) { if (getperms('Z'))
{
$pclass_extended = $active_plugs ? 'header' : ''; $pclass_extended = $active_plugs ? 'header' : '';
$plugin_text = adnav_main(ADLAN_98, e_ADMIN.'plugin.php', E_16_PLUGMANAGER, FALSE, $pclass_extended); $plugin_text = adnav_main(ADLAN_98, e_ADMIN.'plugin.php', E_16_PLUGMANAGER, FALSE, $pclass_extended);
$render_plugins = TRUE; $render_plugins = TRUE;
@@ -110,12 +117,15 @@ if (ADMIN)
$text .= adnav_cat(ADLAN_CL_8, '', E_16_NAV_DOCS, 'docsMenu'); $text .= adnav_cat(ADLAN_CL_8, '', E_16_NAV_DOCS, 'docsMenu');
$text .= "<div id='docsMenu' class='menu' onmouseover=\"menuMouseover(event)\">"; $text .= "<div id='docsMenu' class='menu' onmouseover=\"menuMouseover(event)\">";
if (!$handle=opendir(e_DOCS.e_LANGUAGE."/")) { if (!$handle=opendir(e_DOCS.e_LANGUAGE."/"))
{
$handle=opendir(e_DOCS."English/"); $handle=opendir(e_DOCS."English/");
} }
$i=1; $i=1;
while ($file = readdir($handle)) { while ($file = readdir($handle))
if ($file != "." && $file != ".." && $file != "CVS") { {
if ($file != "." && $file != ".." && $file != "CVS")
{
$text .= adnav_main(str_replace("_", " ", $file), e_ADMIN."docs.php?".$i, E_16_DOCS); $text .= adnav_main(str_replace("_", " ", $file), e_ADMIN."docs.php?".$i, E_16_DOCS);
$i++; $i++;
} }
@@ -127,7 +137,8 @@ if (ADMIN)
$text .= "</div> $text .= "</div>
</td>"; </td>";
if ($exit != 'off') { if ($exit != 'off')
{
$text .= "<td style='width: 160px; white-space: nowrap'> $text .= "<td style='width: 160px; white-space: nowrap'>
<div class='menuBar' style='width: 100%'>"; <div class='menuBar' style='width: 100%'>";

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_handlers/plugin_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
| $Revision: 1.53 $ | $Revision: 1.54 $
| $Date: 2008-12-05 14:18:51 $ | $Date: 2008-12-05 19:56:51 $
| $Author: secretr $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -218,7 +218,7 @@ class e107plugin
// echo "New plugin to add: {$plug_info['name']}<br />"; // echo "New plugin to add: {$plug_info['name']}<br />";
// Can just add to DB - shouldn't matter that its not in our current table // Can just add to DB - shouldn't matter that its not in our current table
// echo "Trying to insert: ".$eplug_folder."<br />"; // echo "Trying to insert: ".$eplug_folder."<br />";
$_installed = ($plug_info['@attributes']['installRequired'] == 'true' || $plug_info['installRequired'] == 1 ? 0 : 1 ); $_installed = ($plug_info['@attributes']['installRequired'] == 'true' || $plug_info['@attributes']['installRequired'] == 1 ? 0 : 1 );
$sql->db_Insert("plugin", "0, '".$tp -> toDB($plug_info['@attributes']['name'], true)."', '".$tp -> toDB($plug_info['@attributes']['version'], true)."', '".$tp -> toDB($plugin_path, true)."', {$_installed}, '{$eplug_addons}' "); $sql->db_Insert("plugin", "0, '".$tp -> toDB($plug_info['@attributes']['name'], true)."', '".$tp -> toDB($plug_info['@attributes']['version'], true)."', '".$tp -> toDB($plugin_path, true)."', {$_installed}, '{$eplug_addons}' ");
} }
} }
@@ -1546,7 +1546,11 @@ class e107plugin
require_once(e_HANDLER.'xml_class.php'); require_once(e_HANDLER.'xml_class.php');
$xml = new xmlClass; $xml = new xmlClass;
$this->plug_vars = $xml->loadXMLfile($path.'plugin.xml', true, true); $this->plug_vars = $xml->loadXMLfile($path.'plugin.xml', true, true);
if ($this->plug_vars === FALSE) return FALSE; if ($this->plug_vars === FALSE)
{
echo "Error reading {$path}/plugin.xml<br />";
return FALSE;
}
// print_a($this->plug_vars); // print_a($this->plug_vars);
return true; return true;
} }

View File

@@ -11,23 +11,26 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/profanity_filter.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/profanity_filter.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:33:56 $ | $Date: 2008-12-05 19:56:51 $
| $Author: mcfly_e107 $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
class e_profanityFilter { class e_profanityFilter
{
var $profanityList; var $profanityList;
function e_profanityFilter() { function e_profanityFilter()
{
global $pref; global $pref;
$words = explode(",", $pref['profanity_words']); $words = explode(",", $pref['profanity_words']);
$word_array = array(); $word_array = array();
foreach($words as $word) { foreach($words as $word)
{
$word = trim($word); $word = trim($word);
if($word != "") if($word != "")
{ {
@@ -36,25 +39,31 @@ class e_profanityFilter {
} }
if(count($word_array)) if(count($word_array))
{ {
$this->profanityList = implode("\b|\b", $word_array); $this->profanityList = str_replace('#','\#',implode("\b|\b", $word_array)); // We can get entities in the string - confuse the regex delimiters
} }
unset($words); unset($words);
return TRUE; return TRUE;
} }
function filterProfanities($text) { function filterProfanities($text)
{
global $pref; global $pref;
if (!$this->profanityList) { if (!$this->profanityList)
{
return $text; return $text;
} }
if ($pref['profanity_replace']) { if ($pref['profanity_replace'])
{
return preg_replace("#\b".$this->profanityList."\b#is", $pref['profanity_replace'], $text); return preg_replace("#\b".$this->profanityList."\b#is", $pref['profanity_replace'], $text);
} else { }
else
{
return preg_replace_callback("#\b".$this->profanityList."\b#is", array($this, 'replaceProfanities'), $text); return preg_replace_callback("#\b".$this->profanityList."\b#is", array($this, 'replaceProfanities'), $text);
} }
} }
function replaceProfanities($matches) { function replaceProfanities($matches)
{
/*! /*!
@function replaceProfanities callback @function replaceProfanities callback
@abstract replaces vowels in profanity words with stars @abstract replaces vowels in profanity words with stars