Location: PHPKode > projects > FeedMeLinks, Social BookmarkingSince2002 > feedmelinks.com/folder-sidebar.php
<%
	include_once( "modules/utils.inc.php" );
	include( "$modules/header.insecure.inc.php" );

$tok =  $_COOKIE["c_pass_token"];
$u   =  $_COOKIE["c_uid"];
$sessionUserId = $u;

$folder = $id ? $id : $folder;
	# $Id: folder-sidebar.php,v 1.4 2004/10/31 21:41:20 hirokai Exp $
	$page = "recent-kompact";
	$site = getSiteUrl();

	$f = $folder;

	$MAX_NAME_LENGTH = 35;

	$searchTerm = $q ? $q : $searchTerm;
	$searchTerm = str_replace( " ", "%", $searchTerm );

	$con_folderSidebar = mysql_connect();
	mysql_selectdb( getDBName() );
	$MAX_LINKS = $max ? $max : 1024;
	$u   =  $sessionUserId = $_COOKIE["c_uid"];

	if( $sessionUserId || $who ) {
		$user = $who ? $who  : $sessionUserId;
		$viewedByOwner = ($sessionUserId == $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' AND groupid " . ($f == "unfiled" ? "IS NULL" : " = $f" ) . ";";
	#echo $qs;
	$q = mysql_query( $qs );
	if( $q ) 
		$numLinks = mysql_result($q,0);
						
%>


<form action="my-recent">

<div class="funnelTD" style="width: 240px; padding: 8px;">
	<img src="/img/lil-folder.gif" /> <select 
	class="textField" 
	onChange="openFolder(this);"><% include_once( "$modules/folder-menu.inc.php" ); %>
</div>
<br />

	<span class="head"><%= makePrettyFolderName( getNameForFolder( $f )) %> <%= isPublicFolder( $f ) ? "<img src=\"/img/lock\" />" : ""  %> </span> (<%= $numLinks %> links)

	<table cellpadding="1" cellspacing="0">
		<tr>
			<td class="boxBorder">

<% if( $numLinks > 0 ) { %>

				<table cellpadding="4" cellspacing="0">
					<tr>
						<td class="header">
							link name
						</td>
					</tr>

<%
	$qs = "SELECT * from links WHERE submitter='$user' AND groupid " .($f == "unfiled" ? "IS NULL" : " = $f" ) .  " ORDER BY createDate DESC";
	$q = mysql_query( $qs );
	$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"));
			$groupid = mysql_result($q,$i,"groupid");
			if( $i % 2 == 0 )
				$bg = "class='r0a'";
			else
				$bg = "class='r1a'";

%>
					<tr>
						<td <%= $bg %>><%= makeSidebarLinkOut( $id ) %> <%= makeSidebarPermaLink( $id ) %></td>
					</tr>
<%
			$i++;
		}
		conClose( $con_folderSidebar );
%>
				</table>
<% 
		} 
	} else { 
%>
				<table cellpadding="4" cellspacing="0" width="390">
					<tr>
						<td class="rowNormal"><br /><center>(<%= $user == $sessionUserId ? "you have" : "$user has" %> not added any links yet)</center><br /></td>
					</tr>
			</table>
<%
	}
%>
		</td>
	</tr>
</table>
<% 
		#echo getColorKey();
%>

<br />
<center><a href="/recent-kompact"><b>recent links</b></a></center>

<%
} else {
	bounceTo( $site . "/portal" );
}  
%>
Return current item: FeedMeLinks, Social BookmarkingSince2002