-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
203 lines (189 loc) · 7.65 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
require_once 'core/init.php';
$session->start();
$Result = "";
if ($Result = $session->check('Email') AND $Result == "FALSE")
{
?>
<!DOCTYPE html>
<html>
<head>
<title>iCiShort - Pemendek URL</title>
<link rel="stylesheet" type="text/css" href="<?php echo $baseurl->get(); ?>assets/css/font.css">
<link rel="stylesheet" type="text/css" href="<?php echo $baseurl->get(); ?>assets/css/style.css">
<script src="<?php echo $baseurl->get(); ?>assets/plugin/sweetalert/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $baseurl->get(); ?>assets/plugin/sweetalert/sweetalert.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
</head>
<body>
<header><a href="index.php">iCiShort</a></header>
<div id="content" style="text-align: center;">
<div class="box">
<form name="PendekkanURL" method="POST">
<input type="text" class="InputURL" placeholder="http://" name="URL"> <input type="submit" class="ButtonShort" value="Generate" name="Proses">
</form>
<br/>
<br/>
<?php
if (isset($_POST['Proses']))
{
$URL = $securityf->Data($_POST['URL']);
$Nama = "Anonim";
if ($validation->empty_field($URL) == "TRUE")
{
echo "<script>sweetAlert('Kesalahan', 'URL masih kosong.', 'error');</script>";
}
else
{
if ($system->insert($URL, $urlshort, $Nama, "0",$code->create()) == "TRUE")
{
?>
<center>
<table>
<tr>
<td><?php echo "Berhasil url anda telah di pendekkan menjadi <a href='".$baseurl->get().$urlshort."' class='aShortURL'>".$baseurl->get().$urlshort."";?></td>
</tr>
</table>
</center>
<?php
}
else
{
echo "<script>sweetAlert('Kesalahan', 'Tidak dapat memperpendek url anda silahkan ulangi lagi.', 'error');</script>";
}
}
}
?>
<br/><br/>
<a href="daftar.php"><button type="submit" class="regButton">Mendaftar</button></a> <a href="masuk.php"><button type="submit" class="logButton">Masuk</button></a>
</div>
</div>
<div id="footer">2017 - iCiShort</div>
</body>
</html>
<?php
}
else
{
?>
<!DOCTYPE html>
<html>
<head>
<title>iCiShort - Pemendek URL</title>
<link rel="stylesheet" type="text/css" href="<?php echo $baseurl->get(); ?>assets/css/font.css">
<link rel="stylesheet" type="text/css" href="<?php echo $baseurl->get(); ?>assets/css/style.css">
<script src="<?php echo $baseurl->get(); ?>assets/plugin/sweetalert/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $baseurl->get(); ?>assets/plugin/sweetalert/sweetalert.css">
</head>
<body>
<header><a href="index.php">iCiShort</a></header>
<div id="content" style="text-align: center;">
<br/>
<br/>
Selamat Datang <strong><?php echo $session->get($Result); ?></strong>.
<div class="box">
<form name="PendekkanURL" method="POST">
<input type="text" class="InputURL" placeholder="http://" name="URL"> <input type="submit" class="ButtonShort" value="Generate" name="Proses">
</form>
<br/>
<br/>
<div class="history">
<?php
if (isset($_POST['Proses']))
{
$URL = $securityf->Data($_POST['URL']);
$Nama = $session->get($Result);
if ($validation->empty_field($URL) == "TRUE")
{
echo "<script>sweetAlert('Kesalahan', 'URL masih kosong.', 'error');</script>";
}
else
{
if ($Result = $system->insert($URL, $urlshort, $Nama, "0", $code->create()) AND $Result == "TRUE")
{
?>
<center>
<table>
<tr>
<td><?php echo "Berhasil url ".$Nama." telah di pendekkan menjadi <a href='".$baseurl->get().$urlshort."' class='aShortURL'>".$baseurl->get().$urlshort."";?></td>
</tr>
</table>
</center>
<?php
}
else
{
echo "<script>sweetAlert('Kesalahan', 'Tidak dapat memperpendek url anda silahkan ulangi lagi.', 'error');</script>";
}
}
}
$getHistory = $system->gethistory($session->get($Result));
if ($getHistory->num_rows > 0)
{
?>
<center>
<h1 class="h1history">Riwayat</h1>
<br/>
<br/>
<table>
<thead>
<tr>
<th>URL Asli</th>
<th>URL Pendek</th>
<th>Dikunjungi</th>
</tr>
</thead>
<tbody>
<?php
while ($history = $getHistory->fetch_assoc())
{
?>
<tr>
<td>
<p><?php echo $history['URLAsli'];?></p>
</td>
<td>
<a href="<?php echo $baseurl->get().$history['URLPendek'];?>"><?php echo $baseurl->get().$history['URLPendek'];?></a>
</td>
<td>
<?php echo $history['Dikunjungi']; ?> x
</td>
</tr>
<?php
}?></tbody></table></center><?php
}
else
{
?>
<center>
<h1 class="h1history">Riwayat</h1>
<br/>
<br/>
<table>
<thead>
<tr>
<th>URL Asli</th>
<th>URL Pendek</th>
<th>Dikunjungi</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Tidak ada data yang dapat ditampilkan.</td>
<td></td>
</tr>
</tbody></table></center>
<?php
}
?>
</div>
<br/>
<br/>
<center><a href="keluar.php"><button type="submit" class="logOutButton">Keluar</button></a></center>
</div>
</div>
<div id="footer">2017 - iCiShort</div>
</body>
</html>
<?php } ?>