controllers.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <?php
  2. class index {
  3. function GET($matches) {
  4. include __DIR__.'/view/index.php';
  5. }
  6. function POST($matches) {
  7. include __DIR__.'/view/index.php';
  8. }
  9. }
  10. class info {
  11. function GET() {
  12. if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) data::set('ajax',array('GET'));
  13. data::set('params', $_GET);
  14. include __DIR__.'/view/info.php';
  15. }
  16. }
  17. class redirect {
  18. function GET() {
  19. header('Location: /info');
  20. }
  21. }
  22. class redirect4 {
  23. function GET() {
  24. header('Location: /search?ln=test@gmail.com&sn=testnumber');
  25. }
  26. }
  27. class redirect_relative {
  28. function GET() {
  29. header('Location: info');
  30. }
  31. }
  32. class redirect2 {
  33. function GET() {
  34. include __DIR__.'/view/redirect2.php';
  35. }
  36. }
  37. class redirect3 {
  38. function GET() {
  39. header('Refresh:0;url=/info');
  40. }
  41. }
  42. class redirect_twice {
  43. function GET() {
  44. header('Location: /redirect3');
  45. }
  46. }
  47. class redirect_params {
  48. function GET() {
  49. include __DIR__.'/view/redirect_params.php';
  50. }
  51. }
  52. class redirect_interval {
  53. function GET() {
  54. include __DIR__.'/view/redirect_interval.php';
  55. }
  56. }
  57. class redirect_meta_refresh {
  58. function GET() {
  59. include __DIR__.'/view/redirect_meta_refresh.php';
  60. }
  61. }
  62. class redirect_header_interval {
  63. function GET() {
  64. include __DIR__.'/view/index.php';
  65. header('Refresh:1800;url=/info');
  66. }
  67. }
  68. class redirect_base_uri_has_path {
  69. function GET() {
  70. header('Refresh:0;url=/somepath/info');
  71. }
  72. }
  73. class redirect_base_uri_has_path_302 {
  74. function GET() {
  75. header('Location: /somepath/info', true, 302);
  76. }
  77. }
  78. class location_201 {
  79. function GET() {
  80. header('Location: /info', true, 201);
  81. }
  82. }
  83. class external_url {
  84. function GET() {
  85. include __DIR__ . '/view/external_url.php';
  86. }
  87. }
  88. class login {
  89. function GET($matches) {
  90. include __DIR__.'/view/login.php';
  91. }
  92. function POST() {
  93. data::set('form', $_POST);
  94. include __DIR__.'/view/login.php';
  95. }
  96. }
  97. class cookies {
  98. function GET($matches) {
  99. if (isset($_COOKIE['foo']) && $_COOKIE['foo'] === 'bar1') {
  100. if (isset($_COOKIE['baz']) && $_COOKIE['baz'] === 'bar2') {
  101. header('Location: /info');
  102. }
  103. } else {
  104. include __DIR__.'/view/cookies.php';
  105. }
  106. }
  107. function POST() {
  108. setcookie('f', 'b', time() + 60, null, null, false, true);
  109. setcookie('foo', 'bar1', time() + 60, null, 'sub.localhost', false, true);
  110. setcookie('baz', 'bar2', time() + 60, null, 'sub.localhost', false, true);
  111. data::set('form', $_POST);
  112. include __DIR__.'/view/cookies.php';
  113. }
  114. }
  115. class cookiesHeader {
  116. public function GET()
  117. {
  118. header("Set-Cookie: a=b;Path=/;");
  119. header("Set-Cookie: c=d;Path=/;", false);
  120. include __DIR__.'/view/index.php';
  121. }
  122. }
  123. class iframe {
  124. public function GET()
  125. {
  126. include __DIR__.'/view/iframe.php';
  127. }
  128. }
  129. class facebookController {
  130. function GET($matches) {
  131. include __DIR__.'/view/facebook.php';
  132. }
  133. }
  134. class form {
  135. function GET($matches) {
  136. $url = strtolower($matches[1]);
  137. if (empty($matches[1])) {
  138. $url = 'index';
  139. }
  140. include __DIR__.'/view/form/'.$url.'.php';
  141. }
  142. function POST() {
  143. data::set('query', $_GET);
  144. data::set('form', $_POST);
  145. data::set('files', $_FILES);
  146. if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
  147. data::set('ajax','post');
  148. }
  149. $notice = 'Thank you!';
  150. include __DIR__.'/view/index.php';
  151. }
  152. }
  153. class articles {
  154. function DELETE() {
  155. }
  156. function PUT() {
  157. }
  158. }
  159. class search {
  160. function GET($matches) {
  161. $result = null;
  162. if (isset($_GET['searchQuery']) && $_GET['searchQuery'] == 'test') {
  163. $result = 'Success';
  164. }
  165. data::set('params', $_GET);
  166. include __DIR__.'/view/search.php';
  167. }
  168. }
  169. class httpAuth {
  170. function GET() {
  171. if (!isset($_SERVER['PHP_AUTH_USER'])) {
  172. header('WWW-Authenticate: Basic realm="test"');
  173. header('HTTP/1.0 401 Unauthorized');
  174. echo 'Unauthorized';
  175. return;
  176. }
  177. if ($_SERVER['PHP_AUTH_PW'] == 'password') {
  178. echo "Welcome, " . $_SERVER['PHP_AUTH_USER'];
  179. return;
  180. }
  181. echo "Forbidden";
  182. }
  183. }
  184. class register {
  185. function GET() {
  186. include __DIR__.'/view/register.php';
  187. }
  188. function POST() {
  189. $this->GET();
  190. }
  191. }
  192. class contentType1 {
  193. function GET() {
  194. header('Content-Type:', true);
  195. include __DIR__.'/view/content_type.php';
  196. }
  197. }
  198. class contentType2 {
  199. function GET() {
  200. header('Content-Type:', true);
  201. include __DIR__.'/view/content_type2.php';
  202. }
  203. }
  204. class unsetCookie {
  205. function GET() {
  206. header('Set-Cookie: a=; Expires=Thu, 01 Jan 1970 00:00:01 GMT');
  207. }
  208. }
  209. class basehref {
  210. function GET() {
  211. include __DIR__.'/view/basehref.php';
  212. }
  213. }
  214. class jserroronload {
  215. function GET() {
  216. include __DIR__.'/view/jserroronload.php';
  217. }
  218. }