Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.52 KB | None | 0 0
  1. <?php
  2.  
  3. $sv_name = "localhost";
  4. $username = "root";
  5. $password = "slash112bot";
  6. $db_name = "uni";
  7. $con = mysql_connect($sv_name, $username, $password) or die(mysql_error());
  8. mysql_select_db($db_name, $con) or die(mysql_error());
  9.  
  10.  
  11. $showsub1 = 1;
  12. $showsub2 = 1;
  13. $showsub3 = 1;
  14. $showsub4 = 1;
  15.  
  16. $foundsub1 = 0;
  17. $foundsub2 = 0;
  18. $foundsub3 = 0;
  19. $foundsub4 = 0;
  20.  
  21.  
  22. $pages_table_name = "uni_combinations";
  23. $query_subjects = "SELECT * FROM " . $pages_table_name;
  24. $result_subjects = mysql_query($query_subjects, $con) or die(mysql_error());
  25.  
  26.  
  27. while($row_subjects = mysql_fetch_array($result_subjects))
  28. {
  29. if($_GET['typeid'] == $row_subjects['typeid'])
  30. {
  31. //echo "<br/>combinationid: " . $row_subjects['id'];
  32.  
  33. if (
  34. $_GET['subid1'] == $row_subjects['subid1'] ||
  35. $_GET['subid1'] == $row_subjects['subid2'] ||
  36. $_GET['subid1'] == $row_subjects['subid3'] ||
  37. $_GET['subid1'] == $row_subjects['subid4']
  38. )
  39. {
  40. $foundsub1 = 1;
  41. }
  42. if (
  43. ($_GET['subid1'] == $row_subjects['subid1'] ||
  44. $_GET['subid1'] == $row_subjects['subid2'] ||
  45. $_GET['subid1'] == $row_subjects['subid3'] ||
  46. $_GET['subid1'] == $row_subjects['subid4'])
  47. &&
  48. ($_GET['subid2'] == $row_subjects['subid1'] ||
  49. $_GET['subid2'] == $row_subjects['subid2'] ||
  50. $_GET['subid2'] == $row_subjects['subid3'] ||
  51. $_GET['subid2'] == $row_subjects['subid4'])
  52. )
  53. {
  54. $foundsub2 = 1;
  55. }
  56. if (
  57. ($_GET['subid1'] == $row_subjects['subid1'] ||
  58. $_GET['subid1'] == $row_subjects['subid2'] ||
  59. $_GET['subid1'] == $row_subjects['subid3'] ||
  60. $_GET['subid1'] == $row_subjects['subid4'])
  61. &&
  62. ($_GET['subid2'] == $row_subjects['subid1'] ||
  63. $_GET['subid2'] == $row_subjects['subid2'] ||
  64. $_GET['subid2'] == $row_subjects['subid3'] ||
  65. $_GET['subid2'] == $row_subjects['subid4'])
  66. &&
  67. ($_GET['subid3'] == $row_subjects['subid1'] ||
  68. $_GET['subid3'] == $row_subjects['subid2'] ||
  69. $_GET['subid3'] == $row_subjects['subid3'] ||
  70. $_GET['subid3'] == $row_subjects['subid4'])
  71. )
  72. {
  73. $foundsub3 = 1;
  74. }
  75. if (
  76. ($_GET['subid1'] == $row_subjects['subid1'] ||
  77. $_GET['subid1'] == $row_subjects['subid2'] ||
  78. $_GET['subid1'] == $row_subjects['subid3'] ||
  79. $_GET['subid1'] == $row_subjects['subid4'])
  80. &&
  81. ($_GET['subid2'] == $row_subjects['subid1'] ||
  82. $_GET['subid2'] == $row_subjects['subid2'] ||
  83. $_GET['subid2'] == $row_subjects['subid3'] ||
  84. $_GET['subid2'] == $row_subjects['subid4'])
  85. &&
  86. ($_GET['subid3'] == $row_subjects['subid1'] ||
  87. $_GET['subid3'] == $row_subjects['subid2'] ||
  88. $_GET['subid3'] == $row_subjects['subid3'] ||
  89. $_GET['subid3'] == $row_subjects['subid4'])
  90. &&
  91. ($_GET['subid4'] == $row_subjects['subid1'] ||
  92. $_GET['subid4'] == $row_subjects['subid2'] ||
  93. $_GET['subid4'] == $row_subjects['subid3'] ||
  94. $_GET['subid4'] == $row_subjects['subid4'])
  95. )
  96. {
  97. $foundsub4 = 1;
  98. }
  99.  
  100. if (
  101. ($_GET['subid1'] == $row_subjects['subid1'] ||
  102. $_GET['subid1'] == $row_subjects['subid2'] ||
  103. $_GET['subid1'] == $row_subjects['subid3'] ||
  104. $_GET['subid1'] == $row_subjects['subid4'])
  105. &&
  106. ($_GET['subid2'] == $row_subjects['subid1'] ||
  107. $_GET['subid2'] == $row_subjects['subid2'] ||
  108. $_GET['subid2'] == $row_subjects['subid3'] ||
  109. $_GET['subid2'] == $row_subjects['subid4'])
  110. &&
  111. ($_GET['subid3'] == $row_subjects['subid1'] ||
  112. $_GET['subid3'] == $row_subjects['subid2'] ||
  113. $_GET['subid3'] == $row_subjects['subid3'] ||
  114. $_GET['subid3'] == $row_subjects['subid4'])
  115. &&
  116. ($_GET['subid4'] == $row_subjects['subid1'] ||
  117. $_GET['subid4'] == $row_subjects['subid2'] ||
  118. $_GET['subid4'] == $row_subjects['subid3'] ||
  119. $_GET['subid4'] == $row_subjects['subid4'])
  120. )
  121. {
  122. $combinationid = $row_subjects['id'];
  123. }
  124. }
  125. }
  126.  
  127. $pages_table_name = "uni_combinations";
  128. $query_subjects = "SELECT * FROM " . $pages_table_name . " WHERE id='" . $combinationid . "'";
  129. $result_subjects = mysql_query($query_subjects, $con) or die(mysql_error());
  130. while($row_subjects = mysql_fetch_array($result_subjects))
  131. {
  132. $type = $row_subjects['typeid'];
  133. $sub1 = $row_subjects['subid1'];
  134. $sub2 = $row_subjects['subid2'];
  135. $sub3 = $row_subjects['subid3'];
  136. $sub4 = $row_subjects['subid4'];
  137. }
  138. $pages_table_name = "uni_subjects";
  139.  
  140.  
  141. $query_subjects = "SELECT * FROM " . $pages_table_name;
  142.  
  143. $result_subjects = mysql_query($query_subjects, $con) or die(mysql_error());
  144. while($row_subjects = mysql_fetch_array($result_subjects))
  145. { //disable all subjects which are not $sub1, $sub2, $sub3 or $sub4
  146. if(
  147. $row_subjects['id'] != $sub1 &&
  148. $row_subjects['id'] != $sub2 &&
  149. $row_subjects['id'] != $sub3 &&
  150. $row_subjects['id'] != $sub4
  151. )
  152. {
  153. //echo "<input type=\"hidden\" name=\"disable" . $x . "\" value=\"1\"/>";
  154. }
  155. else
  156. {
  157. //echo "<input type=\"hidden\" name=\"disable" . $x . "\" value=\"0\"/>";
  158. }
  159. }
  160.  
  161.  
  162. //if ($foundsub1 == 1)
  163. //{
  164. $showsub1 = 1;
  165. //}
  166. //if ($foundsub2 == 1)
  167. //{
  168. $showsub2 = 1;
  169. //}
  170. //if ($foundsub3 == 1)
  171. //{
  172. $showsub3 = 1;
  173. //}
  174. //if ($foundsub4 == 1)
  175. //{
  176. $showsub4 = 1;
  177. //}
  178.  
  179. /*if ($foundsub1 == 0)
  180. {
  181. $showsub1 = 0;
  182. }
  183. if ($foundsub2 == 0)
  184. {
  185. $showsub2 = 0;
  186. }
  187. if ($foundsub3 == 0)
  188. {
  189. $showsub3 = 0;
  190. }
  191. if ($foundsub4 == 0)
  192. {
  193. $showsub4 = 0;
  194. }*/
  195.  
  196. $typeid = $_GET['typeid'];
  197. $subid1 = $_GET['subid1'];
  198. $subid2 = $_GET['subid2'];
  199. $subid3 = $_GET['subid3'];
  200. $subid4 = $_GET['subid4'];
  201.  
  202. if ($typeid == 1 || $typeid == 3)
  203. {
  204. $subs = 3;
  205. }
  206. if ($typeid == 2)
  207. {
  208. $subs = 2;
  209. }
  210. if ($typeid == 4)
  211. {
  212. $subs = 4;
  213. }
  214.  
  215.  
  216.  
  217.  
  218. echo "<table><tr><th>";
  219. echo "<br/>";
  220. if ($_GET['subid1'] != 0)
  221. {
  222. echo "<a onmouseover=\"this.style.cursor='pointer';\" onclick=\"if(document.getElementById('modules1').style.display=='none'){document.getElementById('modules1').style.display='';} else{document.getElementById('modules1').style.display='none'}\">Show Modules</a>";
  223. }
  224. echo "<span id=\"modules1\" style=\"display:none;\">";
  225. $pages_table_name = "uni_subjects";
  226. $query_combinations1 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string($_GET['subid1']) . "'";
  227. $result_combinations1 = mysql_query($query_combinations1, $con) or die(mysql_error());
  228. while($row_combinations1 = mysql_fetch_array($result_combinations1))
  229. {
  230. if ($_GET['typeid'] == 1)
  231. {
  232. $ex = explode(',', $row_combinations1['modules1']);
  233. }
  234. if ($_GET['typeid'] == 2)
  235. {
  236. $ex = explode(',', $row_combinations1['modules2']);
  237. }
  238. if ($_GET['typeid'] == 3)
  239. {
  240. $ex = explode(',', $row_combinations1['modules3']);
  241. }
  242. if ($_GET['typeid'] == 4)
  243. {
  244. $ex = explode(',', $row_combinations1['modules4']);
  245. }
  246. $pages_table_name = "uni_modules";
  247. for($i=0; $i<count($ex); $i++)
  248. {
  249. $query_combinations1 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string(trim($ex[$i])) . "'";
  250. $result_modules1 = mysql_query($query_combinations1, $con) or die(mysql_error());
  251. while($row_modules1 = mysql_fetch_array($result_modules1))
  252. {
  253. if ($showsub1 == 1)
  254. {
  255. echo "<br/><a target=\"_blank\" href=\"" . $row_modules1['summaryid'] . "\">" . urlencode($row_modules1['name']) . "</a>";
  256. }
  257. }
  258. }
  259. }
  260. if ($_GET['subid1'] != 0)
  261. {
  262. echo "</span>";
  263. }
  264.  
  265. echo "</th><th>";
  266. echo "<br/>";
  267. if ($_GET['subid2'] != 0)
  268. {
  269. echo "<a onmouseover=\"this.style.cursor='pointer';\" onclick=\"if(document.getElementById('modules2').style.display=='none'){document.getElementById('modules2').style.display='';} else{document.getElementById('modules2').style.display='none'}\">Show Modules</a>";
  270. }
  271. echo "<span id=\"modules2\" style=\"display:none;\">";
  272.  
  273. $pages_table_name = "uni_subjects";
  274. $query_combinations2 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string($_GET['subid2']) . "'";
  275. $result_combinations2 = mysql_query($query_combinations2, $con) or die(mysql_error());
  276. while($row_combinations2 = mysql_fetch_array($result_combinations2))
  277. {
  278. if ($_GET['typeid'] == 1)
  279. {
  280. $ex = explode(',', $row_combinations2['modules1']);
  281. }
  282. if ($_GET['typeid'] == 2)
  283. {
  284. $ex = explode(',', $row_combinations2['modules2']);
  285. }
  286. if ($_GET['typeid'] == 3)
  287. {
  288. $ex = explode(',', $row_combinations2['modules3']);
  289. }
  290. if ($_GET['typeid'] == 4)
  291. {
  292. $ex = explode(',', $row_combinations2['modules4']);
  293. }
  294. $pages_table_name = "uni_modules";
  295. for($i=0; $i<count($ex); $i++)
  296. {
  297. $query_combinations2 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string(trim($ex[$i])) . "'";
  298. $result_modules2 = mysql_query($query_combinations2, $con) or die(mysql_error());
  299. while($row_modules2 = mysql_fetch_array($result_modules2))
  300. {
  301. if ($showsub2 == 1)
  302. {
  303. echo "<br/><a target=\"_blank\" href=\"" . $row_modules2['summaryid'] . "\">" . urlencode($row_modules2['name']) . "</a>";
  304. }
  305. }
  306. }
  307. }
  308. if ($_GET['subid2'] != 0)
  309. {
  310. echo "</span>";
  311. }
  312.  
  313.  
  314. echo "</th> <th>";
  315. echo "<br/>";
  316. if ($_GET['subid3'] != 0)
  317. {
  318. echo "<a onmouseover=\"this.style.cursor='pointer';\" onclick=\"if(document.getElementById('modules3').style.display=='none'){document.getElementById('modules3').style.display='';} else{document.getElementById('modules3').style.display='none'}\">Show Modules</a>";
  319. }
  320. echo "<span id=\"modules3\" style=\"display:none;\">";
  321.  
  322. $pages_table_name = "uni_subjects";
  323. $query_combinations3 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string($_GET['subid3']) . "'";
  324. $result_combinations3 = mysql_query($query_combinations3, $con) or die(mysql_error());
  325. while($row_combinations3 = mysql_fetch_array($result_combinations3))
  326. {
  327. if ($_GET['typeid'] == 1)
  328. {
  329. $ex = explode(',', $row_combinations3['modules1']);
  330. }
  331. if ($_GET['typeid'] == 2)
  332. {
  333. $ex = explode(',', $row_combinations3['modules2']);
  334. }
  335. if ($_GET['typeid'] == 3)
  336. {
  337. $ex = explode(',', $row_combinations3['modules3']);
  338. }
  339. if ($_GET['typeid'] == 4)
  340. {
  341. $ex = explode(',', $row_combinations3['modules4']);
  342. }
  343. $pages_table_name = "uni_modules";
  344. for($i=0; $i<count($ex); $i++)
  345. {
  346. $query_combinations3 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string(trim($ex[$i])) . "'";
  347. $result_modules3 = mysql_query($query_combinations3, $con) or die(mysql_error());
  348. while($row_modules3 = mysql_fetch_array($result_modules3))
  349. {
  350. if ($showsub3 == 1)
  351. {
  352. echo "<br/><a target=\"_blank\" href=\"" . $row_modules3['summaryid'] . "\">" . urlencode($row_modules3['name']) . "</a>";
  353. }
  354. }
  355. }
  356. }
  357. if ($_GET['subid3'] != 0)
  358. {
  359. echo "</span>";
  360. }
  361.  
  362.  
  363. echo "</th> <th>";
  364. echo "<br/>";
  365. if ($_GET['subid4'] != 0)
  366. {
  367. echo "<a onmouseover=\"this.style.cursor='pointer';\" onclick=\"if(document.getElementById('modules4').style.display=='none'){document.getElementById('modules4').style.display='';} else{document.getElementById('modules4').style.display='none'}\">Show Modules</a>";
  368. }
  369. echo "<span id=\"modules4\" style=\"display:none;\">";
  370.  
  371. $pages_table_name = "uni_subjects";
  372. $query_combinations4 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string($_GET['subid4']) . "'";
  373. $result_combinations4 = mysql_query($query_combinations4, $con) or die(mysql_error());
  374. while($row_combinations4 = mysql_fetch_array($result_combinations4))
  375. {
  376. if ($_GET['typeid'] == 1)
  377. {
  378. $ex = explode(',', $row_combinations4['modules1']);
  379. }
  380. if ($_GET['typeid'] == 2)
  381. {
  382. $ex = explode(',', $row_combinations4['modules2']);
  383. }
  384. if ($_GET['typeid'] == 3)
  385. {
  386. $ex = explode(',', $row_combinations4['modules3']);
  387. }
  388. if ($_GET['typeid'] == 4)
  389. {
  390. $ex = explode(',', $row_combinations4['modules4']);
  391. }
  392. $pages_table_name = "uni_modules";
  393. for($i=0; $i<count($ex); $i++)
  394. {
  395. $query_combinations4 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string(trim($ex[$i])) . "'";
  396. $result_modules4 = mysql_query($query_combinations4, $con) or die(mysql_error());
  397. while($row_modules4 = mysql_fetch_array($result_modules4))
  398. {
  399. if ($showsub4 == 1)
  400. {
  401. echo "<br/><a target=\"_blank\" href=\"" . $row_modules4['summaryid'] . "\">" . urlencode($row_modules4['name']) . "</a>";
  402. }
  403. }
  404. }
  405. }
  406. if ($_GET['subid4'] != 0)
  407. {
  408. echo "</span>";
  409. }
  410.  
  411. echo "<br/>";
  412.  
  413.  
  414. echo "</th></tr><tr><td>";
  415.  
  416. $pages_table_name = "uni_subjects";
  417. $query_subjects1 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string($subid1) . "'";
  418. $result_subjects1 = mysql_query($query_subjects1, $con) or die(mysql_error());
  419. while($row_subjects1 = mysql_fetch_array($result_subjects1))
  420. {
  421. if ($showsub1 == 1)
  422. {
  423. echo "<img src=\"" . $row_subjects1['id'] . "-" . $typeid . ".png\"/>";
  424. }
  425. else
  426. {
  427. echo "<img src=\"wrongcombo.png\"/>";
  428. }
  429. }
  430.  
  431. echo "</td><td>";
  432.  
  433. $pages_table_name = "uni_subjects";
  434. $query_subjects2 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string($subid2) . "'";
  435. $result_subjects2 = mysql_query($query_subjects2, $con) or die(mysql_error());
  436. while($row_subjects2 = mysql_fetch_array($result_subjects2))
  437. {
  438. if ($showsub2 == 1)
  439. {
  440. echo "<img src=\"" . $row_subjects2['id'] . "-" . $typeid . ".png\"/>";
  441. }
  442. else
  443. {
  444. echo "<img src=\"wrongcombo.png\"/>";
  445. }
  446. }
  447.  
  448. echo "</td><td>";
  449.  
  450. $pages_table_name = "uni_subjects";
  451. if ($subs > 2)
  452. {
  453. $query_subjects3 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string($subid3) . "'";
  454. $result_subjects3 = mysql_query($query_subjects3, $con) or die(mysql_error());
  455. while($row_subjects3 = mysql_fetch_array($result_subjects3))
  456. {
  457. if ($showsub3 == 1)
  458. {
  459. echo "<img src=\"" . $row_subjects3['id'] . "-" . $typeid . ".png\"/>";
  460. }
  461. else
  462. {
  463. echo "<img src=\"wrongcombo.png\"/>";
  464. }
  465. }
  466. }
  467.  
  468. echo "</td><td>";
  469.  
  470. $pages_table_name = "uni_subjects";
  471. if ($subs > 3)
  472. {
  473. $query_subjects4 = "SELECT * FROM " . $pages_table_name . " WHERE id='" . mysql_real_escape_string($subid4) . "'";
  474. $result_subjects4 = mysql_query($query_subjects4, $con) or die(mysql_error());
  475. while($row_subjects4 = mysql_fetch_array($result_subjects4))
  476. {
  477. if ($showsub4 == 1)
  478. {
  479. echo "<img src=\"" . $row_subjects4['id'] . "-" . $typeid . ".png\"/>";
  480. }
  481. else
  482. {
  483. echo "<img src=\"wrongcombo.png\"/>";
  484. }
  485. }
  486. }
  487. echo "</td></tr></table>";
  488.  
  489. // echo "<br /><img src=\"timetable.jpg\" width=\"100%\" alt=\"Timetable\"></img>";
  490. // echo "<span style=\"width: 50%;\"><br /><img src=\"" . $_GET['combinationid'] . ".png\" alt=\"Timetable\"></img></span>";
  491. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement