1: | <?php
|
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: |
|
20: |
|
21: | |
22: | |
23: | |
24: | |
25: | |
26: |
|
27: | class MyTextSanitizerExtension
|
28: | {
|
29: | public $instance;
|
30: | public $myts;
|
31: | public $config;
|
32: | public $image_path;
|
33: |
|
34: | |
35: | |
36: | |
37: | |
38: |
|
39: | public function __construct(MyTextSanitizer $myts)
|
40: | {
|
41: | $this->myts = $myts;
|
42: | $this->image_path = XOOPS_URL . '/images/form';
|
43: | }
|
44: |
|
45: | |
46: | |
47: | |
48: | |
49: | |
50: |
|
51: | public static function loadConfig($path = null)
|
52: | {
|
53: | $myts = \MyTextSanitizer::getInstance();
|
54: | $extensionName = (null === $path) ? '' : basename($path);
|
55: | $pathDist = $myts->path_basic;
|
56: | $pathConfig = $myts->path_config;
|
57: |
|
58: | if ('' !== $extensionName) {
|
59: | $configFileName = $pathConfig . '/config.' . $extensionName . '.php';
|
60: | $distFileName = $pathDist . '/' . $extensionName . '/config.' . $extensionName . '.dist.php';
|
61: | } else {
|
62: | $configFileName = $pathConfig . '/config.php';
|
63: | $distFileName = $pathDist . '/config.dist.php';
|
64: | }
|
65: | if (!file_exists($configFileName)) {
|
66: | if (false === copy($distFileName, $configFileName)) {
|
67: | trigger_error('Could not create textsanitizer config file ' . basename($configFileName));
|
68: | return $a = array();
|
69: | }
|
70: | }
|
71: | $configs = include $configFileName;
|
72: | return $configs;
|
73: | }
|
74: |
|
75: | |
76: | |
77: | |
78: | |
79: | |
80: | |
81: |
|
82: | public static function mergeConfig($config_default, $config_custom)
|
83: | {
|
84: | if (is_array($config_custom)) {
|
85: | foreach ($config_custom as $key => $val) {
|
86: | if (is_array($config_default[$key])) {
|
87: | $config_default[$key] = self::mergeConfig($config_default[$key], $config_custom[$key]);
|
88: | } else {
|
89: | $config_default[$key] = $val;
|
90: | }
|
91: | }
|
92: | }
|
93: |
|
94: | return $config_default;
|
95: | }
|
96: |
|
97: | |
98: | |
99: | |
100: | |
101: | |
102: | |
103: |
|
104: | public function encode($textarea_id)
|
105: | {
|
106: | return array(array(), array());
|
107: | }
|
108: |
|
109: | |
110: | |
111: | |
112: | |
113: | |
114: | |
115: | |
116: | |
117: |
|
118: | public static function decode($url, $width, $height)
|
119: | {
|
120: | return null;
|
121: | }
|
122: | }
|
123: |
|
124: | |
125: | |
126: | |
127: | |
128: | |
129: | |
130: | |
131: | |
132: | |
133: | |
134: | |
135: |
|
136: | class MyTextSanitizer
|
137: | {
|
138: | |
139: | |
140: | |
141: |
|
142: | public $smileys = array();
|
143: |
|
144: | |
145: |
|
146: | public $censorConf;
|
147: |
|
148: | |
149: | |
150: | |
151: |
|
152: | public $text = '';
|
153: | public $patterns = array();
|
154: | public $replacements = array();
|
155: | public $callbackPatterns = array();
|
156: | public $callbacks = array();
|
157: |
|
158: | public $path_basic;
|
159: | public $path_config;
|
160: | public $path_plugin;
|
161: |
|
162: | public $config;
|
163: |
|
164: | |
165: | |
166: | |
167: | |
168: | |
169: | |
170: | |
171: | |
172: |
|
173: |
|
174: | public function __construct()
|
175: | {
|
176: | $this->path_basic = XOOPS_ROOT_PATH . '/class/textsanitizer';
|
177: | $this->path_config = XOOPS_VAR_PATH . '/configs/textsanitizer';
|
178: | $this->path_plugin = XOOPS_ROOT_PATH . '/Frameworks/textsanitizer';
|
179: | $this->config = $this->loadConfig();
|
180: | }
|
181: |
|
182: | |
183: | |
184: | |
185: | |
186: | |
187: |
|
188: | public function loadConfig($name = null)
|
189: | {
|
190: |
|
191: | if (!empty($name)) {
|
192: | return MyTextSanitizerExtension::loadConfig($name);
|
193: | }
|
194: |
|
195: | $configFileName = $this->path_config . '/config.php';
|
196: | $distFileName = $this->path_basic . '/config.dist.php';
|
197: |
|
198: | if (!file_exists($configFileName)) {
|
199: | if (false===copy($distFileName, $configFileName)) {
|
200: | trigger_error('Could not create textsanitizer config file ' . basename($configFileName));
|
201: | return array();
|
202: | }
|
203: | }
|
204: | return include $configFileName;
|
205: | }
|
206: |
|
207: | |
208: | |
209: | |
210: | |
211: | |
212: | |
213: |
|
214: | public function mergeConfig($config_default, $config_custom)
|
215: | {
|
216: | if (is_array($config_custom)) {
|
217: | foreach ($config_custom as $key => $val) {
|
218: | if (isset($config_default[$key]) && \is_array($config_default[$key])) {
|
219: | $config_default[$key] = $this->mergeConfig($config_default[$key], $config_custom[$key]);
|
220: | } else {
|
221: | $config_default[$key] = $val;
|
222: | }
|
223: | }
|
224: | }
|
225: |
|
226: | return $config_default;
|
227: | }
|
228: |
|
229: | |
230: | |
231: | |
232: | |
233: |
|
234: | public static function getInstance()
|
235: | {
|
236: | static $instance;
|
237: | if (!isset($instance)) {
|
238: | $instance = new MyTextSanitizer();
|
239: | }
|
240: |
|
241: | return $instance;
|
242: | }
|
243: |
|
244: | |
245: | |
246: | |
247: | |
248: | |
249: | |
250: |
|
251: | public function getSmileys($isAll = true)
|
252: | {
|
253: | if (count($this->smileys) == 0) {
|
254: |
|
255: | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
|
256: | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('smiles');
|
257: | $result = $xoopsDB->query($sql);
|
258: | if ($xoopsDB->isResultSet($result)) {
|
259: | while (false !== ($smiles = $xoopsDB->fetchArray($result))) {
|
260: | $this->smileys[] = $smiles;
|
261: | }
|
262: | }
|
263: | }
|
264: | if ($isAll) {
|
265: | return $this->smileys;
|
266: | }
|
267: |
|
268: | $smileys = array();
|
269: | foreach ($this->smileys as $smile) {
|
270: | if (empty($smile['display'])) {
|
271: | continue;
|
272: | }
|
273: | $smileys[] = $smile;
|
274: | }
|
275: |
|
276: | return $smileys;
|
277: | }
|
278: |
|
279: | |
280: | |
281: | |
282: | |
283: | |
284: |
|
285: | public function smiley($message)
|
286: | {
|
287: | $smileys = $this->getSmileys();
|
288: | foreach ($smileys as $smile) {
|
289: | $message = str_replace($smile['code'], '<img class="imgsmile" src="' . XOOPS_UPLOAD_URL . '/' . htmlspecialchars($smile['smile_url'], ENT_QUOTES) . '" alt="" />', $message);
|
290: | }
|
291: |
|
292: | return $message;
|
293: | }
|
294: |
|
295: | |
296: | |
297: | |
298: | |
299: | |
300: | |
301: |
|
302: | protected function makeClickableCallbackEmailAddress($match)
|
303: | {
|
304: | return $match[1] . "<a href=\"mailto:$match[2]@$match[3]\" title=\"$match[2]@$match[3]\">" . $match[2] . '@' . $match[3] . '</a>';
|
305: | }
|
306: |
|
307: | |
308: | |
309: | |
310: | |
311: | |
312: | |
313: | |
314: |
|
315: | public function makeClickable($text)
|
316: | {
|
317: | $pattern = "/(^|[^]_a-z0-9-=\"'\/:\.])([-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+)@((?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?)/i";
|
318: | $text = preg_replace_callback($pattern, 'self::makeClickableCallbackEmailAddress', $text);
|
319: |
|
320: |
|
321: |
|
322: |
|
323: | $pattern = "/(?:\s+|^)(https?:\/\/)([-A-Z0-9.\_*?&:;=#\/\[\]\%@]+)/i";
|
324: | $replacement = '<a href="$1$2" target="_blank" rel="external noopener nofollow">$1$2</a>';
|
325: | $text = preg_replace($pattern, $replacement, $text);
|
326: |
|
327: | $pattern = "%(?:\s+|^)(s?ftp://)([-A-Z0-9./_*?&:;=#\[\]\%@]+)%i";
|
328: | $replacement = '<a href="$1$2" target="_blank" rel="external">$1$2</a>';
|
329: | $text = preg_replace($pattern, $replacement, $text);
|
330: |
|
331: | return $text;
|
332: | }
|
333: |
|
334: | |
335: | |
336: | |
337: | |
338: | |
339: |
|
340: | public function truncate($text)
|
341: | {
|
342: | $instance = \MyTextSanitizer::getInstance();
|
343: | if (empty($text) || empty($instance->config['truncate_length']) || strlen($text) < $instance->config['truncate_length']) {
|
344: | return $text;
|
345: | }
|
346: | $len = floor($instance->config['truncate_length'] / 2);
|
347: | $ret = substr($text, 0, $len) . ' ... ' . substr($text, 5 - $len);
|
348: |
|
349: | return $ret;
|
350: | }
|
351: |
|
352: | |
353: | |
354: | |
355: | |
356: | |
357: | |
358: | |
359: |
|
360: | public function &xoopsCodeDecode(&$text, $allowimage = 1)
|
361: | {
|
362: | $patterns = array();
|
363: | $replacements = array();
|
364: | $patterns[] = "/\[siteurl=(['\"]?)([^\"'<>]*)\\1](.*)\[\/siteurl\]/sU";
|
365: | $replacements[] = '<a href="' . XOOPS_URL . '/\\2" title="">\\3</a>';
|
366: | $patterns[] = "/\[url=(['\"]?)(http[s]?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
|
367: | $replacements[] = '<a href="\\2" rel="noopener external" title="">\\3</a>';
|
368: | $patterns[] = "/\[url=(['\"]?)(ftp?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
|
369: | $replacements[] = '<a href="\\2" rel="external" title="">\\3</a>';
|
370: | $patterns[] = "/\[url=(['\"]?)([^'\"<>]*)\\1](.*)\[\/url\]/sU";
|
371: | $replacements[] = '<a href="http://\\2" rel="noopener external" title="">\\3</a>';
|
372: | $patterns[] = "/\[color=(['\"]?)([a-zA-Z0-9#]*)\\1](.*)\[\/color\]/sU";
|
373: | $replacements[] = '<span style="color: \\2;">\\3</span>';
|
374: | $patterns[] = "/\[size=(['\"]?)([a-zA-Z0-9.#]*)\\1](.*)\[\/size\]/sU";
|
375: | $replacements[] = '<span style="font-size: \\2;">\\3</span>';
|
376: | $patterns[] = "/\[font=(['\"]?)([^;<>\*\(\)\"']*)\\1](.*)\[\/font\]/sU";
|
377: | $replacements[] = '<span style="font-family: \\2;">\\3</span>';
|
378: | $patterns[] = "/\[email]([^;<>\*\(\)\"']*)\[\/email\]/sU";
|
379: | $replacements[] = '<a href="mailto:\\1" title="">\\1</a>';
|
380: |
|
381: | $patterns[] = "/\[b](.*)\[\/b\]/sU";
|
382: | $replacements[] = '<strong>\\1</strong>';
|
383: | $patterns[] = "/\[i](.*)\[\/i\]/sU";
|
384: | $replacements[] = '<em>\\1</em>';
|
385: | $patterns[] = "/\[u](.*)\[\/u\]/sU";
|
386: | $replacements[] = '<span style="text-decoration: underline;">\\1</span>';
|
387: | $patterns[] = "/\[d](.*)\[\/d\]/sU";
|
388: | $replacements[] = '<del>\\1</del>';
|
389: | $patterns[] = "/\[center](.*)\[\/center\]/sU";
|
390: | $replacements[] = '<div style="text-align: center;">\\1</div>';
|
391: | $patterns[] = "/\[left](.*)\[\/left\]/sU";
|
392: | $replacements[] = '<div style="text-align: left;">\\1</div>';
|
393: | $patterns[] = "/\[right](.*)\[\/right\]/sU";
|
394: | $replacements[] = '<div style="text-align: right;">\\1</div>';
|
395: |
|
396: | $this->text = $text;
|
397: | $this->patterns = $patterns;
|
398: | $this->replacements = $replacements;
|
399: |
|
400: | $this->config['allowimage'] = $allowimage;
|
401: | $this->executeExtensions();
|
402: |
|
403: | $text = preg_replace($this->patterns, $this->replacements, $this->text);
|
404: |
|
405: | $count = count($this->callbackPatterns);
|
406: |
|
407: | for ($i = 0; $i < $count; ++$i) {
|
408: | $text = preg_replace_callback($this->callbackPatterns[$i], $this->callbacks[$i], $text);
|
409: | }
|
410: |
|
411: | $text = $this->quoteConv($text);
|
412: |
|
413: | return $text;
|
414: | }
|
415: |
|
416: | |
417: | |
418: | |
419: | |
420: | |
421: |
|
422: | public function quoteConv($text)
|
423: | {
|
424: |
|
425: | $pattern = "/\[quote](.*)\[\/quote\]/sU";
|
426: | $replacement = _QUOTEC . '<div class="xoopsQuote"><blockquote>\\1</blockquote></div>';
|
427: |
|
428: | $text = preg_replace($pattern, $replacement, $text, -1, $count);
|
429: |
|
430: | if (!$count) {
|
431: | return $text;
|
432: | }
|
433: |
|
434: |
|
435: | return $this->quoteConv($text);
|
436: | }
|
437: |
|
438: | |
439: | |
440: | |
441: | |
442: | |
443: | |
444: |
|
445: | public function filterXss($text)
|
446: | {
|
447: | $patterns = array();
|
448: | $replacements = array();
|
449: | $text = str_replace("\x00", '', $text);
|
450: | $c = "[\x01-\x1f]*";
|
451: | $patterns[] = "/\bj{$c}a{$c}v{$c}a{$c}s{$c}c{$c}r{$c}i{$c}p{$c}t{$c}[\s]*:/si";
|
452: | $replacements[] = 'javascript;';
|
453: | $patterns[] = "/\ba{$c}b{$c}o{$c}u{$c}t{$c}[\s]*:/si";
|
454: | $replacements[] = 'about;';
|
455: | $patterns[] = "/\bx{$c}s{$c}s{$c}[\s]*:/si";
|
456: | $replacements[] = 'xss;';
|
457: | $text = preg_replace($patterns, $replacements, $text);
|
458: |
|
459: | return $text;
|
460: | }
|
461: |
|
462: | |
463: | |
464: | |
465: | |
466: | |
467: |
|
468: | public function nl2Br($text)
|
469: | {
|
470: | return preg_replace('/(\015\012)|(\015)|(\012)/', '<br>', $text);
|
471: | }
|
472: |
|
473: | |
474: | |
475: | |
476: | |
477: | |
478: |
|
479: | public function addSlashes($text)
|
480: | {
|
481: | if (!@get_magic_quotes_gpc()) {
|
482: | $text = addslashes($text);
|
483: | }
|
484: |
|
485: | return $text;
|
486: | }
|
487: |
|
488: | |
489: | |
490: | |
491: | |
492: | |
493: | |
494: | |
495: | |
496: |
|
497: | public function htmlSpecialChars($text, $quote_style = NULL, $charset = null, $double_encode = true)
|
498: | {
|
499: | if ($quote_style === NULL) {
|
500: | $quote_style = ENT_QUOTES;
|
501: | }
|
502: | $text = (string) $text;
|
503: | if (version_compare(phpversion(), '5.2.3', '>=')) {
|
504: | $text = htmlspecialchars($text, $quote_style, $charset ?: (defined('_CHARSET') ? _CHARSET : 'UTF-8'), $double_encode);
|
505: | } else {
|
506: | $text = htmlspecialchars($text, $quote_style);
|
507: | }
|
508: |
|
509: | return preg_replace(array('/&/i', '/ /i'), array('&', '&nbsp;'), $text);
|
510: | }
|
511: |
|
512: | |
513: | |
514: | |
515: | |
516: | |
517: |
|
518: | public function undoHtmlSpecialChars($text)
|
519: | {
|
520: | return preg_replace(array('/>/i', '/</i', '/"/i', '/'/i', '/&nbsp;/i'), array('>', '<', '"', '\'', ' '), $text);
|
521: | }
|
522: |
|
523: | |
524: | |
525: | |
526: | |
527: | |
528: | |
529: | |
530: | |
531: | |
532: | |
533: |
|
534: | public function &displayTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
|
535: | {
|
536: | $text = (string) $text;
|
537: | $charset = (defined('_CHARSET') ? _CHARSET : 'UTF-8');
|
538: | if (function_exists('mb_convert_encoding')) {
|
539: | $text = mb_convert_encoding($text, $charset, mb_detect_encoding($text, mb_detect_order(), true));
|
540: | }
|
541: | if ($html && $br) {
|
542: | $testText = strip_tags($text);
|
543: | if (mb_strlen($text) != mb_strlen($testText)) {
|
544: | $br = 0;
|
545: | }
|
546: | unset($testText);
|
547: | }
|
548: | if ($html != 1) {
|
549: |
|
550: | $text = $this->htmlSpecialChars($text, ENT_COMPAT, $charset);
|
551: | }
|
552: | $text = $this->codePreConv($text, $xcode);
|
553: | if ($smiley != 0) {
|
554: |
|
555: | $text = $this->smiley($text);
|
556: | }
|
557: | if ($xcode != 0) {
|
558: |
|
559: | if ($image != 0) {
|
560: |
|
561: | $text =& $this->xoopsCodeDecode($text);
|
562: | } else {
|
563: |
|
564: | $text =& $this->xoopsCodeDecode($text, 0);
|
565: | }
|
566: | }
|
567: | if ($br != 0) {
|
568: | $text = $this->nl2Br($text);
|
569: | }
|
570: | $text = $this->codeConv($text, $xcode);
|
571: | $text = $this->makeClickable($text);
|
572: | if (!empty($this->config['filterxss_on_display'])) {
|
573: | $text = $this->filterXss($text);
|
574: | }
|
575: |
|
576: | return $text;
|
577: | }
|
578: |
|
579: | |
580: | |
581: | |
582: | |
583: | |
584: | |
585: | |
586: | |
587: | |
588: | |
589: |
|
590: | public function &previewTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
|
591: | {
|
592: | $text = $this->stripSlashesGPC($text);
|
593: | $text =& $this->displayTarea($text, $html, $smiley, $xcode, $image, $br);
|
594: |
|
595: | return $text;
|
596: | }
|
597: |
|
598: | |
599: | |
600: | |
601: | |
602: | |
603: |
|
604: | public function &censorString(&$text)
|
605: | {
|
606: | $ret = $this->executeExtension('censor', $text);
|
607: | if ($ret === false) {
|
608: | return $text;
|
609: | }
|
610: |
|
611: | return $ret;
|
612: | }
|
613: |
|
614: | |
615: | |
616: | |
617: | |
618: | |
619: | |
620: |
|
621: | public function codePreConv($text, $xcode = 1)
|
622: | {
|
623: | if ($xcode != 0) {
|
624: |
|
625: |
|
626: |
|
627: | $patterns = "/\[code([^\]]*?)\](.*)\[\/code\]/sU";
|
628: | $text = preg_replace_callback(
|
629: | $patterns,
|
630: | function ($matches) {
|
631: | return '[code'. $matches[1] . ']' . base64_encode($matches[2]) . '[/code]';
|
632: | },
|
633: | $text
|
634: | );
|
635: | }
|
636: |
|
637: | return $text;
|
638: | }
|
639: |
|
640: | |
641: | |
642: | |
643: | |
644: |
|
645: | public function codeConvCallback($match)
|
646: | {
|
647: | return '<div class="xoopsCode">' . $this->executeExtension('syntaxhighlight', str_replace('\\\"', '\"', base64_decode($match[2])), $match[1]) . '</div>';
|
648: | }
|
649: |
|
650: | |
651: | |
652: | |
653: | |
654: | |
655: | |
656: |
|
657: | public function codeConv($text, $xcode = 1)
|
658: | {
|
659: | if (empty($xcode)) {
|
660: | return $text;
|
661: | }
|
662: | $patterns = "/\[code([^\]]*?)\](.*)\[\/code\]/sU";
|
663: | $text1 = preg_replace_callback($patterns, array($this, 'codeConvCallback'), $text);
|
664: |
|
665: | return $text1;
|
666: | }
|
667: |
|
668: | |
669: | |
670: | |
671: | |
672: |
|
673: | public function executeExtensions()
|
674: | {
|
675: | $extensions = array_filter($this->config['extensions']);
|
676: | if (empty($extensions)) {
|
677: | return true;
|
678: | }
|
679: | foreach (array_keys($extensions) as $extension) {
|
680: | $this->executeExtension($extension);
|
681: | }
|
682: | return null;
|
683: | }
|
684: |
|
685: | |
686: | |
687: | |
688: | |
689: | |
690: |
|
691: | public function loadExtension($name)
|
692: | {
|
693: | if (file_exists($file = $this->path_basic . '/' . $name . '/' . $name . '.php')) {
|
694: | include_once $file;
|
695: | } elseif (file_exists($file = $this->path_plugin . '/' . $name . '/' . $name . '.php')) {
|
696: | include_once $file;
|
697: | } else {
|
698: | return false;
|
699: | }
|
700: | $class = 'Myts' . ucfirst($name);
|
701: | if (!class_exists($class)) {
|
702: | trigger_error("Extension '{$name}' does not exist", E_USER_WARNING);
|
703: |
|
704: | return false;
|
705: | }
|
706: | return new $class($this);
|
707: | }
|
708: |
|
709: | |
710: | |
711: | |
712: | |
713: | |
714: |
|
715: | public function executeExtension($name)
|
716: | {
|
717: | $extension = $this->loadExtension($name);
|
718: | $args = array_slice(func_get_args(), 1);
|
719: | array_unshift($args, $this);
|
720: |
|
721: | return call_user_func_array(array($extension, 'load'), $args);
|
722: | }
|
723: |
|
724: | |
725: | |
726: | |
727: | |
728: | |
729: | |
730: | |
731: |
|
732: | public function textFilter($text, $force = false)
|
733: | {
|
734: | $ret = $this->executeExtension('textfilter', $text, $force);
|
735: | if ($ret === false) {
|
736: | return $text;
|
737: | }
|
738: |
|
739: | return $ret;
|
740: | }
|
741: |
|
742: |
|
743: |
|
744: | |
745: | |
746: | |
747: | |
748: | |
749: | |
750: | |
751: | |
752: |
|
753: | public function stripSlashesGPC($text)
|
754: | {
|
755: | if (@get_magic_quotes_gpc()) {
|
756: | $text = stripslashes($text);
|
757: | }
|
758: |
|
759: | return $text;
|
760: | }
|
761: |
|
762: | |
763: | |
764: | |
765: | |
766: | |
767: | |
768: | |
769: |
|
770: | public function codeSanitizer($str, $image = 1)
|
771: | {
|
772: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
773: | $str = $this->htmlSpecialChars(str_replace('\"', '"', base64_decode($str)));
|
774: | $str =& $this->xoopsCodeDecode($str, $image);
|
775: |
|
776: | return $str;
|
777: | }
|
778: |
|
779: | |
780: | |
781: | |
782: | |
783: | |
784: | |
785: | |
786: | |
787: | |
788: |
|
789: | public function sanitizeForDisplay($text, $allowhtml = 0, $smiley = 1, $bbcode = 1)
|
790: | {
|
791: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
792: | if ($allowhtml == 0) {
|
793: | $text = $this->htmlSpecialChars($text);
|
794: | } else {
|
795: |
|
796: |
|
797: |
|
798: | $text = $this->makeClickable($text);
|
799: | }
|
800: | if ($smiley == 1) {
|
801: | $text = $this->smiley($text);
|
802: | }
|
803: | if ($bbcode == 1) {
|
804: | $text =& $this->xoopsCodeDecode($text);
|
805: | }
|
806: | $text = $this->nl2Br($text);
|
807: |
|
808: | return $text;
|
809: | }
|
810: |
|
811: | |
812: | |
813: | |
814: | |
815: | |
816: | |
817: | |
818: | |
819: | |
820: |
|
821: | public function sanitizeForPreview($text, $allowhtml = 0, $smiley = 1, $bbcode = 1)
|
822: | {
|
823: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
824: | $text = $this->oopsStripSlashesGPC($text);
|
825: | if ($allowhtml == 0) {
|
826: | $text = $this->htmlSpecialChars($text);
|
827: | } else {
|
828: |
|
829: |
|
830: |
|
831: | $text = $this->makeClickable($text);
|
832: | }
|
833: | if ($smiley == 1) {
|
834: | $text = $this->smiley($text);
|
835: | }
|
836: | if ($bbcode == 1) {
|
837: | $text =& $this->xoopsCodeDecode($text);
|
838: | }
|
839: | $text = $this->nl2Br($text);
|
840: |
|
841: | return $text;
|
842: | }
|
843: |
|
844: | |
845: | |
846: | |
847: | |
848: | |
849: | |
850: |
|
851: | public function makeTboxData4Save($text)
|
852: | {
|
853: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
854: |
|
855: |
|
856: | return $this->addSlashes($text);
|
857: | }
|
858: |
|
859: | |
860: | |
861: | |
862: | |
863: | |
864: | |
865: | |
866: |
|
867: | public function makeTboxData4Show($text, $smiley = 0)
|
868: | {
|
869: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
870: | $text = $this->htmlSpecialChars($text);
|
871: |
|
872: | return $text;
|
873: | }
|
874: |
|
875: | |
876: | |
877: | |
878: | |
879: | |
880: | |
881: |
|
882: | public function makeTboxData4Edit($text)
|
883: | {
|
884: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
885: |
|
886: | return $this->htmlSpecialChars($text);
|
887: | }
|
888: |
|
889: | |
890: | |
891: | |
892: | |
893: | |
894: | |
895: | |
896: |
|
897: | public function makeTboxData4Preview($text, $smiley = 0)
|
898: | {
|
899: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
900: | $text = $this->stripSlashesGPC($text);
|
901: | $text = $this->htmlSpecialChars($text);
|
902: |
|
903: | return $text;
|
904: | }
|
905: |
|
906: | |
907: | |
908: | |
909: | |
910: | |
911: | |
912: |
|
913: | public function makeTboxData4PreviewInForm($text)
|
914: | {
|
915: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
916: | $text = $this->stripSlashesGPC($text);
|
917: |
|
918: | return $this->htmlSpecialChars($text);
|
919: | }
|
920: |
|
921: | |
922: | |
923: | |
924: | |
925: | |
926: | |
927: |
|
928: | public function makeTareaData4Save($text)
|
929: | {
|
930: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
931: |
|
932: | return $this->addSlashes($text);
|
933: | }
|
934: |
|
935: | |
936: | |
937: | |
938: | |
939: | |
940: | |
941: | |
942: | |
943: | |
944: |
|
945: | public function &makeTareaData4Show(&$text, $html = 1, $smiley = 1, $xcode = 1)
|
946: | {
|
947: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
948: | $text =& $this->displayTarea($text, $html, $smiley, $xcode);
|
949: |
|
950: | return $text;
|
951: | }
|
952: |
|
953: | |
954: | |
955: | |
956: | |
957: | |
958: | |
959: |
|
960: | public function makeTareaData4Edit($text)
|
961: | {
|
962: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
963: |
|
964: | return $this->htmlSpecialChars($text);
|
965: | }
|
966: |
|
967: | |
968: | |
969: | |
970: | |
971: | |
972: | |
973: | |
974: | |
975: | |
976: |
|
977: | public function &makeTareaData4Preview(&$text, $html = 1, $smiley = 1, $xcode = 1)
|
978: | {
|
979: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
980: | $text =& $this->previewTarea($text, $html, $smiley, $xcode);
|
981: |
|
982: | return $text;
|
983: | }
|
984: |
|
985: | |
986: | |
987: | |
988: | |
989: | |
990: | |
991: |
|
992: | public function makeTareaData4PreviewInForm($text)
|
993: | {
|
994: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
995: |
|
996: | $text = $this->stripSlashesGPC($text);
|
997: |
|
998: | return $this->htmlSpecialChars($text);
|
999: | }
|
1000: |
|
1001: | |
1002: | |
1003: | |
1004: | |
1005: | |
1006: | |
1007: |
|
1008: | public function makeTareaData4InsideQuotes($text)
|
1009: | {
|
1010: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
1011: |
|
1012: | return $this->htmlSpecialChars($text);
|
1013: | }
|
1014: |
|
1015: | |
1016: | |
1017: | |
1018: | |
1019: | |
1020: | |
1021: |
|
1022: | public function oopsStripSlashesGPC($text)
|
1023: | {
|
1024: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
1025: |
|
1026: | return $this->stripSlashesGPC($text);
|
1027: | }
|
1028: |
|
1029: | |
1030: | |
1031: | |
1032: | |
1033: | |
1034: | |
1035: |
|
1036: | public function oopsStripSlashesRT($text)
|
1037: | {
|
1038: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
1039: | if (get_magic_quotes_runtime()) {
|
1040: | $text = stripslashes($text);
|
1041: | }
|
1042: |
|
1043: | return $text;
|
1044: | }
|
1045: |
|
1046: | |
1047: | |
1048: | |
1049: | |
1050: | |
1051: | |
1052: |
|
1053: | public function oopsAddSlashes($text)
|
1054: | {
|
1055: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
1056: |
|
1057: | return $this->addSlashes($text);
|
1058: | }
|
1059: |
|
1060: | |
1061: | |
1062: | |
1063: | |
1064: | |
1065: | |
1066: |
|
1067: | public function oopsHtmlSpecialChars($text)
|
1068: | {
|
1069: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
1070: |
|
1071: | return $this->htmlSpecialChars($text);
|
1072: | }
|
1073: |
|
1074: | |
1075: | |
1076: | |
1077: | |
1078: | |
1079: | |
1080: |
|
1081: | public function oopsNl2Br($text)
|
1082: | {
|
1083: | $GLOBALS['xoopsLogger']->addDeprecated(__METHOD__ . ' is deprecated');
|
1084: |
|
1085: | return $this->nl2Br($text);
|
1086: | }
|
1087: | }
|
1088: | |