<%
# $Id: my-recent.inc.php,v 1.23 2005/01/22 20:29:13 hirokai Exp $
$site = getSiteUrl();
global $prof;
$MAX_NAME_LENGTH = 35;
$con_myRecent = mysql_connect();
mysql_selectdb( getDBName() );
$MAX_LINKS = $max ? $max : 15;
if( $u || $who ) {
$user = $who ? $who : $u;
$viewedByOwner = ($u == $user) ? true : false;
if( $debug ) {
echo "DEBUG: \$who: $who<br/>";
echo "DEBUG: \$u: $u<br/>";
echo "DEBUG: \$viewedByOwner: $viewedByOwner<br/>";
}
$qs = "SELECT count(*) FROM links WHERE submitter = '$user';";
$q = mysql_query( $qs );
if( $q )
$numLinks = mysql_result($q,0);
%>
<!-- <form action="my-recent"> -->
<!-- start my recent box -->
<div id="your_recent" class="box">
<div class="subhead">
<%
if( !$who || $u == $who )
echo "your";
else
echo "$who's";
%>
recent links
</div>
<% if( $numLinks > 0 ) {
$qs = $viewedByOwner
? "SELECT * from links WHERE submitter='$user' ORDER BY createDate DESC"
: "SELECT * from links WHERE submitter='$user' AND isPrivate is NULL ORDER BY createDate DESC";
$q = mysql_query( $qs );
if( $q ) {
$numRows = mysql_num_rows($q);
if( $numRows ) {
if( $numRows < $MAX_LINKS )
$MAX_LINKS = $numRows;
$i = 0;
while ($i < $MAX_LINKS) {
$id = mysql_result($q,$i,"ID");
$name = makeSafeName( mysql_result($q,$i,"name"));
if( strlen( $name ) > $MAX_NAME_LENGTH )
$name = substr( $name, 0, $MAX_NAME_LENGTH ) . "...";
$url = urldecode( mysql_result($q,$i,"url"));
if( $i % 2 == 0 )
$class = "r0";
else
$class = "r1";
%>
<div class="<%= $class %>">
<%= makeLink( $id, "/t/$id", urldecode( mysql_result($q,$i,"name")), $url, "", "" ) %>
<%= makePermaLink( $id ) %>
<% echo "\n"; %> <div style="text-align: right;"> in: <% $cats = getShortCategoriesForLinkAsHTML( $id, $u, 0, 0 ); %> <%= $cats ? "$cats" : "(" . getUnCattedName() . ")" %>
<%
if( ! $viewedByOwner ) { %>
<%= makeStealItLink( $id ) %>
<% } %>
</div>
</div>
<%
$i++;
}
}
}
} else {
%>
<table cellpadding="4" cellspacing="0" width="390">
<tr>
<td class="rowNormal"><br /><center>(<%= $user == $u ? "you have" : "$user has" %> not added any links yet)</center><br /></td>
</tr>
</table>
<%
}
%>
</div>
<!-- end my recent box -->
<%
conClose( $con_myRecent );
if( $viewedByOwner ) {
echo getColorKey();
}
} else {
echo bounceTo( $site . "/portal" );
}
%>