-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
94 lines (90 loc) · 2.89 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
#IMPORTANT: URL DECLARATION#
$baseurl = "https://spartavote.notrealurl.com";
$loginurl = "https://login.itb.ac.id/cas/login?service=".$baseurl;
$res = "";
if(isset($_GET["ticket"])){
$ticket = $_GET["ticket"];
#SSO IS URL DEPENDANT#
$credurl = "https://login.itb.ac.id/cas/serviceValidate?ticket=".$ticket."&service=".$baseurl;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $credurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($curl);
#TICKET VALIDATION#
if (!strpos($res, "INVALID_TICKET")) {
$resarr = explode(" ",$res);
$tmnim = array_values(array_slice($resarr, -33))[0];
$nim = explode("<",explode(">",$tmnim)[1])[0];
}
curl_close($curl);
}
?>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Ganesha Vote</title>
<link rel="stylesheet" type="text/css" href="css/flexboxgrid.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<header>
<div class="container">
<div class="row end-xs" id="header-row" >
<div class="col-xs-2">
<div class="box" id="header-title" ><b>GaneshaVote</b></div>
</div>
<div class="col-xs-10">
<?if ((!strpos($res, "INVALID_TICKET")) && (isset($_GET["ticket"]))):?>
<span>Logged in as <?php echo $nim;?></span>
<?php endif;?>
</div>
</div>
</div>
</header>
<div class="container" id="main">
<?if ((!strpos($res, "INVALID_TICKET")) && (isset($_GET["ticket"]))): ?>
<div class="row center-xs votebox">
<div class="col-xs-6">
<div class="box">
<img src="example-res/face1.png" class="fotopaslon"><br>
<span>AGUS DOE</span>
</div>
</div>
<div class="col-xs-6">
<div class="box">
<img src="example-res/face2.jpeg" class="fotopaslon"><br>
<span>JOHN FULAN</span>
</div>
</div>
</div>
<form action="submit.php" method="post">
<div class="row center-xs votebox">
<div class="col-xs-6">
<input type="radio" name="choice" value="1"><b>PASLON 1</b>
</div>
<div class="col-xs-6">
<input type="radio" name="choice" value="2"><b>PASLON 2</b>
</div>
</div>
<div class="row center-xs votebox">
<div class="col">
<input type="hidden" name="nim" value="<?php echo $nim;?>">
<input type="hidden" name="ticket" value="<?php echo $ticket;?>">
<input type="submit">
</div>
</div>
</form>
</div>
<?php else:?>
<div class="row center-xs">
<div class="col">
<span>You're not logged in. Click <a href="<?php echo $loginurl;?>">here</a> to login!</span>
</div>
</div>
</div>
<?php endif;?>
</body>
</html>