/ wordfilters / global.php
global.php
 1  <?php
 2  function word_filter_callback($m) {
 3    static $vals = array(
 4      'smh' => 'baka',
 5      'SMH' => 'BAKA',
 6      'tbh' => 'desu',
 7      'TBH' => 'DESU',
 8      'fam' => 'senpai',
 9      'FAM' => 'SENPAI',
10      'Fam' => 'Senpai',
11      'fams' => 'senpaitachi',
12      'FAMS' => 'SENPAITACHI',
13      'FAMs' => 'SENPAITACHI',
14      'Fams' => 'Senpaitachi'
15    );
16    
17    if (!isset($vals[$m[2]])) {
18      return $m[0];
19    }
20    
21    return "{$m[1]}{$vals[$m[2]]}{$m[3]}";
22  }
23  
24  function word_filter_callback_soy($m) {
25    $is_uc = $m[2] === strtoupper($m[2]);
26    
27    $lc = strtolower($m[4]);
28    
29    if ($lc === 'uz') {
30      return $m[0];
31    }
32    
33    if ($lc === 'im' || $lc === 'lent') {
34      $m[4] = '';
35    }
36    
37    if (!isset($m[4][1])) {
38      if ($is_uc) {
39        $onions = 'ONIONS';
40      }
41      else {
42        if ($m[2][0] === 's') {
43          $onions = 'onions';
44        }
45        else {
46          $onions = 'Onions';
47        }
48      }
49      
50      return "{$m[1]}{$onions}{$m[4]}";
51    }
52    
53    if ($m[2][0] === 's') {
54      $b = 'b';
55    }
56    else {
57      $b = 'B';
58    }
59    
60    $ac = mb_strlen($m[3]);
61    
62    if ($ac == 1) {
63      $a = 'a';
64    }
65    else {
66      if ($ac < 35) {
67        $a = str_repeat('a', $ac);
68      }
69      else {
70        $a = 'a';
71      }
72    }
73    
74    $based = "{$b}{$a}sed";
75    
76    if ($is_uc) {
77      $based = strtoupper($based);
78    }
79    
80    return $m[1] . $based . $m[4];
81  }
82  
83  // $text contents of a field
84  // $type name of the field
85  function word_filter($text, $type) {
86    if ($type !== 'com') {
87      return $text;
88    }
89    
90  //  $text = str_replace('Cuck', 'Kek', $text);
91  //  $text = str_replace('cuck', 'kek', $text);
92    $text = str_replace('CUCK', 'KEK', $text);
93    
94    $text = preg_replace_callback('/(\b)(sjw|sjws|smh|tbh|fams|fam)(\b)/i', 'word_filter_callback', $text);
95    
96    $text = preg_replace_callback('/(\b)(s([o0οоօჿ]+)[yуΥ])(\b|[[:alpha:]]{2,4})/iu', 'word_filter_callback_soy', $text);
97    
98    return $text;
99  }