Advertisement
Guest User

rest

a guest
Nov 2nd, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.34 KB | None | 0 0
  1. <%@ page language="java"
  2. contentType="text/html;
  3. charset=windows-1256"
  4. pageEncoding="windows-1256"
  5. import="java.net.URL"
  6. import="javax.net.ssl.HttpsURLConnection"
  7. import="java.net.HttpURLConnection"
  8. import="java.io.InputStream"
  9. import="java.io.InputStreamReader"
  10. import="java.io.BufferedReader"
  11. import="com.fasterxml.jackson.databind.JsonNode"
  12. import="com.fasterxml.jackson.databind.ObjectMapper"
  13. import="com.fasterxml.jackson.core.type.TypeReference"
  14. import="java.util.List"
  15. import="java.util.Iterator"
  16.  
  17. %>
  18.  
  19. <%
  20. request.setCharacterEncoding("UTF-8");
  21. response.setCharacterEncoding("UTF-8");
  22. %>
  23.  
  24. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  25. <html>
  26. <head>
  27.  
  28. <meta charset="utf-8">
  29. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  30. <meta name="viewport" content="width=device-width, initial-scale=1">
  31.  
  32. <title>LMS Webinar</title>
  33. <link rel="shortcut icon" href="assets/images/favicon.png" />
  34. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
  35. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css">
  36. <link rel="stylesheet" href="assets/css/style.css">
  37.  
  38. </head>
  39. <body>
  40.  
  41. <%@ include file="bbb_api.jsp"%>
  42.  
  43.  
  44. <%!
  45.  
  46. public static class User {
  47.  
  48. private int webinar_id;
  49. private String nama_session;
  50. private String start_date;
  51. private String start_time;
  52. private String end_time;
  53. private String password_tutor;
  54. private String password_student;
  55. private int status;
  56. private String create_date;
  57. private String modifield_date;
  58.  
  59.  
  60. public int getWebinar_id() {
  61. return webinar_id;
  62. }
  63. public void setWebinar_id(int webinar_id) {
  64. this.webinar_id = webinar_id;
  65. }
  66. public String getNama_session() {
  67. return nama_session;
  68. }
  69. public void setNama_session(String nama_session) {
  70. this.nama_session = nama_session;
  71. }
  72. public String getStart_date() {
  73. return start_date;
  74. }
  75. public void setStart_date(String start_date) {
  76. this.start_date = start_date;
  77. }
  78. public String getStart_time() {
  79. return start_time;
  80. }
  81. public void setStart_time(String start_time) {
  82. this.start_time = start_time;
  83. }
  84. public String getEnd_time() {
  85. return end_time;
  86. }
  87. public void setEnd_time(String end_time) {
  88. this.end_time = end_time;
  89. }
  90. public String getPassword_tutor() {
  91. return password_tutor;
  92. }
  93. public void setPassword_tutor(String password_tutor) {
  94. this.password_tutor = password_tutor;
  95. }
  96. public String getPassword_student() {
  97. return password_student;
  98. }
  99. public void setPassword_student(String password_student) {
  100. this.password_student = password_student;
  101. }
  102. public int getStatus() {
  103. return status;
  104. }
  105. public void setStatus(int status) {
  106. this.status = status;
  107. }
  108. public String getCreate_date() {
  109. return create_date;
  110. }
  111. public void setCreate_date(String create_date) {
  112. this.create_date = create_date;
  113. }
  114. public String getModifield_date() {
  115. return modifield_date;
  116. }
  117. public void setModifield_date(String modifield_date) {
  118. this.modifield_date = modifield_date;
  119. }
  120.  
  121. public String toString(){
  122. return getWebinar_id() + ", "+getNama_session()+", "+getStart_date()+","+getStart_time()+", "+getEnd_time()+", "+getPassword_tutor()+", "+getPassword_student()+","
  123. + " "+getStatus()+", "+getCreate_date()+", "+getModifield_date();
  124. }
  125. }
  126.  
  127. %>
  128.  
  129.  
  130. <%
  131.  
  132. URL url = new URL("https://client.sibertama.com/lms-web/services");
  133. HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
  134. InputStream is = urlConnection.getInputStream();
  135. InputStreamReader isr = new InputStreamReader(is);
  136. BufferedReader br = new BufferedReader(isr);
  137.  
  138. String inputLine;
  139. String jsonText="";
  140.  
  141. while ((inputLine = br.readLine()) != null) {
  142. jsonText = jsonText + inputLine;
  143. }
  144.  
  145. br.close();
  146.  
  147. //out.println(jsonText);
  148.  
  149. ObjectMapper mapper = new ObjectMapper();
  150. List<User> list = mapper.readValue(jsonText, new TypeReference<List<User>>() { });
  151.  
  152. Iterator<String> meetingIterator = null;
  153. HashMap<String,HashMap> allMeetings;
  154. HashMap<String,String> meeting;
  155.  
  156. // allMeetings = null;
  157.  
  158. for(User item : list){
  159.  
  160. String Nama = item.getNama_session();
  161. String password_tutor = item.getPassword_tutor();
  162. String password_student = item.getPassword_student();
  163.  
  164. allMeetings = new HashMap<String,HashMap>();
  165.  
  166. // HashMap<String,HashMap> allMeetings = new HashMap<String,HashMap>();
  167.  
  168.  
  169. String welcome = "<br>Welcome to <b>%%CONFNAME%%</b>!<br><br>To understand how BigBlueButton works see our <a href=\"event:http://www.bigbluebutton.org/cont$";
  170.  
  171. meeting = new HashMap<String, String>();
  172. allMeetings.put(Nama, meeting);
  173. meeting.put("welcomeMsg",welcome);
  174. meeting.put("moderatorPW",password_tutor);
  175. meeting.put("viewerPW",password_student);
  176. meeting.put("voiceBridge","72013");
  177. meeting.put("logoutURL","https://webinar.dhooki.com/class/join.jsp");
  178.  
  179. meeting = null;
  180.  
  181. meetingIterator = new TreeSet<String>(allMeetings.keySet()).iterator();
  182. }
  183.  
  184. if (request.getParameterMap().isEmpty()) {
  185.  
  186.  
  187.  
  188. %>
  189.  
  190. <div class="container">
  191. <div class="row">
  192. <div class="col-sm-offset-4 col-sm-4">
  193. <div class="wrapper-form">
  194. <div class="form-top">
  195. <div class="form-top-left">
  196. <h3>LMS Webinar</h3>
  197. <p>Tell us who you are:</p>
  198. </div>
  199. <div class="form-top-right">
  200. <!-- <i class="fa fa-user"></i> -->
  201. <img src="assets/images/logo2.png" />
  202. </div>
  203. </div>
  204. <div class="form-bottom">
  205. <form name="form1" METHOD="GET">
  206. <div class="form-group">
  207. <label for="fullname">Fullname</label>
  208. <input type="text" class="form-control" id="username" name="username" required>
  209. </div>
  210.  
  211. <div class="form-group">
  212. <label for="session">Session</label>
  213. <select class="form-control" name="meetingID" required>
  214. <option selected="true" value="">-= Please Chooice =-</option>
  215. <%
  216. String key;
  217. while (meetingIterator.hasNext()) {
  218. key = meetingIterator.next();
  219. out.println("<option value=\"" + key + "\">" + key + "</option>");
  220. }
  221. %>
  222. </select>
  223. </div>
  224.  
  225.  
  226. <div class="form-group">
  227. <label for="password">Password</label>
  228. <input type="password" class="form-control" id="password" name="password" required>
  229. </div>
  230. <button type="submit" class="btn btn-login" value="join">Join</button>
  231. <INPUT TYPE=hidden NAME=action VALUE="create">
  232. </form>
  233. </div>
  234. </div>
  235. <div class="link">
  236. <a href="#" title="Go to LMS Website">Go to LMS Website</a>
  237. </div>
  238. </div>
  239. </div>
  240. </div>
  241.  
  242. <%
  243. } else if (request.getParameter("action").equals("create")) {
  244.  
  245. String username = request.getParameter("username");
  246. String meetingID = request.getParameter("meetingID");
  247. String password = request.getParameter("password");
  248.  
  249. meeting = allMeetings.get(meetingID);
  250.  
  251. String welcomeMsg = meeting.get("welcomeMsg");
  252. String logoutURL = meeting.get("logoutURL");
  253. Integer voiceBridge = Integer.parseInt( meeting.get("voiceBridge").trim() );
  254.  
  255. String viewerPW = meeting.get("viewerPW");
  256. String moderatorPW = meeting.get("moderatorPW");
  257.  
  258. if ( ! password.equals(viewerPW) && ! password.equals(moderatorPW) ) {
  259. %>
  260.  
  261.  
  262. <div class="container">
  263. <div class="row">
  264. <div class="col-sm-offset-4 col-sm-4">
  265. <div class="wrapper-form">
  266. <div class="form-top">
  267. <div class="form-top-left">
  268. <h3>LMS Webinar</h3>
  269. <p>Tell us who you are:</p>
  270. </div>
  271. <div class="form-top-right">
  272. <img src="assets/images/logo2.png" />
  273. </div>
  274. </div>
  275. <div class="form-bottom">
  276. <div class="form-group">
  277. <div style="text-align:center; color:red;"> Invalid Password </div>
  278. </div>
  279. <a class="btn btn-danger" href="javascript:history.go(-1)">try again</a>
  280. </div>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285.  
  286.  
  287. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  288. <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  289. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.4/jquery.backstretch.min.js"></script>
  290. <script src="assets/js/vendor.js"></script>
  291.  
  292.  
  293. <%
  294. return;
  295. }
  296.  
  297. String meeting_ID = createMeeting( meetingID, welcomeMsg, moderatorPW, "Welcome moderator! (moderator only message)", viewerPW, voiceBridge, logoutURL );
  298.  
  299. if( meeting_ID.startsWith("Error ")) {
  300. %>
  301.  
  302.  
  303. <div class="container">
  304. <div class="row">
  305. <div class="col-sm-offset-4 col-sm-4">
  306. <div class="wrapper-form">
  307. <div class="form-top">
  308. <div class="form-top-left">
  309. <h3>LMS Webinar</h3>
  310. <p>Tell us who you are:</p>
  311. </div>
  312. <div class="form-top-right">
  313. <img src="assets/images/logo2.png" />
  314. </div>
  315. </div>
  316. <div class="form-bottom">
  317. <div class="form-group">
  318. <div style="text-align:center; color:red;"> Error: createMeeting() failed </div>
  319. </div>
  320. <a class="btn btn-danger" href="javascript:history.go(-1)">try again</a>
  321. </div>
  322. </div>
  323. </div>
  324. </div>
  325. </div>
  326.  
  327.  
  328. <%
  329. return;
  330. }
  331.  
  332. String joinURL = getJoinMeetingURL(username, meeting_ID, password, null, request.getParameter("guest") != null);
  333. %>
  334.  
  335. <script language="javascript" type="text/javascript">
  336. window.location.href="<%=joinURL%>";
  337. </script>
  338.  
  339. <%
  340. }
  341. %>
  342.  
  343. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  344. <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  345. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.4/jquery.backstretch.min.js"></script>
  346. <script src="assets/js/vendor.js"></script>
  347.  
  348. </body>
  349. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement