-
Notifications
You must be signed in to change notification settings - Fork 0
/
Minigame.php
78 lines (78 loc) · 2.65 KB
/
Minigame.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
<?php session_start(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Minigame</title>
<?php include './assets/include/framework.php'; ?>
<link rel="stylesheet" href="./assets/css/editprofile.css">
</head>
<body>
<?php include './assets/include/header.php'; ?>
<?php include './assets/include/check.php'; ?>
<?php include './assets/include/check-invalid-user.php'; ?>
<main>
<hr class="mb-3">
<form action="./assets/PHP/getcoin.php" method="POST">
<?php
if (isset($_REQUEST['category'])) {
$url = $_REQUEST['url']."&category=".$_REQUEST['category']."&type=".$_REQUEST['type'];
}
else {
$url = $_REQUEST['url']."&type=".$_REQUEST['type'];
}
function file_get_contents_ssl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3000); // 3 sec.
curl_setopt($ch, CURLOPT_TIMEOUT, 10000); // 10 sec.
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$get = file_get_contents_ssl($url);
$json = json_decode($get);
$i = 0;
foreach ($json->results as $question) {
$i++;
echo
'
<div class="card mb-3 mt-3">
<div class="card-body">
<h4 class="text-success">Câu '.$i.': '.$question->question.'</h4>
<h5 class="text-success">Độ khó: '.$question->difficulty.'</h5>
<div class="form-check">
<input class="form-check-input" type="radio" name="choose_'.$i.'" id="true_'.$i.'" value="True" required>
<label class="form-check-label text-danger" for="true_'.$i.'">
Đúng
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="choose_'.$i.'" id="false_'.$i.'" value="False" required>
<label class="form-check-label text-danger" for="false_'.$i.'">
Sai
</label>
</div>
<input type="hidden" name="'.$i.'" value='.$question->correct_answer.'>
</div>
</div>
<hr>
';
}
?>
<div class="d-flex justify-content-end m-2">
<button type="submit" class="btn btn-success">Gửi kết quả</button>
</div>
</form>
<?php include "./assets/include/music-kit.php"; ?>
</main>
<?php include './assets/include/footer.php'; ?>
</body>
</html>