Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. <?
  2. switch($_GET['kw']){
  3.  
  4. case "berlingo":
  5. include 'berlingo.php'
  6. break;
  7. case "c4":
  8. include 'c4.php';
  9. break;
  10.  
  11. }
  12. ?>
  13.  
  14. $linkKW = $_GET['kw'];
  15.  
  16. switch (true){
  17. case stristr($linkKW,'berlingo'):
  18. include 'berlingo.php';
  19. break;
  20. case stristr($linkKW,'c4'):
  21. include 'c4.php';
  22. break;
  23. }
  24.  
  25. $linkKW = $_GET['kw'];
  26.  
  27. switch (true){
  28. case stripos($linkKW,'berlingo') !== false:
  29. include 'berlingo.php';
  30. break;
  31. case stripos($linkKW,'c4') !== false:
  32. include 'c4.php';
  33. break;
  34. }
  35.  
  36. if (strpos($_GET['kw'], 'berlingo') !== false) {
  37. include 'berlingo.php';
  38. } else if (strpos($_GET['kw'], 'c4') !== false) {
  39. include 'c4.php';
  40. } … and so on …
  41.  
  42. $map = array('berlingo' => 'berlingo.php', 'c4' => 'c4.php', …);
  43. foreach ($map as $keyword => $file) {
  44. if (strpos($_GET['kw'], $keyword) !== false) {
  45. include $file;
  46. break;
  47. }
  48. }
  49.  
  50. $keywords = array('berlingo', 'c4', …);
  51. foreach ($keywords as $keyword) {
  52. if (strpos($_GET['kw'], $keyword) !== false) {
  53. include "$keyword.php";
  54. break;
  55. }
  56. }
  57.  
  58. if(strpos($_GET['kw'],'berlingo') !== false) {
  59. include 'berlingo.php';
  60. }
  61. if(strpos($_GET['kw'],'c4') !== false) {
  62. include 'c4.php';
  63. }
  64.  
  65. $keywords = array('berlingo', 'c4');
  66. foreach($keywords as $keyword)
  67. if(strpos($_GET['kw'], $keyword) !== FALSE)
  68. include("$keyword.php");
  69.  
  70. <?php
  71.  
  72. $kw = filter_input(INPUT_GET, "kw");
  73.  
  74. switch($kw){
  75.  
  76. case (preg_match('/*berlingo*/', $kw) ? true : false):
  77. include 'berlingo.php';
  78. break;
  79.  
  80. case "c4":
  81. include 'c4.php';
  82. break;
  83.  
  84. }
  85. ?>
  86.  
  87. $map = array('berlingo' => 'berlingo.php', 'c4' => 'c4.php', …);
  88.  
  89. if( !isset( $map[$_GET['kw']] ))
  90. throw new Exception("Blah!!");
  91.  
  92. include $map[$_GET['kw']];
  93.  
  94. class Haystack {
  95. public $value;
  96.  
  97. public function __construct($value)
  98. {
  99. $this->value = $value;
  100. }
  101.  
  102. public function contains($needle):
  103. {
  104. if (strpos($this->value, $needle) !== false)
  105. return $this;
  106. }
  107. }
  108.  
  109. $kw = new Haystack($_GET['kw']);
  110.  
  111. switch ($kw) {
  112. case $kw->contains('berlingo'):
  113. require_once 'berlingo.php';
  114. case $kw->contains('c4'):
  115. require_once 'c4.php';
  116. }
  117.  
  118. final class Haystack {
  119. private $value;
  120. private $isMain;
  121.  
  122. public function __construct(string $value, bool $isMain = true)
  123. {
  124. $this->value = $value;
  125. $this->isMain = $isMain;
  126. }
  127.  
  128. final public function contains($needle): Haystack
  129. {
  130. if (strpos($this->value, $needle) !== false)
  131. return $this;
  132. return new Haystack($needle, false);
  133. }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement