43 $this->image_path = XOOPS_URL .
'/images/form';
67 if (
false === strpos(
$path,
'/')) {
68 if (is_dir(
$ts->path_basic .
'/' .
$path)) {
71 if (is_dir(
$ts->path_plugin .
'/' .
$path)) {
77 $config_default = array();
78 $config_custom = array();
79 if (file_exists(
$path .
'/config.php')) {
80 $config_default = include
$path .
'/config.php';
82 if (file_exists(
$path .
'/config.custom.php')) {
83 $config_custom = include
$path .
'/config.custom.php';
85 return $this->
mergeConfig($config_default, $config_custom);
97 if (is_array($config_custom)) {
98 foreach ($config_custom as $key => $val) {
99 if (is_array($config_default[$key])) {
100 $config_default[$key] = $this->
mergeConfig($config_default[$key], $config_custom[$key]);
102 $config_default[$key] = $val;
106 return $config_default;
169 $this->path_basic = XOOPS_ROOT_PATH .
'/class/textsanitizer';
170 $this->path_plugin = XOOPS_ROOT_PATH .
'/Frameworks/textsanitizer';
200 $config_default = include $this->path_basic .
'/config.php';
201 $config_custom = array();
202 if (file_exists(
$file = $this->path_basic .
'/config.custom.php')) {
203 $config_custom = include
$file;
205 return $this->
mergeConfig($config_default, $config_custom);
217 if (is_array($config_custom)) {
218 foreach ($config_custom as $key => $val) {
219 if (isset($config_default[$key]) && is_array($config_default[$key])) {
220 $config_default[$key] = $this->
mergeConfig($config_default[$key], $config_custom[$key]);
222 $config_default[$key] = $val;
226 return $config_default;
239 if (!isset($instance)) {
253 if (count($this->smileys) == 0) {
255 if ($getsmiles =
$xoopsDB->query(
'SELECT * FROM ' .
$xoopsDB->prefix(
'smiles'))) {
256 while ($smiles =
$xoopsDB->fetchArray($getsmiles)) {
257 array_push($this->smileys, $smiles);
266 foreach($this->smileys as $smile) {
267 if (empty($smile[
'display'])) {
285 $message = str_replace($smile[
'code'],
'<img class="imgsmile" src="' .
XOOPS_UPLOAD_URL .
'/' . htmlspecialchars($smile[
'smile_url']) .
'" alt="" />', $message);
297 $valid_chars =
"a-z0-9\/\-_+=.~!%@?#&;:$\|";
298 $end_chars =
"a-z0-9\/\-_+=~!%@?#&;:$\|";
303 $patterns[] =
"/(^|[^]_a-z0-9-=\"'\/])([a-z]+?):\/\/([{$valid_chars}]+[{$end_chars}])/ei";
304 $replacements[] =
"'\\1<a href=\"\\2://\\3\" title=\"\\2://\\3\" rel=\"external\">\\2://'.MyTextSanitizer::truncate( '\\3' ).'</a>'";
306 $patterns[] =
"/(^|[^]_a-z0-9-=\"'\/:\.])www\.((([a-zA-Z0-9\-]*\.){1,}){1}([a-zA-Z]{2,6}){1})((\/([a-zA-Z0-9\-\._\?\,\'\/\\+&%\$#\=~])*)*)/ei";
307 $replacements[] =
"'\\1<a href=\"http://www.\\2\\6\" title=\"www.\\2\\6\" rel=\"external\">'.MyTextSanitizer::truncate( 'www.\\2\\6' ).'</a>'";
309 $patterns[] =
"/(^|[^]_a-z0-9-=\"'\/])ftp\.([a-z0-9\-]+)\.([{$valid_chars}]+[{$end_chars}])/ei";
310 $replacements[] =
"'\\1<a href=\"ftp://ftp.\\2.\\3\" title=\"ftp.\\2.\\3\" rel=\"external\">'.MyTextSanitizer::truncate( 'ftp.\\2.\\3' ).'</a>'";
312 $patterns[] =
"/(^|[^]_a-z0-9-=\"'\/:\.])([-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+)@((?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?)/ei";
313 $replacements[] =
"'\\1<a href=\"mailto:\\2@\\3\" title=\"\\2@\\3\">'.MyTextSanitizer::truncate( '\\2@\\3' ).'</a>'";
328 if (empty(
$text) || empty($instance->config[
'truncate_length']) || strlen(
$text) < $instance->config[
'truncate_length']) {
331 $len = floor($instance->config[
'truncate_length'] / 2);
332 $ret = substr(
$text, 0, $len) .
' ... ' . substr(
$text, 5 - $len);
348 $patterns[] =
"/\[siteurl=(['\"]?)([^\"'<>]*)\\1](.*)\[\/siteurl\]/sU";
349 $replacements[] =
'<a href="' . XOOPS_URL .
'/\\2" title="">\\3</a>';
350 $patterns[] =
"/\[url=(['\"]?)(http[s]?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
351 $replacements[] =
'<a href="\\2" rel="external" title="">\\3</a>';
352 $patterns[] =
"/\[url=(['\"]?)(ftp?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
353 $replacements[] =
'<a href="\\2" rel="external" title="">\\3</a>';
354 $patterns[] =
"/\[url=(['\"]?)([^'\"<>]*)\\1](.*)\[\/url\]/sU";
355 $replacements[] =
'<a href="http://\\2" rel="external" title="">\\3</a>';
356 $patterns[] =
"/\[color=(['\"]?)([a-zA-Z0-9]*)\\1](.*)\[\/color\]/sU";
358 $patterns[] =
"/\[size=(['\"]?)([a-z0-9-]*)\\1](.*)\[\/size\]/sU";
359 $replacements[] =
'<span style="font-size: \\2;">\\3</span>';
360 $patterns[] =
"/\[font=(['\"]?)([^;<>\*\(\)\"']*)\\1](.*)\[\/font\]/sU";
361 $replacements[] =
'<span style="font-family: \\2;">\\3</span>';
362 $patterns[] =
"/\[email]([^;<>\*\(\)\"']*)\[\/email\]/sU";
373 $patterns[] =
"/\[center](.*)\[\/center\]/sU";
374 $replacements[] =
'<div style="text-align: center;">\\1</div>';
375 $patterns[] =
"/\[left](.*)\[\/left\]/sU";
376 $replacements[] =
'<div style="text-align: left;">\\1</div>';
377 $patterns[] =
"/\[right](.*)\[\/right\]/sU";
378 $replacements[] =
'<div style="text-align: right;">\\1</div>';
384 $this->config[
'allowimage'] = $allowimage;
387 $text = preg_replace($this->patterns, $this->replacements, $this->text);
401 $pattern =
"/\[quote](.*)\[\/quote\]/sU";
402 $replacement =
_QUOTEC .
'<div class="xoopsQuote"><blockquote>\\1</blockquote></div>';
404 $text = preg_replace($pattern, $replacement,
$text, -1, $count);
424 $patterns[] =
"/\bj{$c}a{$c}v{$c}a{$c}s{$c}c{$c}r{$c}i{$c}p{$c}t{$c}[\s]*:/si";
426 $patterns[] =
"/\ba{$c}b{$c}o{$c}u{$c}t{$c}[\s]*:/si";
428 $patterns[] =
"/\bx{$c}s{$c}s{$c}[\s]*:/si";
442 return preg_replace(
'/(\015\012)|(\015)|(\012)/',
'<br />',
$text);
453 if (!get_magic_quotes_gpc()) {
467 if (get_magic_quotes_gpc()) {
484 if (version_compare(phpversion(),
'5.2.3',
'>=')) {
485 $text = htmlspecialchars(
$text, $quote_style, $charset ? $charset : (defined(
'_CHARSET') ?
_CHARSET :
'UTF-8'), $double_encode);
487 $text = htmlspecialchars(
$text, $quote_style);
489 return preg_replace(array(
'/&/i' ,
'/ /i'), array(
'&' ,
'&nbsp;'),
$text);
500 return preg_replace(array(
'/>/i' ,
'/</i' ,
'/"/i' ,
'/'/i' ,
'/&nbsp;/i'), array(
'>' ,
'<' ,
'"' ,
'\'' ,
" "),
$text);
516 $charset = (defined(
'_CHARSET') ?
_CHARSET :
'UTF-8');
517 $text = mb_convert_encoding(
$text, $charset, mb_detect_encoding(
$text,$charset.
', ISO-8859-1',
true));
542 if (!empty($this->config[
'filterxss_on_display'])) {
576 if (
$ret ===
false) {
592 $patterns =
"/\[code([^\]]*?)\](.*)\[\/code\]/esU";
593 $replacements =
"'[code\\1]'.base64_encode('\\2').'[/code]'";
611 $patterns =
"/\[code([^\]]*?)\](.*)\[\/code\]/esU";
612 $replacements =
"'<div class=\"xoopsCode\">'.\$this->executeExtension('syntaxhighlight', str_replace('\\\"', '\"', base64_decode('$2')), '$1').'</div>'";
624 $extensions = array_filter($this->config[
'extensions']);
625 if (empty($extensions)) {
628 foreach (array_keys($extensions) as $extension) {
641 if (file_exists(
$file = $this->path_basic .
'/' . $name .
'/' . $name .
'.php')) {
643 }
else if (file_exists(
$file = $this->path_plugin .
'/' . $name .
'/' . $name .
'.php')) {
648 $class =
'Myts' . ucfirst($name);
649 if (!class_exists($class)) {
650 trigger_error(
"Extension '{$name}' does not exist", E_USER_WARNING);
654 $extension =
new $class($this);
667 $args = array_slice(func_get_args(), 1);
668 return call_user_func_array(array($extension ,
'load'), array_merge(array(&$this), $args));
682 if (
$ret ===
false) {
703 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
704 $str = $this->
htmlSpecialChars(str_replace(
'\"',
'"', base64_decode($str)));
720 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
721 if ($allowhtml == 0) {
750 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
752 if ($allowhtml == 0) {
778 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
792 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
805 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
818 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
832 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
845 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
860 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
873 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
888 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
901 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
915 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
927 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
939 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
940 if (get_magic_quotes_runtime()) {
954 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
966 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
978 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
"::" . __FUNCTION__ .
' is deprecated');
979 return $this->nl2br(
$text);