course.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?PHP
  2. include "../pcdl/html_head.php";
  3. ?>
  4. <body>
  5. <?php
  6. require_once("../pcdl/head_bar.php");
  7. ?>
  8. <style>
  9. #main_video_win iframe{
  10. width:100%;
  11. height:100%;
  12. }
  13. </style>
  14. <?php
  15. //
  16. require_once "../path.php";
  17. require_once "../public/_pdo.php";
  18. require_once '../ucenter/function.php';
  19. require_once '../public/function.php';
  20. global $PDO;
  21. PDO_Connect("sqlite:"._FILE_DB_COURSE_);
  22. $query = "select * from course where id = '{$_GET["id"]}' limit 0,1";
  23. $Fetch = PDO_FetchAll($query);
  24. if(count($Fetch)==0)
  25. {
  26. echo "无法找到此课程。可能该课程已经被拥有者删除。";
  27. exit;
  28. }
  29. $course_info = $Fetch[0];
  30. echo "<div id='course_head_bar' style='background-color:var(--tool-bg-color1);padding:1em 10px 10px 10px;'>";
  31. echo "<div class='index_inner '>";
  32. echo "<div style='font-size:140%'>";
  33. echo "<a href='../uhome/course.php?userid={$course_info["teacher"]}'>";
  34. echo ucenter_getA($course_info["teacher"]);
  35. echo "</a>";
  36. echo " > ";
  37. echo $course_info["title"];
  38. echo "</div>";
  39. echo '<div class="summary" style="padding-bottom:5px;">'.$course_info["subtitle"].'</div>';
  40. echo '<div class="summary" style=""><button>关注</button><button>报名</button><button>分享</button></div>';
  41. echo "</div>";
  42. echo '</div>';
  43. echo "<div class='index_inner'>";
  44. echo '<div class="card" style="margin:1em;padding:10px;">';
  45. echo '<div class="title">';
  46. echo '简介';
  47. echo '</div>';
  48. echo '<div id="course_summary" class="detail">';
  49. echo '</div>';
  50. echo '<div class="title">';
  51. echo '参考资料';
  52. echo '</div>';
  53. echo '<div id="course_attachment" class="detail">';
  54. echo '</div>';
  55. echo '</div>';
  56. echo "<div id='lesson_list'>";
  57. echo "</div>";
  58. ?>
  59. </div>
  60. <script>
  61. $("#main_video_win").height($("#main_video_win").width()*9/16);
  62. $.get("../course/course_get.php",
  63. {
  64. id:"<?php echo $_GET["id"]; ?>"
  65. },
  66. function(data,status){
  67. let arrLesson = JSON.parse(data);
  68. if(arrLesson && arrLesson.length>0){
  69. let summary = "";
  70. try{
  71. summary = marked(arrLesson[0]["summary"]);
  72. }
  73. catch(e){
  74. }
  75. $("#course_summary").html(summary);
  76. let attachment = "";
  77. try{
  78. attachment = marked(arrLesson[0]["attachment"]);
  79. }
  80. catch(e){
  81. }
  82. $("#course_attachment").html(attachment);
  83. }
  84. });
  85. $.get("../course/lesson_list.php",
  86. {
  87. id:"<?php echo $_GET["id"]; ?>"
  88. },
  89. function(data,status){
  90. let arrLesson = JSON.parse(data);
  91. let html="";
  92. for(const lesson of arrLesson){
  93. html+= '<div class="card" style="display:flex;margin:1em;padding:10px;">';
  94. html+= '<div style="flex:7;">';
  95. html+= '<div class="pd-10">';
  96. html+= '<div class="title" style="padding-bottom:5px;font-size:200%;font-weight:600;"><a href="../course/lesson.php?id='+lesson["id"]+'" style="color:var(--main-color);">'+lesson["title"]+'</a></div>';
  97. html += '<div style="overflow-y: scroll;max-height: 20em;">';
  98. let summary = "";
  99. try{
  100. summary = marked(lesson["summary"]);
  101. }
  102. catch{
  103. }
  104. html+= '<div class="summary" style="padding-bottom:5px;">'+summary+'</div>';
  105. let live = "";
  106. try{
  107. live = marked(lesson["live"]);
  108. }
  109. catch{
  110. }
  111. html+= '<div class="summary" style="padding-bottom:5px;">'+live+'</div>';
  112. let replay = "";
  113. try{
  114. replay = marked(lesson["replay"]);
  115. }
  116. catch{
  117. }
  118. html+= '<div class="summary" style="padding-bottom:5px;">'+replay+'</div>';
  119. let attachment = "";
  120. try{
  121. attachment = marked(lesson["attachment"]);
  122. }
  123. catch{
  124. }
  125. html+= '<div class="summary" style="padding-bottom:5px;">'+attachment+'</div>';
  126. html+= '</div>';
  127. html+= '</div>';
  128. html+= '</div>';
  129. html+= '<div style="flex:3;max-width:15em;">';
  130. let d = new Date();
  131. d.setTime(lesson["date"]);
  132. let strData = d.toLocaleDateString();
  133. let strTime = d.toLocaleTimeString();
  134. html+= '<div >'+gLocal.gui.date+':'+strData +'</div>';
  135. html+= '<div >'+gLocal.gui.time+':'+strTime +'</div>';
  136. let dt = lesson["duration"]/60;
  137. let sdt = "";
  138. if(dt>59){
  139. sdt += Math.floor(dt/60)+"小时";
  140. }
  141. let m = (dt % 60);
  142. if(m>0){
  143. sdt +=(dt % 60)+"分钟";
  144. }
  145. html+= "<div >持续时间:"+sdt+"</div>";
  146. let now = new Date();
  147. let lesson_time="";
  148. if(now<lesson["date"]){
  149. lesson_time = gLocal.gui.not_started;
  150. }
  151. else if(now>lesson["date"] && now<(lesson["date"]+dt*1000)){
  152. lesson_time = gLocal.gui.in_progress;
  153. }
  154. else{
  155. lesson_time = gLocal.gui.already_over;
  156. }
  157. html+= '<div ><span class="lesson_status">'+lesson_time+'</span></div>';
  158. html+= '</div>';
  159. html+= '</div>';
  160. }
  161. $("#lesson_list").html(html);
  162. });
  163. </script>
  164. <?php
  165. include "../pcdl/html_foot.php";
  166. ?>