1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: /**
13: * Class to "clean up" text for various uses
14: *
15: * @category Core
16: * @package Kernel
17: * @author Kazumi Ono <onokazu@xoops.org>
18: * @author Taiwen Jiang <phppp@users.sourceforge.net>
19: * @author Goghs Cheng
20: * @copyright 2000-2015 XOOPS Project (http://xoops.org)
21: * @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
22: * @link http://xoops.org
23: */
24: class MyTextSanitizer extends Xoops\Core\Text\Sanitizer
25: {
26: /**
27: * @var Sanitizer The reference to *Singleton* instance of this class
28: */
29: private static $instance;
30:
31: /**
32: * Returns the *Singleton* instance of this class.
33: *
34: * @return Sanitizer The *Singleton* instance.
35: */
36: public static function getInstance()
37: {
38: if (null === static::$instance) {
39: static::$instance = new static();
40: }
41:
42: return static::$instance;
43: }
44:
45: /**
46: * Add slashes to the text if magic_quotes_gpc is turned off.
47: *
48: * @param string $text text to not process
49: *
50: * @return string
51: *
52: * @throws LogicException
53: */
54: public function addSlashes($text)
55: {
56: throw new LogicException('GPC is dead. Please stop.');
57: return $text;
58: }
59:
60: /**
61: * if magic_quotes_gpc is on, strip back slashes
62: *
63: * @param string $text text to not process
64: *
65: * @return string
66: *
67: * @throws LogicException
68: */
69: public function stripSlashesGPC($text)
70: {
71: throw new LogicException('GPC is dead. Please stop.');
72: return $text;
73: }
74:
75: /**
76: * Filters textarea form data in DB for display
77: *
78: * @param string $text string to filter
79: * @param int $html allow html?
80: * @param int $smiley allow smileys?
81: * @param int $xcode allow xoopscode?
82: * @param int $image allow inline images?
83: * @param int $br convert linebreaks?
84: *
85: * @return string
86: */
87: public function displayTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
88: {
89: return $this->filterForDisplay($text, $html, $smiley, $xcode, $image, $br);
90: }
91:
92: /**
93: * Filters textarea form data submitted for preview
94: *
95: * @param string $text string to filter
96: * @param int $html allow html?
97: * @param int $smiley allow smileys?
98: * @param int $xcode allow xoopscode?
99: * @param int $image allow inline images?
100: * @param int $br convert linebreaks?
101: *
102: * @return string
103: */
104: public function previewTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
105: {
106: return $this->filterForDisplay($text, $html, $smiley, $xcode, $image, $br);
107: }
108: }
109: