Advertisement
Guest User

Untitled

a guest
Feb 10th, 2019
1,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.98 KB | None | 0 0
  1. #! /Python34/python
  2.  
  3. import cgi, cgitb, sys, mysql.connector
  4. print("Content-type: text/html \n")
  5.  
  6. cgitb.enable()
  7.  
  8. form = cgi.FieldStorage()
  9.  
  10.  
  11. radio = form.getvalue('radio') #if none -> invalid sesion search again
  12. start_dest = form.getvalue('start_dest')
  13. end_dest = form.getvalue('end_dest')
  14. start_date = form.getvalue('start_date')
  15. end_date = form.getvalue('end_date')
  16. adl = form.getvalue('adl')
  17. adl = int(adl)
  18. child = form.getvalue('child')
  19. child = int(child)
  20. num = 0
  21. args = (start_dest,end_dest,)
  22. args1 = (end_dest,start_dest,)
  23.  
  24. conn = mysql.connector.connect(host='localhost',
  25. database='webair',
  26. user='root',
  27. password='')
  28.  
  29. print("""
  30.  
  31. <html>
  32. <head>
  33. <meta charset="utf-8">
  34.  
  35. <link rel="StyleSheet" href="try.css" type="text/css" media="screen">
  36. <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
  37.  
  38.  
  39. <script>
  40. $(document).ready(function () {
  41. "use strict"
  42.  
  43. $("html,body").animate({scrollTop: 0}, 500);
  44.  
  45. })
  46.  
  47.  
  48. var keys = {32: 1, 33: 1, 34: 1, 35: 1, 36: 1, 37: 1, 38: 1, 39: 1, 40: 1};
  49.  
  50. function preventDefault(e) {
  51. e = e || window.event;
  52. if (e.preventDefault)
  53. e.preventDefault();
  54. e.returnValue = false;
  55. }
  56.  
  57. function preventDefaultForScrollKeys(e) {
  58. if (keys[e.keyCode]) {
  59. preventDefault(e);
  60. return false;
  61. }
  62. }
  63. function disableScroll() {
  64. if (window.addEventListener) // older FF
  65. window.addEventListener('DOMMouseScroll', preventDefault, false);
  66. window.onwheel = preventDefault; // modern standard
  67. window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
  68. window.ontouchmove = preventDefault; // mobile
  69. document.onkeydown = preventDefaultForScrollKeys;
  70. }
  71.  
  72. function enableScroll() {
  73. if (window.removeEventListener)
  74. window.removeEventListener('DOMMouseScroll', preventDefault, false);
  75. window.onmousewheel = document.onmousewheel = null;
  76. window.onwheel = null;
  77. window.ontouchmove = null;
  78. document.onkeydown = null;
  79. }
  80.  
  81. window.addEventListener("load", function(){
  82. disableScroll();
  83. var load_screen = document.getElementById("load_screen");
  84. $("#load_screen").animate({ opacity: '0'}, 3000, function(){
  85. document.body.removeChild(load_screen);
  86. enableScroll();
  87. });
  88. });
  89.  
  90. function slider() {
  91. var obj = document.getElementById('slide');
  92. obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
  93. obj.style.height = (obj.style.height == '0px' || obj.style.height == '') ? '150px' : '0px';
  94. }
  95.  
  96. </script>
  97. </head>
  98.  
  99.  
  100. <body>
  101.  
  102.  
  103. <div class="mpc_preloader" id="load_screen">
  104. <div class="mpc_preloader18"></div>
  105. <span class="mpc_preloader18_label">Loading...</span>
  106. </div>""")
  107.  
  108.  
  109.  
  110. print("""
  111.  
  112. <div id="wrapper">
  113. <div id="header">
  114.  
  115. <div id="main1-left-clamp-results">
  116.  
  117. <div id="clamp-gradient">
  118. </div>
  119.  
  120. </div>
  121.  
  122. <div id="main1-right-clamp-results">
  123.  
  124. <div id="clamp-gradient">
  125. </div>
  126.  
  127. </div>
  128. <div id="box-shadow"></div>
  129. <div id="header-gradient">
  130.  
  131. <div id="header-position">
  132.  
  133. <form>
  134. <a href="/webprog/WebAir/" id="home" style="border-bottom: 1px solid #e02e36;" class="button-top">Home</a>
  135. <a href="#" id="info" class="button-top">Flights Info</a>
  136. <a href="/webprog/WebAir/manage_ticket.py" id="manage" class="button-top">Manage Ticket</a>
  137. <a href="#" id="about" class="button-top">About Us</a>
  138. </form>
  139.  
  140. </div>
  141. <p class="account" onclick="slider();">Account</p>
  142. </div>
  143. <div id="logo-box">
  144. <img src="http://i67.tinypic.com/f6w5i.png" style="width:100%;height:100%;">
  145. </div>
  146. </div>
  147. <div id="main1-results">
  148. <div id="box">
  149. <div id="box-gradient-results">
  150. <div id="results-num">
  151. """)
  152. if conn.is_connected():
  153. if radio == "1":
  154. cursor = conn.cursor()
  155. cursor.execute("SELECT * FROM journey_times WHERE jt_leave_destination = %s AND jt_arrive_destination = %s" ,args)
  156. row = cursor.fetchone()
  157. while row is not None:
  158. if row[5] >= (adl+child):
  159. num+=1
  160. row = cursor.fetchone()
  161. else:
  162. row = cursor.fetchone()
  163. cursor.close()
  164. print("<p>",num,"results found</p>","""
  165. </div>
  166. </div>
  167.  
  168. </div>
  169.  
  170. </div>
  171.  
  172. <div id="results-page">""")
  173. cursor1 = conn.cursor()
  174. cursor1.execute("SELECT * FROM journey_times WHERE jt_leave_destination = %s AND jt_arrive_destination = %s" ,args)
  175. row1 = cursor1.fetchone()
  176. while row1 is not None:
  177. if row1[5] >= (adl+child):
  178. flight_time1=row1[4]-row1[2]
  179. print("""<form action="results_sub.py" method="POST">
  180. <input class="get_var_invisible" name="radio" value='""",radio,"""'/>
  181. <input class="get_var_invisible" name="start_dest" value='""",start_dest,"""'/>
  182. <input class="get_var_invisible" name="end_dest" value='""",end_dest,"""'/>
  183. <input class="get_var_invisible" name="start_date" value='""",start_date,"""'/>
  184. <input class="get_var_invisible" name="leave1" value='""",row1[2],"""'/>
  185. <input class="get_var_invisible" name="flight_time1" value='""",flight_time1,"""'/>
  186. <input class="get_var_invisible" name="arrive1" value='""",row1[4],"""'/>
  187. <input class="get_var_invisible" name="seats_num" value='""",adl+child,"""'/>
  188. <input class="get_var_invisible" name="adl_num" value='""",adl,"""'/>
  189. <input class="get_var_invisible" name="child_num" value='""",child,"""'/>
  190. <input class="get_var_invisible" name="fare1" value='""",row1[6],"""'/>
  191. <div id="empty-div">""</div>
  192. <div id="results-offer">
  193. <div id="results-offer-select">""")
  194. print("<p style='font-size:33px;'>&#163;")
  195. if adl > 0:
  196. print(((row1[6]*adl)+(row1[6]*child-(row1[6]*child*0.2))),"</p>","<input class='get_var_invisible' name='fare' value='",((row1[6]*adl)+(row1[6]*child-(row1[6]*child*0.2))),"'/>")
  197. else:
  198. print(row1[6]*child,"</p>","<input class='get_var_invisible' name='fare' value='",row1[6]*child,"'/>")
  199. print("""
  200. <button id="results-select-pos" class="button2">Select</button>""")
  201. print("<p style='font-size:20px;'>",row1[5],"free seats</p>","""
  202. </div>
  203. <div id="results-depart">
  204. <p style="font-size:20px;color:red;">Depart</p><p style="font-size:18px;">""",start_dest,"-",end_dest,"</p><p style='font-size:17px;'>",start_date,"""</p> <br><br>
  205. <table id="table-size">
  206. <tr>
  207. <th align="left">Leave</th>
  208. <th align="center">Journey Time</th>
  209. <th align="right">Arrive</th>
  210. </tr>
  211. <tr>
  212. <td align="left">""",row1[2],"""</td>
  213. <td align="center">""",row1[4]-row1[2],"""</td>
  214. <td align="right">""",row1[4],"""</td>
  215. </tr>
  216. </table>
  217. </div>
  218. </div>
  219. </form>""")
  220. row1 = cursor1.fetchone()
  221. else:
  222. row1 = cursor1.fetchone()
  223. cursor1.close()
  224. else:
  225. cursor2 = conn.cursor(buffered=True)
  226. cursor2.execute("SELECT * FROM journey_times WHERE jt_leave_destination = %s AND jt_arrive_destination = %s" ,args1)
  227. row2 = cursor2.fetchone()
  228. while row2 is not None:
  229. cursor1 = conn.cursor()
  230. cursor1.execute("SELECT * FROM journey_times WHERE jt_leave_destination = %s AND jt_arrive_destination = %s" ,args)
  231. row1 = cursor1.fetchone()
  232. while row1 is not None:
  233. if row1[5] >= (adl+child) and row2[5] >= (adl+child):
  234. num+=1
  235. row1 = cursor1.fetchone()
  236. else:
  237. row1 = cursor1.fetchone()
  238. cursor1.close()
  239. row2 = cursor2.fetchone()
  240. cursor2.close()
  241. print("<p>",num,"results found</p>","""
  242. </div>
  243. </div>
  244.  
  245. </div>
  246.  
  247. </div>
  248.  
  249. <div id="results-page">""")
  250. cursor2 = conn.cursor(buffered=True)
  251. cursor2.execute("SELECT * FROM journey_times WHERE jt_leave_destination = %s AND jt_arrive_destination = %s" ,args1)
  252. row2 = cursor2.fetchone()
  253. while row2 is not None:
  254. cursor1 = conn.cursor()
  255. cursor1.execute("SELECT * FROM journey_times WHERE jt_leave_destination = %s AND jt_arrive_destination = %s" ,args)
  256. row1 = cursor1.fetchone()
  257. while row1 is not None:
  258. if row1[5] >= (adl+child) and row2[5] >= (adl+child):
  259. flight_time1=row1[4]-row1[2]
  260. flight_time2=row2[4]-row2[2]
  261. print("""<form action="results_sub.py" method="POST">
  262. <input class="get_var_invisible" name="start_dest" value='""",start_dest,"""'/>
  263. <input class="get_var_invisible" name="end_dest" value='""",end_dest,"""'/>
  264. <input class="get_var_invisible" name="start_date" value='""",start_date,"""'/>
  265. <input class="get_var_invisible" name="end_date" value='""",end_date,"""'/>
  266. <input class="get_var_invisible" name="leave1" value='""",row1[2],"""'/>
  267. <input class="get_var_invisible" name="leave2" value='""",row2[2],"""'/>
  268. <input class="get_var_invisible" name="flight_time1" value='""",flight_time1,"""'/>
  269. <input class="get_var_invisible" name="flight_time2" value='""",flight_time2,"""'/>
  270. <input class="get_var_invisible" name="arrive1" value='""",row1[4],"""'/>
  271. <input class="get_var_invisible" name="arrive2" value='""",row2[4],"""'/>
  272. <input class="get_var_invisible" name="seats_num" value='""",adl+child,"""'/>
  273. <input class="get_var_invisible" name="adl_num" value='""",adl,"""'/>
  274. <input class="get_var_invisible" name="child_num" value='""",child,"""'/>
  275. <input class="get_var_invisible" name="fare1" value='""",row1[6],"""'/>
  276. <input class="get_var_invisible" name="fare2" value='""",row2[6],"""'/>
  277. <div id="empty-div">""</div>
  278. <div id="results-offer">
  279. <div id="results-offer-select">
  280. <p style="font-size:33px;">&#163;""")
  281. if adl > 0:
  282. print(((row1[6]*adl)+(row1[6]*child-(row1[6]*child*0.2)))+((row2[6]*adl)+(row2[6]*child-(row2[6]*child*0.2))),"</p>","<input class='get_var_invisible' name='fare' value='",((row1[6]*adl)+(row1[6]*child-(row1[6]*child*0.2)))+((row2[6]*adl)+(row2[6]*child-(row2[6]*child*0.2))),"'/>")
  283. else:
  284. print((row1[6]*child+row2[6]*child),"</p>","<input class='get_var_invisible' name='fare' value='",(row1[6]*child+row2[6]*child),"'/>")
  285. print("""</p>
  286. <button id="results-select-pos" class="button2">Select</button>
  287. <p style="font-size:20px;">""")
  288. if row1[5] < row2[5]:
  289. print(row1[5])
  290. else:
  291. print(row2[5])
  292. print("""free seats</p>
  293. </div>
  294. <div style="border-bottom:1px solid #636363;" id="results-depart">
  295. <p style="font-size:20px;color:red;">Depart</p><p style="font-size:18px;">""",start_dest,"-",end_dest,"</p><p style='font-size:17px;'>",start_date,"""</p> <br><br>
  296. <table id="table-size">
  297. <tr>
  298. <th align="left">Leave</th>
  299. <th align="center">Journey Time</th>
  300. <th align="right">Arrive</th>
  301. </tr>
  302. <tr>
  303. <td align="left">""",row1[2],"""</td>
  304. <td align="center">""",row1[4]-row1[2],"""</td>
  305. <td align="right">""",row1[4],"""</td>
  306. </tr>
  307. </table>
  308. </div>
  309. <div id="results-depart">
  310. <p style="font-size:20px;color:red;">Return</p><p style="font-size:18px;">""",end_dest,"-",start_dest,"</p><p style='font-size:17px;'>",end_date,"""</p> <br><br>
  311. <table id="table-size">
  312. <tr>
  313. <th align="left">Leave</th>
  314. <th align="center">Journey Time</th>
  315. <th align="right">Arrive</th>
  316. </tr>
  317. <tr>
  318. <td align="left">""",row2[2],"""</td>
  319. <td align="center">""",row2[4]-row2[2],"""</td>
  320. <td align="right">""",row2[4],"""</td>
  321. </tr>
  322. </table>
  323. </div>
  324. </div>
  325. </form>""")
  326. row1 = cursor1.fetchone()
  327. else:
  328. row1 = cursor1.fetchone()
  329. cursor1.close()
  330. row2 = cursor2.fetchone()
  331. cursor2.close()
  332. print("""
  333. <div id="empty-div">""</div>
  334. </div>
  335. <div id="footer">
  336. <div id="box-shadow"></div>
  337. <div id="header-gradient">
  338. <div id="footer-position">
  339. &#174 2016 UWE WebAir. All rights reserved.
  340. </div>
  341. </div>
  342.  
  343. </div>
  344. <div id="slide" class="slide">
  345. <div id="logo-box">
  346. <form>
  347. <p style="font-size:13px;">Sign in to see exclusive Member Pricing</p>
  348. <button class="button1">Sign in</button>
  349. <p>New? <a href="url" style="color:red;">Create an Account</a></p>
  350. </form>
  351. </div>
  352. </div>
  353. </div>
  354. </body>
  355. </html>""")
  356. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement