/home/banprang/domains/plai.go.th/public_html/coremain/function_word_sencor.php


1
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php

function check_word_sencor($word) {
  return 
_textfilter($word);
}

function 
_textfilter($text) {
  
$tf = new textfilter();
  return 
$tf->_textfilter_leave($text);
}

class 
textfilter {

  var 
$leaveword;
  var 
$filterword;
  var 
$dangerrword;

  function 
__construct() {
    
//this is constructor
    
$this->leaveword file($_SESSION['root_path']."coremain/module/word_censor/leaveword.inc.php")or die('missing data');
    
$this->filterword file($_SESSION['root_path']."coremain/module/word_censor/filterword.inc.php")or die('missing data');
    
$this->dangerrword file($_SESSION['root_path']."coremain/module/word_censor/dangerword.inc.php")or die('missing data');
//    $this->leaveword = file("{$_SERVER['DOCUMENT_ROOT']}/coremain/module/word_censor/leaveword.inc.php")or die('missing data');
//    $this->filterword = file("{$_SERVER['DOCUMENT_ROOT']}/coremain/module/word_censor/filterword.inc.php")or die('missing data');
//    $this->dangerrword = file("{$_SERVER['DOCUMENT_ROOT']}/coremain/module/word_censor/dangerword.inc.php")or die('missing data');
  
}

  function 
_textfilter_leave($text) {
    return 
$this->_textfilterlib($this->_textleave_decodelib($this->_textfilterlib($this->_textleave_endcodelib($text), $this->filterword)), $this->dangerrword);
  }

  private function 
_textfilterlib($text$filterwordinput) {
    
$worngword = array();
    
$trueword = array();
    for (
$i 0$i sizeof($filterwordinput); $i++) {
      
$word explode(','$filterwordinput[$i]);
      
$worngword[$i] = trim($word[0]);
      if (isset(
$word[1])) {
        
$trueword[$i] = "<font color='red'>" trim($word[1]) . "</font>";
      } else {
        
$trueword[$i] = "<font color='red'>*</font>";
      }
    }

    for (
$i 0$i sizeof($worngword); $i++) {
      
$text str_replace($worngword[$i], $trueword[$i], $text);
    }
    return 
$text;
  }

  private function 
_textleave_endcodelib($text) {
    for (
$i 0$i sizeof($this->leaveword); $i++) {
      
$_tmptext trim(($this->leaveword[$i]));
      
$text str_replace($_tmptextbase64_encode($_tmptext), $text);
    }
    return 
$text;
  }

  private function 
_textleave_decodelib($text) {
    for (
$i 0$i sizeof($this->leaveword); $i++) {
      
$_tmptext trim(($this->leaveword[$i]));
      
$text str_replace(base64_encode($_tmptext), $_tmptext$text);
    }
    return 
$text;
  }

}

// #################ʴк Popup ##############
function check_word_sencor_popup($word) {
  return 
_textfilter1($word);
}

function 
_textfilter1($text) {
  
$tf = new textfilter1();
  return 
$tf->_textfilter1_leave($text);
}

class 
textfilter1 {

  var 
$leaveword;
  var 
$filterword;
  var 
$dangerrword;

  function 
__construct() {
    
//this is constructor

    
$this->leaveword file("{$_SERVER['DOCUMENT_ROOT']}/coremain/mainfile/word_censor/leaveword.inc.php")or die('missing data');
    
$this->filterword file("{$_SERVER['DOCUMENT_ROOT']}/coremain/mainfile/word_censor/filterword.inc.php")or die('missing data');
    
$this->dangerrword file("{$_SERVER['DOCUMENT_ROOT']}/coremain/mainfile/word_censor/dangerword.inc.php")or die('missing data');
  }

  function 
_textfilter1_leave($text) {
    return 
$this->_textfilter1lib($this->_textleave_decodelib($this->_textfilter1lib($this->_textleave_endcodelib($text), $this->filterword)), $this->dangerrword);
  }

  private function 
_textfilter1lib($text$filterwordinput) {
    
$worngword = array();
    
$trueword = array();
    for (
$i 0$i sizeof($filterwordinput); $i++) {
      
$word explode(','$filterwordinput[$i]);
      
$worngword[$i] = trim($word[0]);
      if (isset(
$word[1])) {
        
$trueword[$i] = "<font color='red'>" trim($word[1]) . "</font>";
      } else {
        
$trueword[$i] = "<font color='red'>*</font>";
      }
    }

    for (
$i 0$i sizeof($worngword); $i++) {
      
$text str_replace($worngword[$i], $trueword[$i], $text);
    }
    return 
$text;
  }

  private function 
_textleave_endcodelib($text) {
    for (
$i 0$i sizeof($this->leaveword); $i++) {
      
$_tmptext trim(($this->leaveword[$i]));
      
$text str_replace($_tmptextbase64_encode($_tmptext), $text);
    }
    return 
$text;
  }

  private function 
_textleave_decodelib($text) {
    for (
$i 0$i sizeof($this->leaveword); $i++) {
      
$_tmptext trim(($this->leaveword[$i]));
      
$text str_replace(base64_encode($_tmptext), $_tmptext$text);
    }
    return 
$text;
  }

}

?>