forked from pranavrc/chennai-hackers.in
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
181 lines (180 loc) · 3.74 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
<!DOCTYPE html>
<html>
<head>
<title>#chennai-hackers</title>
<style type="text/css">
body {
background-image:url("chbg.png");
padding: 0;
margin: 0;
color: #222;
font-family: Verdana;
}
a {
color: inherit;
text-decoration: none;
}
.container {
width: 940px;
margin: 0 auto;
padding: 0 10px;
}
.header {
text-align: center;
font-size: 50px;
text-shadow: #444 2px 2px 2px;
border-bottom: medium dashed #999;
}
.header p {
margin: 20px 0px;
}
.content {
padding: 10px;
}
.footer {
text-align: center;
font-size: 13px;
border-top: medium dashed #999;
}
.person {
width: 280px;
height: 125px;
padding: 10px;
padding-top: 30px;
}
.person-meta {
width: 155px;
float: right;
}
.dp {
background-image: url("dpbg.png");
padding: 7px;
width: 108px;
height: 108px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
float: left;
}
.person-name {
font-size: 20px;
text-align: center;
}
.person-name p {
margin: 6px 0;
}
.person-desc {
font-size: 12px;
text-align: center;
}
.person-desc p {
margin: 6px 0;
}
.person-sep {
height: 10px;
width: 40px;
clear: both;
padding: 0 130px;
border-bottom: thin dashed #999;
}
.col1, .col2, .col3 {
width: 300px;
float: left;
padding-bottom: 10px;
}
.clear {
clear: both;
}
.col1, .col2 {
border-right: thin dashed #999;
}
</style>
</head>
<?php
function readData() {
// read data
$file = "data.json" or die("Couldn't open the file `data.json`");
$fh = fopen($file, "r") or die("Couldn't open the file `data.json`");
$data = fread($fh, filesize($file)) or die("Couldn't open the file `data.json`");
fclose($fh);
//parse data
$jsondata = json_decode($data, true);
//var_dump($jsondata);
return $jsondata;
}
function getProfileBatch($handle) {
shuffle($handle["desc"]);
shuffle($handle["avatar"]);
$desc = array_pop($handle["desc"]);
$avatar = array_pop($handle["avatar"]);
if (!$avatar) {
$avatar = "avatars/default.jpg";
}
?>
<div class="person">
<a href="<?php echo $handle["profileurl"]; ?>"><div class="dp">
<img src="<?php echo $avatar; ?>"/>
</div>
<div class="person-meta">
<div class="person-name">
<p><?php echo $handle["screenname"];; ?></p>
</div>
<div class="person-desc">
<p><?php echo $desc; ?></p>
</div>
</div>
<div class="person-sep">
</div></a>
</div> <!-- person div ends -->
<?php
}
?>
<body>
<div class="container">
<div class="header">
<p>#chennai-hackers</p>
</div>
<div class="content">
<?php
$jsondata = readData();
$numprofile = sizeof($jsondata);
$quotent = (int) ($numprofile/3);
$remainder = $numprofile%3;
$col1 = $col2 = $col3 = $quotent;
if ($remainder > 0) {
$col1 += 1;
}
if ($remainder > 1) {
$col2 += 1;
}
shuffle($jsondata);
for ($col=1; $col<=3; $col++) {
if ($col == 1) {
$collen = $col1;
} else if ($col == 2) {
$collen = $col2;
} else if ($col == 3) {
$collen = $col3;
}
?>
<div class="col<?php echo $col?>">
<?php
for ($i=0; $i<$collen; $i++) {
getProfileBatch(array_pop($jsondata));
}
if ($collen == 0) {
echo " ";
}
?>
</div>
<?php } ?>
<div class="clear">
</div>
</div>
<div class="footer">
<p>we are #chennai-hackers on irc.freenode.net</p>
</div>
</div>
</body>
</html>