get-date.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. //
  3. require_once "../../../../path.php";
  4. require_once "../../../../public/_pdo.php";
  5. if(isset($_GET["teacher"])){
  6. $teacher = " teacher = ? ";
  7. }
  8. else{
  9. $teacher = " 1= 1";
  10. }
  11. global $PDO;
  12. PDO_Connect("sqlite:"._FILE_DB_COURSE_);
  13. $query = "select * from course where $teacher order by create_time DESC limit 0,100";
  14. if(isset($_GET["teacher"])){
  15. $Fetch = PDO_FetchAll($query,array($_GET["teacher"]));
  16. }
  17. else{
  18. $Fetch = PDO_FetchAll($query);
  19. }
  20. $output = array();
  21. foreach ($Fetch as $key => $couse) {
  22. # code...
  23. $query = "select * from lesson where course_id = '{$couse["id"]}' limit 0,300";
  24. $fAllLesson = PDO_FetchAll($query);
  25. foreach ($fAllLesson as $lesson) {
  26. # code...
  27. # "id": "999",
  28. #"title": "Dhammacakkha",
  29. #"url": "https://www.wikipali.org/app/course/lesson.php?id=6a42e993-8f7e-414a-a291-a4094764f992",
  30. #"start": "2020-12-11T08:00:00+06:30",
  31. #"end": "2020-12-11T09:30:00+06:30"
  32. $start = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000);
  33. $end = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000+$lesson["duration"]);
  34. $output[]=array("id"=>$lesson["id"],
  35. "title"=>$couse["title"],
  36. "url"=>"../../../course/lesson.php?id=".$lesson["id"],
  37. "start"=> $start,
  38. "end"=>$end
  39. );
  40. }
  41. }
  42. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  43. ?>