api.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. @session_start();
  3. require_once('php/include.php');
  4. // MYSQL default bugs:bugs
  5. function retj($json,$title){
  6. $type=$_GET['type'];
  7. $id=$_GET['id'];
  8. $json['state'] = Array();
  9. $json['state']['data'] = $_GET;
  10. $json['state']['title'] = $title;
  11. switch($type){
  12. case 'user':$url='~'.$id;break;
  13. case 'group':$url='+'.$id;break;
  14. case 'issue':$url='!'.$id;break;
  15. case 'template':$url='page-'.$id;break;
  16. default:$url=$type.'-'.$id;
  17. }
  18. $json['state']['url'] = $url;
  19. die(json_encode($json));
  20. }
  21. // TODO - Add API handling.
  22. $method = $_SERVER['REQUEST_METHOD'];
  23. $ret = Array();
  24. if(isset($_GET['type'])){
  25. if(isset($_GET['id'])){
  26. $id = $_GET['id'];
  27. switch($_GET['type']){
  28. case 'user':
  29. // TODO - handle user requests
  30. break;
  31. case 'group':
  32. // TODO - handle group requests
  33. break;
  34. case 'issue':
  35. // TODO - handle issue requests
  36. break;
  37. case 'scrum':
  38. // TODO - handle scrum requests
  39. break;
  40. case 'admin':
  41. // TODO - handle admin requests
  42. break;
  43. case 'template':
  44. $ret['template'] = file_get_contents('data/'.$id.'.template.html');
  45. $ret['context'] = json_decode(file_get_contents('data/'.$id.'.context.json'));
  46. retj($ret,$id);
  47. break;
  48. case 'login':
  49. // TODO - handle logins
  50. break;
  51. default:
  52. die("invalid type");
  53. }
  54. }else{
  55. die("id missing");
  56. }
  57. }else{
  58. die("type missing");
  59. }
  60. ?>