[xoops-cvslog 590] CVS update: xoops2jp/html/class

Back to archive index

onokazu onoka****@users*****
2005年 10月 24日 (月) 20:26:50 JST


Index: xoops2jp/html/class/commentrenderer.php
diff -u xoops2jp/html/class/commentrenderer.php:1.2 xoops2jp/html/class/commentrenderer.php:1.2.14.1
--- xoops2jp/html/class/commentrenderer.php:1.2	Fri Mar 18 21:51:55 2005
+++ xoops2jp/html/class/commentrenderer.php	Mon Oct 24 20:26:50 2005
@@ -1,387 +1,389 @@
-<?php
-// $Id: commentrenderer.php,v 1.2 2005/03/18 12:51:55 onokazu Exp $
-//  ------------------------------------------------------------------------ //
-//                XOOPS - PHP Content Management System                      //
-//                    Copyright (c) 2000 XOOPS.org                           //
-//                       <http://www.xoops.org/>                             //
-//  ------------------------------------------------------------------------ //
-//  This program is free software; you can redistribute it and/or modify     //
-//  it under the terms of the GNU General Public License as published by     //
-//  the Free Software Foundation; either version 2 of the License, or        //
-//  (at your option) any later version.                                      //
-//                                                                           //
-//  You may not change or alter any portion of this comment or credits       //
-//  of supporting developers from this source code or any supporting         //
-//  source code which is considered copyrighted (c) material of the          //
-//  original comment or credit authors.                                      //
-//                                                                           //
-//  This program is distributed in the hope that it will be useful,          //
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
-//  GNU General Public License for more details.                             //
-//                                                                           //
-//  You should have received a copy of the GNU General Public License        //
-//  along with this program; if not, write to the Free Software              //
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
-//  ------------------------------------------------------------------------ //
-// Author: Kazumi Ono (AKA onokazu)                                          //
-// URL: http://www.xoops.org/ http://jp.xoops.org/  http://www.myweb.ne.jp/  //
-// Project: The XOOPS Project (http://www.xoops.org/)                        //
-// ------------------------------------------------------------------------- //
-/**
- * Display comments
- *
- * @package		kernel
- * @subpackage	comment
- *
- * @author		Kazumi Ono 	<onoka****@xoops*****>
- * @copyright	(c) 2000-2003 The Xoops Project - www.xoops.org
- */
-class XoopsCommentRenderer {
-
-	/**#@+
-     * @access	private
-     */
-    var $_tpl;
-	var $_comments = null;
-	var $_useIcons = true;
-	var $_doIconCheck = false;
-	var $_memberHandler;
-	var $_statusText;
-    /**#@-*/
-
-	/**
-	 * Constructor
-	 * 
-	 * @param   object  &$tpl   
-	 * @param   boolean $use_icons
-	 * @param   boolean $do_iconcheck
-	 **/
-	function XoopsCommentRenderer(&$tpl, $use_icons = true, $do_iconcheck = false)
-	{
-		$this->_tpl =& $tpl;
-		$this->_useIcons = $use_icons;
-		$this->_doIconCheck = $do_iconcheck;
-		$this->_memberHandler =& xoops_gethandler('member');
-		$this->_statusText = array(XOOPS_COMMENT_PENDING => '<span style="text-decoration: none; font-weight: bold; color: #00ff00;">'._CM_PENDING.'</span>', XOOPS_COMMENT_ACTIVE => '<span style="text-decoration: none; font-weight: bold; color: #ff0000;">'._CM_ACTIVE.'</span>', XOOPS_COMMENT_HIDDEN => '<span style="text-decoration: none; font-weight: bold; color: #0000ff;">'._CM_HIDDEN.'</span>');
-	}
-
-	/**
-	 * Access the only instance of this class
-	 * 
-	 * @param   object  $tpl        reference to a {@link Smarty} object
-	 * @param   boolean $use_icons
-	 * @param   boolean $do_iconcheck
-	 * @return 
-	 **/
-	function &instance(&$tpl, $use_icons = true, $do_iconcheck = false)
-	{
-		static $instance;
-		if (!isset($instance)) {
-			$instance = new XoopsCommentRenderer($tpl, $use_icons, $do_iconcheck);
-		}
-		return $instance;
-	}
-
-	/**
-	 * Accessor
-	 * 
-	 * @param   object  &$comments_arr  array of {@link XoopsComment} objects
-	 **/
-	function setComments(&$comments_arr)
-	{
-		if (isset($this->_comments)) {
-			unset($this->_comments);
-		}
-		$this->_comments =& $comments_arr;
-	}
-
-	/**
-	 * Render the comments in flat view
-	 * 
-	 * @param boolean $admin_view
-	 **/
-	function renderFlatView($admin_view = false)
-	{
-		$count = count($this->_comments);
-		for ($i = 0; $i < $count; $i++) {
-			if (false != $this->_useIcons) {
-				$title = $this->_getTitleIcon($this->_comments[$i]->getVar('com_icon')).'&nbsp;'.$this->_comments[$i]->getVar('com_title');
-			} else {
-				$title = $this->_comments[$i]->getVar('com_title');
-			}
-			$poster = $this->_getPosterArray($this->_comments[$i]->getVar('com_uid'));
-			if (false != $admin_view) {
-				$text = $this->_comments[$i]->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$this->_comments[$i]->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$this->_comments[$i]->getVar('com_ip').'</span></div>';
-			} else {
-				// hide comments that are not active
-				if (XOOPS_COMMENT_ACTIVE != $this->_comments[$i]->getVar('com_status')) {
-					continue;
-				} else {
-					$text = $this->_comments[$i]->getVar('com_text');
-				}
-			}
-			$this->_tpl->append('comments', array('id' => $this->_comments[$i]->getVar('com_id'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($this->_comments[$i]->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($this->_comments[$i]->getVar('com_modified'), 'm'), 'poster' => $poster));
-		}
-	}
-
-	/**
-	 * Render the comments in thread view
-     * 
-     * This method calls itself recursively
-	 * 
-	 * @param integer $comment_id   Should be "0" when called by client
-	 * @param boolean $admin_view
-	 * @param boolean $show_nav
-	 **/
-	function renderThreadView($comment_id = 0, $admin_view = false, $show_nav = true)
-	{
-		include_once XOOPS_ROOT_PATH.'/class/tree.php';
-		// construct comment tree
-		$xot = new XoopsObjectTree($this->_comments, 'com_id', 'com_pid', 'com_rootid');
-		$tree =& $xot->getTree();
-
-		if (false != $this->_useIcons) {
-			$title = $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).'&nbsp;'.$tree[$comment_id]['obj']->getVar('com_title');
-		} else {
-			$title = $tree[$comment_id]['obj']->getVar('com_title');
-		}
-		if (false != $show_nav && $tree[$comment_id]['obj']->getVar('com_pid') != 0) {
-			$this->_tpl->assign('lang_top', _CM_TOP);
-			$this->_tpl->assign('lang_parent', _CM_PARENT);
-			$this->_tpl->assign('show_threadnav', true);
-		} else {
-			$this->_tpl->assign('show_threadnav', false);
-		}
-		if (false != $admin_view) {
-			// admins can see all
-			$text = $tree[$comment_id]['obj']->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$tree[$comment_id]['obj']->getVar('com_ip').'</span></div>';
-		} else {
-			// hide comments that are not active
-			if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) {
-				// if there are any child comments, display them as root comments
-				if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
-					foreach ($tree[$comment_id]['child'] as $child_id) {
-						$this->renderThreadView($child_id, $admin_view, false);
-					}
-				}
-				return;
-			} else {
-				$text = $tree[$comment_id]['obj']->getVar('com_text');
-			}
-		}
-		$replies = array();
-		$this->_renderThreadReplies($tree, $comment_id, $replies, '&nbsp;&nbsp;', $admin_view);
-		$show_replies = (count($replies) > 0) ? true : false;
-		$this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies, 'show_replies' => $show_replies));
-	}
-
-	/**
-	 * Render replies to a thread
-	 * 
-	 * @param   array   &$thread
-	 * @param   int     $key
-	 * @param   array   $replies
-	 * @param   string  $prefix
-	 * @param   bool    $admin_view
-	 * @param   integer $depth
-	 * @param   string  $current_prefix
-     * 
-     * @access	private
-	 **/
-	function _renderThreadReplies(&$thread, $key, &$replies, $prefix, $admin_view, $depth = 0, $current_prefix = '')
-	{
-        if ($depth > 0) {
-			if (false != $this->_useIcons) {
-				$title = $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).'&nbsp;'.$thread[$key]['obj']->getVar('com_title');
-			} else {
-				$title = $thread[$key]['obj']->getVar('com_title');
-			}
-			$title = (false != $admin_view) ? $title.' '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')] : $title;
-			$replies[] = array('id' => $key, 'prefix' => $current_prefix, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'title' => $title, 'root_id' => $thread[$key]['obj']->getVar('com_rootid'), 'status' => $this->_statusText[$thread[$key]['obj']->getVar('com_status')], 'poster' => $this->_getPosterName($thread[$key]['obj']->getVar('com_uid')));
-            $current_prefix .= $prefix;
-        }
-        if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) {
-			$depth++;
-            foreach ($thread[$key]['child'] as $childkey) {
-                if (!$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) {
-                    // skip this comment if it is not active and continue on processing its child comments instead
-                    if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
-                        foreach ($thread[$childkey]['child'] as $childchildkey) {
-                            $this->_renderThreadReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth);
-                        }
-                    }
-                } else {
-                    $this->_renderThreadReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth, $current_prefix);
-                }
-            }
-        }
-	}
-
-	/**
-	 * Render comments in nested view
-     * 
-     * Danger: Recursive!
-	 * 
-	 * @param integer $comment_id   Always "0" when called by client.
-	 * @param boolean $admin_view
-	 **/
-	function renderNestView($comment_id = 0, $admin_view = false)
-	{
-		include_once XOOPS_ROOT_PATH.'/class/tree.php';
-		$xot = new XoopsObjectTree($this->_comments, 'com_id', 'com_pid', 'com_rootid');
-		$tree =& $xot->getTree();
-		if (false != $this->_useIcons) {
-			$title = $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).'&nbsp;'.$tree[$comment_id]['obj']->getVar('com_title');
-		} else {
-			$title = $tree[$comment_id]['obj']->getVar('com_title');
-		}
-		if (false != $admin_view) {
-			$text = $tree[$comment_id]['obj']->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$tree[$comment_id]['obj']->getVar('com_ip').'</span></div>';
-		} else {
-			// skip this comment if it is not active and continue on processing its child comments instead
-			if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) {
-				// if there are any child comments, display them as root comments
-				if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
-					foreach ($tree[$comment_id]['child'] as $child_id) {
-						$this->renderNestView($child_id, $admin_view);
-					}
-				}
-				return;
-			} else {
-				$text = $tree[$comment_id]['obj']->getVar('com_text');
-			}
-		}
-		$replies = array();
-		$this->_renderNestReplies($tree, $comment_id, $replies, 25, $admin_view);
-		$this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies));
-	}
-
-	/**
-	 * Render replies in nested view
-	 * 
-	 * @param   array   $thread
-	 * @param   int     $key
-	 * @param   array   $replies
-	 * @param   string  $prefix
-	 * @param   bool    $admin_view
-	 * @param   integer $depth
-     * 
-     * @access	private 
-	 **/
-	function _renderNestReplies(&$thread, $key, &$replies, $prefix, $admin_view, $depth = 0)
-	{
-        if ($depth > 0) {
-			if (false != $this->_useIcons) {
-				$title = $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).'&nbsp;'.$thread[$key]['obj']->getVar('com_title');
-			} else {
-				$title = $thread[$key]['obj']->getVar('com_title');
-			}
-			$text = (false != $admin_view) ? $thread[$key]['obj']->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$thread[$key]['obj']->getVar('com_ip').'</span></div>' : $thread[$key]['obj']->getVar('com_text');
-			$replies[] = array('id' => $key, 'prefix' => $prefix, 'pid' => $thread[$key]['obj']->getVar('com_pid'), 'itemid' => $thread[$key]['obj']->getVar('com_itemid'), 'rootid' => $thread[$key]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($thread[$key]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($thread[$key]['obj']->getVar('com_uid')));
-
-            $prefix = $prefix + 25;
-        }
-        if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) {
-			$depth++;
-            foreach ($thread[$key]['child'] as $childkey) {
-                if (!$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) {
-                    // skip this comment if it is not active and continue on processing its child comments instead
-                    if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
-                        foreach ($thread[$childkey]['child'] as $childchildkey) {
-                            $this->_renderNestReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth);
-                        }
-                    }
-                } else {
-                    $this->_renderNestReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth);
-                }
-            }
-        }
-	}
-
-
-	/**
-	 * Get the name of the poster
-	 * 
-	 * @param   int $poster_id
-	 * @return  string
-     * 
-     * @access	private
-	 **/
-	function _getPosterName($poster_id)
-	{
-		$poster['id'] = intval($poster_id);
-		if ($poster['id'] > 0) {
-			$com_poster =& $this->_memberHandler->getUser($poster_id);
-			if (is_object($com_poster)) {
-				$poster['uname'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'</a>';
-				return $poster;
-			}
-		}
-        $poster['id'] = 0; // to cope with deleted user accounts
-		$poster['uname'] = $GLOBALS['xoopsConfig']['anonymous'];
-		return $poster;
-	}
-
-	/**
-	 * Get an array with info about the poster
-	 * 
-	 * @param   int $poster_id
-	 * @return  array
-     * 
-     * @access	private
-	 **/
-	function _getPosterArray($poster_id)
-	{
-		$poster['id'] = intval($poster_id);
-		if ($poster['id'] > 0) {
-			$com_poster =& $this->_memberHandler->getUser($poster['id']);
-			if (is_object($com_poster)) {
-				$poster['uname'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'</a>';
-				$poster_rank = $com_poster->rank();
-				$poster['rank_image'] = ($poster_rank['image'] != '') ? $poster_rank['image'] : 'blank.gif'; 
-				$poster['rank_title'] = $poster_rank['title'];
-				$poster['avatar'] = $com_poster->getVar('user_avatar');
-				$poster['regdate'] = formatTimestamp($com_poster->getVar('user_regdate'), 's');
-				$poster['from'] = $com_poster->getVar('user_from');
-				$poster['postnum'] = $com_poster->getVar('posts');
-				$poster['status'] = $com_poster->isOnline() ? _CM_ONLINE : '';
-				return $poster;
-			}
-		}
-        $poster['id'] = 0; // to cope with deleted user accounts
-		$poster['uname'] = $GLOBALS['xoopsConfig']['anonymous'];
-		$poster['rank_title'] = '';
-		$poster['avatar'] = 'blank.gif';
-		$poster['regdate'] = '';
-		$poster['from'] = '';
-		$poster['postnum'] = 0;
-		$poster['status'] = '';
-		return $poster;
-	}
-
-	/**
-	 * Get the IMG tag for the title icon
-	 * 
-	 * @param   string  $icon_image
-	 * @return  string  HTML IMG tag
-     * 
-     * @access	private
-	 **/
-	function _getTitleIcon($icon_image)
-	{
-		if ($icon_image != '') {
-			if (false != $this->_doIconCheck) {
-				if (!file_exists(XOOPS_URL.'/images/subject/'.$icon_image)) {
-					return '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
-				} else {
-					return '<img src="'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />';
-				}
-			} else {
-				return '<img src="'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />';
-			}
-		}
-		return '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
-	}
-}
+<?php
+// $Id: commentrenderer.php,v 1.2.14.1 2005/10/24 11:26:50 onokazu Exp $
+//  ------------------------------------------------------------------------ //
+//                XOOPS - PHP Content Management System                      //
+//                    Copyright (c) 2000 XOOPS.org                           //
+//                       <http://www.xoops.org/>                             //
+//  ------------------------------------------------------------------------ //
+//  This program is free software; you can redistribute it and/or modify     //
+//  it under the terms of the GNU General Public License as published by     //
+//  the Free Software Foundation; either version 2 of the License, or        //
+//  (at your option) any later version.                                      //
+//                                                                           //
+//  You may not change or alter any portion of this comment or credits       //
+//  of supporting developers from this source code or any supporting         //
+//  source code which is considered copyrighted (c) material of the          //
+//  original comment or credit authors.                                      //
+//                                                                           //
+//  This program is distributed in the hope that it will be useful,          //
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
+//  GNU General Public License for more details.                             //
+//                                                                           //
+//  You should have received a copy of the GNU General Public License        //
+//  along with this program; if not, write to the Free Software              //
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
+//  ------------------------------------------------------------------------ //
+// Author: Kazumi Ono (AKA onokazu)                                          //
+// URL: http://www.xoops.org/ http://jp.xoops.org/  http://www.myweb.ne.jp/  //
+// Project: The XOOPS Project (http://www.xoops.org/)                        //
+// ------------------------------------------------------------------------- //
+/**
+ * Display comments
+ *
+ * @package     kernel
+ * @subpackage  comment
+ *
+ * @author      Kazumi Ono  <onoka****@xoops*****>
+ * @copyright   (c) 2000-2003 The Xoops Project - www.xoops.org
+ */
+class XoopsCommentRenderer {
+
+    /**#@+
+     * @access  private
+     */
+    var $_tpl;
+    var $_comments = null;
+    var $_useIcons = true;
+    var $_doIconCheck = false;
+    var $_memberHandler;
+    var $_statusText;
+    /**#@-*/
+
+    /**
+     * Constructor
+     *
+     * @param   object  &$tpl
+     * @param   boolean $use_icons
+     * @param   boolean $do_iconcheck
+     **/
+    function XoopsCommentRenderer(&$tpl, $use_icons = true, $do_iconcheck = false)
+    {
+        $this->_tpl =& $tpl;
+        $this->_useIcons = $use_icons;
+        $this->_doIconCheck = $do_iconcheck;
+        $this->_memberHandler =& xoops_gethandler('member');
+        $this->_statusText = array(XOOPS_COMMENT_PENDING => '<span style="text-decoration: none; font-weight: bold; color: #00ff00;">'._CM_PENDING.'</span>', XOOPS_COMMENT_ACTIVE => '<span style="text-decoration: none; font-weight: bold; color: #ff0000;">'._CM_ACTIVE.'</span>', XOOPS_COMMENT_HIDDEN => '<span style="text-decoration: none; font-weight: bold; color: #0000ff;">'._CM_HIDDEN.'</span>');
+    }
+
+    /**
+     * Access the only instance of this class
+     *
+     * @param   object  $tpl        reference to a {@link Smarty} object
+     * @param   boolean $use_icons
+     * @param   boolean $do_iconcheck
+     * @return
+     **/
+    function &instance(&$tpl, $use_icons = true, $do_iconcheck = false)
+    {
+        static $instance;
+        if (!isset($instance)) {
+            $instance = new XoopsCommentRenderer($tpl, $use_icons, $do_iconcheck);
+        }
+        return $instance;
+    }
+
+    /**
+     * Accessor
+     *
+     * @param   object  &$comments_arr  array of {@link XoopsComment} objects
+     **/
+    function setComments(&$comments_arr)
+    {
+        if (isset($this->_comments)) {
+            unset($this->_comments);
+        }
+        $this->_comments =& $comments_arr;
+    }
+
+    /**
+     * Render the comments in flat view
+     *
+     * @param boolean $admin_view
+     **/
+    function renderFlatView($admin_view = false)
+    {
+        $count = count($this->_comments);
+        for ($i = 0; $i < $count; $i++) {
+            if (false != $this->_useIcons) {
+                $title = $this->_getTitleIcon($this->_comments[$i]->getVar('com_icon')).'&nbsp;'.$this->_comments[$i]->getVar('com_title');
+            } else {
+                $title = $this->_comments[$i]->getVar('com_title');
+            }
+            $poster = $this->_getPosterArray($this->_comments[$i]->getVar('com_uid'));
+            if (false != $admin_view) {
+                $text = $this->_comments[$i]->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$this->_comments[$i]->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$this->_comments[$i]->getVar('com_ip').'</span></div>';
+            } else {
+                // hide comments that are not active
+                if (XOOPS_COMMENT_ACTIVE != $this->_comments[$i]->getVar('com_status')) {
+                    continue;
+                } else {
+                    $text = $this->_comments[$i]->getVar('com_text');
+                }
+            }
+            $this->_tpl->append('comments', array('id' => $this->_comments[$i]->getVar('com_id'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($this->_comments[$i]->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($this->_comments[$i]->getVar('com_modified'), 'm'), 'poster' => $poster));
+        }
+    }
+
+    /**
+     * Render the comments in thread view
+     *
+     * This method calls itself recursively
+     *
+     * @param integer $comment_id   Should be "0" when called by client
+     * @param boolean $admin_view
+     * @param boolean $show_nav
+     **/
+    function renderThreadView($comment_id = 0, $admin_view = false, $show_nav = true)
+    {
+        include_once XOOPS_ROOT_PATH.'/class/tree.php';
+        // construct comment tree
+        $xot = new XoopsObjectTree($this->_comments, 'com_id', 'com_pid', 'com_rootid');
+        $tree =& $xot->getTree();
+
+        if (false != $this->_useIcons) {
+            $title = $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).'&nbsp;'.$tree[$comment_id]['obj']->getVar('com_title');
+        } else {
+            $title = $tree[$comment_id]['obj']->getVar('com_title');
+        }
+        if (false != $show_nav && $tree[$comment_id]['obj']->getVar('com_pid') != 0) {
+            $this->_tpl->assign('lang_top', _CM_TOP);
+            $this->_tpl->assign('lang_parent', _CM_PARENT);
+            $this->_tpl->assign('show_threadnav', true);
+        } else {
+            $this->_tpl->assign('show_threadnav', false);
+        }
+        if (false != $admin_view) {
+            // admins can see all
+            $text = $tree[$comment_id]['obj']->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$tree[$comment_id]['obj']->getVar('com_ip').'</span></div>';
+        } else {
+            // hide comments that are not active
+            if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) {
+                // if there are any child comments, display them as root comments
+                if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
+                    foreach ($tree[$comment_id]['child'] as $child_id) {
+                        $this->renderThreadView($child_id, $admin_view, false);
+                    }
+                }
+                return;
+            } else {
+                $text = $tree[$comment_id]['obj']->getVar('com_text');
+            }
+        }
+        $replies = array();
+        $this->_renderThreadReplies($tree, $comment_id, $replies, '&nbsp;&nbsp;', $admin_view);
+        $show_replies = (count($replies) > 0) ? true : false;
+        $this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies, 'show_replies' => $show_replies));
+    }
+
+    /**
+     * Render replies to a thread
+     *
+     * @param   array   &$thread
+     * @param   int     $key
+     * @param   array   $replies
+     * @param   string  $prefix
+     * @param   bool    $admin_view
+     * @param   integer $depth
+     * @param   string  $current_prefix
+     *
+     * @access  private
+     **/
+    function _renderThreadReplies(&$thread, $key, &$replies, $prefix, $admin_view, $depth = 0, $current_prefix = '')
+    {
+        if ($depth > 0) {
+            if (false != $this->_useIcons) {
+                $title = $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).'&nbsp;'.$thread[$key]['obj']->getVar('com_title');
+            } else {
+                $title = $thread[$key]['obj']->getVar('com_title');
+            }
+            $title = (false != $admin_view) ? $title.' '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')] : $title;
+            $replies[] = array('id' => $key, 'prefix' => $current_prefix, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'title' => $title, 'root_id' => $thread[$key]['obj']->getVar('com_rootid'), 'status' => $this->_statusText[$thread[$key]['obj']->getVar('com_status')], 'poster' => $this->_getPosterName($thread[$key]['obj']->getVar('com_uid')));
+            $current_prefix .= $prefix;
+        }
+        if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) {
+            $depth++;
+            foreach ($thread[$key]['child'] as $childkey) {
+                if (!$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) {
+                    // skip this comment if it is not active and continue on processing its child comments instead
+                    if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
+                        foreach ($thread[$childkey]['child'] as $childchildkey) {
+                            $this->_renderThreadReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth);
+                        }
+                    }
+                } else {
+                    $this->_renderThreadReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth, $current_prefix);
+                }
+            }
+        }
+    }
+
+    /**
+     * Render comments in nested view
+     *
+     * Danger: Recursive!
+     *
+     * @param integer $comment_id   Always "0" when called by client.
+     * @param boolean $admin_view
+     **/
+    function renderNestView($comment_id = 0, $admin_view = false)
+    {
+        include_once XOOPS_ROOT_PATH.'/class/tree.php';
+        $xot = new XoopsObjectTree($this->_comments, 'com_id', 'com_pid', 'com_rootid');
+        $tree =& $xot->getTree();
+        if (false != $this->_useIcons) {
+            $title = $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).'&nbsp;'.$tree[$comment_id]['obj']->getVar('com_title');
+        } else {
+            $title = $tree[$comment_id]['obj']->getVar('com_title');
+        }
+        if (false != $admin_view) {
+            $text = $tree[$comment_id]['obj']->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$tree[$comment_id]['obj']->getVar('com_ip').'</span></div>';
+        } else {
+            // skip this comment if it is not active and continue on processing its child comments instead
+            if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) {
+                // if there are any child comments, display them as root comments
+                if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
+                    foreach ($tree[$comment_id]['child'] as $child_id) {
+                        $this->renderNestView($child_id, $admin_view);
+                    }
+                }
+                return;
+            } else {
+                $text = $tree[$comment_id]['obj']->getVar('com_text');
+            }
+        }
+        $replies = array();
+        $this->_renderNestReplies($tree, $comment_id, $replies, 25, $admin_view);
+        $this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies));
+    }
+
+    /**
+     * Render replies in nested view
+     *
+     * @param   array   $thread
+     * @param   int     $key
+     * @param   array   $replies
+     * @param   string  $prefix
+     * @param   bool    $admin_view
+     * @param   integer $depth
+     *
+     * @access  private
+     **/
+    function _renderNestReplies(&$thread, $key, &$replies, $prefix, $admin_view, $depth = 0)
+    {
+        if ($depth > 0) {
+            if (false != $this->_useIcons) {
+                $title = $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).'&nbsp;'.$thread[$key]['obj']->getVar('com_title');
+            } else {
+                $title = $thread[$key]['obj']->getVar('com_title');
+            }
+            $text = (false != $admin_view) ? $thread[$key]['obj']->getVar('com_text').'<div style="text-align:right; margin-top: 2px; margin-right: 2px;">'._CM_STATUS.': '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')].'<br />IP: <span style="font-weight: bold;">'.$thread[$key]['obj']->getVar('com_ip').'</span></div>' : $thread[$key]['obj']->getVar('com_text');
+            $replies[] = array('id' => $key, 'prefix' => $prefix, 'pid' => $thread[$key]['obj']->getVar('com_pid'), 'itemid' => $thread[$key]['obj']->getVar('com_itemid'), 'rootid' => $thread[$key]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($thread[$key]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($thread[$key]['obj']->getVar('com_uid')));
+
+            $prefix = $prefix + 25;
+        }
+        if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) {
+            $depth++;
+            foreach ($thread[$key]['child'] as $childkey) {
+                if (!$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) {
+                    // skip this comment if it is not active and continue on processing its child comments instead
+                    if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
+                        foreach ($thread[$childkey]['child'] as $childchildkey) {
+                            $this->_renderNestReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth);
+                        }
+                    }
+                } else {
+                    $this->_renderNestReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth);
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Get the name of the poster
+     *
+     * @param   int $poster_id
+     * @return  string
+     *
+     * @access  private
+     **/
+    function _getPosterName($poster_id)
+    {
+        $poster['id'] = intval($poster_id);
+        if ($poster['id'] > 0) {
+            $com_poster =& $this->_memberHandler->getUser($poster_id);
+            if (is_object($com_poster)) {
+                $poster['uname'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'</a>';
+                return $poster;
+            }
+        }
+        $poster['id'] = 0; // to cope with deleted user accounts
+        $poster['uname'] = $GLOBALS['xoopsConfig']['anonymous'];
+        return $poster;
+    }
+
+    /**
+     * Get an array with info about the poster
+     *
+     * @param   int $poster_id
+     * @return  array
+     *
+     * @access  private
+     **/
+    function _getPosterArray($poster_id)
+    {
+        $poster['id'] = intval($poster_id);
+        if ($poster['id'] > 0) {
+            $com_poster =& $this->_memberHandler->getUser($poster['id']);
+            if (is_object($com_poster)) {
+                $poster['uname'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'</a>';
+                $poster_rank = $com_poster->rank();
+                $poster['rank_image'] = ($poster_rank['image'] != '') ? $poster_rank['image'] : 'blank.gif';
+                $poster['rank_title'] = $poster_rank['title'];
+                $poster['avatar'] = $com_poster->getVar('user_avatar');
+                $poster['regdate'] = formatTimestamp($com_poster->getVar('user_regdate'), 's');
+                $poster['from'] = $com_poster->getVar('user_from');
+                $poster['postnum'] = $com_poster->getVar('posts');
+                $poster['status'] = $com_poster->isOnline() ? _CM_ONLINE : '';
+                return $poster;
+            }
+        }
+        $poster['id'] = 0; // to cope with deleted user accounts
+        $poster['uname'] = $GLOBALS['xoopsConfig']['anonymous'];
+        $poster['rank_title'] = '';
+        $poster['avatar'] = 'blank.gif';
+        $poster['regdate'] = '';
+        $poster['from'] = '';
+        $poster['postnum'] = 0;
+        $poster['status'] = '';
+        return $poster;
+    }
+
+    /**
+     * Get the IMG tag for the title icon
+     *
+     * @param   string  $icon_image
+     * @return  string  HTML IMG tag
+     *
+     * @access  private
+     **/
+    function _getTitleIcon($icon_image)
+    {
+        $icon_image = trim($icon_image);
+        if ($icon_image != '') {
+            $icon_image = htmlspecialchars($icon_image);
+            if (false != $this->_doIconCheck) {
+                if (!file_exists(XOOPS_URL.'/images/subject/'.$icon_image)) {
+                    return '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
+                } else {
+                    return '<img src="'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />';
+                }
+            } else {
+                return '<img src="'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />';
+            }
+        }
+        return '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
+    }
+}
 ?>
\ No newline at end of file
Index: xoops2jp/html/class/module.textsanitizer.php
diff -u xoops2jp/html/class/module.textsanitizer.php:1.5 xoops2jp/html/class/module.textsanitizer.php:1.5.2.1
--- xoops2jp/html/class/module.textsanitizer.php:1.5	Mon Sep  5 05:46:08 2005
+++ xoops2jp/html/class/module.textsanitizer.php	Mon Oct 24 20:26:50 2005
@@ -1,568 +1,602 @@
-<?php
-// $Id: module.textsanitizer.php,v 1.5 2005/09/04 20:46:08 onokazu Exp $
-//  ------------------------------------------------------------------------ //
-//                XOOPS - PHP Content Management System                      //
-//                    Copyright (c) 2000 XOOPS.org                           //
-//                       <http://www.xoops.org/>                             //
-//  ------------------------------------------------------------------------ //
-//  This program is free software; you can redistribute it and/or modify     //
-//  it under the terms of the GNU General Public License as published by     //
-//  the Free Software Foundation; either version 2 of the License, or        //
-//  (at your option) any later version.                                      //
-//                                                                           //
-//  You may not change or alter any portion of this comment or credits       //
-//  of supporting developers from this source code or any supporting         //
-//  source code which is considered copyrighted (c) material of the          //
-//  original comment or credit authors.                                      //
-//                                                                           //
-//  This program is distributed in the hope that it will be useful,          //
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
-//  GNU General Public License for more details.                             //
-//                                                                           //
-//  You should have received a copy of the GNU General Public License        //
-//  along with this program; if not, write to the Free Software              //
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
-//  ------------------------------------------------------------------------ //
-// Author: Kazumi Ono (http://www.myweb.ne.jp/, http://jp.xoops.org/)        //
-//         Goghs Cheng (http://www.eqiao.com, http://www.devbeez.com/)       //
-// Project: The XOOPS Project (http://www.xoops.org/)                        //
-// ------------------------------------------------------------------------- //
-
-/**
- * Class to "clean up" text for various uses
- *
- * <b>Singleton</b>
- *
- * @package     kernel
- * @subpackage  core
- *
- * @author      Kazumi Ono  <onoka****@xoops*****>
- * @author      Goghs Cheng
- * @copyright   (c) 2000-2003 The Xoops Project - www.xoops.org
- */
-class MyTextSanitizer
-{
-    /**
-     * @var array
-     */
-    var $smileys = array();
-
-    /**
-     *
-     */
-    var $censorConf;
-
-    /*
-    * Constructor of this class
-    *
-    * Gets allowed html tags from admin config settings
-    * <br> should not be allowed since nl2br will be used
-    * when storing data.
-    *
-    * @access   private
-    *
-    * @todo Sofar, this does nuttin' ;-)
-    */
-    function MyTextSanitizer()
-    {
-
-    }
-
-    /**
-     * Access the only instance of this class
-     *
-     * @return  object
-     *
-     * @static
-     * @staticvar   object
-     */
-    function &getInstance()
-    {
-        static $instance;
-        if (!isset($instance)) {
-            $instance = new MyTextSanitizer();
-        }
-        return $instance;
-    }
-
-    /**
-     * Get the smileys
-     *
-     * @return  array
-     */
-    function getSmileys()
-    {
-        return $this->smileys;
-    }
-
-    /**
-     * Replace emoticons in the message with smiley images
-     *
-     * @param   string  $message
-     *
-     * @return  string
-     */
-    function &smiley($message)
-    {
-        $db =& Database::getInstance();
-        if (count($this->smileys) == 0) {
-            if ($getsmiles = $db->query("SELECT * FROM ".$db->prefix("smiles"))){
-                while ($smiles = $db->fetchArray($getsmiles)) {
-                    $message =& str_replace($smiles['code'], '<img src="'.XOOPS_UPLOAD_URL.'/'.htmlspecialchars($smiles['smile_url']).'" alt="" />', $message);
-                    array_push($this->smileys, $smiles);
-                }
-            }
-        }
-        elseif (is_array($this->smileys)) {
-            foreach ($this->smileys as $smile) {
-                $message =& str_replace($smile['code'], '<img src="'.XOOPS_UPLOAD_URL.'/'.htmlspecialchars($smile['smile_url']).'" alt="" />', $message);
-            }
-        }
-        return $message;
-    }
-
-    /**
-     * Make links in the text clickable
-     *
-     * @param   string  $text
-     * @return  string
-     **/
-    function &makeClickable(&$text)
-    {
-        $patterns = array("/(^|[^]_a-z0-9-=\"'\/])([a-z]+?):\/\/([^, \r\n\"\(\)'<>]+)/i", "/(^|[^]_a-z0-9-=\"'\/])www\.([a-z0-9\-]+)\.([^, \r\n\"\(\)'<>]+)/i", "/(^|[^]_a-z0-9-=\"'\/])ftp\.([a-z0-9\-]+)\.([^, \r\n\"\(\)'<>]+)/i", "/(^|[^]_a-z0-9-=\"'\/:\.])([a-z0-9\-_\.]+?)@([^, \r\n\"\(\)'<>\[\]]+)/i");
-        $replacements = array("\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", "\\1<a href=\"http://www.\\2.\\3\" target=\"_blank\">www.\\2.\\3</a>", "\\1<a href=\"ftp://ftp.\\2.\\3\" target=\"_blank\">ftp.\\2.\\3</a>", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>");
-        return preg_replace($patterns, $replacements, $text);
-    }
-
-    /**
-     * Replace XoopsCodes with their equivalent HTML formatting
-     *
-     * @param   string  $text
-     * @param   bool    $allowimage Allow images in the text?
-     *                              On FALSE, uses links to images.
-     * @return  string
-     **/
-    function &xoopsCodeDecode(&$text, $allowimage = 1)
-    {
-        $patterns = array();
-        $replacements = array();
-        // RMV: added new markup for intrasite url (allows easier site moves)
-        // TODO: automatically convert other URLs to this format if XOOPS_URL matches??
-        $patterns[] = "/\[siteurl=(['\"]?)([^\"'<>]*)\\1](.*)\[\/siteurl\]/sU";
-        $replacements[] = '<a href="'.XOOPS_URL.'/\\2" target="_blank">\\3</a>';
-        $patterns[] = "/\[url=(['\"]?)(http[s]?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
-        $replacements[] = '<a href="\\2" target="_blank">\\3</a>';
-        $patterns[] = "/\[url=(['\"]?)(ftp?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
-        $replacements[] = '<a href="\\2" target="_blank">\\3</a>';
-        $patterns[] = "/\[url=(['\"]?)([^\"'<>]*)\\1](.*)\[\/url\]/sU";
-        $replacements[] = '<a href="http://\\2" target="_blank">\\3</a>';
-        $patterns[] = "/\[color=(['\"]?)([a-zA-Z0-9]*)\\1](.*)\[\/color\]/sU";
-        $replacements[] = '<span style="color: #\\2;">\\3</span>';
-        $patterns[] = "/\[size=(['\"]?)([a-z0-9-]*)\\1](.*)\[\/size\]/sU";
-        $replacements[] = '<span style="font-size: \\2;">\\3</span>';
-        $patterns[] = "/\[font=(['\"]?)([^;<>\*\(\)\"']*)\\1](.*)\[\/font\]/sU";
-        $replacements[] = '<span style="font-family: \\2;">\\3</span>';
-        $patterns[] = "/\[email]([^;<>\*\(\)\"']*)\[\/email\]/sU";
-        $replacements[] = '<a href="mailto:\\1">\\1</a>';
-        $patterns[] = "/\[b](.*)\[\/b\]/sU";
-        $replacements[] = '<b>\\1</b>';
-        $patterns[] = "/\[i](.*)\[\/i\]/sU";
-        $replacements[] = '<i>\\1</i>';
-        $patterns[] = "/\[u](.*)\[\/u\]/sU";
-        $replacements[] = '<u>\\1</u>';
-        $patterns[] = "/\[d](.*)\[\/d\]/sU";
-        $replacements[] = '<del>\\1</del>';
-        //$patterns[] = "/\[li](.*)\[\/li\]/sU";
-        //$replacements[] = '<li>\\1</li>';
-        $patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
-        $patterns[] = "/\[img]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
-        $patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1 id=(['\"]?)([0-9]*)\\3]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
-        $patterns[] = "/\[img id=(['\"]?)([0-9]*)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
-        if ($allowimage != 1) {
-            $replacements[] = '<a href="\\3" target="_blank">\\3</a>';
-            $replacements[] = '<a href="\\1" target="_blank">\\1</a>';
-            $replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\\4" target="_blank">\\5</a>';
-            $replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\\2" target="_blank">\\3</a>';
-        } else {
-            $replacements[] = '<img src="\\3" align="\\2" alt="" />';
-            $replacements[] = '<img src="\\1" alt="" />';
-            $replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\\4" align="\\2" alt="\\5" />';
-            $replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\\2" alt="\\3" />';
-        }
-        $patterns[] = "/\[quote]/sU";
-        $replacements[] = _QUOTEC.'<div class="xoopsQuote"><blockquote>';
-        //$replacements[] = 'Quote: <div class="xoopsQuote"><blockquote>';
-        $patterns[] = "/\[\/quote]/sU";
-        $replacements[] = '</blockquote></div>';
-        $patterns[] = "/javascript:/si";
-        $replacements[] = "java script:";
-        $patterns[] = "/about:/si";
-        $replacements[] = "about :";
-        return preg_replace($patterns, $replacements, $text);
-    }
-
-    /**
-     * Convert linebreaks to <br /> tags
-     *
-     * @param   string  $text
-     *
-     * @return  string
-     */
-    function &nl2Br($text)
-    {
-        return preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$text);
-    }
-
-    /**
-     * Add slashes to the text if magic_quotes_gpc is turned off.
-     *
-     * @param   string  $text
-     * @return  string
-     **/
-    function &addSlashes($text)
-    {
-        if (!get_magic_quotes_gpc()) {
-            $text =& addslashes($text);
-        }
-        return $text;
-    }
-    /*
-    * if magic_quotes_gpc is on, stirip back slashes
-    *
-    * @param    string  $text
-    *
-    * @return   string
-    */
-    function &stripSlashesGPC($text)
-    {
-        if (get_magic_quotes_gpc()) {
-            $text =& stripslashes($text);
-        }
-        return $text;
-    }
-
-    /*
-    *  for displaying data in html textbox forms
-    *
-    * @param    string  $text
-    *
-    * @return   string
-    */
-    function &htmlSpecialChars($text)
-    {
-        //return preg_replace("/&amp;/i", '&', htmlspecialchars($text, ENT_QUOTES));
-        return preg_replace(array("/&amp;/i", "/&nbsp;/i"), array('&', '&amp;nbsp;'), htmlspecialchars($text, ENT_QUOTES));
-    }
-
-    /**
-     * Reverses {@link htmlSpecialChars()}
-     *
-     * @param   string  $text
-     * @return  string
-     **/
-    function &undoHtmlSpecialChars(&$text)
-    {
-        return preg_replace(array("/&gt;/i", "/&lt;/i", "/&quot;/i", "/&#039;/i"), array(">", "<", "\"", "'"), $text);
-    }
-
-    /**
-     * Filters textarea form data in DB for display
-     *
-     * @param   string  $text
-     * @param   bool    $html   allow html?
-     * @param   bool    $smiley allow smileys?
-     * @param   bool    $xcode  allow xoopscode?
-     * @param   bool    $image  allow inline images?
-     * @param   bool    $br     convert linebreaks?
-     * @return  string
-     **/
-    function &displayTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
-    {
-        if ($html != 1) {
-            // html not allowed
-            $text =& $this->htmlSpecialChars($text);
-        }
-        $text =& $this->codePreConv($text, $xcode); // Ryuji_edit(2003-11-18)
-        $text =& $this->makeClickable($text);
-        if ($smiley != 0) {
-            // process smiley
-            $text =& $this->smiley($text);
-        }
-        if ($xcode != 0) {
-            // decode xcode
-            if ($image != 0) {
-                // image allowed
-                $text =& $this->xoopsCodeDecode($text);
-                    } else {
-                        // image not allowed
-                        $text =& $this->xoopsCodeDecode($text, 0);
-            }
-        }
-        if ($br != 0) {
-            $text =& $this->nl2Br($text);
-        }
-        $text =& $this->codeConv($text, $xcode, $image);    // Ryuji_edit(2003-11-18)
-        return $text;
-    }
-
-    /**
-     * Filters textarea form data submitted for preview
-     *
-     * @param   string  $text
-     * @param   bool    $html   allow html?
-     * @param   bool    $smiley allow smileys?
-     * @param   bool    $xcode  allow xoopscode?
-     * @param   bool    $image  allow inline images?
-     * @param   bool    $br     convert linebreaks?
-     * @return  string
-     **/
-    function &previewTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
-    {
-        $text =& $this->stripSlashesGPC($text);
-        if ($html != 1) {
-            // html not allowed
-            $text =& $this->htmlSpecialChars($text);
-        }
-        $text =& $this->codePreConv($text, $xcode); // Ryuji_edit(2003-11-18)
-        $text =& $this->makeClickable($text);
-        if ($smiley != 0) {
-            // process smiley
-            $text =& $this->smiley($text);
-        }
-        if ($xcode != 0) {
-            // decode xcode
-            if ($image != 0) {
-                // image allowed
-                $text =& $this->xoopsCodeDecode($text);
-            } else {
-                // image not allowed
-                $text =& $this->xoopsCodeDecode($text, 0);
-            }
-        }
-        if ($br != 0) {
-            $text =& $this->nl2Br($text);
-        }
-        $text =& $this->codeConv($text, $xcode, $image);    // Ryuji_edit(2003-11-18)
-        return $text;
-    }
-
-    /**
-     * Replaces banned words in a string with their replacements
-     *
-     * @param   string $text
-     * @return  string
-     *
-     * @deprecated
-     **/
-    function &censorString(&$text)
-    {
-        if (!isset($this->censorConf)) {
-            $config_handler =& xoops_gethandler('config');
-            $this->censorConf =& $config_handler->getConfigsByCat(XOOPS_CONF_CENSOR);
-        }
-        if ($this->censorConf['censor_enable'] == 1) {
-            $replacement = $this->censorConf['censor_replace'];
-            foreach ($this->censorConf['censor_words'] as $bad) {
-                if ( !empty($bad) ) {
-                    $bad = quotemeta($bad);
-                    $patterns[] = "/(\s)".$bad."/siU";
-                    $replacements[] = "\\1".$replacement;
-                    $patterns[] = "/^".$bad."/siU";
-                    $replacements[] = $replacement;
-                    $patterns[] = "/(\n)".$bad."/siU";
-                    $replacements[] = "\\1".$replacement;
-                    $patterns[] = "/]".$bad."/siU";
-                    $replacements[] = "]".$replacement;
-                    $text = preg_replace($patterns, $replacements, $text);
-                }
-            }
-        }
-        return $text;
-    }
-
-
-    /**#@+
-     * Sanitizing of [code] tag
-     */
-    function codePreConv($text, $xcode = 1) {
-        if($xcode != 0){
-            $patterns = "/\[code](.*)\[\/code\]/esU";
-            $replacements = "'[code]'.base64_encode('$1').'[/code]'";
-            $text =  preg_replace($patterns, $replacements, $text);
-        }
-        return $text;
-    }
-
-    function codeConv($text, $xcode = 1, $image = 1){
-        if($xcode != 0){
-            $patterns = "/\[code](.*)\[\/code\]/esU";
-            if ($image != 0) {
-                // image allowed
-                $replacements = "'<div class=\"xoopsCode\"><pre><code>'.MyTextSanitizer::codeSanitizer('$1').'</code></pre></div>'";
-                //$text =& $this->xoopsCodeDecode($text);
-            } else {
-                // image not allowed
-                $replacements = "'<div class=\"xoopsCode\"><pre><code>'.MyTextSanitizer::codeSanitizer('$1', 0).'</code></pre></div>'";
-                //$text =& $this->xoopsCodeDecode($text, 0);
-            }
-            $text =  preg_replace($patterns, $replacements, $text);
-        }
-        return $text;
-    }
-
-    function codeSanitizer($str, $image = 1){
-        if($image != 0){
-            $str = $this->xoopsCodeDecode(
-                $this->htmlSpecialChars(str_replace('\"', '"', base64_decode($str)))
-                );
-        }else{
-            $str = $this->xoopsCodeDecode(
-                $this->htmlSpecialChars(str_replace('\"', '"', base64_decode($str))),0
-                );
-        }
-        return $str;
-    }
-
-
-    /**#@-*/
-
-
-##################### Deprecated Methods ######################
-
-    /**#@+
-     * @deprecated
-     */
-    function sanitizeForDisplay($text, $allowhtml = 0, $smiley = 1, $bbcode = 1)
-    {
-        if ( $allowhtml == 0 ) {
-            $text = $this->htmlSpecialChars($text);
-        } else {
-            //$config =& $GLOBALS['xoopsConfig'];
-            //$allowed = $config['allowed_html'];
-            //$text = strip_tags($text, $allowed);
-            $text = $this->makeClickable($text);
-        }
-        if ( $smiley == 1 ) {
-            $text = $this->smiley($text);
-        }
-        if ( $bbcode == 1 ) {
-            $text = $this->xoopsCodeDecode($text);
-        }
-        $text = $this->nl2Br($text);
-        return $text;
-    }
-
-    function sanitizeForPreview($text, $allowhtml = 0, $smiley = 1, $bbcode = 1)
-    {
-        $text = $this->oopsStripSlashesGPC($text);
-        if ( $allowhtml == 0 ) {
-            $text = $this->htmlSpecialChars($text);
-        } else {
-            //$config =& $GLOBALS['xoopsConfig'];
-            //$allowed = $config['allowed_html'];
-            //$text = strip_tags($text, $allowed);
-            $text = $this->makeClickable($text);
-        }
-        if ( $smiley == 1 ) {
-            $text = $this->smiley($text);
-        }
-        if ( $bbcode == 1 ) {
-            $text = $this->xoopsCodeDecode($text);
-        }
-        $text = $this->nl2Br($text);
-        return $text;
-    }
-
-    function makeTboxData4Save($text)
-    {
-        //$text = $this->undoHtmlSpecialChars($text);
-        return $this->addSlashes($text);
-    }
-
-    function makeTboxData4Show($text, $smiley=0)
-    {
-        $text = $this->htmlSpecialChars($text);
-        return $text;
-    }
-
-    function makeTboxData4Edit($text)
-    {
-        return $this->htmlSpecialChars($text);
-    }
-
-    function makeTboxData4Preview($text, $smiley=0)
-    {
-        $text = $this->stripSlashesGPC($text);
-        $text = $this->htmlSpecialChars($text);
-        return $text;
-    }
-
-    function makeTboxData4PreviewInForm($text)
-    {
-        $text = $this->stripSlashesGPC($text);
-        return $this->htmlSpecialChars($text);
-    }
-
-    function makeTareaData4Save($text)
-    {
-        return $this->addSlashes($text);
-    }
-
-    function &makeTareaData4Show(&$text, $html=1, $smiley=1, $xcode=1)
-    {
-        return $this->displayTarea($text, $html, $smiley, $xcode);
-    }
-
-    function makeTareaData4Edit($text)
-    {
-        return $this->htmlSpecialChars($text);
-    }
-
-    function &makeTareaData4Preview(&$text, $html=1, $smiley=1, $xcode=1)
-    {
-        return $this->previewTarea($text, $html, $smiley, $xcode);
-    }
-
-    function makeTareaData4PreviewInForm($text)
-    {
-        //if magic_quotes_gpc is on, do stipslashes
-        $text = $this->stripSlashesGPC($text);
-        return $this->htmlSpecialChars($text);
-    }
-
-    function makeTareaData4InsideQuotes($text)
-    {
-        return $this->htmlSpecialChars($text);
-    }
-
-    function &oopsStripSlashesGPC($text)
-    {
-        return $this->stripSlashesGPC($text);
-    }
-
-    function &oopsStripSlashesRT($text)
-    {
-        if (get_magic_quotes_runtime()) {
-            $text =& stripslashes($text);
-        }
-        return $text;
-    }
-
-    function &oopsAddSlashes($text)
-    {
-        return $this->addSlashes($text);
-    }
-
-    function &oopsHtmlSpecialChars($text)
-    {
-        return $this->htmlSpecialChars($text);
-    }
-
-    function &oopsNl2Br($text)
-    {
-        return $this->nl2br($text);
-    }
-    /**#@-*/
-}
+<?php
+// $Id: module.textsanitizer.php,v 1.5.2.1 2005/10/24 11:26:50 onokazu Exp $
+//  ------------------------------------------------------------------------ //
+//                XOOPS - PHP Content Management System                      //
+//                    Copyright (c) 2000 XOOPS.org                           //
+//                       <http://www.xoops.org/>                             //
+//  ------------------------------------------------------------------------ //
+//  This program is free software; you can redistribute it and/or modify     //
+//  it under the terms of the GNU General Public License as published by     //
+//  the Free Software Foundation; either version 2 of the License, or        //
+//  (at your option) any later version.                                      //
+//                                                                           //
+//  You may not change or alter any portion of this comment or credits       //
+//  of supporting developers from this source code or any supporting         //
+//  source code which is considered copyrighted (c) material of the          //
+//  original comment or credit authors.                                      //
+//                                                                           //
+//  This program is distributed in the hope that it will be useful,          //
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
+//  GNU General Public License for more details.                             //
+//                                                                           //
+//  You should have received a copy of the GNU General Public License        //
+//  along with this program; if not, write to the Free Software              //
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
+//  ------------------------------------------------------------------------ //
+// Author: Kazumi Ono (http://www.myweb.ne.jp/, http://jp.xoops.org/)        //
+//         Goghs Cheng (http://www.eqiao.com, http://www.devbeez.com/)       //
+// Project: The XOOPS Project (http://www.xoops.org/)                        //
+// ------------------------------------------------------------------------- //
+
+/**
+ * Class to "clean up" text for various uses
+ *
+ * <b>Singleton</b>
+ *
+ * @package     kernel
+ * @subpackage  core
+ *
+ * @author      Kazumi Ono  <onoka****@xoops*****>
+ * @author      Goghs Cheng
+ * @copyright   (c) 2000-2003 The Xoops Project - www.xoops.org
+ */
+class MyTextSanitizer
+{
+    /**
+     * @var array
+     */
+    var $smileys = array();
+
+    /**
+     *
+     */
+    var $censorConf;
+
+    /*
+    * Constructor of this class
+    *
+    * Gets allowed html tags from admin config settings
+    * <br> should not be allowed since nl2br will be used
+    * when storing data.
+    *
+    * @access   private
+    *
+    * @todo Sofar, this does nuttin' ;-)
+    */
+    function MyTextSanitizer()
+    {
+
+    }
+
+    /**
+     * Access the only instance of this class
+     *
+     * @return  object
+     *
+     * @static
+     * @staticvar   object
+     */
+    function &getInstance()
+    {
+        static $instance;
+        if (!isset($instance)) {
+            $instance = new MyTextSanitizer();
+        }
+        return $instance;
+    }
+
+    /**
+     * Get the smileys
+     *
+     * @return  array
+     */
+    function getSmileys()
+    {
+        return $this->smileys;
+    }
+
+    /**
+     * Replace emoticons in the message with smiley images
+     *
+     * @param   string  $message
+     *
+     * @return  string
+     */
+    function &smiley($message)
+    {
+        $db =& Database::getInstance();
+        if (count($this->smileys) == 0) {
+            if ($getsmiles = $db->query("SELECT * FROM ".$db->prefix("smiles"))){
+                while ($smiles = $db->fetchArray($getsmiles)) {
+                    $message =& str_replace($smiles['code'], '<img src="'.XOOPS_UPLOAD_URL.'/'.htmlspecialchars($smiles['smile_url']).'" alt="" />', $message);
+                    array_push($this->smileys, $smiles);
+                }
+            }
+        }
+        elseif (is_array($this->smileys)) {
+            foreach ($this->smileys as $smile) {
+                $message =& str_replace($smile['code'], '<img src="'.XOOPS_UPLOAD_URL.'/'.htmlspecialchars($smile['smile_url']).'" alt="" />', $message);
+            }
+        }
+        return $message;
+    }
+
+    /**
+     * Make links in the text clickable
+     *
+     * @param   string  $text
+     * @return  string
+     **/
+    function &makeClickable(&$text)
+    {
+        $patterns = array("/(^|[^]_a-z0-9-=\"'\/])([a-z]+?):\/\/([^, \r\n\"\(\)'<>]+)/i", "/(^|[^]_a-z0-9-=\"'\/])www\.([a-z0-9\-]+)\.([^, \r\n\"\(\)'<>]+)/i", "/(^|[^]_a-z0-9-=\"'\/])ftp\.([a-z0-9\-]+)\.([^, \r\n\"\(\)'<>]+)/i", "/(^|[^]_a-z0-9-=\"'\/:\.])([a-z0-9\-_\.]+?)@([^, \r\n\"\(\)'<>\[\]]+)/i");
+        $replacements = array("\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", "\\1<a href=\"http://www.\\2.\\3\" target=\"_blank\">www.\\2.\\3</a>", "\\1<a href=\"ftp://ftp.\\2.\\3\" target=\"_blank\">ftp.\\2.\\3</a>", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>");
+        return preg_replace($patterns, $replacements, $text);
+    }
+
+    /**
+     * Replace XoopsCodes with their equivalent HTML formatting
+     *
+     * @param   string  $text
+     * @param   bool    $allowimage Allow images in the text?
+     *                              On FALSE, uses links to images.
+     * @return  string
+     **/
+    function &xoopsCodeDecode(&$text, $allowimage = 1)
+    {
+        $imgCallbackPattern = "/\[img( align=\w+)]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
+        $text = preg_replace_callback($imgCallbackPattern, array($this, '_filterImgUrl'), $text);
+
+        $patterns = array();
+        $replacements = array();
+        // RMV: added new markup for intrasite url (allows easier site moves)
+        // TODO: automatically convert other URLs to this format if XOOPS_URL matches??
+        $patterns[] = "/\[siteurl=(['\"]?)([^\"'<>]*)\\1](.*)\[\/siteurl\]/sU";
+        $replacements[] = '<a href="'.XOOPS_URL.'/\\2" target="_blank">\\3</a>';
+        $patterns[] = "/\[url=(['\"]?)(http[s]?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
+        $replacements[] = '<a href="\\2" target="_blank">\\3</a>';
+        $patterns[] = "/\[url=(['\"]?)(ftp?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
+        $replacements[] = '<a href="\\2" target="_blank">\\3</a>';
+        $patterns[] = "/\[url=(['\"]?)([^\"'<>]*)\\1](.*)\[\/url\]/sU";
+        $replacements[] = '<a href="http://\\2" target="_blank">\\3</a>';
+        $patterns[] = "/\[color=(['\"]?)([a-zA-Z0-9]*)\\1](.*)\[\/color\]/sU";
+        $replacements[] = '<span style="color: #\\2;">\\3</span>';
+        $patterns[] = "/\[size=(['\"]?)([a-z0-9-]*)\\1](.*)\[\/size\]/sU";
+        $replacements[] = '<span style="font-size: \\2;">\\3</span>';
+        $patterns[] = "/\[font=(['\"]?)([^;<>\*\(\)\"']*)\\1](.*)\[\/font\]/sU";
+        $replacements[] = '<span style="font-family: \\2;">\\3</span>';
+        $patterns[] = "/\[email]([^;<>\*\(\)\"']*)\[\/email\]/sU";
+        $replacements[] = '<a href="mailto:\\1">\\1</a>';
+        $patterns[] = "/\[b](.*)\[\/b\]/sU";
+        $replacements[] = '<b>\\1</b>';
+        $patterns[] = "/\[i](.*)\[\/i\]/sU";
+        $replacements[] = '<i>\\1</i>';
+        $patterns[] = "/\[u](.*)\[\/u\]/sU";
+        $replacements[] = '<u>\\1</u>';
+        $patterns[] = "/\[d](.*)\[\/d\]/sU";
+        $replacements[] = '<del>\\1</del>';
+        //$patterns[] = "/\[li](.*)\[\/li\]/sU";
+        //$replacements[] = '<li>\\1</li>';
+        $patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
+        $patterns[] = "/\[img]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
+        $patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1 id=(['\"]?)([0-9]*)\\3]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
+        $patterns[] = "/\[img id=(['\"]?)([0-9]*)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
+        if ($allowimage != 1) {
+            $replacements[] = '<a href="\\3" target="_blank">\\3</a>';
+            $replacements[] = '<a href="\\1" target="_blank">\\1</a>';
+            $replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\\4" target="_blank">\\5</a>';
+            $replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\\2" target="_blank">\\3</a>';
+        } else {
+            $replacements[] = '<img src="\\3" align="\\2" alt="" />';
+            $replacements[] = '<img src="\\1" alt="" />';
+            $replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\\4" align="\\2" alt="\\5" />';
+            $replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\\2" alt="\\3" />';
+        }
+        $patterns[] = "/\[quote]/sU";
+        $replacements[] = _QUOTEC.'<div class="xoopsQuote"><blockquote>';
+        //$replacements[] = 'Quote: <div class="xoopsQuote"><blockquote>';
+        $patterns[] = "/\[\/quote]/sU";
+        $replacements[] = '</blockquote></div>';
+        $patterns[] = "/javascript:/si";
+        $replacements[] = "java script:";
+        $patterns[] = "/about:/si";
+        $replacements[] = "about :";
+        return preg_replace($patterns, $replacements, $text);
+    }
+
+    /**
+     * Filters out invalid strings included in URL, if any
+     *
+     * @param   array  $matches
+     * @return  string
+     */
+    function _filterImgUrl($matches)
+    {
+        if ($this->checkUrlString($matches[2])) {
+            return $matches[0];
+        } else {
+            return "";
+        }
+    }
+
+    /**
+     * Checks if invalid strings are included in URL
+     *
+     * @param   string  $text
+     * @return  bool
+     */
+    function checkUrlString($text)
+    {
+        // Check control code
+        if (preg_match("/[\\0-\\31]/", $text)) {
+            return false;
+        }
+        // check black pattern(deprecated)
+        return !preg_match("/^(javascript|vbscript|about):/i", $text);
+    }
+
+    /**
+     * Convert linebreaks to <br /> tags
+     *
+     * @param   string  $text
+     *
+     * @return  string
+     */
+    function &nl2Br($text)
+    {
+        return preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$text);
+    }
+
+    /**
+     * Add slashes to the text if magic_quotes_gpc is turned off.
+     *
+     * @param   string  $text
+     * @return  string
+     **/
+    function &addSlashes($text)
+    {
+        if (!get_magic_quotes_gpc()) {
+            $text =& addslashes($text);
+        }
+        return $text;
+    }
+    /*
+    * if magic_quotes_gpc is on, stirip back slashes
+    *
+    * @param    string  $text
+    *
+    * @return   string
+    */
+    function &stripSlashesGPC($text)
+    {
+        if (get_magic_quotes_gpc()) {
+            $text =& stripslashes($text);
+        }
+        return $text;
+    }
+
+    /*
+    *  for displaying data in html textbox forms
+    *
+    * @param    string  $text
+    *
+    * @return   string
+    */
+    function &htmlSpecialChars($text)
+    {
+        //return preg_replace("/&amp;/i", '&', htmlspecialchars($text, ENT_QUOTES));
+        return preg_replace(array("/&amp;/i", "/&nbsp;/i"), array('&', '&amp;nbsp;'), htmlspecialchars($text, ENT_QUOTES));
+    }
+
+    /**
+     * Reverses {@link htmlSpecialChars()}
+     *
+     * @param   string  $text
+     * @return  string
+     **/
+    function &undoHtmlSpecialChars(&$text)
+    {
+        return preg_replace(array("/&gt;/i", "/&lt;/i", "/&quot;/i", "/&#039;/i"), array(">", "<", "\"", "'"), $text);
+    }
+
+    /**
+     * Filters textarea form data in DB for display
+     *
+     * @param   string  $text
+     * @param   bool    $html   allow html?
+     * @param   bool    $smiley allow smileys?
+     * @param   bool    $xcode  allow xoopscode?
+     * @param   bool    $image  allow inline images?
+     * @param   bool    $br     convert linebreaks?
+     * @return  string
+     **/
+    function &displayTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
+    {
+        if ($html != 1) {
+            // html not allowed
+            $text =& $this->htmlSpecialChars($text);
+        }
+        $text =& $this->codePreConv($text, $xcode); // Ryuji_edit(2003-11-18)
+        $text =& $this->makeClickable($text);
+        if ($smiley != 0) {
+            // process smiley
+            $text =& $this->smiley($text);
+        }
+        if ($xcode != 0) {
+            // decode xcode
+            if ($image != 0) {
+                // image allowed
+                $text =& $this->xoopsCodeDecode($text);
+                    } else {
+                        // image not allowed
+                        $text =& $this->xoopsCodeDecode($text, 0);
+            }
+        }
+        if ($br != 0) {
+            $text =& $this->nl2Br($text);
+        }
+        $text =& $this->codeConv($text, $xcode, $image);    // Ryuji_edit(2003-11-18)
+        return $text;
+    }
+
+    /**
+     * Filters textarea form data submitted for preview
+     *
+     * @param   string  $text
+     * @param   bool    $html   allow html?
+     * @param   bool    $smiley allow smileys?
+     * @param   bool    $xcode  allow xoopscode?
+     * @param   bool    $image  allow inline images?
+     * @param   bool    $br     convert linebreaks?
+     * @return  string
+     **/
+    function &previewTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
+    {
+        $text =& $this->stripSlashesGPC($text);
+        if ($html != 1) {
+            // html not allowed
+            $text =& $this->htmlSpecialChars($text);
+        }
+        $text =& $this->codePreConv($text, $xcode); // Ryuji_edit(2003-11-18)
+        $text =& $this->makeClickable($text);
+        if ($smiley != 0) {
+            // process smiley
+            $text =& $this->smiley($text);
+        }
+        if ($xcode != 0) {
+            // decode xcode
+            if ($image != 0) {
+                // image allowed
+                $text =& $this->xoopsCodeDecode($text);
+            } else {
+                // image not allowed
+                $text =& $this->xoopsCodeDecode($text, 0);
+            }
+        }
+        if ($br != 0) {
+            $text =& $this->nl2Br($text);
+        }
+        $text =& $this->codeConv($text, $xcode, $image);    // Ryuji_edit(2003-11-18)
+        return $text;
+    }
+
+    /**
+     * Replaces banned words in a string with their replacements
+     *
+     * @param   string $text
+     * @return  string
+     *
+     * @deprecated
+     **/
+    function &censorString(&$text)
+    {
+        if (!isset($this->censorConf)) {
+            $config_handler =& xoops_gethandler('config');
+            $this->censorConf =& $config_handler->getConfigsByCat(XOOPS_CONF_CENSOR);
+        }
+        if ($this->censorConf['censor_enable'] == 1) {
+            $replacement = $this->censorConf['censor_replace'];
+            foreach ($this->censorConf['censor_words'] as $bad) {
+                if ( !empty($bad) ) {
+                    $bad = quotemeta($bad);
+                    $patterns[] = "/(\s)".$bad."/siU";
+                    $replacements[] = "\\1".$replacement;
+                    $patterns[] = "/^".$bad."/siU";
+                    $replacements[] = $replacement;
+                    $patterns[] = "/(\n)".$bad."/siU";
+                    $replacements[] = "\\1".$replacement;
+                    $patterns[] = "/]".$bad."/siU";
+                    $replacements[] = "]".$replacement;
+                    $text = preg_replace($patterns, $replacements, $text);
+                }
+            }
+        }
+        return $text;
+    }
+
+
+    /**#@+
+     * Sanitizing of [code] tag
+     */
+    function codePreConv($text, $xcode = 1) {
+        if($xcode != 0){
+            $patterns = "/\[code](.*)\[\/code\]/esU";
+            $replacements = "'[code]'.base64_encode('$1').'[/code]'";
+            $text =  preg_replace($patterns, $replacements, $text);
+        }
+        return $text;
+    }
+
+    function codeConv($text, $xcode = 1, $image = 1){
+        if($xcode != 0){
+            $patterns = "/\[code](.*)\[\/code\]/esU";
+            if ($image != 0) {
+                // image allowed
+                $replacements = "'<div class=\"xoopsCode\"><pre><code>'.MyTextSanitizer::codeSanitizer('$1').'</code></pre></div>'";
+                //$text =& $this->xoopsCodeDecode($text);
+            } else {
+                // image not allowed
+                $replacements = "'<div class=\"xoopsCode\"><pre><code>'.MyTextSanitizer::codeSanitizer('$1', 0).'</code></pre></div>'";
+                //$text =& $this->xoopsCodeDecode($text, 0);
+            }
+            $text =  preg_replace($patterns, $replacements, $text);
+        }
+        return $text;
+    }
+
+    function codeSanitizer($str, $image = 1){
+        if($image != 0){
+            $str = $this->xoopsCodeDecode(
+                $this->htmlSpecialChars(str_replace('\"', '"', base64_decode($str)))
+                );
+        }else{
+            $str = $this->xoopsCodeDecode(
+                $this->htmlSpecialChars(str_replace('\"', '"', base64_decode($str))),0
+                );
+        }
+        return $str;
+    }
+
+
+    /**#@-*/
+
+
+##################### Deprecated Methods ######################
+
+    /**#@+
+     * @deprecated
+     */
+    function sanitizeForDisplay($text, $allowhtml = 0, $smiley = 1, $bbcode = 1)
+    {
+        if ( $allowhtml == 0 ) {
+            $text = $this->htmlSpecialChars($text);
+        } else {
+            //$config =& $GLOBALS['xoopsConfig'];
+            //$allowed = $config['allowed_html'];
+            //$text = strip_tags($text, $allowed);
+            $text = $this->makeClickable($text);
+        }
+        if ( $smiley == 1 ) {
+            $text = $this->smiley($text);
+        }
+        if ( $bbcode == 1 ) {
+            $text = $this->xoopsCodeDecode($text);
+        }
+        $text = $this->nl2Br($text);
+        return $text;
+    }
+
+    function sanitizeForPreview($text, $allowhtml = 0, $smiley = 1, $bbcode = 1)
+    {
+        $text = $this->oopsStripSlashesGPC($text);
+        if ( $allowhtml == 0 ) {
+            $text = $this->htmlSpecialChars($text);
+        } else {
+            //$config =& $GLOBALS['xoopsConfig'];
+            //$allowed = $config['allowed_html'];
+            //$text = strip_tags($text, $allowed);
+            $text = $this->makeClickable($text);
+        }
+        if ( $smiley == 1 ) {
+            $text = $this->smiley($text);
+        }
+        if ( $bbcode == 1 ) {
+            $text = $this->xoopsCodeDecode($text);
+        }
+        $text = $this->nl2Br($text);
+        return $text;
+    }
+
+    function makeTboxData4Save($text)
+    {
+        //$text = $this->undoHtmlSpecialChars($text);
+        return $this->addSlashes($text);
+    }
+
+    function makeTboxData4Show($text, $smiley=0)
+    {
+        $text = $this->htmlSpecialChars($text);
+        return $text;
+    }
+
+    function makeTboxData4Edit($text)
+    {
+        return $this->htmlSpecialChars($text);
+    }
+
+    function makeTboxData4Preview($text, $smiley=0)
+    {
+        $text = $this->stripSlashesGPC($text);
+        $text = $this->htmlSpecialChars($text);
+        return $text;
+    }
+
+    function makeTboxData4PreviewInForm($text)
+    {
+        $text = $this->stripSlashesGPC($text);
+        return $this->htmlSpecialChars($text);
+    }
+
+    function makeTareaData4Save($text)
+    {
+        return $this->addSlashes($text);
+    }
+
+    function &makeTareaData4Show(&$text, $html=1, $smiley=1, $xcode=1)
+    {
+        return $this->displayTarea($text, $html, $smiley, $xcode);
+    }
+
+    function makeTareaData4Edit($text)
+    {
+        return $this->htmlSpecialChars($text);
+    }
+
+    function &makeTareaData4Preview(&$text, $html=1, $smiley=1, $xcode=1)
+    {
+        return $this->previewTarea($text, $html, $smiley, $xcode);
+    }
+
+    function makeTareaData4PreviewInForm($text)
+    {
+        //if magic_quotes_gpc is on, do stipslashes
+        $text = $this->stripSlashesGPC($text);
+        return $this->htmlSpecialChars($text);
+    }
+
+    function makeTareaData4InsideQuotes($text)
+    {
+        return $this->htmlSpecialChars($text);
+    }
+
+    function &oopsStripSlashesGPC($text)
+    {
+        return $this->stripSlashesGPC($text);
+    }
+
+    function &oopsStripSlashesRT($text)
+    {
+        if (get_magic_quotes_runtime()) {
+            $text =& stripslashes($text);
+        }
+        return $text;
+    }
+
+    function &oopsAddSlashes($text)
+    {
+        return $this->addSlashes($text);
+    }
+
+    function &oopsHtmlSpecialChars($text)
+    {
+        return $this->htmlSpecialChars($text);
+    }
+
+    function &oopsNl2Br($text)
+    {
+        return $this->nl2br($text);
+    }
+    /**#@-*/
+}
 ?>
\ No newline at end of file


xoops-cvslog メーリングリストの案内
Back to archive index