Index: mythweb/skins/default/music.css
===================================================================
--- mythweb/skins/default/music.css	(revision 0)
+++ mythweb/skins/default/music.css	(revision 0)
@@ -0,0 +1,471 @@
+mp3act {
+	padding: 22px;
+	margin:0;
+	color: #333;
+	text-align: center;
+	font: 65% Verdana, Sans-serif;
+}
+
+h2.music{
+	font-size: 100%;
+	margin:0;
+	padding: 0 0 5px 0;
+
+}
+ul.music{
+	list-style-type: none;
+}
+a.music{
+	color: blue;
+}
+
+a.music:hover{
+	/*color: #fff;
+	background: #F21518;
+	text-decoration: none;*/
+	color: #F21518;
+}
+img{
+	border: 0;
+}
+input,select{
+	border: 1px solid #ccc;
+	border-color: #aaa #ccc #ccc #aaa;
+	background: #f3f3f3;
+	color: #555;
+	font-size: 100%;
+	padding: 2px 3px;
+	vertical-align: middle;
+	
+}
+input.check{
+  border:0;
+  padding:0;
+  background: transparent;
+}
+select{
+	padding: 2px 0 2px 3px;
+}
+input:focus{
+	border: 1px solid #999;
+	background: #FBF9D3;
+	color: #000;
+	border-color: #777 #bbb #bbb #777;
+}
+
+input.btn,input.redbtn{
+	background: #244A79;
+	color: #fff;
+	padding: 2px;
+	border-color: #0E2F58;
+	font: normal 10px sans-serif;
+}
+input.redbtn{
+	background: #F21518;	
+}
+input.redbtn:hover{
+	background: #BE0D0F;
+}
+input.btn:hover{
+	background: #0E2F58;
+}
+
+input.btn2{
+	font-weight: bold;
+	padding: 2px;
+}
+
+input.btn2:hover{
+	background: #eee;
+	border-color: #888;
+	color: #222;
+}
+
+.left{
+	float: left;
+}
+.right{
+	float: right;
+}
+.center{
+	text-align: center;
+}
+.clear{
+  clear: both;
+}
+.error{
+	color: #E63838;
+	font-weight: bold;
+}
+p#error{
+	color: #f20000;
+	font-weight: bold;
+}
+#breadcrumb{
+	height: 14px;
+	padding:2px 0 0 0;
+}
+#breadcrumb span{
+position: relative;
+}
+#breadcrumb span:hover ul{
+	display: block;
+}
+#breadcrumb ul{
+	z-index: 5;
+	border: 1px solid #333;
+	display: none;
+	top:12px;
+	left:0;
+	position: absolute;
+	background: transparent url("./img/music/libg.png");
+	color: #fff;
+	margin:-1px 0 0 0;
+	padding:0;
+	width: 150px;
+	
+}
+#breadcrumb ul#letters{
+	left: -55px;
+	width: auto;
+}
+#breadcrumb span{
+	padding: 0;
+	margin:0;
+}
+#breadcrumb ul li{
+width: 100%;
+	padding:0;
+	margin:0;
+	z-index: 6;
+}
+#breadcrumb ul li a{
+	display: block;
+	padding: 2px 4px;
+	color: #fff;
+	margin:0;
+	z-index: 5;
+	text-decoration: none;
+	font-weight: normal;
+	font-size: 90%;
+}
+
+#breadcrumb ul#letters li{
+	float: left;
+
+}
+#breadcrumb ul#letters li a{
+	float: left;
+	
+}
+#breadcrumb ul li a:hover{
+	background: #FCF7A5;
+	color: #000;
+}
+#breadcrumb ul#letters li a:hover{
+	background: #FCF7A5;
+	color: #000;
+}
+#topinfo{
+	
+	font-size: 90%;
+	color: #666;
+	text-align: left;
+	padding: 0 0 4px 0;
+	
+}
+p.pad{
+	padding: 0px 8px;
+}
+
+#wrap{
+	/*background: #fff;
+	border: 1px solid #ccc;*/
+	text-align: left;
+	padding: 0px;
+	margin:0;
+	position: relative;
+
+	color: #333;
+}
+
+#header{
+	position: relative;
+/*	background: #0E2F58;*/
+	height: 50px;
+	color: #fff;
+	padding: 8px 0 0px 15px;
+}
+#header #controls{
+	float: right;
+	background: transparent;
+	height: 48px;
+	margin-right: 8px;
+	width: 48%;
+	font-size: 90%;
+	line-height: 1.1em;
+	color: #fff;
+}
+
+#header #controls .buttons{
+	float: left;
+	margin: 3px 5px 0 5px;
+}
+#header #controls .current{
+	float: left;
+	margin-top: 3px;
+	
+}
+#header h1{
+	color: #9ABEE5;
+	padding: 0;
+	margin:0;
+	font-size: 150%;
+}
+ul#nav{
+	position: absolute;
+	bottom:0;
+	list-style-type: none;
+	margin:0;
+	padding:0;
+}
+ul#nav li{
+	float: left;
+	margin-right: 5px;
+}
+ul#nav li a{
+	display: block;
+	background: #265990; //#244A79;
+	padding: 4px 5px;
+	color: #dedede;
+	text-decoration: none;
+	margin:0;
+}
+ul#nav li a:hover{
+	background: #416899;
+	color: #fff;
+}
+ul#nav li a.c{
+	background: #fff;
+	color: #F48603;
+	font-weight: bold;
+}
+#loading{
+	display: none;
+	position: absolute;
+	top: 80px;
+	color: #78B855;
+	padding: 10px;
+	background: #CCFF99;
+	border: 1px solid #78B855;
+	z-index: 4;
+	left: 30%;
+}
+#loading h1{
+  font-size: 140%;
+}
+#left{
+	float: left;
+	width: 48%;
+	margin: 15px 0 25px 15px;
+}
+#right{
+	float: right;
+	width: 45%;
+	margin: 15px 15px 25px 0;
+
+}
+.box{
+	background: #E0E0E0;
+	border: 1px solid #ccc;
+	padding: 0 0 8px 0;
+	position: relative;
+}
+#box_extra{
+	display: none;
+	z-index: 2;
+	position: absolute;
+	top: 25px;
+	left:5%;
+	width: 450px;
+	height: 190px;
+	background: transparent url("./img/music/libg.png");
+	color: #fff;
+	font-size: 110%;
+	padding: 5px;
+}
+#box_extra h2{
+	font-size: 120%;
+}
+#box_extra input{
+	background: #333;
+	border-color: #999;
+	color: #fff;
+}
+
+#box_extra select{
+	background: #333;
+	border-color: #999;
+	color: #fff;
+}
+
+.box ul{
+	margin: 0 10px;
+	padding: 0px 0px;
+	background: #f3f3f3;
+	clear: both;
+}
+.box ul li{
+	padding: 2px 0 1px 4px;
+	border: 1px solid transparent;
+	border-width: 1px 0px 1px 0px;
+	position: relative;
+	background: #f3f3f3; 
+}
+
+.box ul li.alt{
+	background: #DEE6EC;
+}
+.box ul li span.user{
+	float: left;
+	width: 200px;
+}
+.box ul li small{
+	color: #888;
+	letter-spacing: -1px;
+}
+
+.box ul li span.links a{
+	text-decoration: underline;
+	color: blue;
+}
+.box ul li span.links a:hover{
+	color: red;
+}
+.box ul li:hover{
+	background: #FCF7A5;
+	color: #000;
+	border-color: #999;
+}
+.box ul li.currentplay{
+	background: #96D1EF;
+	color: #000;
+	border-color: #666;
+}
+
+.box ul li p{
+	z-index:5;
+	display: none;
+	position: absolute;
+	top: 7px;
+	font-size: 90%;
+	padding: 2px;
+	right: 15px;
+	width: 145px;
+	background: transparent url("./img/music/libg.png");
+	color: #fff;
+}
+
+.box ul li:hover p{
+	display: block;
+}
+
+.box ul li a{
+	text-decoration: none;
+	color: #333;
+}
+.box ul li a:hover{
+	color: #000;
+}
+.box ul#letters{
+	height: 18px;
+	padding-left: 5px;
+}
+
+.box ul#letters li{
+	float: left;
+	padding: 2px 2px;
+	background: none;
+	border: 1px solid transparent;
+}
+
+.box ul#letters li:hover{
+	background: #FCF7A5;
+	border-color: #999;
+}
+
+.box p{
+	padding: 0 10px;
+	margin: 8px 0 4px 0;
+
+}
+.box p img{
+	display: block;
+	width: 60px;
+	float: right;
+	padding: 2px;
+	background: #f3f3f3;
+	border: 1px solid #999;
+	margin-bottom: 4px;	
+}
+.box img#bigart{
+	display: none;
+	position: absolute;
+	z-index: 2;
+	background: #f3f3f3;
+	padding: 3px;
+	border: 1px solid #666;
+	top:10px;
+	right: 80px;
+}
+.box p img:hover{
+	border-color: #555;
+	cursor: pointer;
+}
+
+.box .head{
+	padding: 4px;
+	background: #ccc;
+}
+.box .head a{
+	background: #244A79;
+	color: #fff;
+	padding: 2px;
+	text-decoration: none;
+	font: normal 9px sans-serif;
+}
+.box .head a:hover{
+	background: #0E2F58;
+}
+.box .head a.red{
+	background: #F21518;
+}	
+.box .head a.red:hover{
+	background: #BE0D0F;
+}
+.box .head h2{
+	font-size: 120%;
+	padding: 0;
+}
+.box h3{
+	padding: 0 0 0 0px;
+	margin: 0 10px 0 10px;
+	font-size: 120%;
+	border-bottom: 1px solid #ccc;
+}
+
+.loginbox{
+	width: 250px;
+	margin:0 auto;
+	background: #fff;
+	border: 1px solid #ccc;
+	text-align: left;
+}
+.loginbox p{
+	padding: 8px 15px;
+	margin:0;
+}
+.noborder{
+	background: transparent;
+	border:0;
+}

Property changes on: mythweb/skins/default/music.css
___________________________________________________________________
Name: svn:executable
   + *

Index: mythweb/skins/default/img/music/ff_big.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/ff_big.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/libg.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/libg.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/rew_big.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/rew_big.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/paypal_donate.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/paypal_donate.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/vol.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/vol.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/rem.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/rem.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/up.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/up.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/play.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/play.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/play_big.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/play_big.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/stop_big.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/stop_big.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/down.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/down.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/add.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/add.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/default/img/music/progress_bar.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/default/img/music/progress_bar.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/music.css
===================================================================
--- mythweb/skins/grey/music.css	(revision 0)
+++ mythweb/skins/grey/music.css	(revision 0)
@@ -0,0 +1,471 @@
+mp3act {
+	padding: 22px;
+	margin:0;
+	color: #333;
+	text-align: center;
+	font: 65% Verdana, Sans-serif;
+}
+
+h2.music{
+	font-size: 100%;
+	margin:0;
+	padding: 0 0 5px 0;
+
+}
+ul.music{
+	list-style-type: none;
+}
+a.music{
+	color: blue;
+}
+
+a.music:hover{
+	/*color: #fff;
+	background: #F21518;
+	text-decoration: none;*/
+	color: #F21518;
+}
+img{
+	border: 0;
+}
+input,select{
+	border: 1px solid #ccc;
+	border-color: #aaa #ccc #ccc #aaa;
+	background: #f3f3f3;
+	color: #555;
+	font-size: 100%;
+	padding: 2px 3px;
+	vertical-align: middle;
+	
+}
+input.check{
+  border:0;
+  padding:0;
+  background: transparent;
+}
+select{
+	padding: 2px 0 2px 3px;
+}
+input:focus{
+	border: 1px solid #999;
+	background: #FBF9D3;
+	color: #000;
+	border-color: #777 #bbb #bbb #777;
+}
+
+input.btn,input.redbtn{
+	background: #244A79;
+	color: #fff;
+	padding: 2px;
+	border-color: #0E2F58;
+	font: normal 10px sans-serif;
+}
+input.redbtn{
+	background: #F21518;	
+}
+input.redbtn:hover{
+	background: #BE0D0F;
+}
+input.btn:hover{
+	background: #0E2F58;
+}
+
+input.btn2{
+	font-weight: bold;
+	padding: 2px;
+}
+
+input.btn2:hover{
+	background: #eee;
+	border-color: #888;
+	color: #222;
+}
+
+.left{
+	float: left;
+}
+.right{
+	float: right;
+}
+.center{
+	text-align: center;
+}
+.clear{
+  clear: both;
+}
+.error{
+	color: #E63838;
+	font-weight: bold;
+}
+p#error{
+	color: #f20000;
+	font-weight: bold;
+}
+#breadcrumb{
+	height: 14px;
+	padding:2px 0 0 0;
+}
+#breadcrumb span{
+position: relative;
+}
+#breadcrumb span:hover ul{
+	display: block;
+}
+#breadcrumb ul{
+	z-index: 5;
+	border: 1px solid #333;
+	display: none;
+	top:12px;
+	left:0;
+	position: absolute;
+	background: transparent url("./img/music/libg.png");
+	color: #fff;
+	margin:-1px 0 0 0;
+	padding:0;
+	width: 150px;
+	
+}
+#breadcrumb ul#letters{
+	left: -55px;
+	width: auto;
+}
+#breadcrumb span{
+	padding: 0;
+	margin:0;
+}
+#breadcrumb ul li{
+width: 100%;
+	padding:0;
+	margin:0;
+	z-index: 6;
+}
+#breadcrumb ul li a{
+	display: block;
+	padding: 2px 4px;
+	color: #fff;
+	margin:0;
+	z-index: 5;
+	text-decoration: none;
+	font-weight: normal;
+	font-size: 90%;
+}
+
+#breadcrumb ul#letters li{
+	float: left;
+
+}
+#breadcrumb ul#letters li a{
+	float: left;
+	
+}
+#breadcrumb ul li a:hover{
+	background: #FCF7A5;
+	color: #000;
+}
+#breadcrumb ul#letters li a:hover{
+	background: #FCF7A5;
+	color: #000;
+}
+#topinfo{
+	
+	font-size: 90%;
+	color: #666;
+	text-align: left;
+	padding: 0 0 4px 0;
+	
+}
+p.pad{
+	padding: 0px 8px;
+}
+
+#wrap{
+	/*background: #fff;
+	border: 1px solid #ccc;*/
+	text-align: left;
+	padding: 0px;
+	margin:0;
+	position: relative;
+
+	color: #333;
+}
+
+#header{
+	position: relative;
+/*	background: #0E2F58;*/
+	height: 50px;
+	color: #fff;
+	padding: 8px 0 0px 15px;
+}
+#header #controls{
+	float: right;
+	background: transparent;
+	height: 48px;
+	margin-right: 8px;
+	width: 48%;
+	font-size: 90%;
+	line-height: 1.1em;
+	color: #fff;
+}
+
+#header #controls .buttons{
+	float: left;
+	margin: 3px 5px 0 5px;
+}
+#header #controls .current{
+	float: left;
+	margin-top: 3px;
+	
+}
+#header h1{
+	color: #9ABEE5;
+	padding: 0;
+	margin:0;
+	font-size: 150%;
+}
+ul#nav{
+	position: absolute;
+	bottom:0;
+	list-style-type: none;
+	margin:0;
+	padding:0;
+}
+ul#nav li{
+	float: left;
+	margin-right: 5px;
+}
+ul#nav li a{
+	display: block;
+	background: #666666; //#244A79;
+	padding: 4px 5px;
+	color: #ffffff;
+	text-decoration: none;
+	margin:0;
+}
+ul#nav li a:hover{
+	background: #416899;
+	color: #fff;
+}
+ul#nav li a.c{
+	background: #fff;
+	color: #F48603;
+	font-weight: bold;
+}
+#loading{
+	display: none;
+	position: absolute;
+	top: 80px;
+	color: #78B855;
+	padding: 10px;
+	background: #CCFF99;
+	border: 1px solid #78B855;
+	z-index: 4;
+	left: 30%;
+}
+#loading h1{
+  font-size: 140%;
+}
+#left{
+	float: left;
+	width: 48%;
+	margin: 15px 0 25px 15px;
+}
+#right{
+	float: right;
+	width: 45%;
+	margin: 15px 15px 25px 0;
+
+}
+.box{
+	background: #E0E0E0;
+	border: 1px solid #ccc;
+	padding: 0 0 8px 0;
+	position: relative;
+}
+#box_extra{
+	display: none;
+	z-index: 2;
+	position: absolute;
+	top: 25px;
+	left:5%;
+	width: 450px;
+	height: 190px;
+	background: transparent url("./img/music/libg.png");
+	color: #fff;
+	font-size: 110%;
+	padding: 5px;
+}
+#box_extra h2{
+	font-size: 120%;
+}
+#box_extra input{
+	background: #333;
+	border-color: #999;
+	color: #fff;
+}
+
+#box_extra select{
+	background: #333;
+	border-color: #999;
+	color: #fff;
+}
+
+.box ul{
+	margin: 0 10px;
+	padding: 0px 0px;
+	background: #f3f3f3;
+	clear: both;
+}
+.box ul li{
+	padding: 2px 0 1px 4px;
+	border: 1px solid transparent;
+	border-width: 1px 0px 1px 0px;
+	position: relative;
+	background: #f3f3f3; 
+}
+
+.box ul li.alt{
+	background: #DEE6EC;
+}
+.box ul li span.user{
+	float: left;
+	width: 200px;
+}
+.box ul li small{
+	color: #888;
+	letter-spacing: -1px;
+}
+
+.box ul li span.links a{
+	text-decoration: underline;
+	color: blue;
+}
+.box ul li span.links a:hover{
+	color: red;
+}
+.box ul li:hover{
+	background: #FCF7A5;
+	color: #000;
+	border-color: #999;
+}
+.box ul li.currentplay{
+	background: #96D1EF;
+	color: #000;
+	border-color: #666;
+}
+
+.box ul li p{
+	z-index:5;
+	display: none;
+	position: absolute;
+	top: 7px;
+	font-size: 90%;
+	padding: 2px;
+	right: 15px;
+	width: 145px;
+	background: transparent url("./img/music/libg.png");
+	color: #fff;
+}
+
+.box ul li:hover p{
+	display: block;
+}
+
+.box ul li a{
+	text-decoration: none;
+	color: #333;
+}
+.box ul li a:hover{
+	color: #000;
+}
+.box ul#letters{
+	height: 18px;
+	padding-left: 5px;
+}
+
+.box ul#letters li{
+	float: left;
+	padding: 2px 2px;
+	background: none;
+	border: 1px solid transparent;
+}
+
+.box ul#letters li:hover{
+	background: #FCF7A5;
+	border-color: #999;
+}
+
+.box p{
+	padding: 0 10px;
+	margin: 8px 0 4px 0;
+
+}
+.box p img{
+	display: block;
+	width: 60px;
+	float: right;
+	padding: 2px;
+	background: #f3f3f3;
+	border: 1px solid #999;
+	margin-bottom: 4px;	
+}
+.box img#bigart{
+	display: none;
+	position: absolute;
+	z-index: 2;
+	background: #f3f3f3;
+	padding: 3px;
+	border: 1px solid #666;
+	top:10px;
+	right: 80px;
+}
+.box p img:hover{
+	border-color: #555;
+	cursor: pointer;
+}
+
+.box .head{
+	padding: 4px;
+	background: #ccc;
+}
+.box .head a{
+	background: #244A79;
+	color: #fff;
+	padding: 2px;
+	text-decoration: none;
+	font: normal 9px sans-serif;
+}
+.box .head a:hover{
+	background: #0E2F58;
+}
+.box .head a.red{
+	background: #F21518;
+}	
+.box .head a.red:hover{
+	background: #BE0D0F;
+}
+.box .head h2{
+	font-size: 120%;
+	padding: 0;
+}
+.box h3{
+	padding: 0 0 0 0px;
+	margin: 0 10px 0 10px;
+	font-size: 120%;
+	border-bottom: 1px solid #ccc;
+}
+
+.loginbox{
+	width: 250px;
+	margin:0 auto;
+	background: #fff;
+	border: 1px solid #ccc;
+	text-align: left;
+}
+.loginbox p{
+	padding: 8px 15px;
+	margin:0;
+}
+.noborder{
+	background: transparent;
+	border:0;
+}

Property changes on: mythweb/skins/grey/music.css
___________________________________________________________________
Name: svn:executable
   + *

Index: mythweb/skins/grey/img/music/ff_big.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/ff_big.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/libg.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/libg.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/rew_big.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/rew_big.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/paypal_donate.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/paypal_donate.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/vol.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/vol.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/rem.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/rem.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/up.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/up.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/play.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/play.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/play_big.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/play_big.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/stop_big.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/stop_big.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/down.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/down.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/add.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/add.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/skins/grey/img/music/progress_bar.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: mythweb/skins/grey/img/music/progress_bar.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Index: mythweb/modules/music/mp3act_main.php
===================================================================
--- mythweb/modules/music/mp3act_main.php	(revision 0)
+++ mythweb/modules/music/mp3act_main.php	(revision 0)
@@ -0,0 +1,84 @@
+<?php
+/*************************************************************************
+*  mp3act Digital Music System - A streaming and jukebox solution for your digital music collection
+*  http://www.mp3act.net
+*  Copyright (C) 2005 Jon Buda (www.jonbuda.com)
+*  
+*  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+*  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+*  
+*  You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*************************************************************************/
+
+include_once("modules/music/mp3act_functions.php"); 
+require_once("modules/music/mp3act_sajax.php");
+
+$sajax_remote_uri = 'http://'.$_SERVER['HTTP_HOST'].substr($_SERVER['SCRIPT_NAME'],0,strlen($_SERVER['SCRIPT_NAME']) - 11).'music/';
+$sajax_request_type = "POST";
+sajax_init();
+sajax_export("getplaylistnames","musicLookup","playlist_rem","playlist_add","playlistInfo","clearPlaylist","buildBreadcrumb","play","playlist_move","searchMusic","viewPlaylist","getDropDown","savePlaylist","getRandItems","randAdd","deletePlaylist"); 
+sajax_handle_client_request(); 
+
+require 'modules/_shared/tmpl/'.tmpl.'/header.php';
+?>
+<link rel="Stylesheet" href="<?php echo skin_url ?>music.css" type="text/css" />
+
+	<script type="text/javascript"> 
+			var page = 'search';
+			var mode = '<?php echo $_SESSION['sess_playmode']; ?>';
+			var bc_parenttype = '';
+			var bc_parentitem = '';
+			var bc_childtype = '';
+			var bc_childitem = '';
+			var prevpage = '';
+			var currentpage = 'search';
+			var nowplaying = 0;
+			var isplaying = 0;
+			var clearbc = 1;
+			
+	<?php sajax_show_javascript(); ?></script>
+	<script type="text/javascript" src="<?php echo root; ?>music/mp3act_js.js.php"></script>	
+	<script type="text/javascript" src="<?php echo root; ?>music/mp3act_fat.js"></script>
+
+<div id="wrap">
+	<div id="header">
+		<div id="controls">
+			
+		</div>
+		<h1 id="pagetitle"></h1>
+		<ul class="music" id="nav">
+			<li><a href="#" id="search_music" onclick="switchPage('search'); return false;" title="Search the Music Database"><?php echo t("Search"); ?></a></li>
+			<li><a href="#" id="browse" onclick="switchPage('browse'); return false;"  title="Browse the Music Database" class="c"><?php echo t("Browse"); ?></a></li>
+			<li><a href="#" id="random" onclick="switchPage('random'); return false;" title="Create Random Mixes"><?php echo t("Random"); ?></a></li>
+			<li><a href="#" id="playlists" onclick="switchPage('playlists'); return false;" title="Load Saved Playlists"><?php echo t("Playlists"); ?></a></li>
+			<li><a href="#" id="stats" onclick="switchPage('stats'); return false;" title="View Server Statistics"><?php echo t("Stats"); ?></a></li>
+		</ul>
+		
+	</div>
+	<div id="loading"><h1><?php echo t("LOADING"); ?>...</h1></div>
+	<div id="left">
+		<h2 id="breadcrumb"></h2>		
+		<div class="box" id="info">
+		</div>
+	</div>
+	
+	<div id="right">
+			<div class="box">
+				<div class="head">
+					<div class="right"><a href="#" onclick="play('pl',0); return false;" title="Play This Playlist Now">play</a> <a href="#" onclick="savePL('open',0); return false;" title="Save Current Playlist">save</a> <a href="#" onclick="plclear(); return false;"class="red" title="Clear the Current Playlist">clear</a></div>
+					<h2 id="pl_title"></h2><span id="pl_info"></span>
+				</div>
+			<ul class="music" id="playlist">
+					
+			</ul>
+			
+			<div id="box_extra"> </div>
+			</div>
+	</div>
+	<div class="clear"></div>
+</div>
+<iframe src="<?php echo root; ?>music/mp3act_hidden.php" frameborder="0" height="0" width="0" id="hidden" name="hidden"></iframe>
+<?
+require 'modules/_shared/tmpl/'.tmpl.'/footer.php';
+?>
\ No newline at end of file

Property changes on: mythweb/modules/music/mp3act_main.php
___________________________________________________________________
Name: svn:executable
   + *

Index: mythweb/modules/music/handler.php
===================================================================
--- mythweb/modules/music/handler.php	(revision 9730)
+++ mythweb/modules/music/handler.php	(working copy)
@@ -13,297 +13,23 @@
  *
 /**/
 
-// Make sure the music directory exists
-    if (file_exists('data/music')) {
-    // File is not a directory or a symlink
-        if (!is_dir('data/music') && !is_link('data/music')) {
-            custom_error('An invalid file exists at data/music.  Please remove it in'
-                        .' order to use the music portions of MythWeb.');
-        }
-    }
-// Create the symlink, if possible.
-//
-// NOTE:  Errors have been disabled because if I turn them on, people hosting
-//        MythWeb on Windows machines will have issues.  I will turn the errors
-//        back on when I find a clean way to do so.
-//
-    else {
-        $dir = $db->query_col('SELECT data
-                                 FROM settings
-                                WHERE value="MusicLocation" AND hostname=?',
-                              hostname
-                             );
-        if ($dir) {
-            $ret = @symlink($dir, 'data/music');
-            if (!$ret) {
-                #custom_error("Could not create a symlink to $dir, the local MythMusic directory"
-                #            .' for this hostname ('.hostname.').  Please create a symlink to your'
-                #            .' MythMusic directory at data/music in order to use the music'
-                #            .' portions of MythWeb.');
-            }
-        }
-        else {
-            #custom_error('Could not find a value in the database for the MythMusic directory'
-            #            .' for this hostname ('.hostname.').  Please create a symlink to your'
-            #            .' MythMusic directory at data/music in order to use the music'
-            #            .' portions of MythWeb.');
-        }
-    }
-
-//
-//  Someday, music.php will let us stream
-//  entire playlists to any spot on planet earth
-//
-require_once tmpl_dir.'music.php';
-
-$mythmusic = new mythMusic();
-$mythmusic->display();
-
-class mythMusic {
-    var $filterPlaylist;
-    var $filterArtist;
-    var $filterAlbum;
-    var $filterGenre;
-    var $filterRank;
-    var $filterSonglist;
-    var $keepFilters;
-    var $filter;
-    var $totalCount;
-    var $offset;
-
-    var $result;
-
-
-    var $intid;
-    var $artist;
-    var $album;
-    var $title;
-    var $genre;
-    var $length;
-    var $rating;
-    var $filename;
-    var $urlfilename;
-
-    var $alphalink;
-    var $alphaoffset;
-
-    function mythMusic()
-    {
-        if($_GET['offset'] >=0 )
-            $this->offset=$_GET['offset'];
-        else
-            $this->offset=0;
-
-        /**** If alphalink set, then change offset to new value ****/
-        if ($_GET['alphalink']) {
-            $alphalink = $_GET['alphalink'];
-            $result=mysql_query("select count(1) from musicmetadata where upper(artist) < ".escape($alphalink));
-            $alphaoffset=mysql_fetch_row($result);
-            $this->offset=$alphaoffset[0];
-            mysql_free_result($result);
-        }
-
-        if($_GET['filterPlaylist'])
-        {
-            $this->filterPlaylist=$_GET['filterPlaylist'];
-            $_GET['filterPlaylist'];
-        }
-        else
-            $this->filterPlaylist="_All_";
-
-        if($_GET['filterArtist'])
-        {
-            $this->filterArtist=$_GET['filterArtist'];
-        }
-        else
-            $this->filterArtist="_All_";
-
-        if($_GET['filterAlbum'])
-        {
-            $this->filterAlbum=$_GET['filterAlbum'];
-        }
-        else
-            $this->filterAlbum="_All_";
-        if($_GET['filterGenre'])
-        {
-            $this->filterGenre=$_GET['filterGenre'];
-        }
-        else
-            $this->filterGenre="_All_";
-
-
-        if($_GET['filterRank'])
-            $this->filterRank=$_GET['filterRank'];
-        else
-            $this->filterRank="_All_";
-    }
-
-    function readRow()
-    {
-
-            if($row=mysql_fetch_row($this->result))
-            {
-                $this->intid=$row[0];
-                $this->artist=$row[1];
-                $this->album=$row[2];
-                $this->title=$row[3];
-                $this->genre=$row[4];
-                $this->length=$row[5];
-                $this->rating=$row[6];
-                $this->filename=$row[7];
-
-                $this->urlfilename=root.'data/music';
-                global $musicdir;
-                foreach (preg_split('/\//', substr($this->filename, strlen($musicdir))) as $dir) {
-                    if (!$dir) continue;
-                    $this->urlfilename .= '/'.rawurlencode(utf8tolocal($dir));
-                }
-
-                return(true);
-            }
-            return(false);
-    }
-
-
-
-    function display()
-    {
-        $music = new Theme_music();
-        $this->init($music->getMaxPerPage());
-        $music->setOffset($this->offset);
-        $music->setTotalCount($this->totalCount);
-
-        $music->print_header($this->filterPlaylist,$this->filterArtist,$this->filterAlbum,$this->filterGenre);
-        if($this->totalCount > 0)
-        {
-            while($this->readRow())
-            {
-                $music->printDetail($this->title,$this->length,$this->artist,$this->album,$this->genre,$this->urlfilename);
-            }
-        }
-        else
-        {
-            $music->printNoDetail();
-        }
-        if($this->result)
-            mysql_free_result($this->result);
-
-        $music->print_footer();
-    }
-
-    function prepFilter()
-    {
-        $prevFilter=0;
-        $thisFilter="";
-
-        if($this->filterPlaylist != "_All_")
-        {
-            $playlistResult = mysql_query("select playlistid,name,songlist,hostname from musicplaylist where playlistid=".escape($this->filterPlaylist));
-            if($playlistResult)
-            {
-                if(mysql_num_rows($playlistResult)==1)
-                {
-                    $row=mysql_fetch_row($playlistResult);
-                    if($row)
-                    {
-
-                        $this->filterSonglist=$row[2];
-                        if($prevFilter==1)
-                            $this->filter=$this->filter . "and intid in (" . $this->filterSonglist . ")";
-                        else
-                        {
-                            $this->filter="intid in (" . $this->filterSonglist . ")";
-                            $prevFilter=1;
-                        }
-
-                        $this->keepFilters="&amp;filterPlaylist=" . urlencode($this->filterPlaylist);
-
-                    }
-                }
-            }
-        }
-
-        if($this->filterArtist != "_All_" )
-        {
-            if($prevFilter==1)
-                $this->filter=$this->filter . "and artist=".escape($this->filterArtist);
-            else
-            {
-                $this->filter="artist=".escape($this->filterArtist);
-                $prevFilter=1;
-            }
-
-            $this->keepFilters="&amp;filterArtist=" . urlencode($this->filterArtist);
-
-        }
-        if($this->filterAlbum != "_All_")
-        {
-            if($prevFilter==1)
-            {
-                $this->filter= $this->filter . "and album=\"" . $this->filterAlbum . "\"";
-            }
-            else
-            {
-                $this->filter="album=\"" . $this->filterAlbum . "\"";
-                $prevFilter=1;
-            }
-            $this->keepFilters =$this->keepFilters . "&amp;filterAlbum=" . urlencode($this->filterAlbum) ;
-
-        }
-        if($this->filterGenre != "_All_")
-        {
-            if($prevFilter==1)
-            {
-                $this->filter= $this->filter . "and genre=" . $this->filterGenre ;
-            }
-            else
-            {
-                $this->filter="genre=\"" . $this->filterGenre . "\"";
-                $prevFilter=1;
-            }
-            $this->keepFilters =$this->keepFilters . "&amp;filterGenre=" . urlencode($this->filterGenre);
-
-        }
-
-        if($this->filterRank != "_All_")
-        {
-            if($prevFilter==1)
-            {
-                $this->filter=$this->filter . "and rank=" . $this->filterRank;
-            }
-            else
-            {
-                $this->filter="rank=" . $this->filterRank;
-                $prevFilter=1;
-            }
-            $this->keepFilters =$this->keepFilters . "&amp;filterRank=" . urlencode($this->filterRank);
-        }
-
-
-
-    }
-
-    function init($maxPerPage) {
-        global $db;
-        $this->prepFilter();
-        if (empty($this->filter))
-            $this->totalCount = $db->query_col('SELECT COUNT(*) FROM musicmetadata');
-        else
-            $this->totalCount = $db->query_col('SELECT COUNT(*) FROM musicmetadata WHERE '.$this->filter);
-
-        if ($this->totalCount > 0) {
-            if($this->offset > 0) {
-                $limitText='LIMIT ' . $this->offset . ',' . $maxPerPage;
-            }
-            else
-                $limitText='LIMIT ' . $maxPerPage;
-
-            if (empty($this->filter))
-                $this->result=mysql_query("select intid,artist,album,title,genre,length,rating,filename from musicmetadata order by artist,album,tracknum " . $limitText);
-            else
-                $this->result=mysql_query("select intid,artist,album,title,genre,length,rating,filename from musicmetadata where $this->filter order by artist,album,tracknum $limitText");
-        }
-    }
-}
-
-
+    if (tmpl == "compact")
+	{
+	require_once("modules/music/music_handler.php");
+	}
+    else
+	{
+        if (in_array($Path[1], array('mp3act_js.js.php', 'mp3act_fat.js', 'mp3act_hidden.php')))
+    	    {
+	    require_once 'modules/music/'.$Path[1];
+	    exit();
+		}
+	if (strstr($Path[1],"mp3act_playstream.php") != false)
+	    {
+    	    require_once 'modules/music/mp3act_playstream.php';
+	    exit();
+	    }
+    
+	require_once 'modules/music/mp3act_main.php';
+	}
+?>    
\ No newline at end of file
Index: mythweb/modules/music/music_handler.php
===================================================================
--- mythweb/modules/music/music_handler.php	(revision 0)
+++ mythweb/modules/music/music_handler.php	(revision 0)
@@ -0,0 +1,312 @@
+<?php
+/**
+ * MythMusic browser
+ *
+ * @url         $URL: svn+ssh://xris@cvs.mythtv.org/var/lib/svn/trunk/mythplugins/mythweb/modules/music/init.php $
+ * @date        $Date: 2006-03-26 12:09:14 +0200 (So, 26 Mär 2006) $
+ * @version     $Revision: 9493 $
+ * @author      $Author: xris $
+ * @license     GPL
+ *
+ * @package     MythWeb
+ * @subpackage  Music
+ *
+/**/
+
+// Make sure the music directory exists
+    if (file_exists('data/music')) {
+    // File is not a directory or a symlink
+        if (!is_dir('data/music') && !is_link('data/music')) {
+            custom_error('An invalid file exists at data/music.  Please remove it in'
+                        .' order to use the music portions of MythWeb.');
+        }
+    }
+// Create the symlink, if possible.
+//
+// NOTE:  Errors have been disabled because if I turn them on, people hosting
+//        MythWeb on Windows machines will have issues.  I will turn the errors
+//        back on when I find a clean way to do so.
+//
+    else {
+        $dir = $db->query_col('SELECT data
+                                 FROM settings
+                                WHERE value="MusicLocation" AND hostname=?',
+                              hostname
+                             );
+        if ($dir) {
+            $ret = @symlink($dir, 'data/music');
+            if (!$ret) {
+                #custom_error("Could not create a symlink to $dir, the local MythMusic directory"
+                #            .' for this hostname ('.hostname.').  Please create a symlink to your'
+                #            .' MythMusic directory at data/music in order to use the music'
+                #            .' portions of MythWeb.');
+            }
+        }
+        else {
+            #custom_error('Could not find a value in the database for the MythMusic directory'
+            #            .' for this hostname ('.hostname.').  Please create a symlink to your'
+            #            .' MythMusic directory at data/music in order to use the music'
+            #            .' portions of MythWeb.');
+        }
+    }
+
+//
+//  Someday, music.php will let us stream
+//  entire playlists to any spot on planet earth
+//
+require_once tmpl_dir.'music.php';
+
+$mythmusic = new mythMusic();
+$mythmusic->display();
+
+class mythMusic {
+    var $filterPlaylist;
+    var $filterArtist;
+    var $filterAlbum;
+    var $filterGenre;
+    var $filterRank;
+    var $filterSonglist;
+    var $keepFilters;
+    var $filter;
+    var $totalCount;
+    var $offset;
+
+    var $result;
+
+
+    var $intid;
+    var $artist;
+    var $album;
+    var $title;
+    var $genre;
+    var $length;
+    var $rating;
+    var $filename;
+    var $urlfilename;
+
+    var $alphalink;
+    var $alphaoffset;
+
+    function mythMusic()
+    {
+        if($_GET['offset'] >=0 )
+            $this->offset=$_GET['offset'];
+        else
+            $this->offset=0;
+
+        /**** If alphalink set, then change offset to new value ****/
+        if ($_GET['alphalink']) {
+            $alphalink = $_GET['alphalink'];
+	    
+	    $result=mysql_query("SELECT count(1) FROM music_songs INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id WHERE (((UPPER(music_artists.artist_name))< \"".$alphalink."\")) ORDER BY music_artists.artist_name;");
+            $alphaoffset=mysql_fetch_row($result);
+            $this->offset=$alphaoffset[0];
+            mysql_free_result($result);
+        }
+
+        if($_GET['filterPlaylist'])
+        {
+            $this->filterPlaylist=$_GET['filterPlaylist'];
+            $_GET['filterPlaylist'];
+        }
+        else
+            $this->filterPlaylist="_All_";
+
+        if($_GET['filterArtist'])
+        {
+            $this->filterArtist=$_GET['filterArtist'];
+        }
+        else
+            $this->filterArtist="_All_";
+
+        if($_GET['filterAlbum'])
+        {
+            $this->filterAlbum=$_GET['filterAlbum'];
+        }
+        else
+            $this->filterAlbum="_All_";
+        if($_GET['filterGenre'])
+        {
+            $this->filterGenre=$_GET['filterGenre'];
+        }
+        else
+            $this->filterGenre="_All_";
+
+
+        if($_GET['filterRank'])
+            $this->filterRank=$_GET['filterRank'];
+        else
+            $this->filterRank="_All_";
+    }
+
+    function readRow()
+    {
+
+            if($row=mysql_fetch_row($this->result))
+            {
+                $this->intid=$row[0];
+                $this->artist=$row[1];
+                $this->album=$row[2];
+                $this->title=$row[3];
+                $this->genre=$row[4];
+                $this->length=$row[5];
+                $this->rating=$row[6];
+                $this->filename=$row[7];
+
+                $this->urlfilename=root.'data/music';
+                global $musicdir;
+                foreach (preg_split('/\//', substr($this->filename, strlen($musicdir))) as $dir) {
+                    if (!$dir) continue;
+                    $this->urlfilename .= '/'.rawurlencode(utf8tolocal($dir));
+                }
+
+                return(true);
+            }
+            return(false);
+    }
+
+
+
+    function display()
+    {
+        $music = new Theme_music();
+        $this->init($music->getMaxPerPage());
+        $music->setOffset($this->offset);
+        $music->setTotalCount($this->totalCount);
+
+        $music->print_header($this->filterPlaylist,$this->filterArtist,$this->filterAlbum,$this->filterGenre);
+        if($this->totalCount > 0)
+        {
+            while($this->readRow())
+            {
+                $music->printDetail($this->title,$this->length,$this->artist,$this->album,$this->genre,$this->urlfilename);
+            }
+        }
+        else
+        {
+            $music->printNoDetail();
+        }
+        if($this->result)
+            mysql_free_result($this->result);
+
+        $music->print_footer();
+    }
+
+    function prepFilter()
+    {
+        $prevFilter=0;
+        $thisFilter="";
+
+        if($this->filterPlaylist != "_All_")
+        {
+            $playlistResult = mysql_query("select playlistid,name,songlist,hostname from musicplaylist where playlistid=".escape($this->filterPlaylist));
+            if($playlistResult)
+            {
+                if(mysql_num_rows($playlistResult)==1)
+                {
+                    $row=mysql_fetch_row($playlistResult);
+                    if($row)
+                    {
+
+                        $this->filterSonglist=$row[2];
+                        if($prevFilter==1)
+                            $this->filter=$this->filter . "and song_id in (" . $this->filterSonglist . ")";
+                        else
+                        {
+                            $this->filter="song_id in (" . $this->filterSonglist . ")";
+                            $prevFilter=1;
+                        }
+
+                        $this->keepFilters="&amp;filterPlaylist=" . urlencode($this->filterPlaylist);
+
+                    }
+                }
+            }
+        }
+
+        if($this->filterArtist != "_All_" )
+        {
+            if($prevFilter==1)
+                $this->filter=$this->filter . "and artist_name=".escape($this->filterArtist);
+            else
+            {
+                $this->filter="artist_name=".escape($this->filterArtist);
+                $prevFilter=1;
+            }
+
+            $this->keepFilters="&amp;filterArtist=" . urlencode($this->filterArtist);
+
+        }
+        if($this->filterAlbum != "_All_")
+        {
+            if($prevFilter==1)
+            {
+                $this->filter= $this->filter . "and album_name=\"" . $this->filterAlbum . "\"";
+            }
+            else
+            {
+                $this->filter="album_name=\"" . $this->filterAlbum . "\"";
+                $prevFilter=1;
+            }
+            $this->keepFilters =$this->keepFilters . "&amp;filterAlbum=" . urlencode($this->filterAlbum) ;
+
+        }
+        if($this->filterGenre != "_All_")
+        {
+            if($prevFilter==1)
+            {
+                $this->filter= $this->filter . "and genre=" . $this->filterGenre ;
+            }
+            else
+            {
+                $this->filter="genre=\"" . $this->filterGenre . "\"";
+                $prevFilter=1;
+            }
+            $this->keepFilters =$this->keepFilters . "&amp;filterGenre=" . urlencode($this->filterGenre);
+
+        }
+
+        if($this->filterRank != "_All_")
+        {
+            if($prevFilter==1)
+            {
+                $this->filter=$this->filter . "and rank=" . $this->filterRank;
+            }
+            else
+            {
+                $this->filter="rank=" . $this->filterRank;
+                $prevFilter=1;
+            }
+            $this->keepFilters =$this->keepFilters . "&amp;filterRank=" . urlencode($this->filterRank);
+        }
+
+
+
+    }
+
+    function init($maxPerPage) {
+        global $db;
+        $this->prepFilter();
+        if (empty($this->filter))
+            $this->totalCount = $db->query_col('SELECT COUNT(*) FROM music_songs');
+        else
+            $this->totalCount = $db->query_col('SELECT COUNT(*) FROM ((music_songs INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id) INNER JOIN music_albums ON music_songs.album_id = music_albums.album_id) INNER JOIN music_genres ON music_songs.genre_id = music_genres.genre_id WHERE '.$this->filter);
+        if ($this->totalCount > 0) {
+            if($this->offset > 0) {
+                $limitText='LIMIT ' . $this->offset . ',' . $maxPerPage;
+            }
+            else
+                $limitText='LIMIT ' . $maxPerPage;
+
+            if (empty($this->filter))
+	    
+	        $this->result=mysql_query("SELECT music_songs.song_id, music_artists.artist_name, music_albums.album_name, music_songs.name, music_genres.genre, music_songs.length, music_songs.rating, music_songs.filename FROM ((music_songs INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id) INNER JOIN music_albums ON music_songs.album_id = music_albums.album_id) INNER JOIN music_genres ON music_songs.genre_id = music_genres.genre_id order by artist_name,album_name,track " . $limitText);
+                //$this->result=mysql_query("select intid,artist,album,title,genre,length,rating,filename from music_songs order by artist,album,tracknum " . $limitText);
+            else
+	        $this->result=mysql_query("SELECT music_songs.song_id, music_artists.artist_name, music_albums.album_name, music_songs.name, music_genres.genre, music_songs.length, music_songs.rating, music_songs.filename FROM ((music_songs INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id) INNER JOIN music_albums ON music_songs.album_id = music_albums.album_id) INNER JOIN music_genres ON music_songs.genre_id = music_genres.genre_id where $this->filter order by artist_name,album_name,track " . $limitText);
+                //$this->result=mysql_query("select intid,artist,album,title,genre,length,rating,filename from music_songs where $this->filter order by artist,album,tracknum $limitText");
+        }
+    }
+}
+
+

Property changes on: mythweb/modules/music/music_handler.php
___________________________________________________________________
Name: svn:executable
   + *

Index: mythweb/modules/music/mp3act_sajax.php
===================================================================
--- mythweb/modules/music/mp3act_sajax.php	(revision 0)
+++ mythweb/modules/music/mp3act_sajax.php	(revision 0)
@@ -0,0 +1,308 @@
+<?php	
+if (!isset($SAJAX_INCLUDED)) {
+
+	/*  
+	 * GLOBALS AND DEFAULTS
+	 *
+	 */ 
+	$sajax_debug_mode = 0;
+	$sajax_export_list = array();
+	$sajax_request_type = "GET";
+	$sajax_remote_uri = "";
+	
+	/*
+	 * CODE
+	 *
+	 */ 
+	 
+	//
+	// Initialize the Sajax library.
+	//
+	function sajax_init() {
+	}
+	
+	//
+	// Helper function to return the script's own URI. 
+	// 
+	function sajax_get_my_uri() {
+		global $REQUEST_URI;
+		
+		return $REQUEST_URI;
+	}
+	$sajax_remote_uri = sajax_get_my_uri();
+	
+	//
+	// Helper function to return an eval()-usable representation
+	// of an object in JavaScript.
+	// 
+	function sajax_get_js_repr($value) {
+		$type = gettype($value);
+		
+		if ($type == "boolean" ||
+			$type == "integer") {
+			return "parseInt($value)";
+		} 
+		elseif ($type == "double") {
+			return "parseFloat($value)";
+		} 
+		elseif ($type == "array" || $type == "object" ) {
+			//
+			// XXX Arrays with non-numeric indices are not
+			// permitted according to ECMAScript, yet everyone
+			// uses them.. We'll use an object.
+			// 
+			$s = "{ ";
+			if ($type == "object") {
+				$value = get_object_vars($value);
+			} 
+			foreach ($value as $k=>$v) {
+				$esc_key = sajax_esc($k);
+				if (is_numeric($k)) 
+					$s .= "$k: " . sajax_get_js_repr($v) . ", ";
+				else
+					$s .= "\"$esc_key\": " . sajax_get_js_repr($v) . ", ";
+			}
+			return substr($s, 0, -2) . " }";
+		} 
+		else {
+			$esc_val = sajax_esc($value);
+			$s = "\"$esc_val\"";
+			return $s;
+		}
+	}
+
+	function sajax_handle_client_request() {
+		global $sajax_export_list;
+		
+		$mode = "";
+		
+		if (! empty($_GET["rs"])) 
+			$mode = "get";
+		
+		if (!empty($_POST["rs"]))
+			$mode = "post";
+			
+		if (empty($mode)) 
+			return;
+
+		$target = "";
+		
+		if ($mode == "get") {
+			// Bust cache in the head
+			header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
+			header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+			// always modified
+			header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
+			header ("Pragma: no-cache");                          // HTTP/1.0
+			$func_name = $_GET["rs"];
+			if (! empty($_GET["rsargs"])) 
+				$args = $_GET["rsargs"];
+			else
+				$args = array();
+		}
+		else {
+			$func_name = $_POST["rs"];
+			if (! empty($_POST["rsargs"])) 
+				$args = $_POST["rsargs"];
+			else
+				$args = array();
+		}
+		
+		if (! in_array($func_name, $sajax_export_list))
+			echo "-:$func_name not callable";
+		else {
+			echo "+:";
+			$result = call_user_func_array($func_name, $args);
+			echo "var res = " . sajax_get_js_repr($result) . "; res;";
+		}
+		exit;
+	}
+	
+	function sajax_get_common_js() {
+		global $sajax_debug_mode;
+		global $sajax_request_type;
+		global $sajax_remote_uri;
+		
+		$t = strtoupper($sajax_request_type);
+		if ($t != "" && $t != "GET" && $t != "POST") 
+			return "// Invalid type: $t.. \n\n";
+		
+		ob_start();
+		?>
+		
+		// remote scripting library
+		// (c) copyright 2005 modernmethod, inc
+		var sajax_debug_mode = <?php echo $sajax_debug_mode ? "true" : "false"; ?>;
+		var sajax_request_type = "<?php echo $t; ?>";
+		var sajax_target_id = "";
+		
+		function sajax_debug(text) {
+			if (sajax_debug_mode)
+				alert("RSD: " + text)
+		}
+ 		function sajax_init_object() {
+ 			sajax_debug("sajax_init_object() called..")
+ 			
+ 			var A;
+			try {
+				A=new ActiveXObject("Msxml2.XMLHTTP");
+			} catch (e) {
+				try {
+					A=new ActiveXObject("Microsoft.XMLHTTP");
+				} catch (oc) {
+					A=null;
+				}
+			}
+			if(!A && typeof XMLHttpRequest != "undefined")
+				A = new XMLHttpRequest();
+			if (!A)
+				sajax_debug("Could not create connection object.");
+			return A;
+		}
+		function sajax_do_call(func_name, args) {
+			var i, x, n;
+			var uri;
+			var post_data;
+			var target_id;
+			
+			sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id);
+			target_id = sajax_target_id;
+			if (sajax_request_type == "") 
+				sajax_request_type = "GET";
+			
+			uri = "<?php echo $sajax_remote_uri; ?>";
+			if (sajax_request_type == "GET") {
+			
+				if (uri.indexOf("?") == -1) 
+					uri += "?rs=" + escape(func_name);
+				else
+					uri += "&rs=" + escape(func_name);
+				uri += "&rst=" + escape(sajax_target_id);
+				uri += "&rsrnd=" + new Date().getTime();
+				
+				for (i = 0; i < args.length-1; i++) 
+					uri += "&rsargs[]=" + escape(args[i]);
+
+				post_data = null;
+			} 
+			else if (sajax_request_type == "POST") {
+				post_data = "rs=" + escape(func_name);
+				post_data += "&rst=" + escape(sajax_target_id);
+				post_data += "&rsrnd=" + new Date().getTime();
+				
+				for (i = 0; i < args.length-1; i++) 
+					post_data = post_data + "&rsargs[]=" + escape(args[i]);
+			}
+			else {
+				alert("Illegal request type: " + sajax_request_type);
+			}
+			
+			x = sajax_init_object();
+			x.open(sajax_request_type, uri, true);
+			
+			if (sajax_request_type == "POST") {
+				x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
+				x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+			}
+			
+			x.onreadystatechange = function() {
+				if (x.readyState != 4) 
+					return;
+
+				sajax_debug("received " + x.responseText);
+				
+				var status;
+				var data;
+				status = x.responseText.charAt(0);
+				data = x.responseText.substring(2);
+				if (status == "-") 
+					alert("Error: " + data);
+				else {
+					if (target_id != "") 
+						document.getElementById(target_id).innerHTML = eval(data);
+					else
+						args[args.length-1](eval(data));
+				}
+			}
+			sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
+			x.send(post_data);
+			sajax_debug(func_name + " waiting..");
+			delete x;
+			return true;
+		}
+		
+		<?php
+		$html = ob_get_contents();
+		ob_end_clean();
+		return $html;
+	}
+	
+	function sajax_show_common_js() {
+		echo sajax_get_common_js();
+	}
+	
+	// javascript escape a value
+	function sajax_esc($val)
+	{
+		$val = str_replace("\\", "\\\\", $val);
+		$val = str_replace("\r", "\\r", $val);
+		$val = str_replace("\n", "\\n", $val);
+		return str_replace('"', '\\"', $val);
+	}
+
+	function sajax_get_one_stub($func_name) {
+		ob_start();	
+		?>
+		
+		// wrapper for <?php echo $func_name; ?>
+		
+		function x_<?php echo $func_name; ?>() {
+			sajax_do_call("<?php echo $func_name; ?>",
+				x_<?php echo $func_name; ?>.arguments);
+		}
+		
+		<?php
+		$html = ob_get_contents();
+		ob_end_clean();
+		return $html;
+	}
+	
+	function sajax_show_one_stub($func_name) {
+		echo sajax_get_one_stub($func_name);
+	}
+	
+	function sajax_export() {
+		global $sajax_export_list;
+		
+		$n = func_num_args();
+		for ($i = 0; $i < $n; $i++) {
+			$sajax_export_list[] = func_get_arg($i);
+		}
+	}
+	
+	$sajax_js_has_been_shown = 0;
+	function sajax_get_javascript()
+	{
+		global $sajax_js_has_been_shown;
+		global $sajax_export_list;
+		
+		$html = "";
+		if (! $sajax_js_has_been_shown) {
+			$html .= sajax_get_common_js();
+			$sajax_js_has_been_shown = 1;
+		}
+		foreach ($sajax_export_list as $func) {
+			$html .= sajax_get_one_stub($func);
+		}
+		return $html;
+	}
+	
+	function sajax_show_javascript()
+	{
+		echo sajax_get_javascript();
+	}
+
+	
+	$SAJAX_INCLUDED = 1;
+}
+?>

Property changes on: mythweb/modules/music/mp3act_sajax.php
___________________________________________________________________
Name: svn:executable
   + *

Index: mythweb/modules/music/mp3act_js.js.php
===================================================================
--- mythweb/modules/music/mp3act_js.js.php	(revision 0)
+++ mythweb/modules/music/mp3act_js.js.php	(revision 0)
@@ -0,0 +1,316 @@
+<?php
+function music_dir()
+    {
+    return 'http://'.$_SERVER['HTTP_HOST'].root."music/";
+}
+?>
+    	window.onload=function(){ init(); };
+    	
+    	function init(){
+    		setPageTitle();
+    		x_viewPlaylist(viewPlaylist_cb);
+    		x_playlistInfo(plinfo_cb);
+    		setPLTitle();
+    		setCurrentPage();
+    		updateBox(page,0);
+    	}
+    	function empty_cb(new_data){
+    	  
+    	}
+    	
+    	function setPageNav(){
+    		//document.getElementById("breadcrumb").innerHTML = prevpage;
+    	}
+    
+    	function switchPage(newpage){
+    		prevpage = page;
+    		page = newpage;
+    	
+    		updateBox(page,0);
+    		setPageTitle();
+    		setCurrentPage();
+    		//setPageNav();
+    	}
+    	
+    	function setPLTitle(){
+    		document.getElementById("pl_title").innerHTML = " <? echo t("Playlist"); ?> ";
+    	}
+    	
+    	function viewPlaylist_cb(new_data){
+    		document.getElementById("playlist").innerHTML = new_data;
+    	}
+    	
+    	function setCurrentPage(){
+    		var x = document.getElementById('nav');
+    		var y = x.getElementsByTagName('a');
+    		for (var i=0;i<y.length;i++){
+ 					y[i].removeAttribute("class");
+ 					if(y[i].id == page)
+ 						y[i].setAttribute('class','c');
+				}
+    	}
+    	
+    	function getDropDown(type,id){
+    		x_getDropDown(type,id,getDropDown_cb);
+    	}
+    	
+    	function getDropDown_cb(new_data){
+    		ul = document.getElementById("browse_ul");
+    		ul.innerHTML = new_data;
+    		ul.style.display = 'block';
+    	}
+    	
+    	function closeDropDown(){
+    		ul = document.getElementById("browse_ul");
+    		ul.style.display = 'none';
+    		ul.innerHTML = '';
+    	}
+    	
+	function savePL_cb(data){
+    			var save_form = "<h2>Save Playlist</h2><form onsubmit='return savePL(\"save\",this)' method='get' action=''><strong>Playlist Name</strong><br/><input type='text' name='save_pl_name' id='save_pl_name' size='25' /><input style='left: 350px; position: absolute;' type='submit' value='save new' /></form>";
+			save_form = save_form + "<form onsubmit='return savePL(\"saveold\",this)' method='get' action=''><hr><strong>overwrite Playlist:&nbsp;</strong></ br><select name='overwrite_pl_name'>";
+			save_form = save_form + data;
+			save_form = save_form + "&nbsp;</select>&nbsp;<input style='left: 350px; position: absolute;' type='submit' value='save' /><br><hr><br><input style='left: 400px; position: absolute;' type='button' onclick=\"savePL('close',0); return false;\" value='cancel' /></form> ";    			
+			document.getElementById("box_extra").innerHTML = save_form;
+    			document.getElementById("box_extra").style.display = 'block';
+		}
+    	
+	function savePL(type,data){
+    		if(type=='open'){
+			x_getplaylistnames(savePL_cb);
+    		}
+    		else if(type=='save'){
+    			var pl_name = data.save_pl_name.value;
+			x_savePlaylist(pl_name,0,save_Playlist_cb);			    
+
+    			return false;
+    		}
+    		else if(type=='saveold'){
+			var ov_pl_name = data.overwrite_pl_name.value;
+			x_savePlaylist(ov_pl_name,1,save_Playlist_cb);
+
+    			return false;
+    		}
+    		else if(type=='close')
+    			document.getElementById("box_extra").style.display = 'none';
+    	}
+    	
+    	function save_Playlist_cb(new_data){
+    		box = document.getElementById("box_extra");
+    		box.innerHTML = new_data;
+    		setTimeout("box.style.display='none'","1250");
+    	}
+    	
+    	function movePLItem(direction,item){
+				var y;
+				var temp;
+    		if(direction == "up")
+    			y = item.previousSibling;
+    		else if(direction == "down")
+					y = item.nextSibling;
+					
+				if(y && y.nodeName == 'LI'){	
+    			pl_move(y.id,item.id);
+    			
+    			var temp = y.innerHTML;
+    			y.innerHTML = item.innerHTML;
+    			item.innerHTML = temp;
+    			Fat.fade_element(y.id,null,900,'#ffcc99','#f3f3f3');
+    		}
+    	}
+    	
+    	function setBgcolor(id, c)
+			{
+				if(id != ('pl'+nowplaying)){
+				var o = document.getElementById(id);
+				o.style.backgroundColor = c;
+				}
+			}
+			
+			function setPageTitle(){
+				var pages= new Array()
+				pages["browse"]="<?php echo t("Browse Music"); ?> ";
+				pages["search"]="<?php echo t("Search Music"); ?> ";
+				pages["random"]="<?php echo t("Create a Random Mix"); ?> ";
+				pages["playlists"]="<?php echo t("Load a Saved Playlist"); ?> ";
+				pages["stats"]="<?php echo t("Server Statistics"); ?> ";
+				document.getElementById("pagetitle").innerHTML = pages[page];
+				
+			}
+			
+			function getRandItems(type){
+			  //document.getElementById("breadcrumb").innerHTML = '';
+			  document.getElementById("rand_items").innerHTML = '';
+				x_getRandItems(type,getRandItems_cb);
+			}
+			
+			function getRandItems_cb(new_data){
+				document.getElementById("rand_items").innerHTML = new_data;
+			}
+			
+			function updateBox_cb(new_data){
+				document.getElementById("info").innerHTML = new_data;
+				document.getElementById("loading").style.display = 'none';
+				
+				if(clearbc==1)
+					breadcrumb();
+				clearbc = 1;
+			
+			}
+			
+			function updateBox(type,itemid){
+				document.getElementById("loading").style.display = 'block';
+				x_musicLookup(type,itemid,updateBox_cb);
+				
+				if(type == 'genre' || type == 'letter'){
+					bc_parenttype = '';
+					bc_parentitem = '';
+				}
+				else if(type == 'album' || (type == 'artist' && bc_parenttype != '')){
+					if(bc_childtype == 'all'){
+						bc_parenttype = bc_childtype;
+						bc_parentitem = bc_childitem;
+					}
+				}
+				else if(type == 'browse' || type == 'search' || type == 'about' || type == 'prefs' || type == 'random' || type == 'admin' || type == 'playlists' || type == 'stats'){
+
+					bc_parenttype = '';
+					bc_parentitem = '';
+					itemid='';
+					type='';
+				}
+				else{
+					bc_parenttype = bc_childtype;
+					bc_parentitem = bc_childitem;
+				}
+				
+				bc_childitem = itemid;
+				bc_childtype = type;
+				
+			}
+			
+			function deletePlaylist(id){
+				if(confirm("Are you sure you want to DELETE THIS SAVED PLAYLIST?")){
+					x_deletePlaylist(id,deletePlaylist_cb);
+				}
+			}
+			
+			function deletePlaylist_cb(new_data){
+				// reload saved PL page
+				clearbc = 0;
+				x_musicLookup('playlists',0,updateBox_cb);
+				setMsgText("Saved Playlist Successfully Deleted");
+			}
+			
+			function plrem(item){
+				x_playlist_rem(item,plrem_cb);
+			}
+			
+			function plrem_cb(rem){
+				p = document.getElementById("playlist");
+				d_nested = document.getElementById(rem);
+				throwaway_node = p.removeChild(d_nested);
+				x_playlistInfo(plinfo_cb);
+			}
+			
+			function pladd(type,id){
+				x_playlist_add(type,id,pladd_cb);
+			}
+			
+			function pladd_cb(new_data){
+				
+				if(new_data[0] == 1){
+					x_viewPlaylist(viewPlaylist_cb);
+    			x_playlistInfo(plinfo_cb);
+				}
+				else{
+					document.getElementById("playlist").innerHTML += new_data[0];
+					
+					for(var i=2; i<new_data[1]+2; i++){
+						Fat.fade_element(new_data[i],null,1400,'#B4EAA2','#f3f3f3');
+					}
+					x_playlistInfo(plinfo_cb);
+				}
+			}
+			
+			function pl_move(item1,item2){
+				x_playlist_move(item1,item2,pl_move_cb);
+			}
+			
+			function pl_move_cb(){
+					// do nothing
+			}
+			
+			function plclear(){
+				x_clearPlaylist(plinfo_cb);
+				document.getElementById("playlist").innerHTML = "";
+			}
+			
+			function plinfo_cb(new_data){
+				document.getElementById("pl_info").innerHTML = new_data;
+			}
+			
+			function breadcrumb(){
+					x_buildBreadcrumb(page,bc_parenttype,bc_parentitem,bc_childtype,bc_childitem,breadcrumb_cb);
+			}
+			
+			function breadcrumb_cb(new_data){
+				//if(new_data!="")
+					document.getElementById("breadcrumb").innerHTML = new_data;
+			}
+			
+			function play(type,id){
+					document.getElementById('hidden').src = null;
+					document.getElementById("hidden").src = "<?php echo music_dir(); ?>mp3act_hidden.php?type="+type+"&id="+id;
+			}
+			
+			function randAdd(data){
+				var type = data.random_type.value;
+				if(type == ""){
+					setMsgText("You must choose a random type");
+					return false;
+				}
+				var num=0;
+				num = data.random_count.value;
+				var items ='';
+				if(type != 'all'){
+					for(var i=0;i<data.random_items.options.length;i++){
+						if(data.random_items.options[i].selected == true)
+						 items += data.random_items.options[i].value+" ";
+					}
+					
+					if(items == ""){
+					  setMsgText("You must choose at least one random item");
+					  return false;
+					}
+				}
+				x_randAdd(type,num,items,randadd_cb);
+				return false;
+
+			}
+			
+			function randadd_cb(new_data){
+				x_viewPlaylist(viewPlaylist_cb);
+    				x_playlistInfo(plinfo_cb);
+			}
+
+			function play_cb(new_data){
+				//refresh();
+			}
+			
+			function setMsgText(text){
+					document.getElementById("breadcrumb").innerHTML = "<span class='error'>"+text+"</span>";
+					Fat.fade_element('breadcrumb',null,2000,'#F5C2C2','#ffffff');
+			}
+			
+			function searchMusic(form){
+				if(form.searchbox.value == '' || form.searchbox.value == '[<? echo t("enter your search terms"); ?>]'){
+					setMsgText("You Must Enter Something to Search For");
+				}
+				else{
+					document.getElementById("breadcrumb").innerHTML = "";
+					x_searchMusic(form.searchbox.value,form.search_options.value,updateBox_cb);
+				}
+				return false;
+			}
+			

Property changes on: mythweb/modules/music/mp3act_js.js.php
___________________________________________________________________
Name: svn:executable
   + *

Index: mythweb/modules/music/mp3act_functions.php
===================================================================
--- mythweb/modules/music/mp3act_functions.php	(revision 0)
+++ mythweb/modules/music/mp3act_functions.php	(revision 0)
@@ -0,0 +1,916 @@
+<?php
+/**
+ * Common Functions for the MP3Act part of the MythWeb Music module
+ *
+ * @url         $URL: http://svn.mythtv.org/svn/trunk/mythplugins/mythweb/modules/music/mp3act_functions.php $
+ * @date        $Date: 2006-03-23 08:46:57 +0100 (Do, 23 Mär 2006) $
+ * @version     $Revision: 9478 $
+ * @author      $Author: jochen $
+ * @license     GPL
+ *
+ * @package     MythWeb
+ * @subpackage  Music
+ *
+/**/
+/******************************************
+*	mp3act functions
+*	http://www.mp3act.net
+*	Stripped, because not all this funcionality is needed in MythWEB
+*
+******************************************/
+function pic_dir()
+    {
+    return 'http://'.$_SERVER['HTTP_HOST'].skin_url.'img/music/';
+}
+
+function music_dir()
+    {
+    return 'http://'.$_SERVER['HTTP_HOST'].root."music/";
+}
+
+
+function getplaylistnames(){
+    $output='';
+    $query = "SELECT playlist_name,hostname FROM music_saved_playlists;";
+    $result = mysql_query($query);
+    while($row = mysql_fetch_array($result)){
+	if ($row[1] == "")
+	    $output .= "\"<option>".$row["playlist_name"]."</option>\";";
+	else
+    	    $output .= "\"<option>".$row["playlist_name"]."@".$row["hostname"]."</option>\";";
+    }
+    return $output;
+}
+
+function genreform(){
+  $query = "SELECT * FROM music_genres ORDER BY genre";
+  $result = mysql_query($query);
+  
+  $output = "<select id=\"genre\" name=\"genre\" onchange=\"updateBox('genre',this.options[selectedIndex].value); return false;\">
+    <option value=\"\" selected>".t("Choose Genre..");
+  
+  while($genre = mysql_fetch_array($result)){
+    $output .= "  <option value=\"$genre[genre]\">$genre[genre]\n";
+  }
+  $output .= "</select>";
+ 
+  return $output;
+}
+
+function letters(){
+	$output = "<ul class=\"music\" id=\"letters\">";
+	$letters = array('#','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
+	
+	foreach($letters as $letter){
+		$output .= "<li><a class=music href=\"#\" onclick=\"updateBox('letter','$letter'); return false;\">".strtoupper($letter)."</a></li>\n";
+	}
+	$output .= "</ul>";
+	return $output;
+}
+
+function getDropDown($type, $id){
+	$dropdown = "";
+	return $dropdown;
+}
+
+function buildBreadcrumb($page,$parent,$parentitem,$child,$childitem){
+	$childoutput='';
+	$parentoutput ='';
+	if($page == 'browse' && $child != ''){
+		$output = "<a class=music href=\"#\" onclick=\"updateBox('browse',0); return false;\">Browse</a> &#187; ";
+	}
+	switch($child){
+		case 'album':
+			$query = "SELECT music_albums.album_name,music_artists.artist_name,music_artists.artist_id FROM music_albums,music_artists WHERE music_albums.artist_id=music_artists.artist_id AND music_albums.album_id=$childitem";
+			$result = mysql_query($query);
+			$row = mysql_fetch_array($result);
+			$albums = '';
+			$query = "SELECT album_name,album_id FROM music_albums WHERE artist_id=$row[artist_id] ORDER BY album_name";
+			$result = mysql_query($query);
+			while($row2 = mysql_fetch_array($result)){
+				$albums .= "<li><a class=music href=\"#\" onclick=\"updateBox('album',$row2[album_id]); return false;\" title=\"View Details of $row2[album_name]\">$row2[album_name]</a></li>";
+			}
+			$childoutput .= "<span><a class=music href=\"#\" onclick=\"updateBox('artist'," . $row['artist_id'] . "); return false;\">" . $row['artist_name'] . "</a><ul class=\"music\">$albums</ul></span> &#187; " . htmlentities($row['album_name']);
+		break;
+		case 'artist':
+			$query = "SELECT artist_name FROM music_artists WHERE artist_id=$childitem";
+			$result = mysql_query($query);
+			$row = mysql_fetch_array($result);
+			$albums = '';
+			$query = "SELECT music_albums.album_name, music_albums.album_id FROM music_songs INNER JOIN music_albums ON music_songs.album_id = music_albums.album_id GROUP BY music_albums.album_name, music_albums.album_id, music_songs.artist_id HAVING (((music_songs.artist_id)=$childitem));";
+			$result = mysql_query($query);
+			while($row2 = mysql_fetch_array($result)){
+				$albums .= "<li><a class=music href=\"#\" onclick=\"updateBox('album',$row2[album_id]); return false;\" title=\"View Details of $row2[album_name]\">$row2[album_name]</a></li>";
+			}
+			$childoutput .= "<span><a class=music href=\"#\" onclick=\"updateBox('artist',$childitem); return false;\">$row[artist_name]</a><ul class=\"music\">$albums</ul></span>";
+		break;
+		case 'letter':
+			$childoutput .= "<span><a class=music href=\"#\" onclick=\"updateBox('letter','$childitem'); return false;\">".strtoupper($childitem)."</a>".letters()."</span>";
+		break;
+		case 'genre':
+			$childoutput .=  $childitem;
+		break;
+		case 'all':
+			$childoutput .=  $childitem;
+		break;
+	
+	}
+	switch($parent){
+	
+		case 'letter':
+			$parentoutput .= "<span><a class=music href=\"#\" onclick=\"updateBox('letter','$parentitem'); return false;\">".strtoupper($parentitem)."</a>".letters()."</span> &#187; ";
+		break;
+		case 'genre':
+			$query = "SELECT album_name FROM music_albums WHERE album_id=$childitem";
+			$result = mysql_query($query);
+			$row = mysql_fetch_array($result);
+			$parentoutput .= "<a class=music href=\"#\" onclick=\"updateBox('genre','$parentitem'); return false;\">$parentitem</a> &#187; ";
+		break;
+		case 'all':
+			$parentoutput .=  "<a class=music href=\"#\" onclick=\"updateBox('all','$parentitem'); return false;\">$parentitem</a> &#187; ";
+		break;
+	
+	}
+	if (isset($output)) {
+	  return $output.$parentoutput.$childoutput;
+	} else {
+	  return '';
+	}	
+}
+
+function musicLookup($type,$itemid){
+	switch($type){
+	case 'browse':
+    $output = "<div class=\"head\">";
+			$output .= "<h2 class=music>".t("Browse the Music Database")."</h2></div>";
+			$output .= "<p>";
+			$output .= "<strong>".t("By Artist Beginning With")."</strong><br/>".letters()."<br/></p>\n";
+			$output .= "<p><strong>".t("By Genre")."</strong><br/>\n";
+			$output .= genreForm()."<br/><br/>\n";
+			$output .= "<input type='button' value='".t("Browse All Albums")."' onclick=\"updateBox('all','All'); return false;\" class='btn2' />\n";
+    	$output .= "</p>\n";
+
+	break;
+	case 'search':
+    $output = "<div class=\"head\">";
+			$output .= "<h2 class=music>".t("Search the Music Database")."</h2></div>";
+			$output .= "<form onsubmit='return searchMusic(this)' method='get' action=''>\n";
+			$output .= "<p>
+				<strong>".t("Keywords")."</strong><br/>
+				<input type='text' onfocus='this.select()' name='searchbox' size='35' id='searchbox' value='[".t("enter your search terms")."]' />
+    		<br/><br/>
+    		<strong>".t("Narrow Your Search")."</strong>
+    		<br/>
+    		<select name='search_options' size='1'>
+    			<option value='all'>".t("All Fields")."</option>
+    			<option value='artists'>".t("Artists")."</option>
+    			<option value='albums'>".t("Albums")."</option>
+    			<option value='songs'>".t("Songs")."</option>
+    		</select><br/><br/>
+    		<input type='submit' value='".t("submit search")."' class='btn' /></form>";
+				$output .= "</p>\n";
+
+	break;
+	case 'letter':
+	if($itemid == "#"){
+      $query = "SELECT * FROM music_artists 
+                WHERE artist_name 
+                LIKE '0%' 
+                OR artist_name LIKE '1%' 
+                OR artist_name LIKE '2%' 
+                OR artist_name LIKE '3%' 
+                OR artist_name LIKE '4%' 
+                OR artist_name LIKE '5%' 
+                OR artist_name LIKE '6%' 
+                OR artist_name LIKE '7%' 
+                OR artist_name LIKE '8%'
+                OR artist_name LIKE '9%'
+                ORDER BY artist_name";
+    }else{
+    	$query = "SELECT * FROM music_artists
+                WHERE artist_name LIKE '$itemid%'
+                ORDER BY artist_name";
+    }
+    $result = mysql_query($query);
+    $output = "<div class=\"head\">";
+			$output .= "<h2 class=music>".t("Artists Beginning with")." '".strtoupper($itemid)."'</h2></div>";
+			$output .= "<p>
+				<strong>".t("Artist Listing")."</strong></p>
+				<ul class=\"music\">";
+					$count =1;
+    while($row = mysql_fetch_array($result)){
+    ($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt><a class=music href=\"#\" onclick=\"updateBox('artist',$row[artist_id]); return false;\" title=\"View Albums for $row[artist_name]\">$row[artist_name]</a></li>\n";
+			$count++;
+		}
+				$output .= "</ul>\n";
+
+	break;
+	
+	case 'all':
+			$output = "<div class=\"head\">";
+			$output .= "<h2 class=music>".t("All Albums")."</h2></div> ";
+			$output .= "<p>
+				<strong>".t("Album Listing")."</strong></p>
+				<ul class=\"music\">";
+		$start = $itemid;
+		$query  = "SELECT * FROM music_albums";
+		
+		$result = mysql_query($query);
+			$count = 1;
+		while($row = mysql_fetch_array($result)){
+			($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt><a class=music href=\"#\" onclick=\"pladd('album'," . $row['album_id'] . "); return false;\" title=\"".t("Add Album to Current Playlist")."\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('album'," . $row['album_id'] . "); return false;\" title=\"".t("Play this Album Now")."\"><img src=\"".pic_dir()."play.gif\" /></a> <a class=music href=\"#\" onclick=\"updateBox('album'," . $row['album_id'] . "); return false;\" title=\"".t("View Details of")." " . $row['album_name'] . "\">" . $row['album_name'] . "</a></li>\n";
+			
+			$count++;
+		}
+		$output .= "</ul>\n";
+	break;
+	
+	case 'album':
+		$query = "SELECT count(music_songs.length),sum(music_songs.length) FROM music_songs GROUP BY music_songs.album_id HAVING music_songs.album_id = $itemid;";
+		$result = mysql_query($query);
+		$row = mysql_fetch_array($result);
+		$anzahl = $row[0];
+		$length = $row[1];
+
+		$query="SELECT music_songs.*, music_albums.album_name, music_artists.artist_name FROM (music_songs INNER JOIN music_albums ON music_songs.album_id = music_albums.album_id) INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id WHERE music_albums.album_id = $itemid;";
+		$result = mysql_query($query);
+		$row = mysql_fetch_array($result);
+		
+		$path = $_SERVER["DOCUMENT_ROOT"].root."data/music/".substr($row["filename"],0,strrpos($row["filename"],"/"))	;
+		$verzeichnis = @dir($path);
+		while($datei = @$verzeichnis->read()) {
+		    $end = strtolower(substr($datei,-3));
+		    if ($end == "jpg" || $end == "gif" || $end == "png")
+			{$album_art_arr[] = $datei;}
+		}
+		$verzeichnis->close();		  
+
+		srand(microtime()*1000000);
+	        $zuf = rand(1,count($album_art_arr)-1);    
+		$album_art = $album_art_arr[round($zuf)];
+		
+		$album_art = root."data/music/".substr($row["filename"],0,strrpos($row["filename"],"/"))."/".$album_art;
+
+		$output = "<div class=\"head\">";
+		$output .= "<div class=\"right\"><a class=music href=\"#\" onclick=\"play('album',".$row['album_id']."); return false;\" title=\"Play this Album Now\">play</a> <a class=music href=\"#\" onclick=\"pladd('album',$row[album_id]); return false;\" title=\"".t("Add Album to Current Playlist")."\">add</a> "."</div>";
+		$output .= "<h2 class=music>".$row['album_name']."</h2></div>";
+		$output .= "<center><img width=200 src=\"$album_art\" /></center><br />\n";
+		$output .= "	<strong>".t("Play Time").":</strong> $length\n";
+		$output .= "	<br/><br/>\n";
+		$output .= "	<strong>".t("Album Tracks")."</strong></p>\n";
+		$output .= "<ul class=\"music\">\n";
+		$query = "SELECT music_songs.*,SEC_TO_TIME(music_songs.length) as length , music_artists.artist_name FROM music_songs INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id WHERE album_id=$itemid ORDER BY track";
+		$result = mysql_query($query);
+		$count=1;
+		while($row = mysql_fetch_array($result)){
+			($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt ondblclick=\"pladd('song',$row[song_id]); return false;\" ><a class=music href=\"#\" onclick=\"pladd('song',$row[song_id]); return false;\" title=\"Add Song to Current Playlist\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('song',$row[song_id]); return false;\" title=\"Play this Song Now\"><img src=\"".pic_dir()."play.gif\" /></a> $row[track]. $row[artist_name] - $row[name]<p>$row[numplays] Plays<br/><em>$row[length]</em></p></li>\n";
+			$count++;
+		}
+		
+		$output .= "</ul>\n";
+	break;
+	case 'genre':
+		
+			$output = "<div class=\"head\">";
+			$output .= "<h2 class=\"music\">".t("Songs for Genre")." '$itemid'</h2></div>";
+			$output .= "<p>
+				<strong>".t("Songs")."</strong></p>
+				<ul class=\"music\">";
+
+		$query = "SELECT music_songs.*, music_artists.artist_name, music_genres.genre FROM (music_songs INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id) INNER JOIN music_genres ON music_songs.genre_id = music_genres.genre_id WHERE genre='$itemid';";
+
+		$result = mysql_query($query);
+		$count=1;
+		while($row = mysql_fetch_array($result)){
+			($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt ondblclick=\"pladd('song',$row[song_id]); return false;\" ><a class=music href=\"#\" onclick=\"pladd('song',$row[song_id]); return false;\" title=\"Add Song to Current Playlist\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('song',$row[song_id]); return false;\" title=\"Play this Song Now\"><img src=\"".pic_dir()."play.gif\" /></a> $row[artist_name] - $row[name]<p>$row[numplays] Plays<br/><em>$row[length]</em></p></li>\n";
+			$count++;
+		}
+		$output .= "</ul>\n";
+	break;
+	case 'artist':
+		$query = "SELECT artist_id,artist_name FROM music_artists WHERE artist_id=$itemid";
+		$result = mysql_query($query);
+		$row = mysql_fetch_array($result);
+			
+		
+			$artist = $row[artist_name];
+			
+			$output = "<div class=\"head\">";
+			$output .= "<h2 class=\"music\">$row[artist_name] </h2></div>";
+			$output .= "<p>\n";
+			$output .= "<strong>".t("Songs")."</strong></p>\n";
+			$output .= "<ul class=\"music\">\n";
+
+		$query = "SELECT music_songs.*,SEC_TO_TIME(music_songs.length) as length , music_artists.artist_name FROM music_songs INNER JOIN music_artists ON music_songs.artist_id = music_artists.artist_id WHERE music_songs.artist_id=$itemid;";
+		$result = mysql_query($query);
+		$count=1;
+		while($row = mysql_fetch_array($result)){
+			($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt ondblclick=\"pladd('song',$row[song_id]); return false;\" ><a class=music href=\"#\" onclick=\"pladd('song',$row[song_id]); return false;\" title=\"Add Song to Current Playlist\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('song',$row[song_id]); return false;\" title=\"Play this Song Now\"><img src=\"".pic_dir()."play.gif\" /></a> $row[name]<p>$row[numplays] Plays<br/><em>$row[length]</em></p></li>\n";
+			$count++;
+		}
+		$output .= "</ul><br />\n";
+
+			$output .= "<p>\n";
+			$output .= "<strong>".t("Album's with songs from")." <i>$artist</i></strong></p>\n";
+			$output .= "<ul class=\"music\">\n";
+
+		$query = "SELECT music_albums.album_name, music_albums.album_id FROM music_songs INNER JOIN music_albums ON music_songs.album_id = music_albums.album_id GROUP BY music_albums.album_name, music_albums.album_id, music_songs.artist_id HAVING (((music_songs.artist_id)=$itemid));";
+		$result = mysql_query($query);
+		$count=1;
+		while($row = mysql_fetch_array($result)){
+			($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt><a class=music href=\"#\" onclick=\"pladd('album'," . $row['album_id'] . "); return false;\" title=\"Add Album to Current Playlist\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('album'," . $row['album_id'] . "); return false;\" title=\"Play this Album Now\"><img src=\"".pic_dir()."play.gif\" /></a> <a class=music href=\"#\" onclick=\"updateBox('album'," . $row['album_id'] . "); return false;\" title=\"View Details of " . $row['album_name'] . "\">" . $row['album_name'] . " " . (($row['album_year'] != 0) ? ("<em>(" . $row['album_year'] . ")</em>") : (""))."</a></li>\n";
+			$count++;
+		}
+		$output .= "</ul>\n";
+	break;
+	case 'random':
+			$output = "<div class=\"head\">";
+			$output .= "<h2 class=\"music\">".t("Random Mix Maker")."</h2></div>";
+			$output .= "<form onsubmit='return randAdd(this)' method='get' action=''>\n<p>";
+				$output .= "<strong>".t("Number of Songs")."</strong><br/>\n
+				<select name='random_count'>
+				<option value=10>10 </option>
+				<option value=20>20 </option>
+				<option value=30>30 </option>
+				<option value=40>40 </option>
+				<option value=50>50 </option>
+         </select><br/>\n";
+			$output .= "<strong>".t("Random Type")."</strong><br/>\n
+				<select name='random_type' onchange=\"getRandItems(this.options[selectedIndex].value); return false;\" >
+				<option value='' >".t("Choose Type")."...</option>
+				<option value='artists' >".t("Artists")."</option>
+				<option value='genre' >".t("Genre")."</option>
+				<option value='albums' >".t("Albums")."</option>
+				<option value='all' >".t("Everything")."</option>
+         </select><br/>\n";
+			$output .= "<strong>".t("Random Items")."</strong>\n<span id='rand_items'></span>
+			<br/><br/>";
+			$output .= "<input type='submit' value='".t("add mix")."' class='btn' />";
+			$output .= "</form></p>\n";
+	break;
+	case 'playlists':
+			$query = "SELECT *,SEC_TO_TIME(time) AS time2 FROM music_saved_playlists";
+			$result = mysql_query($query);
+			
+			$output = "<div class=\"head\">";
+			$output .= "<h2 class=\"music\">".t("Saved Playlists")."</h2></div><br />";
+			$output .= "<ul class=\"music\">\n";
+			if(mysql_num_rows($result) == 0)
+				$output .= t("No Public Playlists");
+			while ($row = mysql_fetch_array($result)){
+				if ($row["hostname"] == "")
+    				    $output .= "<li><a class=music href=\"#\" onclick=\"pladd('playlist',$row[playlist_id]); return false;\" title='Load this Saved Playlist'><img src=\"".pic_dir()."add.gif\" /></a> "."<a class=music href=\"#\" onclick=\"deletePlaylist($row[playlist_id]); return false;\" title='DELETE this Saved Playlist'><img src=\"".pic_dir()."rem.gif\" /></a>"." <a onclick=\"updateBox('saved_pl',$row[playlist_id]); \" title='Click to View Playlist' href='#'>$row[playlist_name] - $row[songcount] ".t("Songs")." ($row[time2])</a></li>";
+				else
+				    $output .= "<li><a class=music href=\"#\" onclick=\"pladd('playlist',$row[playlist_id]); return false;\" title='Load this Saved Playlist'><img src=\"".pic_dir()."add.gif\" /></a> "."<a class=music href=\"#\" onclick=\"deletePlaylist($row[playlist_id]); return false;\" title='DELETE this Saved Playlist'><img src=\"".pic_dir()."rem.gif\" /></a>"." <a onclick=\"updateBox('saved_pl',$row[playlist_id]); \" title='Click to View Playlist' href='#'>$row[playlist_name] @ $row[hostname] - $row[songcount] ".t("Songs")." ($row[time2])</a></li>";
+			}
+			$output .= "</ul>\n";
+	break;
+	case 'saved_pl':
+			$query = "SELECT *,SEC_TO_TIME(time) AS time2 FROM music_saved_playlists WHERE playlist_id=$itemid";
+			$result = mysql_query($query);
+			$row = mysql_fetch_array($result);
+			$output = "<div class=\"head\">";
+			$output .= "<div class=\"right\"><a class=music href=\"#\" onclick=\"pladd('playlist',$row[playlist_id]); return false;\" title=\"Load Playlist\">load playlist</a></div>";
+
+			$output .= "<h2 class=\"music\">".t("View Saved Playlist")."</h2></div>";
+			$output .= "<p><strong>".t("Playlist Info")."</strong><br/>$row[songcount] ".t("Songs")."<br/>$row[time2]</p>\n";
+			$output .= "<p><strong>".t("Playlist Songs")."</strong></p>\n";
+			$output .= "<ul class=\"music\">\n";
+			$songs = explode(",",$row['playlist_songs']);
+			
+			if (strlen($row['playlist_songs']) != 0)
+			{
+		$count = 0;
+		foreach($songs as $song){
+			$query = "SELECT music_songs.*,SEC_TO_TIME(music_songs.length) AS length,music_artists.artist_name FROM music_artists,music_songs WHERE music_songs.song_id=$song AND music_artists.artist_id=music_songs.artist_id";
+			$result = mysql_query($query);
+			$row = mysql_fetch_array($result);
+	($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt ondblclick=\"pladd('song',$row[song_id]); return false;\" ><a class=music href=\"#\" onclick=\"pladd('song',$row[song_id]); return false;\" title=\"".t("Add Song to Current Playlist")."\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('song',$row[song_id]); return false;\" title=\"".t("Play this Song Now")."\"><img src=\"".pic_dir()."play.gif\" /></a> $row[artist_name] - $row[name]<p>$row[numplays] ".t("Plays")."<br/><em>$row[length]</em></p></li>\n";
+			$count++;
+		}
+			}
+			else
+			$output = " <b>".t("There are no songs in this Playlist!")."</b>";
+			$output .= "</ul>\n";
+			
+	break;
+	case 'stats':
+		$query = "SELECT * FROM music_stats";
+			$result = mysql_query($query);
+			$row = mysql_fetch_array($result);
+			$query = "SELECT COUNT(play_id) AS songs FROM music_playhistory";
+			$result = mysql_query($query);
+			$row3 = mysql_fetch_array($result);
+			
+			$output = "<div class=\"head\">";
+			$output .= "<h2 class=\"music\">".t("Server Statistics")."</h2></div>";
+			$output .= "<p>\n";
+			$output .= "<a class=music href='#' onclick=\"updateBox('recentadd',0); return false;\" >".t("Recently Added Albums")."</a><br/>";
+			$output .= "<a class=music href='#' onclick=\"updateBox('recentplay',0); return false;\" >".t("Recently Played Songs")."</a><br/>";
+			$output .= "<a class=music href='#' onclick=\"updateBox('topplay',0); return false;\" >".t("Top Played Songs")."</a><br/>";
+
+
+			$output .= "</p>\n";
+				$output .= "<h3>".t("Local Server Statistics")."</h3>\n";
+			  $result = mysql_query("SELECT song_id from music_songs;");	
+			$output .= "<p><strong>".t("Songs").":</strong> ". mysql_num_rows($result)."<br/>\n";
+			  $result = mysql_query("SELECT album_id from music_albums;");	
+			$output .= "<strong>".t("Albums").":</strong> ". mysql_num_rows($result)."<br/>\n";
+			  $result = mysql_query("SELECT artist_id from music_artists;");	
+			$output .= "<strong>".t("Artists").":</strong> ". mysql_num_rows($result)."<br/>\n";
+			  $result = mysql_query("SELECT genre_id from music_genres;");	
+			$output .= "<strong>".t("Genres").":</strong> ". mysql_num_rows($result)."<br/><br/>\n";
+			$output .= "<strong>".t("Songs Played").":</strong> $row3[songs]<br/></p>\n";
+
+	break;
+	case 'recentadd':			
+			$query = "SELECT music_albums.album_name,music_albums.album_id,
+			music_artists.artist_name, 
+			DATE_FORMAT(music_songs.date_entered,'%m.%d.%Y') as pubdate   
+			FROM music_songs,music_albums,music_artists 
+			WHERE music_songs.album_id=music_albums.album_id 
+			AND music_artists.artist_id=music_songs.artist_id 
+			GROUP BY music_songs.album_id ORDER BY music_songs.date_entered DESC LIMIT 40";
+			$result = mysql_query($query);
+			
+			$output = "<div class=\"head\">";
+			$output .= "<div class=\"right\"><a class=music href=\"#\" onclick=\"switchPage('stats'); return false;\" title=\"Return to Statistics Page\">back</a></div>";
+			$output .= "<h2 class=\"music\">".t("Recently Added Albums")."</h2></div><ul class=\"music\">";
+			$count=1;
+		while($row = mysql_fetch_array($result)){
+			($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt><small>$row[pubdate]</small> <a class=music href=\"#\" onclick=\"pladd('album',$row[album_id]); return false;\" title=\"Add Album to Current Playlist\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('album',$row[album_id]); return false;\" title=\"Play this Album Now\"><img src=\"".pic_dir()."play.gif\" /></a> <a class=music href=\"#\" onclick=\"updateBox('album',$row[album_id]); return false;\" title=\"View Details of $row[album_name]\"><em>$row[artist_name]</em> - $row[album_name]</a></li>";		
+			$count++;
+		}
+		$output .= "</ul>";
+			
+
+	break;
+	case 'topplay':			
+			$query = "SELECT music_albums.album_name, music_songs.numplays, music_songs.name, 
+			music_artists.artist_name,music_songs.song_id 
+			FROM music_songs,music_albums,music_artists 
+			WHERE music_songs.album_id=music_albums.album_id 
+			AND music_artists.artist_id=music_songs.artist_id 
+			AND music_songs.numplays > 0 
+			ORDER BY music_songs.numplays DESC LIMIT 40";
+			$result = mysql_query($query);
+			
+			$output = "<div class=\"head\">";
+			$output .= "<div class=\"right\"><a class=music href=\"#\" onclick=\"switchPage('stats'); return false;\" title=\"".t("Return to Statistics Page")."\">".t("back")."</a></div>";
+			$output .= "<h2 class=\"music\">".t("Top Played Songs")."</h2></div><ul class=\"music\">";
+			$count=1;
+		while($row = mysql_fetch_array($result)){
+			($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt><small>$row[numplays] ".t("Plays")."</small> <a class=music href=\"#\" onclick=\"pladd('song',$row[song_id]); return false;\" title=\"Add Song to Current Playlist\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('song',$row[song_id]); return false;\" title=\"Play this Song Now\"><img src=\"".pic_dir()."play.gif\" /></a> <em>$row[artist_name]</em> - $row[name]</li>";		
+			$count++;
+		}
+		$output .= "</ul>";
+	break;
+	case 'recentplay':			
+			$query = "SELECT music_songs.name, music_songs.song_id, 
+			music_artists.artist_name,
+			DATE_FORMAT(music_playhistory.date_played,'%m.%d.%Y') as playdate 
+			FROM music_songs,music_artists,music_playhistory 
+			WHERE music_songs.song_id=music_playhistory.song_id
+			AND music_artists.artist_id=music_songs.artist_id 
+			ORDER BY music_playhistory.play_id DESC LIMIT 40";
+			$result = mysql_query($query);
+			
+			$output = "<div class=\"head\">";
+			$output .= "<div class=\"right\"><a class=music href=\"#\" onclick=\"switchPage('stats'); return false;\" title=\"Return to Statistics Page\">back</a></div>";
+			$output .= "<h2 class=\"music\">Recently Played Songs</h2></div><ul class=\"music\">";
+			$count=1;
+		while($row = mysql_fetch_array($result)){
+			($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+			$output .= "<li $alt><small>$row[playdate]</small> <a class=music href=\"#\" onclick=\"pladd('song',$row[song_id]); return false;\" title=\"Add Song to Current Playlist\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('song',$row[song_id]); return false;\" title=\"Play this Song Now\"><img src=\"".pic_dir()."play.gif\" /></a> <em>$row[artist_name]</em> - $row[name]</li>";		
+			$count++;
+		}
+		$output .= "</ul>";
+			
+
+	break;
+	}
+	
+	return $output;
+		
+}
+
+function getRandItems($type){
+	$options = '';
+	switch($type){
+		case 'artists':
+			$query = "SELECT * FROM music_artists ORDER BY artist_name";
+			$result = mysql_query($query);
+			while($row = mysql_fetch_array($result)){
+				$options .= "<option value=$row[artist_id]>$row[artist_name]</option>\n";
+			}
+		break;
+		case 'genre':
+			$query = "SELECT genre_id,genre FROM music_genres ORDER BY genre";
+			$result = mysql_query($query);
+			while($row = mysql_fetch_array($result)){
+				$options .= "<option value=$row[genre_id]>$row[genre]</option>\n";
+			}
+		break;
+		case 'albums':
+			$query = "SELECT music_albums.album_id,music_albums.album_name FROM music_albums ORDER BY album_name";
+			$result = mysql_query($query);
+			while($row = mysql_fetch_array($result)){
+				$options .= "<option value=$row[album_id]>$row[album_name]</option>\n";
+			}
+		break;
+		case 'all':
+			return "<br/>".t("All Songs");
+		break;
+	}
+	
+	return "<select name='random_items' multiple size='12' style='width: 90%;'>$options</select>";
+}
+
+function searchMusic($terms,$option){
+	$query="SELECT music_songs.song_id, music_albums.album_name,music_songs.track,music_artists.artist_name,music_songs.name,SEC_TO_TIME(music_songs.length) as length 
+						FROM music_songs,music_artists,music_albums WHERE music_songs.artist_id=music_artists.artist_id AND music_albums.album_id=music_songs.album_id AND ";
+	if($option == 'all')
+		$query .= "(music_songs.name LIKE '%$terms%' OR music_artists.artist_name LIKE '%$terms%' OR music_albums.album_name LIKE '%$terms%')";
+	elseif($option == 'artists')
+		$query .= "(music_artists.artist_name LIKE '%$terms%')";
+	elseif($option == 'albums')
+		$query .= "(music_albums.album_name LIKE '%$terms%')";
+	elseif($option == 'songs')
+		$query .= "(music_songs.name LIKE '%$terms%')";
+
+	$query .= " ORDER BY music_artists.artist_name,music_albums.album_name,music_songs.track";
+	
+	$result = mysql_query($query);
+	$count = mysql_num_rows($result);
+
+			$output = "<div class=\"head\">";
+			$output .= "<div class=\"right\"><a class=music href=\"#\" onclick=\"switchPage('search'); return false;\" title=\"Begin a New Search\">new search</a></div>";
+			$output .= "<h2 class=\"music\">".t("Found")." $count ".t("Results for")." '$terms'</h2></div>";	
+			$output .= "<ul class=\"music\">\n";
+		if($count>0){
+			$count=1;
+			while($row = mysql_fetch_array($result)){
+				($count%2 == 0 ? $alt = "class=\"alt\"" : $alt = '');
+				$output .= "<li $alt><a class=music href=\"#\" onclick=\"pladd('song',$row[song_id]); return false;\" title=\"Add Song to Current Playlist\"><img src=\"".pic_dir()."add.gif\" /></a> <a class=music href=\"#\" onclick=\"play('song',$row[song_id]); return false;\" title=\"Play this Song Now\"><img src=\"".pic_dir()."play.gif\" /></a> $row[artist_name] - $row[name]<p>Album: $row[album_name]<br/>Track: $row[track]<br/><em>$row[length]</em></p></li>\n";
+				$count++;
+			}
+		}
+		$output .= "</ul>\n";
+		return $output;
+}
+
+function viewPlaylist(){
+	$output = '';
+	$query = "SELECT music_playlist.*, music_artists.artist_name, music_songs.name,music_albums.album_name,music_songs.track,SEC_TO_TIME(music_songs.length) AS time FROM music_playlist,music_artists,music_songs,music_albums WHERE music_playlist.song_id=music_songs.song_id AND music_artists.artist_id=music_songs.artist_id AND music_songs.album_id=music_albums.album_id ORDER BY music_playlist.pl_id";
+	
+	$result=mysql_query($query);
+	
+	while($row = mysql_fetch_array($result)){
+			$output .= "<li id=\"pl$row[pl_id]\" onmouseover=\"setBgcolor('pl".$row['pl_id']."','#FCF7A5'); return false;\" onmouseout=\"setBgcolor('pl".$row['pl_id']."','#f3f3f3'); return false;\"><a class=music href=\"#\" onclick=\"movePLItem('up',this.parentNode); return false;\" title=\"Move Song Up in Playlist\"><img src=\"".pic_dir()."up.gif\" /></a> <a class=music href=\"#\" onclick=\"movePLItem('down',this.parentNode); return false;\" title=\"Move Song Down in Playlist\"><img src=\"".pic_dir()."down.gif\" /></a> <a class=music href=\"#\" onclick=\"plrem(this.parentNode.id); return false;\" title=\"Remove Song from Playlist\"><img src=\"".pic_dir()."rem.gif\" /></a> $row[artist_name] - $row[name]<p>Album: $row[album_name]<br/>Track: $row[track]<br/>$row[time]</p></li>";
+		}
+	if (isset($output)) {
+		return $output;
+	} else {
+	  return '';
+	}
+}
+function savePlaylist($pl_name, $newpl){
+
+	$songs = array();
+	$time=0;
+	$query = "SELECT music_playlist.song_id,music_songs.length FROM music_playlist,music_songs WHERE music_songs.song_id=music_playlist.song_id ORDER BY music_playlist.pl_id";
+	$result = mysql_query($query);
+	while($row = mysql_fetch_array($result)){
+		$songs[] = $row['song_id'];
+		$time += $row['length'];
+	}
+	$songslist = implode(",",$songs);
+	if ($newpl == 0)
+	    {
+    	    $query = "INSERT INTO music_saved_playlists (playlist_name, playlist_songs, date_created, time, songcount) VALUES (\"$pl_name\",\"$songslist\",NOW(),$time,".count($songs).")";
+	    mysql_query($query);
+	    return "<h2 class=\"music\">Playlist Saved as '".$pl_name."'</h2>";
+	    }
+	else
+	    {
+	    $arr = explode("@",$pl_name);
+	    	    $query = "UPDATE music_saved_playlists SET playlist_songs = \"$songslist\", date_created = NOW(), time = $time, songcount = ".count($songs)." WHERE playlist_name = \"".$arr[0]."\" AND hostname = \"".$arr[1]."\"";									
+	    mysql_query($query);
+	    return "<h2 class=\"music\">Playlist '".$pl_name."' has been updated</h2>";
+	    }
+
+}
+
+function clearPlaylist(){
+	$query = "DELETE FROM music_playlist";
+	mysql_query($query);
+	return "Playlist is empty";
+}
+function deletePlaylist($id){
+	$query = "DELETE FROM music_saved_playlists WHERE playlist_id=$id";
+	mysql_query($query);
+	return 1;
+}
+
+function playlistInfo(){
+	$query = "SELECT COUNT(music_playlist.pl_id) as count, SEC_TO_TIME(SUM(music_songs.length)) as time FROM music_playlist,music_songs WHERE music_playlist.song_id=music_songs.song_id";
+	$result = mysql_query($query);
+	$row = mysql_fetch_array($result);
+	if($row['count'] == 0){
+		return "Playlist is empty";
+	}
+	return "$row[count] Songs - $row[time]";
+}
+
+function playlist_rem($itemid){
+	$id = substr($itemid, 2);
+	$query = "DELETE FROM music_playlist WHERE pl_id=$id";
+	mysql_query($query);
+	return $itemid;
+}
+
+function playlist_move($item1,$item2){
+	$item1 = substr($item1, 2);
+	$item2 = substr($item2, 2);
+	$row = array();
+	$query = "SELECT pl_id,song_id FROM music_playlist WHERE pl_id=$item1 OR pl_id=$item2";
+	$result = mysql_query($query);
+	while($row[] = mysql_fetch_array($result)){
+		
+	}
+	$query = "UPDATE music_playlist SET song_id=" . $row[0]['song_id'] . " WHERE pl_id=" . $row[1]['pl_id'];
+		mysql_query($query);
+		$query = "UPDATE music_playlist SET song_id=" . $row[1]['song_id'] . " WHERE pl_id=" . $row[0]['pl_id'];
+
+	mysql_query($query);
+}
+
+function playlist_add($type,$itemid){
+	
+	switch($type){
+	case 'song':
+		$query = "INSERT INTO music_playlist (song_id) VALUES (N$itemid)";
+		mysql_query($query);
+		$id = mysql_insert_id();
+		$query = "SELECT music_artists.artist_name, music_albums.album_name,SEC_TO_TIME(music_songs.length) AS length,music_songs.name,music_songs.track FROM music_artists,music_songs,music_albums WHERE music_songs.song_id=$itemid AND music_artists.artist_id=music_songs.artist_id AND music_albums.album_id=music_songs.album_id";
+		$result = mysql_query($query);
+		$row = mysql_fetch_array($result);
+		
+		$output[] = "<li id=\"pl$id\" onmouseover=\"setBgcolor('pl".$id."','#FCF7A5'); return false;\" onmouseout=\"setBgcolor('pl".$id."','#f3f3f3'); return false;\"><a class=music href=\"#\" onclick=\"movePLItem('up',this.parentNode); return false;\" title=\"Move Song Up in Playlist\"><img src=\"".pic_dir()."up.gif\" /></a> <a class=music href=\"#\" onclick=\"movePLItem('down',this.parentNode); return false;\" title=\"Move Song Down in Playlist\"><img src=\"".pic_dir()."down.gif\" /></a> <a class=music href=\"#\" onclick=\"plrem(this.parentNode.id); return false;\" title=\"Remove Song from Playlist\"><img src=\"".pic_dir()."rem.gif\" /></a> $row[artist_name] - $row[name]<p>Album: $row[album_name]<br/>Track: $row[track]<br/>$row[length]</p></li>";
+		$output[] = 1;
+		$output[] = 'pl'.$id;
+		return $output;
+	break;
+	case 'album':
+		$items='';
+		$output = array();
+		$query = "SELECT music_songs.song_id,music_songs.name,music_artists.artist_name,music_albums.album_name,SEC_TO_TIME(music_songs.length) AS length,music_songs.name,music_songs.track FROM music_songs,music_artists,music_albums WHERE music_songs.album_id=$itemid AND music_songs.artist_id=music_artists.artist_id AND music_albums.album_id=music_songs.album_id ORDER BY track";
+		$result = mysql_query($query);
+		while($row = mysql_fetch_array($result)){
+		  $query = "INSERT INTO music_playlist (song_id) VALUES(" . $row['song_id'] . ")";
+			mysql_query($query);
+			$id = mysql_insert_id();
+			$output[] = 'pl'.$id;
+			$items .= "<li id=\"pl$id\" onmouseover=\"setBgcolor('pl".$id."','#FCF7A5'); return false;\" onmouseout=\"setBgcolor('pl".$id."','#f3f3f3'); return false;\"><a class=music href=\"#\" onclick=\"movePLItem('up',this.parentNode); return false;\" title=\"Move Song Up in Playlist\"><img src=\"".pic_dir()."up.gif\" /></a> <a class=music href=\"#\" onclick=\"movePLItem('down',this.parentNode); return false;\" title=\"Move Song Down in Playlist\"><img src=\"".pic_dir()."down.gif\" /></a> <a class=music href=\"#\" onclick=\"plrem(this.parentNode.id); return false;\" title=\"Remove Song from Playlist\"><img src=\"".pic_dir()."rem.gif\" /></a> $row[artist_name] - $row[name]<p>Album: $row[album_name]<br/>Track: $row[track]<br/>$row[length]</p></li>";
+		}
+		$text[] = $items;
+		$num[] = count($output);
+		$text = array_merge($text,$num);
+		$output = array_merge($text,$output);
+		return $output;
+
+	break;
+	case 'playlist':
+		clearPlaylist();
+		$query = "SELECT * FROM music_saved_playlists WHERE playlist_id=$itemid LIMIT 1";
+		$result = mysql_query($query);
+		$row = mysql_fetch_array($result);
+		$songs = explode(",",$row['playlist_songs']);
+		
+		foreach($songs as $song){
+			$query = "INSERT INTO music_playlist (song_id) VALUES($song)";
+			mysql_query($query);
+		}
+		$output[0] = 1;
+		return $output;
+
+	break;
+	}
+}
+
+function randAdd($type,$num=0,$items){
+		$tmp = '';
+		$query = '';
+		$items2 = explode(" ",trim($items));
+		$items = '';
+		$output = '';
+		
+		switch($type){
+			case 'artists':
+				foreach($items2 as $item){
+					$items .= " artist_id=$item OR";
+				}				
+				$items = preg_replace("/OR$/","",$items);
+				$query = "SELECT music_songs.song_id FROM music_songs WHERE (".$items.") ORDER BY rand()+0 LIMIT $num";
+				$result = mysql_query($query);
+    				while($row = @mysql_fetch_array($result)){
+				    $query = "INSERT into music_playlist (song_id) values($row[song_id])";
+				    mysql_query($query);
+				}
+				$output[0] = 1;
+			break;
+			case 'genre':
+				foreach($items2 as $item){
+					$items .= " genre_id=$item OR";
+				}				
+				$items = preg_replace("/OR$/","",$items);
+				$query = "SELECT music_songs.song_id FROM music_songs WHERE (".$items.") ORDER BY rand()+0 LIMIT $num";
+				$result = mysql_query($query);
+    				while($row = @mysql_fetch_array($result)){
+				    $query = "INSERT into music_playlist (song_id) values($row[song_id])";
+				    mysql_query($query);
+				}
+				$output[0] = 1;
+			break;
+			case 'albums':
+				foreach($items2 as $item){
+					$items .= " album_id=$item OR";
+				}				
+				$items = preg_replace("/OR$/","",$items);
+				$query = "SELECT music_songs.song_id FROM music_songs WHERE (".$items.") ORDER BY rand()+0 LIMIT $num";
+				$result = mysql_query($query);
+    				while($row = @mysql_fetch_array($result)){
+				    $query = "INSERT into music_playlist (song_id) values($row[song_id])";
+				    mysql_query($query);
+				}
+				$output[0] = 1;
+			break;
+			case 'all':
+				$query = "SELECT music_songs.song_id FROM music_songs ORDER BY rand()+0 LIMIT $num"; 
+				$result = mysql_query($query);
+    				while($row = @mysql_fetch_array($result)){
+				    $query = "INSERT into music_playlist (song_id) values($row[song_id])";
+				    mysql_query($query);
+				}
+				$output[0] = 1;
+			break;
+		}
+			
+		return $output;   
+}
+
+function play($type,$id){
+    $tmp = '';
+    $query = '';
+	
+    session_cache_limiter('nocache');
+    header("Content-Type: audio/mpegurl;");
+    header("Content-Disposition: inline; filename=\"playlist.m3u\"");
+    header("Expires: 0");
+    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+    header("Pragma: nocache"); 
+    $tmp .= "#EXTM3U\n";
+		
+    if($type=='song'){		
+	$query = "SELECT music_songs.song_id,music_artists.artist_name,music_songs.name,music_songs.length FROM music_songs,music_artists WHERE music_songs.song_id=$id AND music_artists.artist_id=music_songs.artist_id"; 
+    }
+    elseif($type=='album'){
+	$query = "SELECT music_songs.song_id,music_artists.artist_name,music_songs.name,music_songs.length FROM music_songs,music_artists WHERE music_artists.artist_id=music_songs.artist_id AND music_songs.album_id=$id ORDER BY music_songs.track"; 
+    }
+    elseif($type=='pl'){
+	$query = "SELECT music_songs.song_id,music_artists.artist_name,music_songs.name,music_songs.length FROM music_songs,music_artists,music_playlist WHERE music_artists.artist_id=music_songs.artist_id AND music_songs.song_id=music_playlist.song_id ORDER BY music_playlist.pl_id"; 			
+    }	
+    
+    $result = mysql_query($query);
+    while($row = mysql_fetch_array($result)){
+	$length = $row['length'];
+	/*if($GLOBALS[sample_mode] == 1){
+	    $length = floor($row['length']/4);
+	}*/
+	$tmp .= "#EXTINF:$length,$row[artist_name] - $row[name]\n";
+	$tmp .= music_dir()."mp3act_playstream.php?i=$row[song_id]\n";
+	}			
+    return $tmp;   
+    exit;
+}
+
+/*
+function download($album){
+	$query = "SELECT music_songs.filename,
+	music_artists.artist_name,
+	music_albums.album_name 
+	FROM music_songs,music_artists,music_albums 
+	WHERE music_songs.album_id=$album 
+	AND music_songs.album_id=music_albums.album_id 
+	AND music_songs.artist_id=music_artists.artist_id LIMIT 1";
+	
+	$result = mysql_query($query);
+	$row = mysql_fetch_array($result);
+	$dir = dirname($row['filename']);
+	
+	$test = new zip_file("/tmp/album_$album.zip");
+	$test->set_options(array('inmemory'=>0,'storepaths'=>0,'level'=>0,'method'=>0,'prepend'=>"$row[artist_name] - $row[album_name]"));
+	$test->add_files($dir);
+	
+	$test->store_files($dir);
+	$test->create_archive();
+	
+	header("Content-type:application/zip");
+
+	$header = "Content-disposition: attachment; filename=\"";
+	$header .= "album_$album.zip";
+	$header .= "\"";
+	header($header);
+	header("Content-length: " . filesize("/tmp/album_$album.zip"));
+	header("Content-transfer-encoding: binary");
+	header("Pragma: no-cache");
+	header("Expires: 0");
+	$chunksize = 1*(1024*1024); // how many bytes per chunk
+  $buffer = '';
+  $handle = fopen("/tmp/album_$album.zip", 'rb');
+  if ($handle === false) {
+   return false;
+  }
+  while (!feof($handle)) {
+   $buffer = fread($handle, $chunksize);
+   print $buffer;
+  }
+  fclose($handle);
+  //readfile("/tmp/album_$album.zip");
+	unlink("/tmp/album_$album.zip");
+	//$test->download_file();
+}*/
+
+function updateNumPlays($num){
+	$query = "UPDATE music_songs SET numplays=numplays+1";
+	$query .= " WHERE song_id=$num";
+        mysql_query($query);
+  
+  	$query = "INSERT INTO music_playhistory VALUES (NULL,$num,NOW())";
+  	mysql_query($query);
+}
+
+function streamPlay($id){
+  $query = "SELECT music_artists.artist_name, 
+  music_songs.name,
+  music_songs.bitrate, 
+  music_songs.length as length, 
+  music_songs.filename as filename, 
+  music_songs.size as size 
+  FROM music_songs,music_artists 
+  WHERE music_songs.song_id=$id 
+  AND music_artists.artist_id=music_songs.artist_id";
+  
+  $result=mysql_query($query);
+  $row = mysql_fetch_array($result);
+	updateNumPlays($id);
+	clearstatcache(); // flush buffer
+  
+	$file['name'] = basename($row['filename']);
+	$mp3out = stripslashes($row['filename']);
+	
+	$size=$row['size'];
+
+	header("Content-Type: audio/mpeg");
+	header("Content-Length: $size");
+	header("Content-Disposition: filename=$row[artist_name] - $row[name]");
+	$bitrate = $row[$bitrate] / 1000;
+	// Run the command, and read back the results at the bitrate size + 1K.
+	$blocksize=($bitrate*1024)+1024;
+	$totaldata=0;
+	/*if($rate!=0 && $mode==1){
+		$temp = @popen($mp3out, "r");
+		while (($data = @fread($temp, $blocksize )) && ($totaldata <= $size ) )
+			{echo $data; $totaldata+=$blocksize; }
+		pclose($temp);
+	}
+	elseif($rate!=0 ){
+		$temp = @popen($mp3out, "r");
+		while ($data = @fread($temp, $blocksize) )
+			{echo $data; }
+		pclose($temp);
+	}
+	elseif($mode==1 ){*/
+		$temp = fopen($mp3out, "r");
+		while (!feof($temp)  && ($totaldata <= $size ) )
+			{$data = @fread($temp, $blocksize); echo $data; $totaldata+=$blocksize; }
+		fclose($temp);
+	/*}
+	else{
+		$temp = @fopen($mp3out, "r");
+		while (!feof($temp) )
+			{$data = @fread($temp, $blocksize); echo $data; }
+		fclose($temp);
+	//}*/
+	exit;
+}
+?>
\ No newline at end of file

Property changes on: mythweb/modules/music/mp3act_functions.php
___________________________________________________________________
Name: svn:executable
   + *

Index: mythweb/modules/music/mp3act_hidden.php
===================================================================
--- mythweb/modules/music/mp3act_hidden.php	(revision 0)
+++ mythweb/modules/music/mp3act_hidden.php	(revision 0)
@@ -0,0 +1,8 @@
+<?php
+// hidden iframe to process streaming
+include("mp3act_functions.php");
+
+// Play the Music
+if ($_GET['id'] != '')
+    echo play($_GET['type'],$_GET['id']);
+?>

Property changes on: mythweb/modules/music/mp3act_hidden.php
___________________________________________________________________
Name: svn:executable
   + *

Index: mythweb/modules/music/init.php
===================================================================
--- mythweb/modules/music/init.php	(revision 9730)
+++ mythweb/modules/music/init.php	(working copy)
@@ -16,7 +16,7 @@
 // First, we should check to see that MythMusic is configured.
 // Make sure to turn off fatal errors in case the table isn't there.
     $db->disable_fatal_errors();
-    $has_music = $db->query_col('SELECT COUNT(*) FROM musicmetadata');
+    $has_music = $db->query_col('SELECT COUNT(*) FROM music_songs');
     $db->enable_fatal_errors();
     $db->error(false);
 
Index: mythweb/modules/music/mp3act_fat.js
===================================================================
--- mythweb/modules/music/mp3act_fat.js	(revision 0)
+++ mythweb/modules/music/mp3act_fat.js	(revision 0)
@@ -0,0 +1,81 @@
+var Fat = {
+	make_hex : function (r,g,b) 
+	{
+		r = r.toString(16); if (r.length == 1) r = '0' + r;
+		g = g.toString(16); if (g.length == 1) g = '0' + g;
+		b = b.toString(16); if (b.length == 1) b = '0' + b;
+		return "#" + r + g + b;
+	},
+	fade_all : function ()
+	{
+		var a = document.getElementsByTagName("*");
+		for (var i = 0; i < a.length; i++) 
+		{
+			var o = a[i];
+			var r = /fade-?(\w{3,6})?/.exec(o.className);
+			if (r)
+			{
+				if (!r[1]) r[1] = "";
+				if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]);
+			}
+		}
+	},
+	fade_element : function (id, fps, duration, from, to) 
+	{
+		if (!fps) fps = 30;
+		if (!duration) duration = 3000;
+		if (!from || from=="#") from = "#FFFF33";
+		if (!to) to = this.get_bgcolor(id);
+		
+		var frames = Math.round(fps * (duration / 1000));
+		var interval = duration / frames;
+		var delay = interval;
+		var frame = 0;
+		
+		if (from.length < 7) from += from.substr(1,3);
+		if (to.length < 7) to += to.substr(1,3);
+		
+		var rf = parseInt(from.substr(1,2),16);
+		var gf = parseInt(from.substr(3,2),16);
+		var bf = parseInt(from.substr(5,2),16);
+		var rt = parseInt(to.substr(1,2),16);
+		var gt = parseInt(to.substr(3,2),16);
+		var bt = parseInt(to.substr(5,2),16);
+		
+		var r,g,b,h;
+		while (frame < frames)
+		{
+			r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));
+			g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));
+			b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
+			h = this.make_hex(r,g,b);
+		
+			setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay);
+
+			frame++;
+			delay = interval * frame; 
+		}
+		setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay);
+	},
+	set_bgcolor : function (id, c)
+	{
+		var o = document.getElementById(id);
+		o.style.backgroundColor = c;
+	},
+	get_bgcolor : function (id)
+	{
+		var o = document.getElementById(id);
+		while(o)
+		{
+			var c;
+			if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");
+			if (o.currentStyle) c = o.currentStyle.backgroundColor;
+			if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; }
+			o = o.parentNode;
+		}
+		if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF";
+		var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);
+		if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));
+		return c;
+	}
+}
\ No newline at end of file

Property changes on: mythweb/modules/music/mp3act_fat.js
___________________________________________________________________
Name: svn:executable
   + *

Index: mythweb/modules/music/mp3act_playstream.php
===================================================================
--- mythweb/modules/music/mp3act_playstream.php	(revision 0)
+++ mythweb/modules/music/mp3act_playstream.php	(revision 0)
@@ -0,0 +1,5 @@
+<?php
+include_once("modules/music/mp3act_functions.php");
+set_time_limit(0);
+streamPlay($_GET['i'])
+?>
\ No newline at end of file

Property changes on: mythweb/modules/music/mp3act_playstream.php
___________________________________________________________________
Name: svn:executable
   + *

Index: mythmusic/mythmusic/playbackbox.cpp
===================================================================
--- mythmusic/mythmusic/playbackbox.cpp	(revision 9730)
+++ mythmusic/mythmusic/playbackbox.cpp	(working copy)
@@ -537,7 +537,7 @@
         return;
 
    closePlaylistPopup();
-   updatePlaylistFromQuickPlaylist("ORDER BY artist, album, tracknum");
+   updatePlaylistFromQuickPlaylist("ORDER BY artist_name, album_name, track");
 }
 
 void PlaybackBoxMusic::fromCD()
@@ -593,8 +593,8 @@
         return;
 
     QString value = formattedFieldValue(curMeta->Artist().utf8());
-    QString whereClause = "WHERE artist = " + value +
-                          " ORDER BY album, tracknum"; 
+    QString whereClause = "WHERE artist_name = " + value +
+                          " ORDER BY album_name, track"; 
 
     closePlaylistPopup();
     updatePlaylistFromQuickPlaylist(whereClause);
@@ -606,8 +606,8 @@
         return;
 
     QString value = formattedFieldValue(curMeta->Album().utf8());
-    QString whereClause = "WHERE album = " + value + 
-                          " ORDER BY tracknum";
+    QString whereClause = "WHERE album_name = " + value + 
+                          " ORDER BY track";
     closePlaylistPopup();
     updatePlaylistFromQuickPlaylist(whereClause);
 }
@@ -619,7 +619,7 @@
 
     QString value = formattedFieldValue(curMeta->Genre().utf8()); 
     QString whereClause = "WHERE genre = " + value +
-                          " ORDER BY artist, album, tracknum";   
+                          " ORDER BY artist_name, album_name, track";   
     closePlaylistPopup();
     updatePlaylistFromQuickPlaylist(whereClause);
 }
@@ -631,7 +631,7 @@
 
     QString value = formattedFieldValue(curMeta->Year()); 
     QString whereClause = "WHERE year = " + value + 
-                          " ORDER BY artist, album, tracknum";
+                          " ORDER BY artist_name, album_name, track";
     closePlaylistPopup();
     updatePlaylistFromQuickPlaylist(whereClause);
 }
Index: mythmusic/mythmusic/search.cpp
===================================================================
--- mythmusic/mythmusic/search.cpp	(revision 9730)
+++ mythmusic/mythmusic/search.cpp	(working copy)
@@ -66,7 +66,7 @@
 
 void SearchDialog::runQuery(QString searchText)
 {
-    // This method will perform a search in the 'musicmetadata' table and fill
+    // This method will perform a search in the various music_* tables and fill
     // the 'listbox' widget with the results.
     // The following columns are searched: filename, artist, album, title.
     // To facilitate usage with a remote, two search modes exist and
@@ -103,8 +103,10 @@
 
     MSqlQuery query(MSqlQuery::InitCon());
 
-    QString queryString("SELECT filename, artist, album, title, intid "
-                        "FROM musicmetadata ");
+    QString queryString("SELECT filename, artist_name, album_name, name, song_id "
+			"FROM music_songs "
+                        "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
+                        "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id ");      
 
     QStringList list = QStringList::split(QRegExp("[>,]"), searchText);
     whereClause = "";
@@ -117,10 +119,10 @@
                  QString stxt = list[i];
                  whereClause += (i) ? " AND ( " : "WHERE (";
                  whereClause +=
-                    "filename LIKE '%" + stxt + "%' OR "
-                    "artist   LIKE '%" + stxt + "%' OR "
-                    "album    LIKE '%" + stxt + "%' OR "
-                    "title    LIKE '%" + stxt + "%')";
+                    "filename    LIKE '%" + stxt + "%' OR "
+                    "artist_name LIKE '%" + stxt + "%' OR "
+                    "album_name  LIKE '%" + stxt + "%' OR "
+                    "name    LIKE '%" + stxt + "%')";
              }
              VERBOSE(VB_GENERAL, QString("alpha whereClause " + whereClause ));
         }
@@ -131,17 +133,17 @@
                 QString stxt = list[i].stripWhiteSpace();
                 whereClause += (i) ? " AND ( " : "WHERE (";
                 whereClause +=
-                    "filename REGEXP '" + stxt + "' OR "
-                    "artist   REGEXP '" + stxt + "' OR "
-                    "album    REGEXP '" + stxt + "' OR "
-                    "title    REGEXP '" + stxt + "')";
+                    "filename    REGEXP '" + stxt + "' OR "
+                    "artist_name REGEXP '" + stxt + "' OR "
+                    "album_name  REGEXP '" + stxt + "' OR "
+                    "name        REGEXP '" + stxt + "')";
             }
             VERBOSE(VB_GENERAL,QString("numeric whereClause " + whereClause ));
         }
     }
 
     queryString += whereClause;
-    queryString += " ORDER BY artist, album, title, intid, filename ";
+    queryString += " ORDER BY artist_name, album_name, name, song_id, filename ";
 
     query.prepare(queryString);
 
@@ -217,7 +219,7 @@
 void SearchDialog::itemSelected(int i)
 {
     unsigned int id = ((SearchListBoxItem*)listbox->item(i))->getId();
-    whereClause = QString("WHERE intid='%1';").arg(id);
+    whereClause = QString("WHERE song_id='%1';").arg(id);
     done(0);
 }
 
Index: mythmusic/mythmusic/metadata.cpp
===================================================================
--- mythmusic/mythmusic/metadata.cpp	(revision 9730)
+++ mythmusic/mythmusic/metadata.cpp	(working copy)
@@ -44,6 +44,8 @@
     rating = rhs->Rating();
     lastplay = rhs->LastPlayStr();
     playcount = rhs->Playcount();
+    bitrate = rhs->Bitrate();
+    filesize = rhs->Filesize();
     compilation = rhs->Compilation();
     id = rhs->ID();
     filename = rhs->Filename();
@@ -62,9 +64,9 @@
 void Metadata::persist()
 {
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("UPDATE musicmetadata set rating = :RATING , "
-                  "playcount = :PLAYCOUNT , lastplay = :LASTPLAY "
-                  "where intid = :ID ;");
+    query.prepare("UPDATE music_songs set rating = :RATING , "
+                  "numplays = :PLAYCOUNT , lastplay = :LASTPLAY "
+                  "where song_id = :ID ;");
     query.bindValue(":RATING", rating);
     query.bindValue(":PLAYCOUNT", playcount);
     query.bindValue(":LASTPLAY", lastplay);
@@ -98,9 +100,17 @@
     QString sqlfilename = filename.remove(0, m_startdir.length());
 
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("SELECT artist,compilation_artist,album,title,genre,year,tracknum,"
-                  "length,intid,rating,playcount,lastplay,compilation,format FROM "
-                  "musicmetadata WHERE filename = :FILENAME ;");
+    query.prepare("SELECT music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, "
+                  "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
+                  "music_songs.track, music_songs.length, music_songs.song_id, music_songs.rating, "
+                  "music_songs.numplays, music_songs.lastplay, music_songs.compilation, "
+                  "music_songs.format "
+                  "FROM music_songs "
+                  "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
+                  "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
+                  "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
+                  "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
+                  "WHERE music_songs.filename = :FILENAME ;");
     query.bindValue(":FILENAME", sqlfilename.utf8());
 
     if (query.exec() && query.isActive() && query.size() > 0)
@@ -146,14 +156,22 @@
     // Don't update the database if a song with the exact same
     // metadata is already there
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("SELECT filename FROM musicmetadata WHERE "
-                  "( ( artist = :ARTIST ) AND "
-                  "( compilation_artist = :COMPILATION_ARTIST ) "
-                  "( album = :ALBUM ) AND ( title = :TITLE ) "
-                  "AND ( genre = :GENRE ) AND "
-                  "( year = :YEAR ) AND ( tracknum = :TRACKNUM ) "
-                  "AND ( length = :LENGTH ) "
-                  "AND ( format = :FORMAT) );");
+    query.prepare("SELECT music_songs.filename "
+                  "FROM music_songs "
+                  "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
+                  "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
+                  "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
+                  "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
+                  "WHERE music_artists.artist_name = :ARTIST"
+                  " AND music_comp_artists.artist_name = :COMPILATION_ARTIST"
+                  " AND music_albums.album_name = :ALBUM"
+                  " AND music_songs.name = :TITLE"
+                  " AND music_genres.genre = :GENRE"
+                  " AND music_songs.year = :YEAR"
+                  " AND music_songs.track = :TRACKNUM"
+                  " AND music_songs.length = :LENGTH"
+                  " AND music_songs.format = :FORMAT ;");
+    
     query.bindValue(":ARTIST", artist.utf8());
     query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8());
     query.bindValue(":ALBUM", album.utf8());
@@ -167,21 +185,137 @@
     if (query.exec() && query.isActive() && query.size() > 0)
         return;
 
-    query.prepare("INSERT INTO musicmetadata "
-                  "(artist,   compilation_artist, album,      title,  "
-                  " genre,    year,               tracknum,   length, "
-                  " filename, compilation,        date_added, date_modified, "
-                  " format ) "
-                  "VALUES "
-                  "(:ARTIST,  :COMPILATION_ARTIST,:ALBUM,     :TITLE,   "
-                  " :GENRE,   :YEAR,              :TRACKNUM,  :LENGTH,  "
-                  " :FILENAME,:COMPILATION,       :DATE_ADDED,:DATE_MOD,"
-                  " :FORMAT)");
+    // Load the artist id or insert it and get the id
+    unsigned int artistId;
+    query.prepare("SELECT artist_id FROM music_artists "
+                  "WHERE artist_name = :ARTIST ;");
     query.bindValue(":ARTIST", artist.utf8());
-    query.bindValue(":COMPILATION_ARTIST", compilation_artist.utf8());
+
+    if (!query.exec() || !query.isActive())
+    {
+        MythContext::DBError("music select artist id", query);
+        return;
+    }
+    if (query.size() > 0)
+    { 
+        query.next();
+        artistId = query.value(0).toInt();
+    }
+    else
+    {
+        query.prepare("INSERT INTO music_artists (artist_name) VALUES (:ARTIST);");
+        query.bindValue(":ARTIST", artist.utf8());
+
+        if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0)
+        {
+            MythContext::DBError("music insert artist", query);
+            return;
+        }
+        artistId = query.lastInsertId().toInt();
+    }
+
+    // Compilation Artist	
+    unsigned int compilationArtistId;
+    query.prepare("SELECT artist_id FROM music_artists "
+                  "WHERE artist_name = :ARTIST ;");
+    query.bindValue(":ARTIST", compilation_artist.utf8());
+    if (!query.exec() || !query.isActive())
+    {
+        MythContext::DBError("music select compilation artist id", query);
+        return;
+    }
+    if (query.size() > 0)
+    { 
+        query.next();
+        compilationArtistId = query.value(0).toInt();
+    }
+    else
+    {
+        query.prepare("INSERT INTO music_artists (artist_name) VALUES (:ARTIST);");
+        query.bindValue(":ARTIST", compilation_artist.utf8());
+
+        if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0)
+        {
+            MythContext::DBError("music insert compilation artist", query);
+            return;
+        }
+        compilationArtistId = query.lastInsertId().toInt();
+    }
+
+    // Album
+    unsigned int albumId;
+    query.prepare("SELECT album_id FROM music_albums "
+                  "WHERE album_name = :ALBUM ;");
     query.bindValue(":ALBUM", album.utf8());
+    if (!query.exec() || !query.isActive())
+    {
+        MythContext::DBError("music select album id", query);
+        return;
+    }
+    if (query.size() > 0)
+    { 
+        query.next();
+        albumId = query.value(0).toInt();
+    }
+    else
+    {
+	query.prepare("INSERT INTO music_albums (album_name) VALUES (:ALBUM);");
+	query.bindValue(":ALBUM", album.utf8());
+
+        if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0)
+        {
+            MythContext::DBError("music insert album", query);
+            return;
+        }
+        albumId = query.lastInsertId().toInt();
+    }
+
+    // Genres
+    unsigned int genreId;
+    query.prepare("SELECT genre_id FROM music_genres "
+                  "WHERE genre = :GENRE ;");
+    query.bindValue(":GENRE", genre.utf8());
+    if (!query.exec() || !query.isActive())
+    {
+        MythContext::DBError("music select genre id", query);
+        return;
+    }
+    if (query.size() > 0)
+    { 
+        query.next();
+        genreId = query.value(0).toInt();
+    }
+    else
+    {
+        query.prepare("INSERT INTO music_genres (genre) VALUES (:GENRE);");
+        query.bindValue(":GENRE", genre.utf8());
+
+        if (!query.exec() || !query.isActive() || query.numRowsAffected() <= 0)
+        {
+            MythContext::DBError("music insert genre", query);
+            return;
+        }
+        genreId = query.lastInsertId().toInt();
+    }
+
+    // We have all the id's now. We can insert it.
+    query.prepare("INSERT INTO music_songs "
+                  "  (artist_id, album_id,     compilationartist_id, name,"
+                  "   genre_id,  year,         track,                length,"
+                  "   filename,  compilation,  date_entered,         date_modified,"
+                  "   format,    size,         bitrate) "
+                  "VALUES "
+                  "  (:ARTIST,   :ALBUM,       :COMPILATION_ARTIST,  :TITLE,"
+                  "   :GENRE,    :YEAR,        :TRACKNUM,            :LENGTH,"
+                  "   :FILENAME, :COMPILATION, :DATE_ADDED,          :DATE_MOD,"
+                  "   :FORMAT,   :FILESIZE,    :BITRATE)"
+                  );
+
+    query.bindValue(":ARTIST", artistId);
+    query.bindValue(":COMPILATION_ARTIST", compilationArtistId);
+    query.bindValue(":ALBUM", albumId);
     query.bindValue(":TITLE", title.utf8());
-    query.bindValue(":GENRE", genre.utf8());
+    query.bindValue(":GENRE", genreId);
     query.bindValue(":YEAR", year);
     query.bindValue(":TRACKNUM", tracknum);
     query.bindValue(":LENGTH", length);
@@ -190,11 +324,14 @@
     query.bindValue(":DATE_ADDED",  QDateTime::currentDateTime());
     query.bindValue(":DATE_MOD",    QDateTime::currentDateTime());
     query.bindValue(":FORMAT", format);
+    query.bindValue(":FILESIZE", filesize);
+    query.bindValue(":BITRATE", bitrate);
     
+    
     query.exec();
 
-    // easiest way to ensure we've got 'id' filled.
-    fillData();
+    if (query.isActive() && 1 == query.numRowsAffected())
+        id = query.lastInsertId().toInt();
 }
 
 // Default values for formats
@@ -341,7 +478,7 @@
 
     MSqlQuery query(MSqlQuery::InitCon());
 
-    query.prepare("UPDATE musicmetadata    "
+    query.prepare("UPDATE music_songs    "
                   "SET artist   = :ARTIST,   "
                   "    album    = :ALBUM,    "
                   "    title    = :TITLE,    "
@@ -353,7 +490,7 @@
                   "    compilation        = :COMPILATION,   "
                   "    compilation_artist = :COMPILATION_ARTIST, "
                   "    format             = :FORMAT "
-                  "WHERE intid = :ID;");
+                  "WHERE song_id = :ID;");
     query.bindValue(":ARTIST",             artist.utf8());
     query.bindValue(":ALBUM",              album.utf8());
     query.bindValue(":TITLE",              title.utf8());
@@ -427,16 +564,24 @@
     if (title == "")
         return;
 
-    QString thequery = "SELECT artist,compilation_artist,album,title,genre,year,tracknum,length,"
-                       "filename,intid,rating,playcount,lastplay,compilation,format "
-                       "FROM musicmetadata WHERE title = :TITLE";
+    QString thequery =  "SELECT music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, "
+                        "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
+            	        "music_songs.track, music_songs.length, music_songs.filename, music_songs.song_id, "
+                        "music_songs.rating, music_songs.numplays, music_songs.lastplay, music_songs.compilation, "
+                        "music_songs.format "
+                        "FROM music_songs "
+                        "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
+                        "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
+                        "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
+                        "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
+                        "WHERE music_songs.name = :TITLE";
 
     if (album != "")
-        thequery += " AND album = :ALBUM";
+        thequery += " AND music_albums.album_name = :ALBUM";
     if (artist != "")
-        thequery += " AND artist = :ARTIST";
+        thequery += " AND music_artists.artist_name = :ARTIST";
     if (compilation_artist != "")
-        thequery += " AND compilation_artist = :COMPILATION_ARTIST";
+        thequery += " AND music_comp_artists.artist_name = :COMPILATION_ARTIST";
 
     thequery += ";";
 
@@ -478,30 +623,37 @@
         return; 
         
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("SELECT title,artist,compilation_artist,album,title,genre,year,tracknum,"
-                  "length,filename,rating,playcount,lastplay,compilation,format FROM "
-                  "musicmetadata WHERE intid = :ID ;");
+    query.prepare("SELECT music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, "
+                  "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
+                  "music_songs.track, music_songs.length, music_songs.filename, "
+                  "music_songs.rating, music_songs.numplays, music_songs.lastplay, music_songs.compilation, "
+                  "music_songs.format "
+                  "FROM music_songs "
+                  "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
+                  "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
+                  "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
+                  "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
+                  "WHERE music_songs.song_id = :ID;");		 
     query.bindValue(":ID", id);
         
     if (query.exec() && query.isActive() && query.numRowsAffected() > 0)
     {
         query.next();
 
-        title = QString::fromUtf8(query.value(0).toString());
-        artist = QString::fromUtf8(query.value(1).toString());
-        compilation_artist = QString::fromUtf8(query.value(2).toString());
-        album = QString::fromUtf8(query.value(3).toString());
-        title = QString::fromUtf8(query.value(4).toString());
-        genre = QString::fromUtf8(query.value(5).toString());
-        year = query.value(6).toInt();
-        tracknum = query.value(7).toInt();
-        length = query.value(8).toInt();
-        filename = QString::fromUtf8(query.value(9).toString());
-        rating = query.value(10).toInt();
-        playcount = query.value(11).toInt();
-        lastplay = query.value(12).toString();
-        compilation = (query.value(13).toInt() > 0);
-        format = query.value(14).toString();
+        artist = QString::fromUtf8(query.value(0).toString());
+        compilation_artist = QString::fromUtf8(query.value(1).toString());
+        album = QString::fromUtf8(query.value(2).toString());
+        title = QString::fromUtf8(query.value(3).toString());
+        genre = QString::fromUtf8(query.value(4).toString());
+        year = query.value(5).toInt();
+        tracknum = query.value(6).toInt();
+        length = query.value(7).toInt();
+        filename = QString::fromUtf8(query.value(8).toString());
+        rating = query.value(9).toInt();
+        playcount = query.value(10).toInt();
+        lastplay = query.value(11).toString();
+        compilation = (query.value(12).toInt() > 0);
+        format = query.value(13).toString();
 
         if (!filename.contains("://"))
             filename = m_startdir + filename;
@@ -644,12 +796,19 @@
 void AllMusic::resync()
 {
     done_loading = false;
-    QString aquery =    "SELECT intid, artist, compilation_artist, album, title, genre, "
-                        "year, tracknum, length, filename, rating, "
-                        "lastplay, playcount, compilation, format "
-                        "FROM musicmetadata "
-                        "ORDER BY intid;";
 
+    QString aquery = "SELECT music_songs.song_id, music_artists.artist_name, music_comp_artists.artist_name AS compilation_artist, "
+                     "music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
+            	     "music_songs.track, music_songs.length, music_songs.filename, "
+                     "music_songs.rating, music_songs.numplays, music_songs.lastplay, music_songs.compilation, "
+                     "music_songs.format, music_songs.bitrate, music_songs.size "
+                     "FROM music_songs "
+                     "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
+                     "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
+                     "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
+                     "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
+                     "ORDER BY music_songs.song_id;";
+
     QString filename, artist, album, title;
 
     MSqlQuery query(MSqlQuery::InitCon());
@@ -692,9 +851,11 @@
                 query.value(7).toInt(),
                 query.value(8).toInt(),
                 query.value(0).toInt(),
-                query.value(10).toInt(),
+                query.value(11).toInt(),
                 query.value(12).toInt(),
-                query.value(11).toString(),
+                query.value(15).toInt(), //bitrate
+                query.value(16).toInt(), //filesize
+                query.value(10).toString(),
                 (query.value(13).toInt() > 0),
                 query.value(14).toString());
             
Index: mythmusic/mythmusic/dbcheck.cpp
===================================================================
--- mythmusic/mythmusic/dbcheck.cpp	(revision 9730)
+++ mythmusic/mythmusic/dbcheck.cpp	(working copy)
@@ -9,7 +9,7 @@
 #include "mythtv/mythcontext.h"
 #include "mythtv/mythdbcon.h"
 
-const QString currentDatabaseVersion = "1005";
+const QString currentDatabaseVersion = "1007";
 
 static void UpdateDBVersionNumber(const QString &newnumber)
 {
@@ -323,5 +323,132 @@
 
         performActualUpdate(updates, "1005", dbver);
     }
+    
+    
+        if (dbver == "1005")
+        {
+            const QString updates[] = {
+"CREATE TABLE music_albums ("
+"    album_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
+"    album_name varchar(255) NOT NULL default '',"
+"    album_art text NOT NULL default '',"
+"    INDEX idx_album_name(album_name)"
+");",
+"CREATE TABLE music_artists ("
+"    artist_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
+"    artist_name varchar(255) NOT NULL default '',"
+"    INDEX idx_artist_name(artist_name)"
+");",
+"CREATE TABLE music_currentsong ("
+"    song_id int(11) unsigned NOT NULL default '0',"
+"    pl_id int(11) unsigned NOT NULL default '0',"
+"    random tinyint(3) NOT NULL default '0'"
+");",
+"CREATE TABLE music_genres ("
+"    genre_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
+"    genre varchar(25) NOT NULL default '',"
+"    INDEX idx_genre(genre)"
+");",
+"CREATE TABLE music_playhistory ("
+"    play_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
+"    song_id int(11) unsigned NOT NULL default '0',"
+"    date_played datetime default NULL"
+");",
+"CREATE TABLE music_playlist ("
+"    pl_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
+"    song_id int(11) unsigned NOT NULL default '0'"
+");",
+"CREATE TABLE music_saved_playlists ("
+"    playlist_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
+"    playlist_name varchar(255) NOT NULL default '',"
+"    playlist_songs text NOT NULL default '',"
+"    date_created datetime default NULL,"
+"    time int(11) default NULL,"
+"    songcount smallint(8) unsigned NOT NULL default '',"
+"    hostname VARCHAR(255) NOT NULL default ''"
+");",
+"CREATE TABLE music_songs ("
+"    song_id int(11) unsigned NOT NULL auto_increment PRIMARY KEY,"
+"    artist_id int(11) unsigned NOT NULL default '0',"
+"    compilationartist_id int(11) unsigned NOT NULL default '0',"
+"    album_id int(11) unsigned NOT NULL default '0',"
+"    genre_id int(11) unsigned NOT NULL default '0',"
+"    year smallint(6) NOT NULL default '0',"
+"    lastplay datetime default NULL,"
+"    date_entered datetime default NULL,"
+"    date_modified datetime default NULL,"
+"    name varchar(255) NOT NULL default '',"
+"    track smallint(6) unsigned NOT NULL default '0',"
+"    length int(11) unsigned NOT NULL default '0',"
+"    size int(11) unsigned NOT NULL default '0',"
+"    bitrate int(11) unsigned NOT NULL default '0',"
+"    type varchar(4) default NULL,"
+"    numplays int(11) unsigned NOT NULL default '0',"
+"    rating tinyint(4) unsigned NOT NULL default '0',"
+"    filename text NOT NULL default '',"
+"    format varchar(4) NOT NULL default '0',"
+"    compilation tinyint(1) unsigned NOT NULL default '0',"
+"    mythdigest VARCHAR(255),"
+"    description VARCHAR(255),"
+"    comment VARCHAR(255),"
+"    disc_count SMALLINT(5) UNSIGNED DEFAULT '0',"
+"    disc_number SMALLINT(5) UNSIGNED DEFAULT '0',"
+"    track_count SMALLINT(5) UNSIGNED DEFAULT '0',"
+"    start_time INT(10) UNSIGNED DEFAULT '0',"
+"    stop_time INT(10) UNSIGNED,"
+"    eq_preset VARCHAR(255),"
+"    relative_volume TINYINT DEFAULT '0',"
+"    bpm SMALLINT(5) UNSIGNED,"
+//   The following field is temporary for schema conversion and is removed in a later query.
+"    compilation_artist VARCHAR(128) NOT NULL,"
+"    INDEX idx_tmp(compilation_artist),"
+//   The rest is standard
+"    INDEX idx_name(name),"
+"    INDEX idx_mythdigest(mythdigest)"
+");",
+"CREATE TABLE music_stats ("
+"    num_artists smallint(5) unsigned NOT NULL default '0',"
+"    num_albums smallint(5) unsigned NOT NULL default '0',"
+"    num_songs mediumint(8) unsigned NOT NULL default '0',"
+"    num_genres tinyint(3) unsigned NOT NULL default '0',"
+"    total_time varchar(12) NOT NULL default '0',"
+"    total_size varchar(10) NOT NULL default '0'"
+");",
+"RENAME TABLE smartplaylist TO music_smartplaylist;",
+"RENAME TABLE smartplaylistitem TO music_smartplaylistitem;",
+"RENAME TABLE smartplaylistcategory TO music_smartplaylistcategory;",
+// Run necessary SQL to migrate the table structure
+"INSERT INTO music_artists (artist_name) SELECT DISTINCT artist FROM musicmetadata;",
+"INSERT INTO music_albums (album_name) SELECT DISTINCT album FROM musicmetadata;",
+"INSERT INTO music_genres (genre) SELECT DISTINCT genre FROM musicmetadata;",
+"INSERT INTO music_songs "
+"   (song_id, artist_id, compilationartist_id, album_id, genre_id, year, lastplay,"
+"    date_entered, date_modified, name, track, length, size, numplays,"
+"    rating, filename, compilation, compilation_artist)"
+"  SELECT intid, ma.artist_id, 0, mb.album_id, mg.genre_id, year, lastplay,"
+"         date_added, date_modified, title, tracknum, length, IFNULL(size,0), playcount,"
+"         rating, filename, compilation, compilation_artist"
+"  FROM musicmetadata AS mmd, music_artists AS ma, music_albums AS mb, music_genres AS mg"
+"  WHERE mmd.artist=ma.artist_name AND mmd.album=mb.album_name AND mmd.genre=mg.genre;",
+"UPDATE music_songs AS ms, music_artists AS ma "
+"  SET ms.compilationartist_id=ma.artist_id, compilation_artist=''"
+"  WHERE ms.compilation_artist=ma.artist_name;",
+"INSERT INTO music_artists (artist_name)"
+"  SELECT DISTINCT compilation_artist FROM music_songs"
+"  WHERE compilation_artist <> '';",
+"UPDATE music_songs AS ms,music_artists AS ma"
+"  SET ms.compilationartist_id=ma.artist_id, compilation_artist=''"
+"  WHERE ms.compilation_artist=ma.artist_name;",
+"ALTER TABLE music_songs DROP COLUMN compilation_artist;",
+"INSERT INTO music_saved_playlists"
+"  (playlist_name,playlist_songs,date_created,hostname)"
+"  SELECT name AS playlist_name, songlist AS playlist_songs,NOW() AS date_created,hostname"
+"  FROM musicplaylist;",
+//"DROP TABLE musicmetadata;",
+//"DROP TABLE musicplaylist;",
+""
+};
+        performActualUpdate(updates, "1006", dbver);
+    }
 }
 
Index: mythmusic/mythmusic/metaioid3v2.h
===================================================================
--- mythmusic/mythmusic/metaioid3v2.h	(revision 9730)
+++ mythmusic/mythmusic/metaioid3v2.h	(working copy)
@@ -23,6 +23,7 @@
     
 private:
     int getTrackLength(QString filename);
+    int getTrackBitRate(QString filename);
 
     QString getRawID3String(union id3_field *pField);
     void removeComment(id3_tag *pTag, const char* pLabel, const QString desc = "");
Index: mythmusic/mythmusic/playlist.cpp
===================================================================
--- mythmusic/mythmusic/playlist.cpp	(revision 9730)
+++ mythmusic/mythmusic/playlist.cpp	(working copy)
@@ -326,13 +326,12 @@
     all_other_playlists->clear();
 
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("SELECT playlistid FROM musicplaylist "
-                  "WHERE name != :DEFAULT  "
-                  "AND name != :BACKUP  "
-                  "AND hostname = :HOST ORDER BY playlistid ;");
+    query.prepare("SELECT playlist_id FROM music_saved_playlists "
+                  "WHERE playlist_name != :DEFAULT"
+                  " AND playlist_name != :BACKUP "
+                  "ORDER BY playlist_id;");
     query.bindValue(":DEFAULT", "default_playlist_storage");
     query.bindValue(":BACKUP", "backup_playlist_storage"); 
-    query.bindValue(":HOST", my_host);
 
     if (query.exec() && query.isActive() && query.size() > 0)
     {
@@ -468,12 +467,24 @@
     }
    
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("SELECT playlistid, name, songlist FROM "
-                  "musicplaylist WHERE name = :NAME AND "
-                  "hostname = :HOST ;");
-    query.bindValue(":NAME", a_name);
-    query.bindValue(":HOST", a_host);
 
+    if (name == "default_playlist_storage" || name == "backup_playlist_storage")
+    {
+        query.prepare("SELECT playlist_id, playlist_name, playlist_songs "
+                      "FROM  music_saved_playlists "
+                      "WHERE playlist_name = :NAME"
+                      " AND hostname = :HOST;");
+	query.bindValue(":NAME", a_name);
+        query.bindValue(":HOST", a_host);
+    }
+    else
+    {
+	query.prepare("SELECT playlist_id, playlist_name, playlist_songs "
+                      "FROM music_saved_playlists "
+                      "WHERE playlist_name = :NAME;");
+	query.bindValue(":NAME", a_name);
+    }
+
     if (query.exec() && query.size() > 0)
     {
         while (query.next())
@@ -498,11 +509,11 @@
 void Playlist::loadPlaylistByID(int id, QString a_host)
 {
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("SELECT playlistid, name, songlist FROM "
-                  "musicplaylist WHERE playlistid = :ID AND "
-                  "hostname = :HOST ;");
+    query.prepare("SELECT playlist_id, playlist_name, playlist_songs "
+                  "FROM music_saved_playlists "
+                  "WHERE playlist_id = :ID;");
     query.bindValue(":ID", id);
-    query.bindValue(":HOST", a_host);
+//    query.bindValue(":HOST", a_host);
 
     query.exec();
 
@@ -603,7 +614,10 @@
 
     QString theQuery;
 
-    theQuery = "SELECT intid FROM musicmetadata ";
+    theQuery = "SELECT song_id FROM music_songs "
+               "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
+               "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
+               "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id ";
 
     if (whereClause.length() > 0)
       theQuery += whereClause;
@@ -718,7 +732,7 @@
     int limitTo;
     
     query.prepare("SELECT smartplaylistid, matchtype, orderby, limitto "
-                  "FROM smartplaylist WHERE categoryid = :CATEGORYID AND name = :NAME;");
+                  "FROM music_smartplaylist WHERE categoryid = :CATEGORYID AND name = :NAME;");
     query.bindValue(":NAME", name.utf8());
     query.bindValue(":CATEGORYID", categoryID);
         
@@ -748,7 +762,7 @@
     QString whereClause = "WHERE ";
     
     query.prepare("SELECT field, operator, value1, value2 "
-                  "FROM smartplaylistitem WHERE smartplaylistid = :ID;");
+                  "FROM music_smartplaylistitem WHERE smartplaylistid = :ID;");
     query.bindValue(":ID", ID);
     query.exec();
     if (query.isActive() && query.numRowsAffected() > 0)
@@ -787,25 +801,46 @@
         return;
 
     fillSonglistFromSongs();
+    MSqlQuery query(MSqlQuery::InitCon());
 
-    MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("SELECT NULL FROM musicplaylist WHERE playlistid = :ID ;");
+    int songcount = 0, playtime = 0, an_int;
+    QStringList list = QStringList::split(",", raw_songlist);
+    QStringList::iterator it = list.begin();
+    for (; it != list.end(); it++)
+    {
+        an_int = QString(*it).toInt();
+        if (an_int != 0)
+        {
+	    songcount++;
+	    query.prepare("SELECT length FROM music_songs WHERE song_id = :ID ;");
+    	    query.bindValue(":ID", an_int);
+    	    query.exec();
+	    query.next();
+	    playtime += query.value(0).toInt();
+	}
+    }
+
+    query.prepare("SELECT NULL FROM music_saved_playlists WHERE playlist_id = :ID ;");
     query.bindValue(":ID", playlistid);
 
     if (query.exec() && query.isActive() && query.size() > 0)
     {
-        query.prepare("UPDATE musicplaylist SET songlist = :LIST , "
-                      "name = :NAME WHERE playlistid = :ID ;");
+        query.prepare("UPDATE music_saved_playlists SET playlist_songs = :LIST , "
+                      "playlist_name = :NAME, songcount = :SONGCOUNT, time = :PLAYTIME WHERE playlist_id = :ID ;");
         query.bindValue(":LIST", raw_songlist);
         query.bindValue(":NAME", a_name.utf8());
+        query.bindValue(":SONGCOUNT", songcount);
+        query.bindValue(":PLAYTIME", playtime);
         query.bindValue(":ID", playlistid);
     }
     else
     {
-        query.prepare("INSERT INTO musicplaylist (name,songlist) "
-                      "VALUES(:NAME, :LIST);");
+        query.prepare("INSERT INTO music_saved_playlists (playlist_name,playlist_songs, songcount, time) "
+                      "VALUES(:NAME, :LIST, :SONGCOUNT, :PLAYTIME);");
         query.bindValue(":LIST", raw_songlist);
         query.bindValue(":NAME", a_name.utf8());
+        query.bindValue(":SONGCOUNT", songcount);
+        query.bindValue(":PLAYTIME", playtime);
     }
 
     query.exec();
@@ -827,17 +862,36 @@
     }
 
     fillSonglistFromSongs();
+    MSqlQuery query(MSqlQuery::InitCon());
+
+    int songcount = 0, playtime = 0, an_int;
+    QStringList list = QStringList::split(",", raw_songlist);
+    QStringList::iterator it = list.begin();
+    for (; it != list.end(); it++)
+    {
+        an_int = QString(*it).toInt();
+        if (an_int != 0)
+        {
+	    songcount++;
+	    query.prepare("SELECT length FROM music_songs WHERE song_id = :ID ;");
+    	    query.bindValue(":ID", an_int);
+    	    query.exec();
+	    query.next();
+	    playtime += query.value(0).toInt();
+	}
+    }
     
-    MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("INSERT musicplaylist (name, hostname) "
-                  "VALUES(:NAME, :HOST);");
+    query.prepare("INSERT music_saved_playlists (playlist_name, hostname, songcount, time) "
+                  "VALUES(:NAME, :HOST, :SONGCOUNT, :PLAYTIME);");
     query.bindValue(":NAME", name.utf8());
     query.bindValue(":HOST", a_host);
+    query.bindValue(":SONGCOUNT", songcount);
+    query.bindValue(":PLAYTIME", playtime);
 
     query.exec();
 
-    query.prepare("SELECT playlistid FROM musicplaylist WHERE "
-                  "name = :NAME AND hostname = :HOST ;");
+    query.prepare("SELECT playlist_id FROM music_saved_playlists WHERE "
+                  "playlist_name = :NAME AND hostname = :HOST;");
     query.bindValue(":NAME", name.utf8());
     query.bindValue(":HOST", a_host);
 
@@ -1210,7 +1264,7 @@
     }
 
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("DELETE FROM musicplaylist WHERE playlistid = :ID ;");
+    query.prepare("DELETE FROM music_saved_playlists WHERE playlist_id = :ID ;");
     query.bindValue(":ID", kill_me);
 
     if (query.exec() || query.size() < 1)
Index: mythmusic/mythmusic/cdrip.cpp
===================================================================
--- mythmusic/mythmusic/cdrip.cpp	(revision 9730)
+++ mythmusic/mythmusic/cdrip.cpp	(working copy)
@@ -284,18 +284,21 @@
     if (gContext->GetNumSetting("OnlyImportNewMusic",1))
     {
         MSqlQuery query(MSqlQuery::InitCon());	
-	QString queryString("SELECT filename, artist, album, title, intid "
-			    "FROM musicmetadata WHERE artist REGEXP \'");      
-	QString token = artist;
+        QString queryString("SELECT filename, artist_name, album_name, name, song_id "
+                            "FROM music_songs "
+                            "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
+                            "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
+                            "WHERE artist_name REGEXP \'");      
+        QString token = artist;
 	token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));
       
-	queryString += token + "\' AND " + "album REGEXP \'";
+	queryString += token + "\' AND " + "album_name REGEXP \'";
 	token = album;
 	token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));
-	queryString += token + "\' AND " + "title    REGEXP \'";
+	queryString += token + "\' AND " + "name    REGEXP \'";
 	token = title;
 	token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"), QString("."));
-	queryString += token + "\' ORDER BY artist, album, title, intid, filename";      
+	queryString += token + "\' ORDER BY artist_name, album_name, name, song_id, filename";      
 	query.prepare(queryString);
 	
 	bool has_entries = true;     
@@ -524,13 +527,31 @@
     delete decoder;
 }
 
-void Ripper::fillComboBox(MythComboBox &box, const QString &db_column)
+void Ripper::fillComboBox(MythComboBox &box, const QString &field)
 {
-    QString querystr = QString("SELECT DISTINCT %1 FROM musicmetadata;")
-                               .arg(db_column);
-      
     MSqlQuery query(MSqlQuery::InitCon());
-    query.exec(querystr);
+    if ("artist" == field || "compilation_artist" == field)
+    {
+        query.prepare("SELECT artist_name FROM music_artists ORDER BY artist_name;");
+    }
+    else if ("album" == field)
+    {
+        query.prepare("SELECT album_name FROM music_albums ORDER BY album_name;");
+    }
+    else if ("title" == field)
+    {
+        query.prepare("SELECT name FROM music_songs ORDER BY name;");
+    }
+    else if ("genre" == field)
+    {
+        query.prepare("SELECT genre FROM music_genres ORDER BY genre;");
+    }
+    else
+    {
+        return;
+    }
+
+    query.exec();
    
     QValueList<QString> list;
    
Index: mythmusic/mythmusic/smartplaylist.cpp
===================================================================
--- mythmusic/mythmusic/smartplaylist.cpp	(revision 9730)
+++ mythmusic/mythmusic/smartplaylist.cpp	(working copy)
@@ -33,18 +33,20 @@
 static SmartPLField SmartPLFields[] = 
 {
     { "",              "",                               ftString,   0,    0,    0 },
-    { "Artist",        "artist",                         ftString,   0,    0,    0 },
-    { "Album",         "album",                          ftString,   0,    0,    0 },
-    { "Title",         "title",                          ftString,   0,    0,    0 },
-    { "Genre",         "genre",                          ftString,   0,    0,    0 },
-    { "Year",          "year",                           ftNumeric,  1900, 2099, 2000 },
-    { "Track No.",     "tracknum",                       ftNumeric,  0,    99,   0 },
-    { "Rating",        "rating",                         ftNumeric,  0,    10,   0 },
-    { "Play Count",    "playcount",                      ftNumeric,  0,    9999, 0 },
-    { "Compilation",   "compilation",                    ftBoolean,  0,    0,    0 },
-    { "Comp. Artist",  "compilation_artist",             ftString,   0,    0,    0 },
-    { "Last Play",     "FROM_DAYS(TO_DAYS(lastplay))",   ftDate,     0,    0,    0 },
-    { "Date Imported", "FROM_DAYS(TO_DAYS(date_added))", ftDate,     0,    0,    0 },
+    { "Artist",        "music_artists.artist_name",      ftString,   0,    0,    0 },
+    { "Album",         "music_songs.album_name",         ftString,   0,    0,    0 },
+    { "Title",         "music_songs.name",               ftString,   0,    0,    0 },
+    { "Genre",         "music_genres.genre",             ftString,   0,    0,    0 },
+    { "Year",          "music_songs.year",               ftNumeric,  1900, 2099, 2000 },
+    { "Track No.",     "music_songs.track",              ftNumeric,  0,    99,   0 },
+    { "Rating",        "music_songs.rating",             ftNumeric,  0,    10,   0 },
+    { "Play Count",    "music_songs.numplays",           ftNumeric,  0,    9999, 0 },
+    { "Compilation",   "music_songs.compilation",        ftBoolean,  0,    0,    0 },
+    { "Comp. Artist",  "music_comp_artists.artist_name", ftString,   0,    0,    0 },
+    { "Last Play",     "FROM_DAYS(TO_DAYS(music_songs.lastplay))",   
+                                                         ftDate,     0,    0,    0 },
+    { "Date Imported", "FROM_DAYS(TO_DAYS(music_songs.date_added))",   
+                                                         ftDate,     0,    0,    0 },
 };        
 
 struct SmartPLOperator
@@ -655,11 +657,28 @@
     searchList.clear();
     
     MSqlQuery query(MSqlQuery::InitCon());
-    QString querystr;
-    querystr = QString("SELECT DISTINCT %1 FROM musicmetadata ORDER BY %2").arg(field).arg(field);
+    if ("artist" == field || "compilation_artist" == field)
+    {
+        query.prepare("SELECT artist_name FROM music_artists ORDER BY artist_name;");
+    }
+    else if ("album" == field)
+    {
+        query.prepare("SELECT album_name FROM music_albums ORDER BY album_name;");
+    }
+    else if ("title" == field)
+    {
+        query.prepare("SELECT name FROM music_songs ORDER BY name;");
+    }
+    else if ("genre" == field)
+    {
+        query.prepare("SELECT genre FROM music_genres ORDER BY genre;");
+    }
+    else
+    {
+        return;
+    }
         
-    query.exec(querystr);
-    if (query.isActive() && query.numRowsAffected())
+    if (query.exec() && query.isActive() && query.numRowsAffected())
     {
         while (query.next())
         {
@@ -815,7 +834,7 @@
     }
     
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("INSERT INTO smartplaylistitem (smartplaylistid, field, operator,"
+    query.prepare("INSERT INTO music_smartplaylistitem (smartplaylistid, field, operator,"
                   " value1, value2)"
                   "VALUES (:SMARTPLAYLISTID, :FIELD, :OPERATOR, :VALUE1, :VALUE2);");
     query.bindValue(":SMARTPLAYLISTID", smartPlaylistID);
@@ -1130,7 +1149,7 @@
 {
     bPlaylistIsValid = true;
     
-    QString sql = "select count(*) from musicmetadata ";
+    QString sql = "select count(*) from music_songs ";
     sql += getWhereClause();
     
     MSqlQuery query(MSqlQuery::InitCon());
@@ -1177,7 +1196,7 @@
     
     MSqlQuery query(MSqlQuery::InitCon());
     // insert new smartplaylist
-    query.prepare("INSERT INTO smartplaylist (name, categoryid, matchtype, orderby, limitto) "
+    query.prepare("INSERT INTO music_smartplaylist (name, categoryid, matchtype, orderby, limitto) "
                 "VALUES (:NAME, :CATEGORYID, :MATCHTYPE, :ORDERBY, :LIMIT);");
     query.bindValue(":NAME", name.utf8());
     query.bindValue(":CATEGORYID", categoryid);
@@ -1193,7 +1212,7 @@
     
     // get smartplaylistid
     int ID;
-    query.prepare("SELECT smartplaylistid FROM smartplaylist "
+    query.prepare("SELECT smartplaylistid FROM music_smartplaylist "
                   "WHERE categoryid = :CATEGORYID AND name = :NAME;");
     query.bindValue(":CATEGORYID", categoryid);
     query.bindValue(":NAME", name.utf8());
@@ -1253,7 +1272,7 @@
     int ID;
     
     query.prepare("SELECT smartplaylistid, name, categoryid, matchtype, orderby, limitto " 
-                  "FROM smartplaylist WHERE name = :NAME AND categoryid = :CATEGORYID;");
+                  "FROM music_smartplaylist WHERE name = :NAME AND categoryid = :CATEGORYID;");
     query.bindValue(":NAME", name.utf8());
     query.bindValue(":CATEGORYID", categoryid);
     if (query.exec())
@@ -1285,7 +1304,7 @@
     uint rowCount;
     
     query.prepare("SELECT field, operator, value1, value2 " 
-                  "FROM smartplaylistitem WHERE smartplaylistid = :ID "
+                  "FROM music_smartplaylistitem WHERE smartplaylistid = :ID "
                   "ORDER BY smartplaylistitemid;");
     query.bindValue(":ID", ID);
     if (!query.exec())
@@ -1392,7 +1411,7 @@
     // insert new smartplaylistcategory
 
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("INSERT INTO smartplaylistcategory (name) "
+    query.prepare("INSERT INTO music_smartplaylistcategory (name) "
                 "VALUES (:NAME);");
     query.bindValue(":NAME", categoryEdit->text().utf8());
     
@@ -1438,7 +1457,7 @@
         
     // change the category     
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("UPDATE smartplaylistcategory SET name = :NEW_CATEGORY "
+    query.prepare("UPDATE music_smartplaylistcategory SET name = :NEW_CATEGORY "
                   "WHERE name = :OLD_CATEGORY;");
     query.bindValue(":OLD_CATEGORY", categoryCombo->currentText().utf8());
     query.bindValue(":NEW_CATEGORY", categoryEdit->text().utf8());
@@ -1458,8 +1477,12 @@
 QString SmartPlaylistEditor::getSQL(QString fields)
 {
     QString sql, whereClause, orderByClause, limitClause;
-    
-    sql = "SELECT " + fields + " FROM musicmetadata ";
+    sql = "SELECT " + fields + " FROM music_songs "
+          "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
+          "LEFT JOIN music_artists AS music_comp_artists ON music_songs.compilationartist_id=music_comp_artists.artist_id "
+          "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
+          "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id ";
+
     whereClause = getWhereClause();
     orderByClause = getOrderByClause();
     if (limitSpinEdit->value() > 0)
@@ -1506,7 +1529,7 @@
 
 void SmartPlaylistEditor::showResultsClicked(void)
 {
-    QString sql = getSQL("intid, artist, album, title, genre, year, tracknum");
+    QString sql = getSQL("song_id, music_artists.artist_name, album_name, name, genre, year, track");
     
     SmartPLResultViewer *resultViewer = new SmartPLResultViewer(gContext->GetMainWindow(), "resultviewer");
     resultViewer->setSQL(sql);
@@ -1535,7 +1558,7 @@
     categoryCombo->clear();
     MSqlQuery query(MSqlQuery::InitCon());
 
-    if (query.exec("SELECT name FROM smartplaylistcategory ORDER BY name;"))
+    if (query.exec("SELECT name FROM music_smartplaylistcategory ORDER BY name;"))
     {
         if (query.isActive() && query.numRowsAffected() > 0)
         {
@@ -1563,7 +1586,7 @@
     
     // get playlist ID
     int ID;
-    query.prepare("SELECT smartplaylistid FROM smartplaylist WHERE name = :NAME "
+    query.prepare("SELECT smartplaylistid FROM music_smartplaylist WHERE name = :NAME "
                   "AND categoryid = :CATEGORYID;");
     query.bindValue(":NAME", name.utf8());
     query.bindValue(":CATEGORYID", categoryid);
@@ -1588,13 +1611,13 @@
     } 
     
     //delete smartplaylist items
-    query.prepare("DELETE FROM smartplaylistitem WHERE smartplaylistid = :ID;");
+    query.prepare("DELETE FROM music_smartplaylistitem WHERE smartplaylistid = :ID;");
     query.bindValue(":ID", ID);
     if (!query.exec())
         MythContext::DBError("Delete smartplaylist items", query);
 
     //delete smartplaylist
-    query.prepare("DELETE FROM smartplaylist WHERE smartplaylistid = :ID;");
+    query.prepare("DELETE FROM music_smartplaylist WHERE smartplaylistid = :ID;");
     query.bindValue(":ID", ID);
     if (!query.exec())
         MythContext::DBError("Delete smartplaylist", query);
@@ -1610,7 +1633,7 @@
     MSqlQuery query(MSqlQuery::InitCon());
     
     //delete all smartplaylists with the selected category
-    query.prepare("SELECT name FROM smartplaylist "
+    query.prepare("SELECT name FROM music_smartplaylist "
                   "WHERE categoryid = :CATEGORYID;");
     query.bindValue(":CATEGORYID", categoryid);
     if (!query.exec())
@@ -1629,7 +1652,7 @@
     }
     
     // delete the category
-    query.prepare("DELETE FROM smartplaylistcategory WHERE categoryid = :ID;");
+    query.prepare("DELETE FROM music_smartplaylistcategory WHERE categoryid = :ID;");
     query.bindValue(":ID", categoryid);
     if (!query.exec())
         MythContext::DBError("Delete smartplaylist category", query);
@@ -1642,7 +1665,7 @@
 {    
     int ID;
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("SELECT categoryid FROM smartplaylistcategory "
+    query.prepare("SELECT categoryid FROM music_smartplaylistcategory "
                   "WHERE name = :CATEGORY;");
     query.bindValue(":CATEGORY", category.utf8());
 
@@ -2023,7 +2046,7 @@
     categoryCombo->clear();
     MSqlQuery query(MSqlQuery::InitCon());
 
-    if (query.exec("SELECT name FROM smartplaylistcategory ORDER BY name;"))
+    if (query.exec("SELECT name FROM music_smartplaylistcategory ORDER BY name;"))
     {
         if (query.isActive() && query.numRowsAffected() > 0)
         {
@@ -2045,7 +2068,7 @@
     listbox->clear();
 
     MSqlQuery query(MSqlQuery::InitCon());    
-    query.prepare("SELECT name FROM smartplaylist WHERE categoryid = :CATEGORYID "
+    query.prepare("SELECT name FROM music_smartplaylist WHERE categoryid = :CATEGORYID "
                   "ORDER BY name;");
     query.bindValue(":CATEGORYID", categoryid);
                    
Index: mythmusic/mythmusic/metadata.h
===================================================================
--- mythmusic/mythmusic/metadata.h	(revision 9730)
+++ mythmusic/mythmusic/metadata.h	(working copy)
@@ -18,7 +18,7 @@
     Metadata(QString lfilename = "", QString lartist = "", QString lcompilation_artist = "", 
              QString lalbum = "", QString ltitle = "", QString lgenre = "",
              int lyear = 0, int ltracknum = 0, int llength = 0, int lid = 0,
-             int lrating = 0, int lplaycount = 0, QString llastplay = "",
+             int lrating = 0, int lplaycount = 0, int lbitrate = 0, int lfilesize = 0, QString llastplay = "",
              bool lcompilation = false, QString lformat="")
             {
                 filename = lfilename;
@@ -35,6 +35,8 @@
                 id = lid;
                 rating = lrating;
                 playcount = lplaycount;
+		bitrate = lbitrate;
+		filesize = lfilesize;
                 lastplay = llastplay;
                 compilation = lcompilation;
                 changed = false;
@@ -59,6 +61,8 @@
                 rating = other.rating;
                 lastplay = other.lastplay;
                 playcount = other.playcount;
+		bitrate = other.bitrate;
+		filesize = other.filesize;
                 compilation = other.compilation;
                 show = other.show;
                 changed = false;
@@ -97,6 +101,12 @@
     int Playcount() { return playcount; }
     void setPlaycount(int lplaycount) { playcount = lplaycount; }
 
+    int Bitrate() { return bitrate; }
+    void setBitrate(int lbitrate) { bitrate = lbitrate; }
+
+    int Filesize() { return filesize; }
+    void setFilesize(int lfilesize) { filesize = lfilesize; }
+
     unsigned int ID() { return id; }
     void setID(int lid) { id = lid; }
     
@@ -158,6 +168,8 @@
     int rating;
     QString lastplay;
     int playcount;
+    int bitrate;
+    int filesize;
     bool compilation;
      
     unsigned int id;
Index: mythmusic/mythmusic/editmetadata.cpp
===================================================================
--- mythmusic/mythmusic/editmetadata.cpp	(revision 9730)
+++ mythmusic/mythmusic/editmetadata.cpp	(working copy)
@@ -368,14 +368,30 @@
 {
     searchList.clear();
     
-    QString querystr;
-    querystr = QString("SELECT DISTINCT %1 FROM musicmetadata ORDER BY %2").arg(field).arg(field);
-         
     MSqlQuery query(MSqlQuery::InitCon());
-    query.exec(querystr);
-
-    if (query.isActive() && query.size())
+    if ("artist" == field || "compilation_artist" == field)
     {
+        query.prepare("SELECT artist_name FROM music_artists ORDER BY artist_name;");
+    }
+    else if ("album" == field)
+    {
+        query.prepare("SELECT album_name FROM music_albums ORDER BY album_name;");
+    }
+    else if ("title" == field)
+    {
+        query.prepare("SELECT name FROM music_songs ORDER BY name;");
+    }
+    else if ("genre" == field)
+    {
+        query.prepare("SELECT genre FROM music_genres ORDER BY genre;");
+    }
+    else
+    {
+        return;
+    }
+        
+    if (query.exec() && query.isActive() && query.size())
+    {
         while (query.next())
         {
             searchList << QString::fromUtf8(query.value(0).toString());
Index: mythmusic/mythmusic/main.cpp
===================================================================
--- mythmusic/mythmusic/main.cpp	(revision 9730)
+++ mythmusic/mythmusic/main.cpp	(working copy)
@@ -76,6 +76,8 @@
     {
         Metadata *data = decoder->getMetadata();
         if (data) {
+	    QFileInfo fi1( filename );
+	    data->setFilesize( fi1.size() );	
             data->dumpToDatabase();
             delete data;
         }
@@ -90,7 +92,7 @@
     QString name(filename);
     name.remove(0, directory.length());
     MSqlQuery query(MSqlQuery::InitCon());
-    query.prepare("DELETE FROM musicmetadata WHERE "
+    query.prepare("DELETE FROM music_songs WHERE "
                   "filename = :NAME ;");
     query.bindValue(":NAME", filename.utf8());
     query.exec();
@@ -260,7 +262,7 @@
 
     MSqlQuery query(MSqlQuery::InitCon());
     query.exec("SELECT filename, date_modified "
-               "FROM musicmetadata "
+               "FROM music_songs "
                "WHERE filename NOT LIKE ('%://%')");
 
     int counter = 0;
@@ -558,7 +560,7 @@
 
 
     MSqlQuery count_query(MSqlQuery::InitCon());
-    count_query.exec("SELECT COUNT(*) FROM musicmetadata;");
+    count_query.exec("SELECT COUNT(*) FROM music_songs;");
 
     bool musicdata_exists = false;
     if (count_query.isActive())
Index: mythmusic/mythmusic/metaioid3v2.cpp
===================================================================
--- mythmusic/mythmusic/metaioid3v2.cpp	(revision 9730)
+++ mythmusic/mythmusic/metaioid3v2.cpp	(working copy)
@@ -174,7 +174,7 @@
 {
     QString artist = "", compilation_artist = "", album = "", title = "", 
             genre = "";
-    int year = 0, tracknum = 0, length = 0;
+    int year = 0, tracknum = 0, length = 0, bitrate = 0;
     bool compilation = false;
     id3_file *p_input = NULL;
     
@@ -251,6 +251,7 @@
     }
 
     length = getTrackLength(filename);
+    bitrate = getTrackBitRate(filename);
 
     // If we don't have title and artist or don't have the length return NULL
     if ((title.isEmpty() && artist.isEmpty()) || length<=0)
@@ -261,7 +262,8 @@
     }
 
     Metadata *retdata = new Metadata(filename, artist, compilation_artist, album,
-                                     title, genre, year, tracknum, length);
+                                     title, genre, year, tracknum, length, 0, 0,
+				     0, bitrate);
                                      
     retdata->setCompilation(compilation);
 
@@ -378,7 +380,113 @@
     return alt_length;
 }
 
+//==========================================================================
+/*!
+ * \brief Find the bitrate of the track (in bytes/sek)
+ *
+ * \param filename The filename for which we want to find the length.
+ * \returns An integer to represent the bitrate.
+ */
+int MetaIOID3v2::getTrackBitRate(QString filename)
+{
+    struct mad_stream stream;
+    struct mad_header header;
+    mad_timer_t timer;
 
+    unsigned char buffer[8192];
+    unsigned int buflen = 0;
+
+    mad_stream_init(&stream);
+    mad_header_init(&header);
+   
+    timer = mad_timer_zero;
+
+    FILE *input = fopen(filename.local8Bit(), "r");
+    if (!input)
+        input = fopen(filename.ascii(), "r");
+
+    if (!input)
+        return 0;
+
+    struct stat s;
+    fstat(fileno(input), &s);
+    unsigned long old_bitrate = 0;
+    bool vbr = false;
+    int amount_checked = 0;
+    bool loop_de_doo = true;
+    
+    while (loop_de_doo) 
+    {
+        if (buflen < sizeof(buffer)) 
+        {
+            int bytes;
+            bytes = fread(buffer + buflen, 1, sizeof(buffer) - buflen, input);
+            if (bytes <= 0)
+                break;
+            buflen += bytes;
+        }
+
+        mad_stream_buffer(&stream, buffer, buflen);
+
+        while (1)
+        {
+            if (mad_header_decode(&header, &stream) == -1)
+            {
+                if (!MAD_RECOVERABLE(stream.error))
+                {
+                    break;
+                }
+                if (stream.error == MAD_ERROR_LOSTSYNC)
+                {
+                    int tagsize = id3_tag_query(stream.this_frame,
+                                                stream.bufend - 
+                                                stream.this_frame);
+                    if (tagsize > 0)
+                    {
+                        mad_stream_skip(&stream, tagsize);
+                        s.st_size -= tagsize;
+                    }
+                }
+            }
+            else
+            {
+                if(amount_checked == 0)
+                {
+                    old_bitrate = header.bitrate;
+                }
+                else if(header.bitrate != old_bitrate)
+                {
+                    vbr = true;
+                }
+                if(amount_checked == 32 && !vbr)
+                {
+                    loop_de_doo = false;
+                    break;
+                }
+                amount_checked++;
+                mad_timer_add(&timer, header.duration);
+            }
+            
+        }
+        
+        if (stream.error != MAD_ERROR_BUFLEN)
+            break;
+
+        memmove(buffer, stream.next_frame, &buffer[buflen] - stream.next_frame);
+        buflen -= stream.next_frame - &buffer[0];
+    }
+
+    mad_header_finish(&header);
+    mad_stream_finish(&stream);
+
+    fclose(input);
+
+//    if (vbr)
+//        return mad_timer_count(timer, MAD_UNITS_MILLISECONDS);
+
+    return old_bitrate;
+}
+
 inline QString MetaIOID3v2::getRawID3String(union id3_field *pField)
 {
     QString tmp = "";
