controllers.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. data::set('query', $_GET);
  137. $url = strtolower($matches[1]);
  138. if (empty($matches[1])) {
  139. $url = 'index';
  140. }
  141. include __DIR__.'/view/form/'.$url.'.php';
  142. }
  143. function POST() {
  144. data::set('query', $_GET);
  145. data::set('form', $_POST);
  146. data::set('files', $_FILES);
  147. if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
  148. data::set('ajax','post');
  149. }
  150. $notice = 'Thank you!';
  151. include __DIR__.'/view/index.php';
  152. }
  153. }
  154. class articles {
  155. function DELETE() {
  156. }
  157. function PUT() {
  158. }
  159. }
  160. class search {
  161. function GET($matches) {
  162. $result = null;
  163. if (isset($_GET['searchQuery']) && $_GET['searchQuery'] == 'test') {
  164. $result = 'Success';
  165. }
  166. data::set('params', $_GET);
  167. include __DIR__.'/view/search.php';
  168. }
  169. }
  170. class httpAuth {
  171. function GET() {
  172. if (!isset($_SERVER['PHP_AUTH_USER'])) {
  173. header('WWW-Authenticate: Basic realm="test"');
  174. header('HTTP/1.0 401 Unauthorized');
  175. echo 'Unauthorized';
  176. return;
  177. }
  178. if ($_SERVER['PHP_AUTH_PW'] == 'password') {
  179. echo "Welcome, " . $_SERVER['PHP_AUTH_USER'];
  180. return;
  181. }
  182. echo "Forbidden";
  183. }
  184. }
  185. class register {
  186. function GET() {
  187. include __DIR__.'/view/register.php';
  188. }
  189. function POST() {
  190. $this->GET();
  191. }
  192. }
  193. class contentType1 {
  194. function GET() {
  195. header('Content-Type:', true);
  196. include __DIR__.'/view/content_type.php';
  197. }
  198. }
  199. class contentType2 {
  200. function GET() {
  201. header('Content-Type:', true);
  202. include __DIR__.'/view/content_type2.php';
  203. }
  204. }
  205. class unsetCookie {
  206. function GET() {
  207. header('Set-Cookie: a=; Expires=Thu, 01 Jan 1970 00:00:01 GMT');
  208. }
  209. }
  210. class basehref {
  211. function GET() {
  212. include __DIR__.'/view/basehref.php';
  213. }
  214. }
  215. class jserroronload {
  216. function GET() {
  217. include __DIR__.'/view/jserroronload.php';
  218. }
  219. }
  220. class userAgent {
  221. function GET() {
  222. echo $_SERVER['HTTP_USER_AGENT'];
  223. }
  224. }
  225. class minimal {
  226. function GET() {
  227. include __DIR__.'/view/minimal.php';
  228. }
  229. }