Advertisement
Guest User

json

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