<%
# $Id: folder-by-tag-name.php,v 1.2 2005/10/23 16:29:23 hirokai Exp $
include_once( "modules/utils.inc.php" );
$tok = $authenticated = $_COOKIE["c_pass_token"];
$u = $sessionUserId = ( $user ? $user : $_COOKIE["c_uid"] );
# TODO: extend this to do delicious/flickr-style "select this tag for all users" view
if( ! $user )
croak( "shit, no username!" );
if( $tok && $tok == md5( getPasswdForUser( $u )))
$authed = true;
$who_hath = ($authed ? "you have" : "$user has" );
if( ! $tag )
croak( "shit, no tag!" );
comment( "user: $user, tag: $tag" );
$con_t = mysql_connect();
mysql_selectdb( getDBName() );
# allow authenticated users to view their own private tags
$taglist_clause = "name = 'p/$tag' OR name = 'p%2F$tag'" . ($authed ? " OR name = '$tag'" : "");
$qs = getQuery( "tag_by_name", $user, "($taglist_clause)" );
$q = mysql_query( $qs );
if( !$q || !( $numRows = mysql_num_rows($q)))
croak( "$who_hath no tag called '$tag', dog!" );
# TODO: either handle this case or remove the if/for statements
if( $numRows > 1)
echo "$who_hath more than one tag called $tag.";
for( $i = 0; $i < $numRows; $i++ ) {
$folder = $tagID = mysql_result($q, $i, "ID");
comment( "<!-- redirect via folder-by-tag-name -->" );
include( "folder.php" );
}
conClose( $con_t);
%>