Location: PHPKode > projects > MP3 Intranet > mp3i-0.3.1/browse.php
<? include_once("inc/header.php"); ?>
<? include_once("inc/genres.php"); ?>
<?
$browse_genre	= $genre;
$new_genre 	= $genres[$genre];

if(!$limit){ $limit = 10; }
if(!$offset){ $offset = 0; }
?>
<font face="Verdana">

<?
if($by == "genre")
{
	$sql = "SELECT id, streamed, filename, artist, song, length, played, downloaded, genre FROM songs WHERE genre LIKE '$new_genre' ORDER BY artist";
	$message = "Browse By Genre";
	$browse = $new_genre;
}
else
{
	$sql = "SELECT id, streamed, filename, artist, song, length, played, downloaded, genre FROM songs WHERE artist LIKE '$browse%' ORDER BY artist";
	$message = "Browse By Artist";
}

$result = mysql_query($sql, $db);
$num_rows = mysql_num_rows($result);

print "<table width=\"50%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\">\n";

print " <tr>\n";
print "  <td align=\"center\" colspan=\"2\" width=\"100%\" nowrap bgcolor=\"#c0c0c0\"><font size=\"5\">$message ( " . strtoupper($browse) . " ) $num_rows</font></td>\n";
print " </tr>\n";

print " <tr>\n";
print "  <td align=\"center\" colspan=\"2\" width=\"100%\" nowrap>&nbsp;</td>\n";
print " </tr>\n";

if($num_rows > 0)
{

	print " <tr>\n";
	print "  <td align=\"center\" colspan=\"2\" width=\"100%\" nowrap bgcolor=\"#c0c0c0\">&nbsp;</td>\n";
	print " </tr>\n";


	if($show_browse_artist)
	{
		print " <tr>\n";
		print "  <td align=\"center\" nowrap colspan=\"2\">";
		include_once("inc/list_artist.php");
		print "  </td>\n";
		print " </tr>\n";
	}

	print " <tr>\n";
	print "  <td align=\"center\" colspan=\"2\" width=\"100%\" nowrap><font size=\"1\">&nbsp;</font></td>\n";
	print " </tr>\n";

	if($show_browse_genre)
	{
		print " <tr>\n";
		print "  <td align=\"center\" nowrap colspan=\"2\">";
		include_once("inc/list_genre.php");
		print "  </td>\n";
		print " </tr>\n";
	}

	print " <tr>\n";
	print "  <td bgcolor=\"#e0e0e0\" align=\"center\" nowrap colspan=\"2\">[ <a href=\"index.php\">Go Back</a> ]</td>\n";
	print " </tr>\n";

	print " <tr>\n";
	print "  <td nowrap colspan=\"2\"><font size=\"1\">&nbsp;</font></td>\n";
	print " </tr>\n";

	print " <tr>\n";
	print "  <td nowrap>\n";

	$i = $offset + 1;
	while($row = mysql_fetch_array($result))
	{
		$filename 	= $row["filename"];
		$artist 	= $row["artist"];
		$length 	= $row["length"];
		$song 		= $row["song"];
		$id 		= $row["id"];
		$played 	= $row["played"];
		$genre		= $row["genre"];
		$streamed	= $row["streamed"];
		$downloaded	= $row["downloaded"];

		if(!$genre){ $genre = "&nbsp;"; }		

		print "<table border=\"2\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#a0a0a0\">\n";
		print " <tr>\n";
		print "  <td nowrap>\n";

		print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
		print " <tr>\n";
		print "  <td bgcolor=\"#c0c0c0\" align=\"left\"><font face=\"Verdana\" size=\"1\">$i</font></td>\n";
	
		if($PHP_AUTH_USER == $admin)
		{
			print "  <td colspan=\"3\" bgcolor=\"#c0c0c0\" align=\"right\"><font face=\"Verdana\" size=\"1\"><a href=\"edit?id=$id&search=$search&offset=$offset&limit=$limit\"><img src=images/edit.gif border=0></a>&nbsp;<a href=\"delete?id=$id&search=$search&offset=$offset&limit=$limit\"><img src=images/delete.gif border=0></a></font></td>\n";
		}
		else
		{
			print "  <td colspan=\"3\" bgcolor=\"#c0c0c0\" align=\"right\"><font face=\"Verdana\" size=\"1\">&nbsp;</td>\n";
		}

		print " </tr>\n";

		print " <tr>\n";
		print "  <td width=\"1%\" align=\"right\" nowrap class=\"top_header1\"><b>Artist:&nbsp;</b></td>\n";
		print "  <td width=\"50%\" align=\"left\" nowrap>$artist</td>\n";
		print "  <td width=\"1%\" align=\"right\" nowrap class=\"top_header1\"><b>Genre:&nbsp;</b></td>\n";
                print "  <td width=\"48%\" align=\"left\" nowrap>$genre</td>\n";
		print " </tr>\n";

		print " <tr>\n";
		print "  <td width=\"1%\" align=\"right\" nowrap class=\"top_header1\"><b>Song:&nbsp;</b></td>\n";
		print "  <td width=\"50%\" align=\"left\" nowrap>$song</td>";
		print "  <td width=\"1%\" align=\"right\" nowrap class=\"top_header1\"><b>Length:&nbsp;</b></td>\n";
		print "  <td width=\"48%\" align=\"left\" nowrap>$length</td>";
		print " </tr>\n";

		print " <tr>\n";
		print "  <td bgcolor=\"#c0c0c0\" align=\"left\" nowrap><font size=\"1\">&lt; Streamed $streamed &gt;</font></td>\n";
		print "  <td bgcolor=\"#c0c0c0\" align=\"left\" nowrap><font size=\"1\">&lt; Downloaded $downloaded &gt;</font></td>\n";
		print "  <td colspan=\"2\" bgcolor=\"#c0c0c0\" align=\"right\" nowrap><font size=\"1\">";
		if($allow_stream){ print "[ <a href=\"stream.php?file=$filename&offset=$offset&id=$id\">Stream</a> ] "; }

		if($allow_download)
		{ 
			print "[ <a href=\"$PHP_SELF?";

			if($by == "genre")
			{
				print "by=$by&genre=$browse_genre&limit=$limit&download_file=$filename\">Download</a> ] ";
			}
			else
			{
				print "browse=$browse&limit=$limit&download_file=$filename\">Download</a> ] ";
			}
		}

		print "  </font></td>";
		print " </tr>\n";
		print "</table>\n";

		print "  </td>\n";
		print " </tr>\n";
		print "</table><br>\n";

		$i++;
	}

	print "  </td>\n";
	print " </tr>\n";

	print " <tr>\n";
	print "  <td bgcolor=\"#c0c0c0\" align=\"center\" nowrap colspan=\"4\">&nbsp;</td>\n";
	print " </tr>\n";
}
else
{
	print " <tr>\n";
	print "  <td align=\"center\" nowrap>";
	include_once("inc/list_artist.php");
	print "  </td>\n";
	print " </tr>\n";

	print " <tr>\n";
	print "  <td align=\"center\" nowrap>&nbsp;</td>\n";
	print " </tr>\n";

	print " <tr>\n";
	print "  <td align=\"center\" nowrap>No Results</td>\n";
	print " </tr>\n";

	print " <tr>\n";
	print "  <td align=\"center\" nowrap>&nbsp;</td>\n";
	print " </tr>\n";

	print " <tr>\n";
	print "  <td bgcolor=\"#c0c0c0\" align=\"center\" nowrap>&nbsp;</td>\n";
	print " </tr>\n";
}


	print " <tr>\n";
	print "  <td bgcolor=\"#e0e0e0\" align=\"center\" nowrap colspan=\"2\">[ <a href=\"index.php\">Go Back</a> ]</td>\n";
	print " </tr>\n";
	print "</table>\n";
?>
</font>
<?

function pagenav()
{
	global $limit, $offset, $numpage, $search, $num_rows, $browse;

	if($search){ $safewhere=urlencode($search); }

	print "<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
	print "<tr><td align=\"center\">";

	if($offset >= $limit)
	{
		$newoff = $offset - $limit;
		print "<a href=\"$PHP_SELF?offset=$newoff&browse=$browse\">PREV $limit</a> ||</td>";
	}
	else
	{
		print "------ ||";
	}

	print "<td align=\"center\">&nbsp;";

	for ($i = 1; $i <= $numpage; $i++)
	{
		if((($i - 1) * $limit) == $offset)
		{
			print "$i ";
		}
		else
		{
			$newoff=($i-1)*$limit;
			print  "<A HREF=\"$PHP_SELF?offset=$newoff&browse=$browse&limit=$limit\">$i</A> ";
		}
	}

	echo "&nbsp; </TD><TD ALIGN=LEFT>";

	if($num_rows >= $limit)
	{
		$newoff=$offset+$limit;
		print "<A HREF=\"$PHP_SELF?offset=$newoff&browse=$browse&limit=$limit\">NEXT $limit</A></TD>";
	}
	else
	{
		echo "------</td>";
	}

	echo "</tr></table>";
}

?> 
<? include_once("inc/footer.php"); ?>
Return current item: MP3 Intranet