Lav sætninger på dansk til brug som password
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

112 lines
2.6 KiB

  1. <!DOCTYPE html>
  2. <html lang="da">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="x-ua-compatible" content="ie=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <title>Sætningsgenerator</title>
  8. <style>
  9. *{margin:0;padding:0;}html{height:100%;}
  10. h1{text-align:center;margin-top:10%;}
  11. </style>
  12. </head>
  13. <body><!--
  14. <?php
  15. $tal = rand(2,79);
  16. $model = rand(0,1);
  17. $end=array(".","!","?","!?","..."," :-)"," ;-)");
  18. $tegn=$end[array_rand($end)];
  19. $result = "";
  20. $ord = array(
  21. "sub"=>JSON_Decode(file_get_contents('data/navneord.json')),
  22. "ver"=>JSON_Decode(file_get_contents('data/verber.json')),
  23. "adj"=>JSON_Decode(file_get_contents('data/adj.json')),
  24. "pro"=>array("jeg","han","hun","den","det","de","I","vi","du","De"),
  25. "tid"=>array("før","efter","imens","inden"),
  26. "for"=>array("over","under","ved siden af","bag","foran","overfor"));
  27. function rando($arr){
  28. return $arr[array_rand($arr)];
  29. }
  30. function word($cla,$conj=null){
  31. global $ord;
  32. $word = $ord[$cla][array_rand($ord[$cla])]; //rand(0,count($ord[$cla]));
  33. if($conj==null){
  34. return $word;
  35. }else{
  36. return $word[$conj];
  37. }
  38. }
  39. function lego($conj=0){
  40. // 0 = ubestemt ental, eks. "en grim tyr" el. "et dumt æg".
  41. // 1 = bestemt ental, eks. "den grimme tyr" el. "det dumme æg"
  42. // 2 = ubestemt flertal, eks. "ægte tedåser"
  43. // 3 = bestemt flertal, eks. "de rådne æbler"
  44. $main = word("sub");
  45. $desc = word("adj");
  46. if($main[4]=="t"){$neutrum=true;}else{$neutrum = false;}
  47. print_r($main);
  48. switch($conj){
  49. case 0:
  50. if($neutrum){
  51. $phrase="et ".word("adj")[1]." ".$main[0];
  52. }else{
  53. $phrase="en ".word("adj")[0]." ".$main[0];
  54. }
  55. break;
  56. case 1:
  57. if($neutrum){
  58. $phrase="det ".word("adj")[2]." ".$main[0];
  59. }else{
  60. $phrase="den ".word("adj")[2]." ".$main[0];
  61. }
  62. break;
  63. case 2:
  64. $phrase=word("adj")[2]." ".$main[2];
  65. break;
  66. case 3:
  67. $phrase="de ".word("adj")[2]." ".$main[2];
  68. break;
  69. }
  70. return $phrase;
  71. }
  72. switch($model){
  73. case 0:
  74. if($tal>1){
  75. $b = lego(2);
  76. }else{
  77. $b = lego(rand(0,1));
  78. }
  79. $c = word("ver",rand(1,4));
  80. $d = word("sub",rando([1,3]));
  81. $result="$tal $b $c $d$tegn";
  82. break;
  83. case 1:
  84. $a = lego(rando([0,1,3]));
  85. $b = word("ver",rand(1,4));
  86. if($tal>1){$c = word("sub",2);}else{$c = word("sub",rando([1,3]));}
  87. $result = "$a $b $tal $c$tegn";
  88. break;
  89. }
  90. #$result=str_replace("\n","",$result);
  91. /*
  92. tal tillæg navneord verb navneord
  93. tillæg navneord verb tal navneord
  94. stedord verb tal tillægsord navneord
  95. stedord verb tid stedord verb tillægsord navneord
  96. stedord tillægsord navneord! stedord verbum.
  97. */
  98. ?>--><h1><?=ucwords($result,"|")?></h1>
  99. </body>
  100. </html>