-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerateNameTag.php
More file actions
132 lines (94 loc) · 2.92 KB
/
Copy pathgenerateNameTag.php
File metadata and controls
132 lines (94 loc) · 2.92 KB
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
<?php
require('database.php');
require('method.php');
require('ini.php');
$studs = array();
$ret = SQL("SELECT `username`, `type` FROM `graduation_prom_2018_tickets` WHERE `type` = 'SINGLE' OR `type` = 'COUPLE' OR `type` = 'ACADEMY' ");
for($t = 0; $t < count($ret); $t ++){
$username = $ret[$t]['username'];
$ret2 = SQL("SELECT `firstName`, `middleName`, `lastName`, `conselorFirstName`, `conselorLastName`, `grade`, `gender` FROM `graduation_prom_2018_account` WHERE `username` = '$username' ");
$studs[$t] = array_merge($ret[$t], $ret2[0]);
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="resource/layui-v2.2.6/css/layui.css" media="all">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel='stylesheet' href='resource/font.css?1.2' type='text/css' />
<style>
body{
padding: 30px;
}
td, th{
padding: 30px;
min-width: 180px;
}
b{
font-weight: 900;
}
.fa-circle{
font-size: 8px;
padding: 1px;
}
</style>
</head>
<body>
<table border="0">
<?php
$column = 5;
$row = (int)(count($studs) / $column) + 1;
$lastRow = count($studs) % $column;
for($t = 0; $t < $row; $t ++){
?>
<tr>
<?php
if($row - 1 == $t){
$column = $lastRow;
}
for($t2 = 0; $t2 < $column; $t2 ++){
?>
<td>
<i class="fa fa-bookmark" aria-hidden="true"></i> <b><?php echo $studs[$t * $column + $t2]['lastName'] ?>, <?php echo $studs[$t * $column + $t2]['firstName'] ?></b> <?php echo $studs[$t * $column + $t2]['middleName'] ?><br>
<?php echo hideStudNum($studs[$t * $column + $t2]['username']) ?>, Grade <?php echo $studs[$t * $column + $t2]['grade'] ?>, <?php echo $studs[$t * $column + $t2]['gender'] ?><br>
<?php echo $studs[$t * $column + $t2]['conselorFirstName'] ?> <?php echo $studs[$t * $column + $t2]['conselorLastName'] ?>, <?php echo $studs[$t * $column + $t2]['type'] ?>
</td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
</body>
</html>
<?php
function hideStudNum($stud){
if(!is_numeric($stud) || strlen($stud) < 8){
return $stud;
}
if(strlen($stud) == 8){
return hideStudNum_($stud, '●', 4, 3);
}else if(strlen($stud) == 10){
return hideStudNum_($stud, '●', 6, 3);
}
}
function hideStudNum_($str, $replacement = '*', $start = 1, $length = 3) {
$len = mb_strlen($str,'utf-8');
if ($len > intval($start+$length)) {
$str1 = mb_substr($str,0,$start,'utf-8');
$str2 = mb_substr($str,intval($start+$length),NULL,'utf-8');
} else {
$str1 = mb_substr($str,0,1,'utf-8');
$str2 = mb_substr($str,$len-1,1,'utf-8');
$length = $len - 2;
}
$new_str = $str1;
for ($i = 0; $i < $length; $i++) {
$new_str .= $replacement;
}
$new_str .= $str2;
return $new_str;
}
?>