-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
205 lines (196 loc) · 8.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
204
205
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Password Generator</title>
</head>
<body>
<h2>컴퓨터께서 행운의 숫자를 주실지니!!</h2>
<div class="mb-4">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">Add date</button>
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#addSpecificNumberModal">Add Specific Number</button>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#removeDateModal">Remove Date</button>
<button type="button" id="archiveButton" class="btn btn-info">Archive</button>
</div>
<div class="mb-2">
우리가 30개의 숫자를 확인한다면 3%의 확률로 당첨될 수 있다.<br/>
이틀동안 하면 5.91% 삼일은 8.73% ..10일은 26.28% 15일은 37.67%이다.<br/>
그리고 우리는 50개 이상도 확인 가능하고 그렇게 15일동안 한다면 53.67%의 확률로 당첨될 수 있다.
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add New Number</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="contact_form" action="./adddate.php" method="GET">
<div class="form-group">
<label for="recipient-name" class="col-form-label">Date</label>
<input type="text" name="date" class="form-control">
</div>
<div class="form-group">
<label for="message-text" class="col-form-label">Number</label>
<input type="number" name="number" class="form-control">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" id="submitForm" class="btn btn-primary">Add New Date</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="addSpecificNumberModal" tabindex="-1" role="dialog" aria-labelledby="addSpecificNumberModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Specific Number</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="add_specific_number_form" action="./addspecificnumber.php" method="GET">
<div class="form-group">
<label for="date-name" class="col-form-label">Date to add</label>
<input type="text" name="date" class="form-control">
<label for="date-name" class="col-form-label">Number to add</label>
<input type="number" name="number" class="form-control">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" id="submitAddSpecificNumber" class="btn btn-success">Add Number</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="removeDateModal" tabindex="-1" role="dialog" aria-labelledby="removeDateModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Remove Date</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="remove_date_form" action="./removedate.php" method="GET">
<div class="form-group">
<label for="date-name" class="col-form-label">Date to remove</label>
<input type="text" name="date" class="form-control">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" id="submitRemoveDate" class="btn btn-danger">Remove Date</button>
</div>
</div>
</div>
</div>
<?php
$dir = "/var/www/html/passgen/history";
// 핸들 획득
$handle = opendir($dir);
$files = [];
// 디렉터리에 포함된 파일을 저장한다.
while (false !== ($filename = readdir($handle))) {
if($filename == "." || $filename == ".."){
continue;
}
// 파일인 경우만 목록에 추가한다.
if(is_file($dir . "/" . $filename)){
$files[$filename] = [];
$fp = fopen($dir."/".$filename, "r");
while( !feof($fp) ) {
$data = preg_replace('/\s+/', '', fgets($fp));
if(is_numeric($data)) {
array_push($files[$filename],(int)$data);
}
}
fclose($fp);
}
}
// 핸들 해제
closedir($handle);
ksort($files);
echo '<nav>';
echo '<div class="nav nav-tabs" id="nav-tab" role="tablist">';
$index = 0;
foreach ($files as $k => $v) {
if($index == 0){
echo '<a class="nav-item nav-link active" data-toggle="tab" href="#nav-'.$k.'" role="tab" aria-selected="true">'.$k.'</a>';
} else {
echo '<a class="nav-item nav-link" data-toggle="tab" href="#nav-'.$k.'" role="tab" aria-selected="true">'.$k.'</a>';
}
$index += 1;
}
echo '</div>';
echo '</nav>';
echo '<div class="tab-content" id="nav-tabContent">';
$index = 0;
foreach ($files as $k => $v) {
if($index == 0) {
echo '<div class="tab-pane fade show active" id="nav-'.$k.'" role="tabpanel">';
} else {
echo '<div class="tab-pane fade" id="nav-'.$k.'" role="tabpanel">';
}
echo '<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter" data-whatever="'.$k.'">';
echo 'Get '.$k.'th date number!';
echo '</button>';
echo '<br/>';
$tmp = array_slice($v, 1);
$count = count($tmp);
echo "우리는 이미 $count 개의 숫자를 확인했다.<br/>";
echo "밑은 우리에게 스러져간 숫자들의 명단이다.<br/>";
sort($tmp);
foreach($tmp as $data) {
echo str_pad((string)$data,4,'0',STR_PAD_LEFT);
echo '<br/>';
}
echo'</div>';
$index += 1;
}
echo '</div>';
?>
<!-- Button trigger modal -->
<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle">Get your lucky number</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<iframe width="100%" height="100%" frameBorder="0" src="https://mit-games.kr/passgen/getnumber.php">
</iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<!-- <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script type="text/javascript" src="func.js"></script>
</body>
</html>