forked from jemjabella/BellaBuffs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
members.php
147 lines (129 loc) · 4.43 KB
/
members.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
<?php
require_once('prefs.php');
include_once('header.php');
if(!fopen(MEMBERS, "r")) {
echo "<p>Could not open members file. Please verify permissions (CHMOD - 666) and actual existence.</p>";
} else {
if (filesize(MEMBERS) > 0) {
$members = file(MEMBERS);
$queryURL = "";
if (isset($_GET['s']) && $_GET['s'] == "sortName") {
natcasesort($members);
$members = array_values($members);
$queryURL = "&s=sortName";
} elseif (isset($_GET['s']) && $_GET['s'] == "sortCountry") {
$countryArray = file(COUNTRIES);
foreach($countryArray as $country) {
$countryArray[] = rtrim($country);
}
if (!isset($_GET['c']) || in_array($_GET['c'], $countryArray) === FALSE) {
// find out who has joined with which country and stick them in an array
foreach ($members as $mem) {
list($name,$email,$dispemail,$url,$country,$fave) = preg_split("/,(?! )/",$mem);
$newArray[] = $country;
}
// count each time country occurs
$countryCount = array_count_values($newArray);
// sort the array so that the countries are in alphabetical order
$newArray = array_unique($newArray);
natcasesort($newArray);
// display the countries
echo "<ul>";
foreach ($newArray as $country) {
foreach ($countryCount as $key => $cc) {
if ($key == $country) {
echo "<li><a href=\"members.php?s=sortCountry&c=".urlencode($country)."\">$country</a> ($cc members)</li>";
}
}
}
echo "</ul>";
exit(include("footer.php"));
} else {
foreach ($members as $key => $memb) {
list($name,$email,$dispemail,$url,$country,$fave) = preg_split("/,(?! )/",$memb);
if (preg_match("/($_GET[c])/i", $country)) {
$NEWmembers[] = "$name,$email,$dispemail,$url,$country,$fave";
}
}
$members = $NEWmembers;
natcasesort($members);
$members = array_values($members);
unset($NEWmembers);
$queryURL = "&s=sortCountry&c=".urlencode($country);
}
}
$count = count($members);
$numpages = ceil($count/$perpage);
if ($perpage < $count) {
echo "<p style=\"text-align: center;\">$count members | ";
if (isset($_GET['page']) && $_GET['page'] > 1 && $_GET['page'] <= $numpages) {
$prev = $_GET['page'] - 1;
echo "<a href='members.php?page={$prev}$queryURL'>Prev</a> · ";
} else {
echo "Prev · ";
}
for ($x=1; $x<=$numpages; $x++) {
if ((isset($_GET['page']) && $x == $_GET['page']) || (!isset($_GET['page']) && $x == 1)) {
echo "<strong>$x</strong> ";
} else {
echo "<a href=\"members.php?page=$x$queryURL\">$x</a> ";
}
}
if ((!isset($_GET['page'])) || (isset($_GET['page']) && $_GET['page'] < $numpages)) {
if (!isset($_GET['page'])) {
$_GET['page'] = 1;
}
$next = $_GET['page'] + 1;
echo " · <a href='members.php?page={$next}$queryURL'>Next</a>";
} else {
echo " · Next";
}
echo "</p> \n\n ";
} else {
echo "<p style=\"text-align: center;\">$count members</p>";
}
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
$i=$perpage*($_GET['page']-1);
} else {
$i=0;
}
$end = $i + $perpage;
if ($end > $count) { $end = $count; }
?>
<table style="width: 100%;">
<tr> <th>Name</th> <th>E-mail</th> <th>Website</th> <th>Country</th> <?php if (isset($favefield) && $favefield == "yes") { echo "<th>{$favetext}</th>"; } ?> </tr>
<?php
while ($i<$end) {
list($name,$email,$dispemail,$url,$country,$fave) = preg_split("/,(?! )/",$members[$i]);
$fave = trim($fave, "\"\x00..\x1F");
if ($dispemail == "yes") {
// this bit of javascript prevents the email address being picked up by bots
$email = "
<script type=\"text/javascript\">
<!--//
document.write('<a href=\"mailto:".fixEmail($email)."\">e-mail<\/a>');
//-->
</script>
";
} else {
$email = "<del>e-mail</del>";
}
if (empty($url) || $url == "http://") $url = "<del>www</del>"; else $url = "<a href=\"$url\" title=\"$name's website\">www</a>";
echo "
<tr> <td>$name</td>
<td>$email</td>
<td>$url</td> <td>$country</td>
";
if (isset($favefield) && $favefield == "yes") { echo "<td>" . str_replace('|', ',', stripslashes($fave)) . "</td>"; }
echo "</tr>";
$i++;
}
?>
</table>
<p><a href="members.php?s=sortName">Sort by Name</a> · <a href="members.php?s=sortCountry">Sort by Country</a></p>
<?php
} else {
echo "<p>No members have joined yet!</p>";
}
}
include('footer.php'); ?>