Advertisement
Guest User

Alay Detector 2

a guest
Sep 21st, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class tes extends CI_Controller {
  4.  
  5. var $replace = array(
  6. 'r' => 12,
  7. 'R' => 12,
  8. 's' => 5,
  9. 'S' => 5,
  10. 'a' => 4,
  11. 'A' => 4,
  12. 'e' => 3,
  13. 'E' => 3,
  14. 'i' => 1,
  15. 'I' => 1,
  16. 'o' => 0,
  17. 'O' => 0,
  18. );
  19.  
  20. public function index(){}
  21.  
  22. public function alay($str)
  23. {
  24. $str = urldecode($str);
  25. $arr = explode(' ', $str);
  26.  
  27. foreach ($arr as $i=>$a)
  28. {
  29. if (!is_numeric($a))
  30. {
  31. $arr[$i] = str_replace(array_keys($this->replace), $this->replace, $arr[$i]);
  32. }
  33. }
  34. return implode(' ', $arr);
  35. }
  36.  
  37. public function dealay($str)
  38. {
  39. $str = urldecode($str);
  40. $arr = explode(' ', $str);
  41.  
  42. foreach ($arr as $i=>$a)
  43. {
  44. if (!is_numeric($a) && strtoupper($a) != $a )
  45. {
  46. $arr[$i] = str_replace($this->replace, array_keys($this->replace), $arr[$i]);
  47. }
  48. }
  49. return implode(' ', $arr);
  50. }
  51.  
  52. public function auto($str)
  53. {
  54. $str = urldecode($str);
  55. $is_alay = false;
  56.  
  57. $arr = explode(' ', $str);
  58. foreach ($arr as $a)
  59. {
  60. if (preg_match('/[A-Za-z]+[0-9]+/', $a) && strlen($a) > 2) $is_alay = true;
  61. }
  62. $str = implode(' ', $arr);
  63. if ($is_alay) $str = $this->dealay($str);
  64. else $str = $this->alay($str);
  65.  
  66. echo $str;
  67. }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement