| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
require_once("../../includes.php"); |
|---|
| 7 |
|
|---|
| 8 |
$search_sql; |
|---|
| 9 |
$filter; |
|---|
| 10 |
$searchtype; |
|---|
| 11 |
$db; |
|---|
| 12 |
$CFG; |
|---|
| 13 |
|
|---|
| 14 |
define("context", "network"); |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
$CFG->browser_search_results = 20; |
|---|
| 18 |
|
|---|
| 19 |
$search_sql = ""; |
|---|
| 20 |
|
|---|
| 21 |
$title = __gettext("Browser"); |
|---|
| 22 |
$display = optional_param('display', '', PARAM_ALPHANUM); |
|---|
| 23 |
$filter = trim(optional_param('filter', '')); |
|---|
| 24 |
$searchtype = optional_param('searchtype', ''); |
|---|
| 25 |
$offset = optional_param('offset', 0, PARAM_INT); |
|---|
| 26 |
$displayicons = optional_param('displayicons',''); |
|---|
| 27 |
$drilldown = optional_param('drilldown',-1,PARAM_INT); |
|---|
| 28 |
$offset = optional_param('offset',0,PARAM_INT); |
|---|
| 29 |
|
|---|
| 30 |
$access_string = run("users:access_level_sql_where",$_SESSION['userid']); |
|---|
| 31 |
$access_string = str_replace("access","t.access",str_replace("owner","t.owner",$access_string)); |
|---|
| 32 |
|
|---|
| 33 |
$searchtype)) { |
|---|
| 34 |
$filter = $searchtype . "::" . $filter; |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
$displayicons == '') { |
|---|
| 38 |
$_COOKIE['displayicons'])) { |
|---|
| 39 |
$displayicons = 0; |
|---|
| 40 |
|
|---|
| 41 |
$displayicons = $_COOKIE['displayicons']; |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
$displayicons != 1) { |
|---|
| 45 |
$displayicons = 0; |
|---|
| 46 |
|
|---|
| 47 |
setcookie("displayicons",$displayicons,time() + (86400 * 365)); |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
$userunderline = ""; |
|---|
| 51 |
$communitiesunderline = ""; |
|---|
| 52 |
$allunderline = ""; |
|---|
| 53 |
|
|---|
| 54 |
$display) { |
|---|
| 55 |
"communities": |
|---|
| 56 |
$usertypefilter = ' u.user_type = "community" '; |
|---|
| 57 |
$communitiesunderline = ' style="text-decoration: underline;" '; |
|---|
| 58 |
|
|---|
| 59 |
"users": |
|---|
| 60 |
$usertypefilter = ' u.user_type = "person" '; |
|---|
| 61 |
$userunderline = ' style="text-decoration: underline;" '; |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
$display = ''; |
|---|
| 65 |
$usertypefilter = ' 1 '; |
|---|
| 66 |
$allunderline = ' style="text-decoration: underline;" '; |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
$functionbody = " |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
; |
|---|
| 82 |
|
|---|
| 83 |
$filter = preg_replace_callback("/([A-Za-z_0-9]*)\:\:/i",create_function('$matches',$functionbody),$filter); |
|---|
| 84 |
|
|---|
| 85 |
$displayfilter = $filter; |
|---|
| 86 |
$searchtype)) { |
|---|
| 87 |
$displayfilter = $searchtype . "::" . $displayfilter; |
|---|
| 88 |
|
|---|
| 89 |
$displayfilter = htmlspecialchars($displayfilter); |
|---|
| 90 |
|
|---|
| 91 |
$all = __gettext("All"); |
|---|
| 92 |
$communities = __gettext("Communities"); |
|---|
| 93 |
$users = __gettext("Users"); |
|---|
| 94 |
$browse = __gettext("Browse"); |
|---|
| 95 |
$filter_text = __gettext("Filter"); |
|---|
| 96 |
|
|---|
| 97 |
$body = <<< END |
|---|
| 98 |
|
|---|
| 99 |
<p><b>$browse ::</b> |
|---|
| 100 |
|
|---|
| 101 |
<a href="index.php?display=all&searchtype=$searchtype&filter=$filter" $allunderline>$all</a> | |
|---|
| 102 |
<a href="index.php?display=users&searchtype=$searchtype&filter=$filter" $userunderline>$users</a> | |
|---|
| 103 |
<a href="index.php?display=communities&searchtype=$searchtype&filter=$filter" $communitiesunderline>$communities</a> | |
|---|
| 104 |
</p> |
|---|
| 105 |
|
|---|
| 106 |
<form action="index.php" method="get"> |
|---|
| 107 |
<p>$filter_text : <input type="textbox" size="60" name="filter" value="$displayfilter" /> |
|---|
| 108 |
<input type="hidden" name="display" value="{$display}" /> <input type="submit" value="$filter_text >>" /></p> |
|---|
| 109 |
</form> |
|---|
| 110 |
|
|---|
| 111 |
END; |
|---|
| 112 |
|
|---|
| 113 |
if (empty($search_sql)) { |
|---|
| 114 |
$formatted_filter = $db->qstr($filter); |
|---|
| 115 |
|
|---|
| 116 |
if (empty($filter)) { |
|---|
| 117 |
$search_sql = "SELECT u.ident, u.username, u.name, u.icon, u.user_type, COUNT(m.ident) AS members FROM `".$CFG->prefix."users` u LEFT JOIN ".$CFG->prefix."friends m ON m.friend = u.ident WHERE " . $usertypefilter . " GROUP BY u.ident ORDER BY members DESC, name DESC"; |
|---|
| 118 |
$count_sql = "SELECT COUNT(DISTINCT u.ident) AS numberofusers, COUNT(m.ident) AS members FROM `".$CFG->prefix."users` u LEFT JOIN ".$CFG->prefix."friends m ON m.friend = u.ident WHERE " . $usertypefilter . ""; |
|---|
| 119 |
} else { |
|---|
| 120 |
if (empty($searchtype)) { |
|---|
| 121 |
$search_sql = "SELECT u.ident, u.username, u.name, u.icon, u.user_type, COUNT(m.ident) AS members FROM ".$CFG->prefix."tags t JOIN ".$CFG->prefix."users u ON u.ident = t.owner LEFT JOIN ".$CFG->prefix."friends m ON m.friend = u.ident WHERE ($access_string) AND t.tag = $formatted_filter AND " . $usertypefilter . " GROUP BY u.ident ORDER BY members DESC, name DESC"; |
|---|
| 122 |
$count_sql = "SELECT COUNT(DISTINCT u.ident) AS numberofusers, COUNT(m.ident) AS members FROM ".$CFG->prefix."tags t JOIN ".$CFG->prefix."users u ON u.ident = t.owner LEFT JOIN ".$CFG->prefix."friends m ON m.friend = u.ident WHERE ($access_string) AND t.tag = $formatted_filter AND " . $usertypefilter . ""; |
|---|
| 123 |
} |
|---|
| 124 |
} |
|---|
| 125 |
|
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
$search_sql .= sql_paging_limit($offset, $CFG->browser_search_results); |
|---|
| 129 |
|
|---|
| 130 |
if ($results = get_records_sql($search_sql)) { |
|---|
| 131 |
|
|---|
| 132 |
if ($displayicons) { |
|---|
| 133 |
$icontoggle = "<a href=\"index.php?display=$display&searchtype=$searchtype&filter=$filter&displayicons=0\">Hide icons</a>"; |
|---|
| 134 |
} else { |
|---|
| 135 |
$icontoggle = "<a href=\"index.php?display=$display&searchtype=$searchtype&filter=$filter&displayicons=1\">Show icons</a>"; |
|---|
| 136 |
} |
|---|
| 137 |
|
|---|
| 138 |
$name = __gettext("Name"); |
|---|
| 139 |
$description = __gettext("Description"); |
|---|
| 140 |
$connections = __gettext("Connections"); |
|---|
| 141 |
$posts = __gettext("Posts"); |
|---|
| 142 |
$type = __gettext("Type"); |
|---|
| 143 |
|
|---|
| 144 |
$body .= <<< END |
|---|
| 145 |
|
|---|
| 146 |
<table id="search_table" cellpadding="0" cellspacing="0"> |
|---|
| 147 |
<tr> |
|---|
| 148 |
<td width="10%" colspan="2">$icontoggle</td> |
|---|
| 149 |
<td width="25%" valign="top"><b>$name</b></td> |
|---|
| 150 |
<td width="25%" valign="top"><b>$description</b></td> |
|---|
| 151 |
<td width="12%" valign="top"><b>$connections</b></td> |
|---|
| 152 |
<td width="12%" valign="top"><b>$posts</b></td> |
|---|
| 153 |
<td width="16%" valign="top"><b>$type</b></td> |
|---|
| 154 |
</tr> |
|---|
| 155 |
|
|---|
| 156 |
END; |
|---|
| 157 |
|
|---|
| 158 |
foreach($results as $result) { |
|---|
| 159 |
|
|---|
| 160 |
$blogposts = count_records("weblog_posts", "weblog", $result->ident); |
|---|
| 161 |
$description = get_field("profile_data", "value", "owner", $result->ident, "name", 'minibio'); |
|---|
| 162 |
|
|---|
| 163 |
$icon_html = user_icon_html($result->ident, 50); |
|---|
| 164 |
|
|---|
| 165 |
$name = htmlspecialchars($result->name); |
|---|
| 166 |
|
|---|
| 167 |
$iconcode = "<a href=\"{$CFG->wwwroot}{$result->username}\">{$icon_html}</a>"; |
|---|
| 168 |
if (!$displayicons) { |
|---|
| 169 |
|
|---|
| 170 |
// $iconcode = "<span style=\"display:none\" class=\"iconhide\">".$iconcode."</span>"; |
|---|
| 171 |
$iconcode = " "; |
|---|
| 172 |
} |
|---|
| 173 |
|
|---|
| 174 |
$rowspan = ""; |
|---|
| 175 |
$plus = ""; |
|---|
| 176 |
|
|---|
| 177 |
if (!empty($filter)) { |
|---|
| 178 |
if ($drilldown != $result->ident) { |
|---|
| 179 |
$plus = "<a href=\"index.php?display=$display&searchtype=$searchtype&filter=$filter&drilldown=".$result->ident."#drilldown".$result->ident."\">+</a>"; |
|---|
| 180 |
} else { |
|---|
| 181 |
$plus = "<a href=\"index.php?display=$display&searchtype=$searchtype&filter=$filter\">-</a>"; |
|---|
| 182 |
$rowspan = "rowspan=\"2\""; |
|---|
| 183 |
} |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
$body .= <<< END |
|---|
| 187 |
|
|---|
| 188 |
<tr> |
|---|
| 189 |
<td style="border-right: 0" $rowspan> </td> |
|---|
| 190 |
<td $rowspan>$iconcode</td> |
|---|
| 191 |
<td><a href="{$CFG->wwwroot}{$result->username}">{$name}</a></td> |
|---|
| 192 |
<td>{$description}</td> |
|---|
| 193 |
<td>{$result->members}</td> |
|---|
| 194 |
<td>{$blogposts}</td> |
|---|
| 195 |
<td>{$result->user_type}</td> |
|---|
| 196 |
</tr> |
|---|
| 197 |
END; |
|---|
| 198 |
|
|---|
| 199 |
} |
|---|
| 200 |
|
|---|
| 201 |
$body .= <<< END |
|---|
| 202 |
|
|---|
| 203 |
</table> |
|---|
| 204 |
|
|---|
| 205 |
END; |
|---|
| 206 |
|
|---|
| 207 |
if (!empty($count_sql) && $search_total = get_record_sql($count_sql)) { |
|---|
| 208 |
$search_total = $search_total->numberofusers; |
|---|
| 209 |
} else { |
|---|
| 210 |
$search_total = 0; |
|---|
| 211 |
} |
|---|
| 212 |
|
|---|
| 213 |
if ($search_total > $CFG->browser_search_results) { |
|---|
| 214 |
|
|---|
| 215 |
$i = 1; |
|---|
| 216 |
while (($i * $CFG->browser_search_results) - $CFG->browser_search_results < $search_total) { |
|---|
| 217 |
|
|---|
| 218 |
$body .= "<a href=\"index.php?display=$display&searchtype=$searchtype&filter=$filter&offset=".(($i * $CFG->browser_search_results) - ($CFG->browser_search_results))."\">"; |
|---|
| 219 |
$body .= $i; |
|---|
| 220 |
$body .= "</a> "; |
|---|
| 221 |
$i++; |
|---|
| 222 |
|
|---|
| 223 |
} |
|---|
| 224 |
|
|---|
| 225 |
} |
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
} else { |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
templates_page_setup(); |
|---|
| 232 |
templates_page_output($title, $body); |
|---|
| 233 |
|
|---|
| 234 |
?> |
|---|