[xiph-commits] r8367 - websites/dir.xiph.org

oddsock at motherfish-iii.xiph.org oddsock at motherfish-iii.xiph.org
Fri Dec 10 14:24:17 PST 2004


Author: oddsock
Date: 2004-12-10 14:24:17 -0800 (Fri, 10 Dec 2004)
New Revision: 8367

Modified:
   websites/dir.xiph.org/index.php
   websites/dir.xiph.org/listen.php
Log:
added true clustering of relays, plus server subtype for distinguishing servers with the same content type (i.e. application/ogg for both Ogg Vorbis and Ogg Theora streams)


Modified: websites/dir.xiph.org/index.php
===================================================================
--- websites/dir.xiph.org/index.php	2004-12-10 21:47:52 UTC (rev 8366)
+++ websites/dir.xiph.org/index.php	2004-12-10 22:24:17 UTC (rev 8367)
@@ -1,473 +1,487 @@
-<? $nopad = 1; ?>
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-   "http://www.w3.org/TR/html4/loose.dtd">
-<?
-	$dirroot = "http://dir.xiph.org/";
-	$iceroot = "http://www.icecast.org/";
-?>
-<html>
-<head>
-<title>Icecast.org</title>
-<link rel="stylesheet" type="text/css" href="common/style.css" />
-</head>
-<body bgcolor="black">
-<table width="100%" border=0 cellpadding=0 cellspacing=0 >
-<tr>
-<td class="xiphnav"><a class="xiphnav_a" href="http://www.xiph.org/">XIPH.ORG</a></td>
-<td class="xiphnav"><a class="xiphnav_a" href="http://www.vorbis.com/">VORBIS.COM</a></td>
-<td class="xiphnav"><a class="xiphnav_a" href="http://www.icecast.org/">ICECAST.ORG</a></td>
-<td class="xiphnav"><a class="xiphnav_a" href="http://www.speex.org/">SPEEX.ORG</a></td>
-<td class="xiphnav" align="right">Open Standards for Internet Multimedia</td>
-</tr>
-</table>
-<table width="100%" border=0 cellpadding=0 cellspacing=0 bgcolor=black>
-<tr><td colspan=3><img alt="Icecast Logo" src="images/icecast.png"></td></tr>
-<tr><td colspan=3 bgcolor="#7B96C6" height=3><img alt="Icecast Logo" src="images/blue.png" height=3></td></tr>
-<tr>
-<td colspan=3 bgcolor="black">
-	<center>
-	<table border=0 cellpadding=1 cellspacing=3 width="90%">
-	<tr>
-	    <td align=center >
-	    <a class="nav" href="<? print $iceroot; ?>index.php">Home</a>&nbsp;&nbsp;|&nbsp;&nbsp;  
-	    <a class="nav" href="<? print $iceroot; ?>download.php">Download</a>&nbsp;&nbsp;|&nbsp;&nbsp;
-	    <a class="nav" href="<? print $iceroot; ?>svn.php">Subversion</a>&nbsp;&nbsp;|&nbsp;&nbsp;
-	    <a class="nav" href="<? print $dirroot; ?>index.php">Stream Directory</a>&nbsp;&nbsp;|&nbsp;&nbsp;
-	    <a class="nav" href="<? print $iceroot; ?>docs.php">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;
-	    <a class="nav" href="<? print $iceroot; ?>3rdparty.php">3rd Party Apps</a>&nbsp;&nbsp;|&nbsp;&nbsp;
-	    <a class="nav" href="<? print $iceroot; ?>ices.php">Ices</a>&nbsp;&nbsp;|&nbsp;&nbsp;
-	    <a class="nav" href="<? print $iceroot; ?>mailinglist.php">Mailing List</a>&nbsp;&nbsp;|&nbsp;&nbsp;
-	    <a class="nav" href="<? print $iceroot; ?>contact.php">Contact</a>
-	    </td></tr>
-	</table>
-	</center>
-</td></tr>
-<tr><td colspan=3 bgcolor="#7B96C6" height=3><img alt="Icecast Logo" src="images/blue.png" height=3></td></tr>
-<tr><td colspan=3><br><br></td></tr>
-<tr>
-<?
-if ($nopad == 1) {
-}
-else {
-?>
-<td width=50><br></td>
-<?
-}
-?>
-<td>
-
-<?
-
-$username = "oddsock";
-$password = "";
-$database = "oddsock";
-$max_per_page = 10;
-$start = $_GET["start"];
-$num = $_GET["num"];
-$sgenre = $_GET["sgenre"];
-$stype = $_GET["stype"];
-$search = $_GET["search"];
-
-$link = mysql_connect("localhost", $username, $password);
-mysql_select_db($database);
-
-if ($num) {
-	$pagesize = $num;
-}
-else {
-	$pagesize = $max_per_page;
-}
-
-function contentTypeLookup($content_type) {
-	if ($content_type == "application/x-ogg") {
-		return "Ogg Vorbis";
-	}
-	if ($content_type == "application/ogg") {
-		return "Ogg Vorbis";
-	}
-	if ($content_type == "audio/mpeg") {
-		return "MP3 Audio";
-	}
-	if ($content_type == "audio/x-mpeg") {
-		return "MP3 Audio";
-	}
-	if ($content_type == "video/nsv") {
-		return "NSV Video";
-	}
-	if ($content_type == "audio/aac") {
-		return "AAC Audio";
-	}
-	if ($content_type == "audio/aacp") {
-		return "AAC+ Audio";
-	}
-	return $content_type;
-}
-function getPrevLink($current, $pagesize, $rowcounter) {
-	global $search;
-	global $sgenre;
-	global $stype;
-
-	if (($current - $pagesize) < 0) {
-		$prev = -1;
-	}
-	else {
-		$prev = $current - $pagesize;
-	}
-	$extra = "";
-	if ($search) {
-		$extra .= "&search=".urlencode($search);
-	}
-	if ($sgenre) {
-		$extra .= "&sgenre=".urlencode($sgenre);
-	}
-	if ($stype) {
-		$extra .= "&stype=".urlencode($stype);
-	}
-	if ($prev >= 0) {
-		return "<a class=\"nav\" href=\"?start=$prev&num=$pagesize$extra\"><font size=3>Prev</font></a>";
-	}
-	else {
-		return "";
-	}
-}
-function getNextLink($current, $pagesize, $rowcounter) {
-	global $search;
-	global $sgenre;
-	global $stype;
-
-	if ($rowcounter < $pagesize) {
-		return "";
-	}
-	$next = $current + $pagesize;
-	$extra = "";
-	if ($search) {
-		$extra .= "&search=".urlencode($search);
-	}
-	if ($sgenre) {
-		$extra .= "&sgenre=".urlencode($sgenre);
-	}
-	if ($stype) {
-		$extra .= "&stype=".urlencode($stype);
-	}
-	return "<a class=\"nav\" href=\"?start=$next&num=$pagesize$extra\"><font size=3>Next</font></a>";
-}
-function getContentTypes() {
-	$query = "select distinct(server_type) from server_details";
-	$result = mysql_query($query);
-	if (!$result) {
-		print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
-	}
-	 
-	$result_string = "Format Search<br>";
-	$result_string .= "<select name='stype'>";
-	$result_string .= "<option value='' selected>";
-	while ($row = mysql_fetch_row($result)) {
-		$result_string .= "<option value='$row[0]'>$row[0]";
-	}
-	$result_string .= "</select>";
-	return $result_string;
-}
-function getTotalListeners() {
-	$query = "select sum(listeners) from servers";
-	$result = mysql_query($query);
-	if (!$result) {
-		print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
-	}
-	 
-	$row = mysql_fetch_row($result);
-	if ($row) {
-		return $row[0];
-	}
-}
-function getTotalServers() {
-	$query = "select count(*) from server_details";
-	$result = mysql_query($query);
-	if (!$result) {
-		print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
-	}
-	 
-	$row = mysql_fetch_row($result);
-	if ($row) {
-		return $row[0];
-	}
-}
-function buildStreamDescription($listeners, $url, $server_name, $bgcolor) {
-	$urllink = "";
-	if ($url != "") {
-		if (substr($url, 0, 7) != "http://") {
-			$url = "http://".$url;
-		}
-		$urllink = '<a class="nav" href="'.$url.'"><b>'.substr($server_name, 0, 60).'</b></a>';
-	}
-	else {
-		$urllink = '<b>'.substr($server_name, 0, 60).'</b>';
-	}
-	$streamLine = '
-	<tr>
-		<td colspan=5 height=3 bgcolor="#333333"></td>
-	</tr>
-	<tr>
-		<td class="streamtd_alt" bgcolor="'.$bgcolor.'"></td><td class="streamtd_alt" colspan=1 bgcolor="'.$bgcolor.'" >'.$urllink.'</td><td class="streamtd_alt" colspan=3 bgcolor="'.$bgcolor.'"></td>
-	</tr>
-';
-	return $streamLine;
-}
-function buildStreamLine($server_name,$listen_url, $genre, $listeners, $description, $current_song, $server_type, $bitrate, $samplerate, $channels, $stream_id, $bgcolor) {
-	if ($channels == "1") {
-		$channels = "Mono";
-	}
-	if ($channels == "2") {
-		$channels = "Stereo";
-	}
-	$mountpoint = preg_replace("/^http:\/\/.*:.*\//", "/", $listen_url);
-	$server_type = contentTypeLookup($server_type);
-	$channels = str_replace(" ", "", $channels);
-	$channels = str_replace("\r\n", "", $channels);
-	if ($channels == "1") {
-		$channels = "Mono";
-	}
-	if ($channels == "2") {
-		$channels = "Stereo";
-	}
-	if ($server_type == "Ogg Vorbis") {
-		if ($bitrate == "Quality 1 at 00") {
-			$bitrate = "";
-		}
-		if ($bitrate > 1000) {
-			$bitrate = "";
-		}
-		if ($bitrate == "0") {
-			$bitrate = "";
-		}
-		if ($samplerate == "") {
-			$samplerate = "";
-		}
-		else {
-			$samplerate = $samplerate."Hz";
-		}
-		if ($channels == "") {
-			$channels = "";
-		}
-		if (substr($bitrate, 0, 5) == "Quali") {
-			$audio_info = $bitrate."<br>".$samplerate." ".$channels;
-
-		}
-		else {
-			$audio_info = $bitrate."kbps<br>".$samplerate." ".$channels;
-		}
-	}
-	else {
-		if ($bitrate == "Quality 0") {
-			$bitrate = "";
-		}
-		if ($bitrate == "0") {
-			$bitrate = "";
-		}
-		if ($samplerate == "") {
-			$samplerate = "";
-		}
-		else {
-			$samplerate = $samplerate."Hz";
-		}
-		if ($channels == "") {
-			$channels = "";
-		}
-		$audio_info = $bitrate."kbps<br>".$samplerate." ".$channels;
-	}
-	if (($samplerate == "0") || ($channels == "0")) {
-		$audio_info = "Unknown";
-	}
-	if ($server_name != $description) {
-		$description_tag = '<font color="#AAAAAA">'.$description.'</font><br>';
-	}
-	$streamLine = '
-	<tr>
-		<td class="streamtd_alt" width=75 valign="middle" bgcolor="'.$bgcolor.'" ><center><a href="listen.php?serverURL='.urlencode($listen_url).'&file=listen.m3u" alt="'.$server_type.'" title="'.$server_type.'" class="listen_a"><div id="listen">'.$server_type.'</div></a></center></td>
-		<td class="streamtd_alt" bgcolor="'.$bgcolor.'">'.$description_tag.'Now playing on <a class="streamtd_alt_2" href="listen.php?serverURL='.urlencode($listen_url).'&file=listen.m3u">'.$mountpoint.'</a> :&nbsp;&nbsp;<font color=yellow>'.substr($current_song, 0, 100).'</font></td>
-		<td class="streamtd_alt" width=75 bgcolor="'.$bgcolor.'"> <center><font color=white>'.substr($genre, 0, 30).'</font></td>
-		<td class="streamtd_alt" width=150 bgcolor="'.$bgcolor.'"><center>'.$audio_info.'</td>
-	</tr>
-';
-	return $streamLine;
-}
-?>
-<td valign=top width=100%>
-<?
-$directory_data = '
-<table border=0 cellpadding=2 cellspacing=0 width="100%">
-<tr>
-		<td colspan=5 bgcolor="#000000" height=2></td>
-</tr>
-<tr>
-		<td colspan=5 bgcolor="#000000" height=3></td>
-</tr>
-<tr>
-		<td bgcolor="#222222"><font size=2><b><center>Listen</b></center></font></td>
-		<td valign="middle" bgcolor="#222222" ><font size=2><b>Streams</td>
-		<td width=75 bgcolor="#222222"> <font size=2><b><center>Genre</td>
-		<td width=150 bgcolor="#222222"><font size=2><b><center>Audio Info</td>
-</tr>
-<tr>
-		<td colspan=5 bgcolor="#222222" height=3></td>
-</tr>
-<tr>
-		<td colspan=5 bgcolor="#222222" height=2></td>
-</tr>
-<tr>
-		<td colspan=5 bgcolor="#222222" height=5></td>
-</tr>
-';
- 
-$query = "select id, server_name, listeners from servers order by rank desc";
-$subquery = "";
-
-if ($sgenre) {
-	$query = "select a.id, a.server_name, a.listeners from servers a, server_details b where a.id = b.parent_id and b.genre like '%$sgenre%' group by a.id, a.server_name, a.listeners order by a.rank desc";
-	$subquery = "and genre like '%$sgenre%'";
-}
-if ($stype) {
-	$query = "select a.id, a.server_name, a.listeners from servers a, server_details b where a.id = b.parent_id and b.server_type like '%$stype%' group by a.id, a.server_name, a.listeners order by a.rank desc";
-	$subquery = "and server_type like '%$stype%'";
-}
-if ($search) {
-	$query = "select a.id, a.server_name, a.listeners from servers a, server_details b where a.id = b.parent_id and (a.server_name like '%$search%' or b.description like '%$search%' or b.current_song like '%$search%' or b.genre like '%$search%') group by a.id, a.server_name, a.listeners order by a.rank desc";
-	$subquery = "and (server_name like '%$search%' or description like '%$search%' or current_song like '%$search%' or genre like '%$search%')";
-}
-$result = mysql_query($query);
-if (!$result) {
-        print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
-}
- 
-$row_counter = 0;
-$printed = 0;
-while ($row = mysql_fetch_row($result)) {
-	$row_counter++;
-	if ($start) {
-		if ($row_counter < $start) {
-			continue;
-		}
-	}
-	if ($pagesize) {
-		if ($printed >= $pagesize) {
-			break;
-		}
-	}
-        $id = $row[0];
-        $server_name = htmlentities($row[1]);
-        $listeners = htmlentities($row[2]);
-	$cluster_flag = 0;
-	if ($cluster_id != "") {
-		$cluster_flag = 1;
-	}
-	if ($swap) {
-		$swap = 0;
-		$bgcolor = "#222222";
-	}
-	else {
-		$swap = 1;
-		$bgcolor = "#444444";
-	}
-	if ($cluster_flag) {
-		$cluster_text = "cluster";
-	}
-	else {
-		$cluster_text = "";
-	}
-	if ($server_name != "") {
-		$all_listeners = $listeners;
-		$query = "select description, genre, url, current_song, listen_url, server_type, bitrate, samplerate, channels, listeners+0, parent_id, id from server_details where parent_id = $id $subquery";
-		
-		$streamDetailsLine = "";
-		$result2 = mysql_query($query);
-		if (!$result2) {
-			print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
-		}
-		 
-		while ($row2 = mysql_fetch_row($result2)) {
-			$description = htmlentities($row2[0]);
-			$genre = htmlentities($row2[1]);
-			$url = htmlentities($row2[2]);
-			$url = str_replace("hTtP", "http", $url);
-			$current_song = htmlentities($row2[3]);
-			$listen_url = urlencode($row2[4]);
-			$listen_url = str_replace("hTtP", "http", $listen_url);
-			$listen_url_raw = htmlentities($row2[4]);
-			$listen_url_raw = str_replace("hTtP", "http", $listen_url_raw);
-			$server_type = htmlentities($row2[5]);
-			$bitrate = htmlentities($row2[6]);
-			$samplerate = htmlentities($row2[7]);
-			$channels = htmlentities($row2[8]);
-			$listeners = htmlentities($row2[9]);
-			$cluster_id = htmlentities($row2[10]);
-			$stream_id = htmlentities($row2[11]);
-			$total_listeners = $total_listeners + $listeners;
-			$streamDetailsLine .= buildStreamLine($server_name, $listen_url_raw, $genre, $listeners, $description, $current_song, $server_type, $bitrate, $samplerate, $channels, $stream_id, $bgcolor);
-		}
-		$streamDescriptionLine = buildStreamDescription($all_listeners, $url, $server_name, $bgcolor);
-		$directory_data .= '
-'.$streamDescriptionLine.'
-'.$streamDetailsLine.'
-';
-		$printed++;
-	}
-}
-$directory_data .= '
-	<tr>
-		<td colspan=5 height=3 bgcolor="#333333"></td>
-	</tr>
-	<tr>
-		<td colspan=5 height=10 bgcolor="black"></td>
-	</tr>
-</table>';
-$nav_text = '
-<table border=0 bordercolor="#333399" cellpadding=0 cellspacing=0 width="100%">
-<tr>
-<td bgcolor="#000000"><font color=white face=Verdana size=1>'.getPrevLink($start, $pagesize, $printed).'</td>
-<td bgcolor="#000000" width=100%>&nbsp;</td>
-<td bgcolor="#000000"><font color=white face=Verdana size=1>'.getNextLink($start, $pagesize, $printed).'</td>
-</tr>
-</table>';
-print $nav_text;
-print $directory_data;
-print $nav_text;
-?>
-</td>
-<td class="streamtd" valign=top align=right>
-<b>Search</b><br>
-<form method=GET action=index.php>
-Genre<br><select style="font-size:8pt" name=sgenre>
-<option>
-<option value="Alternative">Alternative
-<option value="Classical">Classical
-<option value="Comedy">Comedy
-<option value="Country">Country
-<option value="Dance">Dance
-<option value="Funk">Funk
-<option value="Jazz">Jazz
-<option value="Metal">Metal
-<option value="Mixed">Mixed
-<option value="Pop">Pop
-<option value="Rap">Rap
-<option value="RnB">RnB
-<option value="Rock">Rock
-<option value="Talk">Talk
-<option value="Techno">Techno
-<option value="80s">80s
-<option value="70s">70s
-</select>
-<br>
-<? print getContentTypes(); ?><br>
-Freeform Search<br><input name=search style="font-size:8pt">
-<input type=Submit value=Search>
-</form>
-<br>
-<br>
-<b>Statistics</b><br>
-Total Servers: <? print getTotalServers(); ?>
-</td>
-</tr>
-</table>
-</body>
-</html>
-
+<? $nopad = 1; ?>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/html4/loose.dtd">
+<?
+	$dirroot = "http://dir.xiph.org/";
+	$iceroot = "http://www.icecast.org/";
+?>
+<html>
+<head>
+<title>Icecast.org</title>
+<link rel="stylesheet" type="text/css" href="common/style.css" />
+</head>
+<body bgcolor="black">
+<table width="100%" border=0 cellpadding=0 cellspacing=0 >
+<tr>
+<td class="xiphnav"><a class="xiphnav_a" href="http://www.xiph.org/">XIPH.ORG</a></td>
+<td class="xiphnav"><a class="xiphnav_a" href="http://www.vorbis.com/">VORBIS.COM</a></td>
+<td class="xiphnav"><a class="xiphnav_a" href="http://www.icecast.org/">ICECAST.ORG</a></td>
+<td class="xiphnav"><a class="xiphnav_a" href="http://www.speex.org/">SPEEX.ORG</a></td>
+<td class="xiphnav" align="right">Open Standards for Internet Multimedia</td>
+</tr>
+</table>
+<table width="100%" border=0 cellpadding=0 cellspacing=0 bgcolor=black>
+<tr><td colspan=3><img alt="Icecast Logo" src="images/icecast.png"></td></tr>
+<tr><td colspan=3 bgcolor="#7B96C6" height=3><img alt="Icecast Logo" src="images/blue.png" height=3></td></tr>
+<tr>
+<td colspan=3 bgcolor="black">
+	<center>
+	<table border=0 cellpadding=1 cellspacing=3 width="90%">
+	<tr>
+	    <td align=center >
+	    <a class="nav" href="<? print $iceroot; ?>index.php">Home</a>&nbsp;&nbsp;|&nbsp;&nbsp;  
+	    <a class="nav" href="<? print $iceroot; ?>download.php">Download</a>&nbsp;&nbsp;|&nbsp;&nbsp;
+	    <a class="nav" href="<? print $iceroot; ?>svn.php">Subversion</a>&nbsp;&nbsp;|&nbsp;&nbsp;
+	    <a class="nav" href="<? print $dirroot; ?>index.php">Stream Directory</a>&nbsp;&nbsp;|&nbsp;&nbsp;
+	    <a class="nav" href="<? print $iceroot; ?>docs.php">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;
+	    <a class="nav" href="<? print $iceroot; ?>3rdparty.php">3rd Party Apps</a>&nbsp;&nbsp;|&nbsp;&nbsp;
+	    <a class="nav" href="<? print $iceroot; ?>ices.php">Ices</a>&nbsp;&nbsp;|&nbsp;&nbsp;
+	    <a class="nav" href="<? print $iceroot; ?>mailinglist.php">Mailing List</a>&nbsp;&nbsp;|&nbsp;&nbsp;
+	    <a class="nav" href="<? print $iceroot; ?>contact.php">Contact</a>
+	    </td></tr>
+	</table>
+	</center>
+</td></tr>
+<tr><td colspan=3 bgcolor="#7B96C6" height=3><img alt="Icecast Logo" src="images/blue.png" height=3></td></tr>
+<tr><td colspan=3><br><br></td></tr>
+<tr>
+<?
+if ($nopad == 1) {
+}
+else {
+?>
+<td width=50><br></td>
+<?
+}
+?>
+<td>
+
+<?
+
+$username = "oddsock";
+$password = "";
+$database = "oddsock";
+$max_per_page = 10;
+$start = $_GET["start"];
+$num = $_GET["num"];
+$sgenre = $_GET["sgenre"];
+$stype = $_GET["stype"];
+$search = $_GET["search"];
+
+$link = mysql_connect("localhost", $username, $password);
+mysql_select_db($database);
+
+if ($num) {
+	$pagesize = $num;
+}
+else {
+	$pagesize = $max_per_page;
+}
+
+function contentTypeLookup($content_type, $server_subtype) {
+	if ($content_type == "application/x-ogg") {
+		return "Ogg Vorbis";
+	}
+	if ($content_type == "application/ogg") {
+		if (preg_match("/theora/i", $server_subtype)) {
+			return "Ogg Theora";
+		}
+		else if (preg_match("/vorbis/i", $server_subtype)) {
+			return "Ogg Vorbis";
+		}
+		return "Ogg Vorbis";
+	}
+	if ($content_type == "audio/mpeg") {
+		return "MP3 Audio";
+	}
+	if ($content_type == "audio/x-mpeg") {
+		return "MP3 Audio";
+	}
+	if ($content_type == "video/nsv") {
+		return "NSV Video";
+	}
+	if ($content_type == "audio/aac") {
+		return "AAC Audio";
+	}
+	if ($content_type == "audio/aacp") {
+		return "AAC+ Audio";
+	}
+	return $content_type;
+}
+function getPrevLink($current, $pagesize, $rowcounter) {
+	global $search;
+	global $sgenre;
+
+	if (($current - $pagesize) < 0) {
+		$prev = -1;
+	}
+	else {
+		$prev = $current - $pagesize;
+	}
+	$extra = "";
+	if ($search) {
+		$extra .= "&search=".urlencode($search);
+	}
+	if ($sgenre) {
+		$extra .= "&sgenre=".urlencode($sgenre);
+	}
+	if ($prev >= 0) {
+		return "<a class=\"nav\" href=\"?start=$prev&num=$pagesize$extra\"><font size=3>Prev</font></a>";
+	}
+	else {
+		return "";
+	}
+}
+function getNextLink($current, $pagesize, $rowcounter) {
+	global $search;
+	global $sgenre;
+
+	if ($rowcounter < $pagesize) {
+		return "";
+	}
+	$next = $current + $pagesize;
+	$extra = "";
+	if ($search) {
+		$extra .= "&search=".urlencode($search);
+	}
+	if ($sgenre) {
+		$extra .= "&sgenre=".urlencode($sgenre);
+	}
+	return "<a class=\"nav\" href=\"?start=$next&num=$pagesize$extra\"><font size=3>Next</font></a>";
+}
+function getContentTypes() {
+	$query = "select distinct(server_type) from server_details";
+	$result = mysql_query($query);
+	if (!$result) {
+		print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
+	}
+	 
+	$result_string = "Format Search<br>";
+	$result_string .= "<select name='stype'>";
+	$result_string .= "<option value='' selected>";
+	while ($row = mysql_fetch_row($result)) {
+		$result_string .= "<option value='$row[0]'>$row[0]";
+	}
+	$result_string .= "</select>";
+	return $result_string;
+}
+function getTotalListeners() {
+	$query = "select sum(listeners) from servers";
+	$result = mysql_query($query);
+	if (!$result) {
+		print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
+	}
+	 
+	$row = mysql_fetch_row($result);
+	if ($row) {
+		return $row[0];
+	}
+}
+function getTotalServers() {
+	$query = "select count(*) from server_details";
+	$result = mysql_query($query);
+	if (!$result) {
+		print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
+	}
+	 
+	$row = mysql_fetch_row($result);
+	if ($row) {
+		return $row[0];
+	}
+}
+function buildStreamDescription($listeners, $url, $server_name, $bgcolor) {
+	$urllink = "";
+	if ($url != "") {
+		if (substr($url, 0, 7) != "http://") {
+			$url = "http://".$url;
+		}
+		$urllink = '<a class="nav" href="'.$url.'"><b>'.substr($server_name, 0, 60).'</b></a>';
+	}
+	else {
+		$urllink = '<b>'.substr($server_name, 0, 60).'</b>';
+	}
+	$streamLine = '
+	<tr>
+		<td colspan=5 height=3 bgcolor="#333333"></td>
+	</tr>
+	<tr>
+		<td class="streamtd_alt" bgcolor="'.$bgcolor.'"></td><td class="streamtd_alt" colspan=1 bgcolor="'.$bgcolor.'" >'.$urllink.'</td><td class="streamtd_alt" colspan=3 bgcolor="'.$bgcolor.'"></td>
+	</tr>
+';
+	return $streamLine;
+}
+function buildStreamLine($server_name,$listen_url, $genre, $listeners, $description, $current_song, $server_type, $server_subtype, $bitrate, $samplerate, $channels, $stream_id, $bgcolor, $clustercount, $playlist_id) {
+	if ($channels == "1") {
+		$channels = "Mono";
+	}
+	if ($channels == "2") {
+		$channels = "Stereo";
+	}
+	$mountpoint = preg_replace("/^http:\/\/.*:.*\//", "/", $listen_url);
+	$server_type = contentTypeLookup($server_type, $server_subtype);
+	$channels = str_replace(" ", "", $channels);
+	$channels = str_replace("\r\n", "", $channels);
+	if ($channels == "1") {
+		$channels = "Mono";
+	}
+	if ($channels == "2") {
+		$channels = "Stereo";
+	}
+	if ($server_type == "Ogg Vorbis") {
+		if ($bitrate == "Quality 1 at 00") {
+			$bitrate = "";
+		}
+		if ($bitrate > 1000) {
+			$bitrate = "";
+		}
+		if ($bitrate == "0") {
+			$bitrate = "";
+		}
+		if ($samplerate == "") {
+			$samplerate = "";
+		}
+		else {
+			$samplerate = $samplerate."Hz";
+		}
+		if ($channels == "") {
+			$channels = "";
+		}
+		if (substr($bitrate, 0, 5) == "Quali") {
+			$audio_info = $bitrate."<br>".$samplerate." ".$channels;
+
+		}
+		else {
+			$audio_info = $bitrate."kbps<br>".$samplerate." ".$channels;
+		}
+	}
+	else {
+		if ($bitrate == "Quality 0") {
+			$bitrate = "";
+		}
+		if ($bitrate == "0") {
+			$bitrate = "";
+		}
+		if ($samplerate == "") {
+			$samplerate = "";
+		}
+		else {
+			$samplerate = $samplerate."Hz";
+		}
+		if ($channels == "") {
+			$channels = "";
+		}
+		$audio_info = $bitrate."kbps<br>".$samplerate." ".$channels;
+	}
+	if (($samplerate == "0") || ($channels == "0")) {
+		$audio_info = "Unknown";
+	}
+	$clustertext = "";
+	if ($clustercount > 1) {
+		$clustertext = '<font color="#CCCCFF">Cluster</font>';
+	}
+	if ($server_name != $description) {
+		$description_tag = '<font color="#AAAAAA">'.$description.'</font><br>';
+	}
+	else {
+		$description_tag = '<br>';
+	}
+	$streamLine = '
+	<tr>
+		<td class="streamtd_alt" width=75 valign="middle" bgcolor="'.$bgcolor.'" ><center>'.$clustertext.'<a href="listen.php?pid='.$playlist_id.'&file=listen.m3u" alt="'.$server_type.'" title="'.$server_type.'" class="listen_a"><div id="listen">'.$server_type.'</div></a></center></td>
+		<td class="streamtd_alt" bgcolor="'.$bgcolor.'">'.$description_tag.'Now playing on <a class="streamtd_alt_2" href="listen.php?pid='.$playlist_id.'&file=listen.m3u">'.$mountpoint.'</a> :&nbsp;&nbsp;<font color=yellow>'.substr($current_song, 0, 100).'</font></td>
+		<td class="streamtd_alt" width=75 bgcolor="'.$bgcolor.'"> <center><font color=white>'.substr($genre, 0, 30).'</font></td>
+		<td class="streamtd_alt" width=150 bgcolor="'.$bgcolor.'"><center>'.$audio_info.'</td>
+	</tr>
+';
+	return $streamLine;
+}
+?>
+<td valign=top width=100%>
+<?
+$directory_data = '
+<table border=0 cellpadding=2 cellspacing=0 width="100%">
+<tr>
+		<td colspan=5 bgcolor="#000000" height=2></td>
+</tr>
+<tr>
+		<td colspan=5 bgcolor="#000000" height=3></td>
+</tr>
+<tr>
+		<td bgcolor="#222222"><font size=2><b><center>Listen</b></center></font></td>
+		<td valign="middle" bgcolor="#222222" ><font size=2><b>Streams</td>
+		<td width=75 bgcolor="#222222"> <font size=2><b><center>Genre</td>
+		<td width=150 bgcolor="#222222"><font size=2><b><center>Audio Info</td>
+</tr>
+<tr>
+		<td colspan=5 bgcolor="#222222" height=3></td>
+</tr>
+<tr>
+		<td colspan=5 bgcolor="#222222" height=2></td>
+</tr>
+<tr>
+		<td colspan=5 bgcolor="#222222" height=5></td>
+</tr>
+';
+ 
+$query = "select id, server_name, listeners from servers order by rank desc";
+$subquery = "";
+
+if ($sgenre) {
+	$query = "select a.id, a.server_name, a.listeners from servers a, server_details b where a.id = b.parent_id and b.genre like '%$sgenre%' group by a.id, a.server_name, a.listeners order by a.rank desc";
+	$subquery = "and genre like '%$sgenre%'";
+}
+if ($stype) {
+	$query = "select a.id, a.server_name, a.listeners from servers a, server_details b where a.id = b.parent_id and b.server_type like '%$stype%' group by a.id, a.server_name, a.listeners order by a.rank desc";
+	$subquery = "and server_type like '%$stype%'";
+}
+if ($search) {
+	$query = "select a.id, a.server_name, a.listeners from servers a, server_details b where a.id = b.parent_id and (a.server_name like '%$search%' or b.description like '%$search%' or b.current_song like '%$search%' or b.genre like '%$search%') group by a.id, a.server_name, a.listeners order by a.rank desc";
+	$subquery = "and (server_name like '%$search%' or description like '%$search%' or current_song like '%$search%' or genre like '%$search%')";
+}
+$result = mysql_query($query);
+if (!$result) {
+        print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
+}
+ 
+$row_counter = 0;
+$printed = 0;
+while ($row = mysql_fetch_row($result)) {
+	$row_counter++;
+	if ($start) {
+		if ($row_counter < $start) {
+			continue;
+		}
+	}
+	if ($pagesize) {
+		if ($printed >= $pagesize) {
+			break;
+		}
+	}
+        $id = $row[0];
+        $server_name = htmlentities($row[1]);
+        $listeners = htmlentities($row[2]);
+	$cluster_flag = 0;
+	if ($cluster_id != "") {
+		$cluster_flag = 1;
+	}
+	if ($swap) {
+		$swap = 0;
+		$bgcolor = "#222222";
+	}
+	else {
+		$swap = 1;
+		$bgcolor = "#444444";
+	}
+	if ($cluster_flag) {
+		$cluster_text = "cluster";
+	}
+	else {
+		$cluster_text = "";
+	}
+	if ($server_name != "") {
+		$all_listeners = $listeners;
+		$clustercount = 1;
+	
+
+		$query = "select description, genre, url, current_song, listen_url, server_type, bitrate, samplerate, channels, listeners+0, parent_id, id, playlist_id, server_subtype from server_details where parent_id = $id $subquery group by cluster_password";
+		
+		$streamDetailsLine = "";
+		$result2 = mysql_query($query);
+		if (!$result2) {
+			print "<center><font color=red>Mysql Error: ".mysql_error()."!</center><br>";
+		}
+		 
+		while ($row2 = mysql_fetch_row($result2)) {
+			$description = htmlentities($row2[0]);
+			$genre = htmlentities($row2[1]);
+			$url = htmlentities($row2[2]);
+			$url = str_replace("hTtP", "http", $url);
+			$current_song = htmlentities($row2[3]);
+			$listen_url = urlencode($row2[4]);
+			$listen_url = str_replace("hTtP", "http", $listen_url);
+			$listen_url_raw = htmlentities($row2[4]);
+			$listen_url_raw = str_replace("hTtP", "http", $listen_url_raw);
+			$server_type = htmlentities($row2[5]);
+			$bitrate = htmlentities($row2[6]);
+			$samplerate = htmlentities($row2[7]);
+			$channels = htmlentities($row2[8]);
+			$listeners = htmlentities($row2[9]);
+			$cluster_id = htmlentities($row2[10]);
+			$stream_id = htmlentities($row2[11]);
+			$playlist_id = $row2[12];
+			$server_subtype = htmlentities($row2[13]);
+			$total_listeners = $total_listeners + $listeners;
+			$query2 = "select count(*) from playlists where id = $playlist_id";
+			$result3 = mysql_query($query2);
+			$row3 = mysql_fetch_row($result3);
+			$clustercount = $row3[0];
+			$streamDetailsLine .= buildStreamLine($server_name, $listen_url_raw, $genre, $listeners, $description, $current_song, $server_type, $server_subtype, $bitrate, $samplerate, $channels, $stream_id, $bgcolor, $clustercount, $playlist_id);
+		}
+		$streamDescriptionLine = buildStreamDescription($all_listeners, $url, $server_name, $bgcolor);
+		$directory_data .= '
+'.$streamDescriptionLine.'
+'.$streamDetailsLine.'
+';
+		$printed++;
+	}
+}
+$directory_data .= '
+	<tr>
+		<td colspan=5 height=3 bgcolor="#333333"></td>
+	</tr>
+	<tr>
+		<td colspan=5 height=10 bgcolor="black"></td>
+	</tr>
+</table>';
+$nav_text = '
+<table border=0 bordercolor="#333399" cellpadding=0 cellspacing=0 width="100%">
+<tr>
+<td bgcolor="#000000"><font color=white face=Verdana size=1>'.getPrevLink($start, $pagesize, $printed).'</td>
+<td bgcolor="#000000" width=100%>&nbsp;</td>
+<td bgcolor="#000000"><font color=white face=Verdana size=1>'.getNextLink($start, $pagesize, $printed).'</td>
+</tr>
+</table>';
+print $nav_text;
+print $directory_data;
+print $nav_text;
+?>
+</td>
+<td class="streamtd" valign=top align=right>
+<b>Search</b><br>
+<form method=GET action=index.php>
+Genre<br>
+<select style="font-size:8pt" name=sgenre>
+<option>
+<option value="Alternative">Alternative
+<option value="Classical">Classical
+<option value="Comedy">Comedy
+<option value="Country">Country
+<option value="Dance">Dance
+<option value="Funk">Funk
+<option value="Jazz">Jazz
+<option value="Metal">Metal
+<option value="Mixed">Mixed
+<option value="Pop">Pop
+<option value="Rap">Rap
+<option value="RnB">RnB
+<option value="Rock">Rock
+<option value="Talk">Talk
+<option value="Techno">Techno
+<option value="80s">80s
+<option value="70s">70s
+</select>
+<br>
+<? print getContentTypes(); ?><br>
+Freeform Search<br><input name=search style="font-size:8pt">
+<input type=Submit value=Search>
+</form>
+<br>
+<br>
+<b>Statistics</b><br>
+Total Servers: <? print getTotalServers(); ?>
+</td>
+</tr>
+</table>
+</body>
+</html>

Modified: websites/dir.xiph.org/listen.php
===================================================================
--- websites/dir.xiph.org/listen.php	2004-12-10 21:47:52 UTC (rev 8366)
+++ websites/dir.xiph.org/listen.php	2004-12-10 22:24:17 UTC (rev 8367)
@@ -1,6 +1,12 @@
 <?
-$serverURL = $_GET["serverURL"];
+$username = "oddsock";
+$password = "";
+$database = "oddsock";
+$pid = $_GET["pid"];
 
+$link = mysql_connect("localhost", $username, $password);
+mysql_select_db($database);
+
 header("Content-type: audio/m3u");
 if (preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {
 	header("Content-Disposition: filename=\"listen.m3u\"");
@@ -8,5 +14,13 @@
 else {
 	header("Content-Disposition: inline; filename=\"listen.m3u\"");
 }
-print $serverURL."\r\n";
+$query = "select listen_url from playlists where id = $pid";
+$result = mysql_query($query);
+if (!$result) {
+        print mysql_error();
+}
+
+while ($row = mysql_fetch_row($result)) {
+	print $row[0]."\r\n";
+}
 ?>



More information about the commits mailing list