PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/sabre/classes/wordgen_class.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 102 lines | 67 code | 30 blank | 5 comment | 6 complexity | 139983914fdf7c11d8286f9e73167a37 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  1. <?php
  2. class wordGenerator {
  3. // Variables
  4. var $alphaB;
  5. var $firstLetter;
  6. var $nextLetter;
  7. var $lastLetter;
  8. // functions
  9. function create($lower_limit=4, $upper_limit=8, $strict=false) {
  10. // Word generation
  11. $word = "";
  12. if ($lower_limit < 4)
  13. $lower_limit = 4;
  14. if ($upper_limit < 4)
  15. $upper_limit = 4;
  16. if ($upper_limit < $lower_limit)
  17. $upper_limit = $lower_limit;
  18. $randomLength = mt_rand($lower_limit-2, $upper_limit-2);
  19. while (strlen($word) < $randomLength) {
  20. if (strlen($word) == 0)
  21. $a = $this->choice($this->firstLetter);
  22. else
  23. $a = $this->choice($this->nextLetter[strpos($this->alphaB, substr($word, -1))]);
  24. $word .= $a;
  25. }
  26. $a = $this->choice($this->nextLetter[strpos($this->alphaB, substr($word, -1))]);
  27. $i = strpos($this->alphaB, $a);
  28. $word .= $a . $this->lastLetter[$i][floor((mt_rand(0,pow(10,5))/pow(10,5))*(mt_rand(0,pow(10,5))/pow(10,5))*count($this->lastLetter[$i]))];
  29. return ($strict ? substr($word, 0, $upper_limit) : $word);
  30. }
  31. function choice($letters) {
  32. // Choose a letter in a string
  33. return $letters[floor((mt_rand(0,pow(10,5))/pow(10,5))*(mt_rand(0,pow(10,5))/pow(10,5))*strlen($letters))];
  34. }
  35. function wordGenerator() {
  36. $this->__construct();
  37. }
  38. function __construct() {
  39. $this->alphaB = "abcdefghijklmnopqrstuvwxyz";
  40. $this->firstLetter = "toawbcdsfmrhiyeglnpujk";
  41. $this->nextLetter = array("nnttrrllssidcmvbpyugf", "eloyruias", "ooeeahtiklurc", "eeiitaosbuwhrcfdlnpg", "rrssnnddaattcclleeimwopbfvxgu", "toreaflsmuhcwpbnj", "ehatirouslnmcbwpfg", "eeaaiiotrsu", "nnssttooclremdvgafb", "eoua", "esinaltcowgpmbh", "eealiyodsturmfpcb", "eeaoipmusybfwr", "ttddggeessaaocuwhlybfp", "nnrrffuummtswolpadcvkbi", "eoralituphs", "uuuikm", "eeooaaiistycdmnklrwpubvgh", "tteeooiiaashupwcmbfdnr", "hhiieeooaatrsuwylcb", "sntlcgmpadebf", "eeiaou", "haeionyrst", "ptciaheouwbly", "otaisewcbrpfhdmnlgu", "eeaaoilyz");
  42. $this->lastLetter = array();
  43. $this->lastLetter[0]=array("r","s","n","d","nt","m","t","ll","l","ck","it","in","int","ng","x","ys","c");
  44. $this->lastLetter[1]=array("le","el","our","er","les","ers","out","e");
  45. $this->lastLetter[2]=array("h","e","i","hes","es","er","her","hant","le","t","tre","les","hers","ree","ts");
  46. $this->lastLetter[3]=array("e","es","re","er","ent","in","en","ain","ee","it","its");
  47. $this->lastLetter[4]=array("r","s","n","d","t","nt","rs","nts","ant","nd","a","l");
  48. $this->lastLetter[5]=array("fle","f","ond");
  49. $this->lastLetter[6]=array("e","h","ar","le","ht","re","ue","les","out","ues","ing","ion","nant","ard","ast");
  50. $this->lastLetter[7]=array("","t","er");
  51. $this->lastLetter[8]=array("t","n","ng","s","l","ls","on","er","e","c","ers","ons");
  52. $this->lastLetter[9]=array("e","i","a","o","et","er");
  53. $this->lastLetter[10]=array("","s");
  54. $this->lastLetter[11]=array("e","s","es","l","eon","er","ant","or","on","t","ist","ets","et","ee","ts","ons","ors","ot","ent","ier","in","ous");
  55. $this->lastLetter[12]=array("e","ent","es","bre","mes","ain","ore","ents","our","er","ble","p","ant","in","it","ir");
  56. $this->lastLetter[13]=array("e","t","d","te","ck","tre","es","ant","se","dit","tes","ch","dant","on","ger","s","ces","deer","it","see","tend","tent","ches","ner","ton","dent","nent","al","at","er","nes","fin","ox","ton","oon","ew","ies","son");
  57. $this->lastLetter[14]=array("us","n","ur","ut","lt","ir","rt","it","nd","nc","rts","m","rs","x","irs","e","w","rd","l","st","ts");
  58. $this->lastLetter[15]=array("le","e","ers","ee","les","re","ing","ing","ped","ar","es","an","ort","end","on");
  59. $this->lastLetter[16]=array("ue","ues","uin","uins","uant","uet","uel","uer","uets");
  60. $this->lastLetter[17]=array("e","t","es","d","ot","and","al","n","as","ct","on","ous","ch","er","ent","st","ands","ant","se","ain","oy","ts","os","ist","mes","ton","iant","nier","der","ment","bes","ber","mee","cher","gest","ick","ix","tant","all","dent","ee","et","ets","gent","mees","od","ail","des","end","le","gy","oid","tic","rax","per","tent","don","ents","ls","ons","onds","ea","an","at");
  61. $this->lastLetter[18]=array("t","e","ts","ant","es","on","ar","ter","at","er","ant","ent","ons","ters","un","ants","ee","ton","ard","is","ert","ion","ions","ing");
  62. $this->lastLetter[19]=array("e","er","es","t","ant","ers","ion","ist","ry","our","on","ing","re","its","ent","ons","ar","ast");
  63. $this->lastLetter[20]=array("s","n","t","m","e","lt","rn","rs","es");
  64. $this->lastLetter[21]=array("e","er","ant","es","oir","ers","ent","al","ers","rant","as","ax","ient","als","ants");
  65. $this->lastLetter[22]=array("","","e","on","in");
  66. $this->lastLetter[23]=array("e","es","a");
  67. $this->lastLetter[24]=array("","s","z");
  68. $this->lastLetter[25]=array("e","ar","on","z","ol","al");
  69. }
  70. // End of class
  71. }
  72. ?>