Advertisement
Guest User

json

a guest
Nov 5th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.26 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. URL url = new URL("https://client.sibertama.com/lms-web/services");
  130. HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
  131. InputStream is = urlConnection.getInputStream();
  132. InputStreamReader isr = new InputStreamReader(is);
  133. BufferedReader br = new BufferedReader(isr);
  134.  
  135. String inputLine;
  136. String jsonText="";
  137.  
  138. while ((inputLine = br.readLine()) != null) {
  139. jsonText = jsonText + inputLine;
  140. }
  141.  
  142. br.close();
  143.  
  144. ObjectMapper mapper = new ObjectMapper();
  145. List<User> list = mapper.readValue(jsonText, new TypeReference<List<User>>() { });
  146.  
  147. Iterator<String> meetingIterator;
  148. // HashMap<String,HashMap> allMeetings;
  149. HashMap<String,String> meeting;
  150.  
  151.  
  152. for(User item : list){
  153.  
  154. String Nama = item.getNama_session();
  155. String password_tutor = item.getPassword_tutor();
  156. String password_student = item.getPassword_student();
  157.  
  158. //allMeetings = new HashMap<String,HashMap>();
  159.  
  160. HashMap<String,HashMap> allMeetings = new HashMap<String,HashMap>();
  161.  
  162.  
  163. 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$";
  164.  
  165. meeting = new HashMap<String, String>();
  166. allMeetings.put(Nama, meeting);
  167. meeting.put("welcomeMsg",welcome);
  168. meeting.put("moderatorPW",password_tutor);
  169. meeting.put("viewerPW",password_student);
  170. meeting.put("voiceBridge","72013");
  171. meeting.put("logoutURL","https://webinar.dhooki.com/class/join.jsp");
  172.  
  173. meeting = null;
  174.  
  175. meetingIterator = new TreeSet<String>(allMeetings.keySet()).iterator();
  176. }
  177.  
  178.  
  179. if (request.getParameterMap().isEmpty()) {
  180.  
  181. %>
  182.  
  183. <div class="container">
  184. <div class="row">
  185. <div class="col-sm-offset-4 col-sm-4">
  186. <div class="wrapper-form">
  187. <div class="form-top">
  188. <div class="form-top-left">
  189. <h3>LMS Webinar</h3>
  190. <p>Tell us who you are:</p>
  191. </div>
  192. <div class="form-top-right">
  193. <!-- <i class="fa fa-user"></i> -->
  194. <img src="assets/images/logo2.png" />
  195. </div>
  196. </div>
  197. <div class="form-bottom">
  198. <form name="form1" METHOD="GET">
  199. <div class="form-group">
  200. <label for="fullname">Fullname</label>
  201. <input type="text" class="form-control" id="username" name="username" required>
  202. </div>
  203.  
  204. <div class="form-group">
  205. <label for="session">Session</label>
  206. <select class="form-control" name="meetingID" required>
  207. <option selected="true" value="">-= Please Chooice =-</option>
  208. <%
  209. String key;
  210. while (meetingIterator.hasNext()) {
  211. key = meetingIterator.next();
  212. out.println("<option value=\"" + key + "\">" + key + "</option>");
  213. }
  214. %>
  215. </select>
  216. </div>
  217.  
  218.  
  219. <div class="form-group">
  220. <label for="password">Password</label>
  221. <input type="password" class="form-control" id="password" name="password" required>
  222. </div>
  223. <button type="submit" class="btn btn-login" value="join">Join</button>
  224. <INPUT TYPE=hidden NAME=action VALUE="create">
  225. </form>
  226. </div>
  227. </div>
  228. <div class="link">
  229. <a href="#" title="Go to LMS Website">Go to LMS Website</a>
  230. </div>
  231. </div>
  232. </div>
  233. </div>
  234.  
  235. <%
  236. } else if (request.getParameter("action").equals("create")) {
  237.  
  238. String username = request.getParameter("username");
  239. String meetingID = request.getParameter("meetingID");
  240. String password = request.getParameter("password");
  241.  
  242. meeting = allMeetings.get(meetingID);
  243.  
  244. String welcomeMsg = meeting.get("welcomeMsg");
  245. String logoutURL = meeting.get("logoutURL");
  246. Integer voiceBridge = Integer.parseInt( meeting.get("voiceBridge").trim() );
  247.  
  248. String viewerPW = meeting.get("viewerPW");
  249. String moderatorPW = meeting.get("moderatorPW");
  250.  
  251. if ( ! password.equals(viewerPW) && ! password.equals(moderatorPW) ) {
  252. %>
  253.  
  254.  
  255. <div class="container">
  256. <div class="row">
  257. <div class="col-sm-offset-4 col-sm-4">
  258. <div class="wrapper-form">
  259. <div class="form-top">
  260. <div class="form-top-left">
  261. <h3>LMS Webinar</h3>
  262. <p>Tell us who you are:</p>
  263. </div>
  264. <div class="form-top-right">
  265. <img src="assets/images/logo2.png" />
  266. </div>
  267. </div>
  268. <div class="form-bottom">
  269. <div class="form-group">
  270. <div style="text-align:center; color:red;"> Invalid Password </div>
  271. </div>
  272. <a class="btn btn-danger" href="javascript:history.go(-1)">try again</a>
  273. </div>
  274. </div>
  275. </div>
  276. </div>
  277. </div>
  278.  
  279.  
  280. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  281. <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  282. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.4/jquery.backstretch.min.js"></script>
  283. <script src="assets/js/vendor.js"></script>
  284.  
  285.  
  286. <%
  287. return;
  288. }
  289.  
  290. String meeting_ID = createMeeting( meetingID, welcomeMsg, moderatorPW, "Welcome moderator! (moderator only message)", viewerPW, voiceBridge, logoutURL );
  291.  
  292. if( meeting_ID.startsWith("Error ")) {
  293. %>
  294.  
  295.  
  296. <div class="container">
  297. <div class="row">
  298. <div class="col-sm-offset-4 col-sm-4">
  299. <div class="wrapper-form">
  300. <div class="form-top">
  301. <div class="form-top-left">
  302. <h3>LMS Webinar</h3>
  303. <p>Tell us who you are:</p>
  304. </div>
  305. <div class="form-top-right">
  306. <img src="assets/images/logo2.png" />
  307. </div>
  308. </div>
  309. <div class="form-bottom">
  310. <div class="form-group">
  311. <div style="text-align:center; color:red;"> Error: createMeeting() failed </div>
  312. </div>
  313. <a class="btn btn-danger" href="javascript:history.go(-1)">try again</a>
  314. </div>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319.  
  320.  
  321. <%
  322. return;
  323. }
  324.  
  325. String joinURL = getJoinMeetingURL(username, meeting_ID, password, null, request.getParameter("guest") != null);
  326. %>
  327.  
  328. <script language="javascript" type="text/javascript">
  329. window.location.href="<%=joinURL%>";
  330. </script>
  331.  
  332. <%
  333. }
  334. %>
  335.  
  336. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  337. <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  338. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.4/jquery.backstretch.min.js"></script>
  339. <script src="assets/js/vendor.js"></script>
  340.  
  341. </body>
  342. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement