| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
global $search_exclusions; |
|---|
| 4 |
|
|---|
| 5 |
if (isset($parameter) && $parameter[0] == "weblog" || $parameter[0] == "weblogall") { |
|---|
| 6 |
|
|---|
| 7 |
if ($parameter[0] == "weblog") { |
|---|
| 8 |
$search_exclusions[] = "weblogall"; |
|---|
| 9 |
$owner = (int) $_REQUEST['owner']; |
|---|
| 10 |
$searchline = "tagtype = 'weblog' and owner = $owner and tag = '".addslashes($parameter[1])."'"; |
|---|
| 11 |
$searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") and " . $searchline; |
|---|
| 12 |
$refs = db_query("select ref from tags where $searchline"); |
|---|
| 13 |
$searchline = ""; |
|---|
| 14 |
if (sizeof($refs) > 0) { |
|---|
| 15 |
|
|---|
| 16 |
foreach($refs as $ref) { |
|---|
| 17 |
if ($searchline != "") { |
|---|
| 18 |
$searchline .= " or "; |
|---|
| 19 |
} |
|---|
| 20 |
$searchline .= "weblog_posts.ident = " . $ref->ref; |
|---|
| 21 |
} |
|---|
| 22 |
$posts = db_query("select users.name, users.username, weblog_posts.title, weblog_posts.ident, weblog_posts.posted from weblog_posts left join users on users.ident = weblog_posts.owner where ($searchline) order by posted desc"); |
|---|
| 23 |
$run_result .= "<h2>Weblog posts by " . stripslashes($posts[0]->name) . " in category '".$parameter[1]."'</h2>\n<ul>"; |
|---|
| 24 |
foreach($posts as $post) { |
|---|
| 25 |
$run_result .= "<li>"; |
|---|
| 26 |
$run_result .= "<a href=\"/" . $post->username . "/weblog/" . $post->ident . ".html\">" . gmdate("F d, Y",$post->posted) . " - " . stripslashes($post->title) . "</a>\n"; |
|---|
| 27 |
$run_result .= "</li>"; |
|---|
| 28 |
} |
|---|
| 29 |
$run_result .= "</ul>"; |
|---|
| 30 |
} |
|---|
| 31 |
} |
|---|
| 32 |
$searchline = "tagtype = 'weblog' and tag = '".addslashes($parameter[1])."'"; |
|---|
| 33 |
$searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") and " . $searchline; |
|---|
| 34 |
$sql = "select distinct users.* from tags left join users on users.ident = tags.owner where ($searchline)"; |
|---|
| 35 |
if ($parameter[0] == "weblog") { |
|---|
| 36 |
$sql .= " and users.ident != " . $owner; |
|---|
| 37 |
} |
|---|
| 38 |
$users = db_query($sql); |
|---|
| 39 |
|
|---|
| 40 |
if (sizeof($users) > 0) { |
|---|
| 41 |
if ($parameter[0] == "weblog") { |
|---|
| 42 |
$run_result .= "<h2>Other users with weblog posts in category '".$parameter[1]."'</h2>\n"; |
|---|
| 43 |
} else { |
|---|
| 44 |
$run_result .= "<h2>Users with weblog posts in category '".$parameter[1]."'</h2>\n"; |
|---|
| 45 |
} |
|---|
| 46 |
$body = "<table><tr>"; |
|---|
| 47 |
$i = 1; |
|---|
| 48 |
foreach($users as $key => $info) { |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
if ($info->icon != -1) { |
|---|
| 52 |
$icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident); |
|---|
| 53 |
if (sizeof($icon) == 1) { |
|---|
| 54 |
$icon = $icon[0]->filename; |
|---|
| 55 |
} else { |
|---|
| 56 |
$icon = "default.png"; |
|---|
| 57 |
} |
|---|
| 58 |
} else { |
|---|
| 59 |
$icon = "default.png"; |
|---|
| 60 |
} |
|---|
| 61 |
list($width, $height, $type, $attr) = getimagesize(path . "_icons/data/" . $icon); |
|---|
| 62 |
if (sizeof($users) > 4) { |
|---|
| 63 |
$width = round($width / 2); |
|---|
| 64 |
$height = round($height / 2); |
|---|
| 65 |
} |
|---|
| 66 |
$friends_userid = $info->ident; |
|---|
| 67 |
$friends_name = htmlentities(stripslashes($info->name)); |
|---|
| 68 |
$friends_menu = run("users:infobox:menu",array($info->ident)); |
|---|
| 69 |
$link_keyword = urlencode($parameter[1]); |
|---|
| 70 |
$body .= <<< END |
|---|
| 71 |
<td align="center"> |
|---|
| 72 |
<a href="/search/index.php?weblog={$link_keyword}&owner={$friends_userid}"> |
|---|
| 73 |
<img src="/_icons/data/{$icon}" width="{$width}" height="{$height}" alt="{$friends_name}" border="0" /></a><br /> |
|---|
| 74 |
<span class="userdetails"> |
|---|
| 75 |
{$friends_name} |
|---|
| 76 |
{$friends_menu} |
|---|
| 77 |
</span> |
|---|
| 78 |
</td> |
|---|
| 79 |
END; |
|---|
| 80 |
if ($i % 5 == 0) { |
|---|
| 81 |
$body .= "\n</tr><tr>\n"; |
|---|
| 82 |
} |
|---|
| 83 |
$i++; |
|---|
| 84 |
} |
|---|
| 85 |
$body .= "</tr></table>"; |
|---|
| 86 |
$run_result .= $body; |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
?> |
|---|