-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind.php
More file actions
131 lines (95 loc) · 2.97 KB
/
Copy pathfind.php
File metadata and controls
131 lines (95 loc) · 2.97 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
<?php
/*
Runner's Medium
http://www.runnersmedium.com/
find.php
search for users
copyright 2009 Mark Baltrusaitis <http://josieprogramme.com>
*/
require('lib/base.php');
$user->signinCheck(signin());
$search = null;
$doSrch = false;
if (isset($_GET['q']) && notempty($_GET['q'])) {
// search query
$search = trim($_GET['q']);
$doSrch = true;
// defaults
$rows = MAX_SEARCH_RESULTS;
$page = 1;
$ext = new extHelper();
// selected page
if(isset($_GET['page']) && is_numeric($_GET['page'])) {
$page = $_GET['page'];
}
// offset
$offset = ($page - 1) * $rows;
$sqlsearch = mysql_real_escape_string($search);
$result = $conn->query("SELECT COUNT(id) FROM users
WHERE id != ".mysql_real_escape_string($user->ID())."
AND ispublic = 1
AND (username LIKE '%$sqlsearch%'
OR name LIKE '%$sqlsearch%'
OR email LIKE '%$sqlsearch%')");
// calc total pages
$count = $conn->getRow($result);
$max = ceil($count/$rows);
$result = $conn->query("SELECT username, picture, name, TIMESTAMPDIFF(YEAR, birthday, CURDATE()) AS age, location, gender FROM users
WHERE id != ".mysql_real_escape_string($user->ID())."
AND ispublic = 1
AND (username LIKE '%$sqlsearch%'
OR name LIKE '%$sqlsearch%'
OR email LIKE '%$sqlsearch%')
ORDER BY username LIMIT ".
mysql_real_escape_string($offset).', '.
mysql_real_escape_string($rows));
}
$title = 'Runner\'s Medium - Find Rnrs';
require('header.php');
?>
<div id="content">
<?php messages($error, $message); ?>
<h2>Find Runners</h2>
<form action="" method="get" id="searchform">
<fieldset>
<label for="q">Search for Name, Username or Email</label>
<input name="q" id="q" type="text" class="search" value="<?php echo format($search); ?>" />
<input type="submit" value="Search" class="button inline" />
</fieldset>
</form>
<?php if ($doSrch) :
echo '<h3>'.$count.' users found';
if ($count > 0) {
echo ':';
}
echo '</h3>';
if ($count > 0) {
echo '<ol id="users">';
while ($line = $conn->fetchAssoc($result)) :
$theuser = format($line['username']);
echo '<li>';
echo '<div class="pic"><a href="'.profile().$theuser.'">'.$user->getAnyPicture($theuser, $line['picture']).'</a></div>';
echo '<div class="details">';
echo '<h3><a href="'.profile().$theuser.'">'.$theuser.'</a></h3>';
echo '<strong>Name</strong> '.$line['name'];
if (notempty($line['age'])) {
echo ' <strong>'.format($line['age']).'</strong> year old ';
}
if (notempty($line['gender'])) {
echo ' <strong>'.format($line['gender']).'</strong> ';
}
if (notempty($line['location'])) {
echo ' from <strong>'.format($line['location']).'</strong>';
}
echo '</div>';
echo '</li>';
endwhile; // results loop
echo '</ol>';
}
// pagination
$ext->paging('find?q='.format($search.'&'), $page, $max);
endif; // do search ?>
</div>
<?php
require('footer.php');
?>