Ticket #1919: mythmusic_schema_mythweb_full.diff

File mythmusic_schema_mythweb_full.diff, 124.5 KB (added by Colin Guthrie <mythtv@…>, 6 years ago)

v2 Myth Web Only Changes

  • mythweb/skins/default/music.css

     
     1mp3act { 
     2        padding: 22px; 
     3        margin:0; 
     4        color: #333; 
     5        text-align: center; 
     6        font: 65% Verdana, Sans-serif; 
     7} 
     8 
     9h2.music{ 
     10        font-size: 100%; 
     11        margin:0; 
     12        padding: 0 0 5px 0; 
     13 
     14} 
     15ul.music{ 
     16        list-style-type: none; 
     17} 
     18a.music{ 
     19        color: blue; 
     20} 
     21 
     22a.music:hover{ 
     23        /*color: #fff; 
     24        background: #F21518; 
     25        text-decoration: none;*/ 
     26        color: #F21518; 
     27} 
     28img{ 
     29        border: 0; 
     30} 
     31input,select{ 
     32        border: 1px solid #ccc; 
     33        border-color: #aaa #ccc #ccc #aaa; 
     34        background: #f3f3f3; 
     35        color: #555; 
     36        font-size: 100%; 
     37        padding: 2px 3px; 
     38        vertical-align: middle; 
     39 
     40} 
     41input.check{ 
     42  border:0; 
     43  padding:0; 
     44  background: transparent; 
     45} 
     46select{ 
     47        padding: 2px 0 2px 3px; 
     48} 
     49input:focus{ 
     50        border: 1px solid #999; 
     51        background: #FBF9D3; 
     52        color: #000; 
     53        border-color: #777 #bbb #bbb #777; 
     54} 
     55 
     56input.btn,input.redbtn{ 
     57        background: #244A79; 
     58        color: #fff; 
     59        padding: 2px; 
     60        border-color: #0E2F58; 
     61        font: normal 10px sans-serif; 
     62} 
     63input.redbtn{ 
     64        background: #F21518; 
     65} 
     66input.redbtn:hover{ 
     67        background: #BE0D0F; 
     68} 
     69input.btn:hover{ 
     70        background: #0E2F58; 
     71} 
     72 
     73input.btn2{ 
     74        font-weight: bold; 
     75        padding: 2px; 
     76} 
     77 
     78input.btn2:hover{ 
     79        background: #eee; 
     80        border-color: #888; 
     81        color: #222; 
     82} 
     83 
     84.left{ 
     85        float: left; 
     86} 
     87.right{ 
     88        float: right; 
     89} 
     90.center{ 
     91        text-align: center; 
     92} 
     93.clear{ 
     94  clear: both; 
     95} 
     96.error{ 
     97        color: #E63838; 
     98        font-weight: bold; 
     99} 
     100p#error{ 
     101        color: #f20000; 
     102        font-weight: bold; 
     103} 
     104#breadcrumb{ 
     105        height: 14px; 
     106        padding:2px 0 0 0; 
     107} 
     108#breadcrumb span{ 
     109position: relative; 
     110} 
     111#breadcrumb span:hover ul{ 
     112        display: block; 
     113} 
     114#breadcrumb ul{ 
     115        z-index: 5; 
     116        border: 1px solid #333; 
     117        display: none; 
     118        top:12px; 
     119        left:0; 
     120        position: absolute; 
     121        background: transparent url("./img/music/libg.png"); 
     122        color: #fff; 
     123        margin:-1px 0 0 0; 
     124        padding:0; 
     125        width: 150px; 
     126 
     127} 
     128#breadcrumb ul#letters{ 
     129        left: -55px; 
     130        width: auto; 
     131} 
     132#breadcrumb span{ 
     133        padding: 0; 
     134        margin:0; 
     135} 
     136#breadcrumb ul li{ 
     137width: 100%; 
     138        padding:0; 
     139        margin:0; 
     140        z-index: 6; 
     141} 
     142#breadcrumb ul li a{ 
     143        display: block; 
     144        padding: 2px 4px; 
     145        color: #fff; 
     146        margin:0; 
     147        z-index: 5; 
     148        text-decoration: none; 
     149        font-weight: normal; 
     150        font-size: 90%; 
     151} 
     152 
     153#breadcrumb ul#letters li{ 
     154        float: left; 
     155 
     156} 
     157#breadcrumb ul#letters li a{ 
     158        float: left; 
     159 
     160} 
     161#breadcrumb ul li a:hover{ 
     162        background: #FCF7A5; 
     163        color: #000; 
     164} 
     165#breadcrumb ul#letters li a:hover{ 
     166        background: #FCF7A5; 
     167        color: #000; 
     168} 
     169#topinfo{ 
     170 
     171        font-size: 90%; 
     172        color: #666; 
     173        text-align: left; 
     174        padding: 0 0 4px 0; 
     175 
     176} 
     177p.pad{ 
     178        padding: 0px 8px; 
     179} 
     180 
     181#wrap{ 
     182        /*background: #fff; 
     183        border: 1px solid #ccc;*/ 
     184        text-align: left; 
     185        padding: 0px; 
     186        margin:0; 
     187        position: relative; 
     188 
     189        color: #333; 
     190} 
     191 
     192#header{ 
     193        position: relative; 
     194/*      background: #0E2F58;*/ 
     195        height: 50px; 
     196        color: #fff; 
     197        padding: 8px 0 0px 15px; 
     198} 
     199#header #controls{ 
     200        float: right; 
     201        background: transparent; 
     202        height: 48px; 
     203        margin-right: 8px; 
     204        width: 48%; 
     205        font-size: 90%; 
     206        line-height: 1.1em; 
     207        color: #fff; 
     208} 
     209 
     210#header #controls .buttons{ 
     211        float: left; 
     212        margin: 3px 5px 0 5px; 
     213} 
     214#header #controls .current{ 
     215        float: left; 
     216        margin-top: 3px; 
     217 
     218} 
     219#header h1{ 
     220        color: #9ABEE5; 
     221        padding: 0; 
     222        margin:0; 
     223        font-size: 150%; 
     224} 
     225ul#nav{ 
     226        position: absolute; 
     227        bottom:0; 
     228        list-style-type: none; 
     229        margin:0; 
     230        padding:0; 
     231} 
     232ul#nav li{ 
     233        float: left; 
     234        margin-right: 5px; 
     235} 
     236ul#nav li a{ 
     237        display: block; 
     238        background: #265990; /* #244A79; */ 
     239        padding: 4px 5px; 
     240        color: #dedede; 
     241        text-decoration: none; 
     242        margin:0; 
     243} 
     244ul#nav li a:hover{ 
     245        background: #416899; 
     246        color: #fff; 
     247} 
     248ul#nav li a.c{ 
     249        background: #fff; 
     250        color: #F48603; 
     251        font-weight: bold; 
     252} 
     253#loading{ 
     254        display: none; 
     255        position: absolute; 
     256        top: 80px; 
     257        color: #78B855; 
     258        padding: 10px; 
     259        background: #CCFF99; 
     260        border: 1px solid #78B855; 
     261        z-index: 4; 
     262        left: 30%; 
     263} 
     264#loading h1{ 
     265  font-size: 140%; 
     266} 
     267#left{ 
     268        float: left; 
     269        width: 48%; 
     270        margin: 15px 0 25px 15px; 
     271} 
     272#right{ 
     273        float: right; 
     274        width: 45%; 
     275        margin: 15px 15px 25px 0; 
     276 
     277} 
     278.box{ 
     279        background: #E0E0E0; 
     280        border: 1px solid #ccc; 
     281        padding: 0 0 8px 0; 
     282        position: relative; 
     283} 
     284#box_extra{ 
     285        display: none; 
     286        z-index: 2; 
     287        position: absolute; 
     288        top: 25px; 
     289        left:5%; 
     290        width: 450px; 
     291        height: 230px; 
     292        background: transparent url("./img/music/libg.png"); 
     293        color: #fff; 
     294        font-size: 110%; 
     295        padding: 5px; 
     296} 
     297#box_extra h2{ 
     298        font-size: 120%; 
     299} 
     300#box_extra input{ 
     301        background: #333; 
     302        border-color: #999; 
     303        color: #fff; 
     304} 
     305 
     306#box_extra select{ 
     307        background: #333; 
     308        border-color: #999; 
     309        color: #fff; 
     310} 
     311 
     312.box ul{ 
     313        margin: 0 10px; 
     314        padding: 0px 0px; 
     315        background: #f3f3f3; 
     316        clear: both; 
     317} 
     318.box ul li{ 
     319        padding: 2px 0 1px 4px; 
     320        border: 1px solid transparent; 
     321        border-width: 1px 0px 1px 0px; 
     322        position: relative; 
     323        background: #f3f3f3; 
     324} 
     325 
     326.box ul li.alt{ 
     327        background: #DEE6EC; 
     328} 
     329.box ul li span.user{ 
     330        float: left; 
     331        width: 200px; 
     332} 
     333.box ul li small{ 
     334        color: #888; 
     335        letter-spacing: -1px; 
     336} 
     337 
     338.box ul li span.links a{ 
     339        text-decoration: underline; 
     340        color: blue; 
     341} 
     342.box ul li span.links a:hover{ 
     343        color: red; 
     344} 
     345.box ul li:hover{ 
     346        background: #FCF7A5; 
     347        color: #000; 
     348        border-color: #999; 
     349} 
     350.box ul li.currentplay{ 
     351        background: #96D1EF; 
     352        color: #000; 
     353        border-color: #666; 
     354} 
     355 
     356.box ul li p{ 
     357        z-index:5; 
     358        display: none; 
     359        position: absolute; 
     360        top: 7px; 
     361        font-size: 90%; 
     362        padding: 2px; 
     363        right: 15px; 
     364        width: 145px; 
     365        background: transparent url("./img/music/libg.png"); 
     366        color: #fff; 
     367} 
     368 
     369.box ul li:hover p{ 
     370        display: block; 
     371} 
     372 
     373.box ul li a{ 
     374        text-decoration: none; 
     375        color: #333; 
     376} 
     377.box ul li a:hover{ 
     378        color: #000; 
     379} 
     380.box ul#letters{ 
     381        height: 18px; 
     382        padding-left: 5px; 
     383} 
     384 
     385.box ul#letters li{ 
     386        float: left; 
     387        padding: 2px 2px; 
     388        background: none; 
     389        border: 1px solid transparent; 
     390} 
     391 
     392.box ul#letters li:hover{ 
     393        background: #FCF7A5; 
     394        border-color: #999; 
     395} 
     396 
     397.box p{ 
     398        padding: 0 10px; 
     399        margin: 8px 0 4px 0; 
     400 
     401} 
     402.box p img{ 
     403        display: block; 
     404        width: 60px; 
     405        float: right; 
     406        padding: 2px; 
     407        background: #f3f3f3; 
     408        border: 1px solid #999; 
     409        margin-bottom: 4px; 
     410} 
     411.box img#bigart{ 
     412        display: none; 
     413        position: absolute; 
     414        z-index: 2; 
     415        background: #f3f3f3; 
     416        padding: 3px; 
     417        border: 1px solid #666; 
     418        top:10px; 
     419        right: 80px; 
     420} 
     421.box p img:hover{ 
     422        border-color: #555; 
     423        cursor: pointer; 
     424} 
     425 
     426.box .head{ 
     427        padding: 4px; 
     428        background: #ccc; 
     429} 
     430.box .head a{ 
     431        background: #244A79; 
     432        color: #fff; 
     433        padding: 2px; 
     434        text-decoration: none; 
     435        font: normal 9px sans-serif; 
     436} 
     437.box .head a:hover{ 
     438        background: #0E2F58; 
     439} 
     440.box .head a.red{ 
     441        background: #F21518; 
     442} 
     443.box .head a.red:hover{ 
     444        background: #BE0D0F; 
     445} 
     446.box .head h2{ 
     447        font-size: 120%; 
     448        padding: 0; 
     449} 
     450.box h3{ 
     451        padding: 0 0 0 0px; 
     452        margin: 0 10px 0 10px; 
     453        font-size: 120%; 
     454        border-bottom: 1px solid #ccc; 
     455} 
     456 
     457.loginbox{ 
     458        width: 250px; 
     459        margin:0 auto; 
     460        background: #fff; 
     461        border: 1px solid #ccc; 
     462        text-align: left; 
     463} 
     464.loginbox p{ 
     465        padding: 8px 15px; 
     466        margin:0; 
     467} 
     468.noborder{ 
     469        background: transparent; 
     470        border:0; 
     471} 
  • mythweb/skins/grey/music.css

    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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/gif
    
    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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/x-png
    
    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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/gif
    
     
     1mp3act { 
     2        padding: 22px; 
     3        margin:0; 
     4        color: #333; 
     5        text-align: center; 
     6        font: 65% Verdana, Sans-serif; 
     7} 
     8 
     9h2.music{ 
     10        font-size: 100%; 
     11        margin:0; 
     12        padding: 0 0 5px 0; 
     13 
     14} 
     15ul.music{ 
     16        list-style-type: none; 
     17} 
     18a.music{ 
     19        color: blue; 
     20} 
     21 
     22a.music:hover{ 
     23        /*color: #fff; 
     24        background: #F21518; 
     25        text-decoration: none;*/ 
     26        color: #F21518; 
     27} 
     28img{ 
     29        border: 0; 
     30} 
     31input,select{ 
     32        border: 1px solid #ccc; 
     33        border-color: #aaa #ccc #ccc #aaa; 
     34        background: #f3f3f3; 
     35        color: #555; 
     36        font-size: 100%; 
     37        padding: 2px 3px; 
     38        vertical-align: middle; 
     39         
     40} 
     41input.check{ 
     42  border:0; 
     43  padding:0; 
     44  background: transparent; 
     45} 
     46select{ 
     47        padding: 2px 0 2px 3px; 
     48} 
     49input:focus{ 
     50        border: 1px solid #999; 
     51        background: #FBF9D3; 
     52        color: #000; 
     53        border-color: #777 #bbb #bbb #777; 
     54} 
     55 
     56input.btn,input.redbtn{ 
     57        background: #244A79; 
     58        color: #fff; 
     59        padding: 2px; 
     60        border-color: #0E2F58; 
     61        font: normal 10px sans-serif; 
     62} 
     63input.redbtn{ 
     64        background: #F21518;     
     65} 
     66input.redbtn:hover{ 
     67        background: #BE0D0F; 
     68} 
     69input.btn:hover{ 
     70        background: #0E2F58; 
     71} 
     72 
     73input.btn2{ 
     74        font-weight: bold; 
     75        padding: 2px; 
     76} 
     77 
     78input.btn2:hover{ 
     79        background: #eee; 
     80        border-color: #888; 
     81        color: #222; 
     82} 
     83 
     84.left{ 
     85        float: left; 
     86} 
     87.right{ 
     88        float: right; 
     89} 
     90.center{ 
     91        text-align: center; 
     92} 
     93.clear{ 
     94  clear: both; 
     95} 
     96.error{ 
     97        color: #E63838; 
     98        font-weight: bold; 
     99} 
     100p#error{ 
     101        color: #f20000; 
     102        font-weight: bold; 
     103} 
     104#breadcrumb{ 
     105        height: 14px; 
     106        padding:2px 0 0 0; 
     107} 
     108#breadcrumb span{ 
     109position: relative; 
     110} 
     111#breadcrumb span:hover ul{ 
     112        display: block; 
     113} 
     114#breadcrumb ul{ 
     115        z-index: 5; 
     116        border: 1px solid #333; 
     117        display: none; 
     118        top:12px; 
     119        left:0; 
     120        position: absolute; 
     121        background: transparent url("./img/music/libg.png"); 
     122        color: #fff; 
     123        margin:-1px 0 0 0; 
     124        padding:0; 
     125        width: 150px; 
     126         
     127} 
     128#breadcrumb ul#letters{ 
     129        left: -55px; 
     130        width: auto; 
     131} 
     132#breadcrumb span{ 
     133        padding: 0; 
     134        margin:0; 
     135} 
     136#breadcrumb ul li{ 
     137width: 100%; 
     138        padding:0; 
     139        margin:0; 
     140        z-index: 6; 
     141} 
     142#breadcrumb ul li a{ 
     143        display: block; 
     144        padding: 2px 4px; 
     145        color: #fff; 
     146        margin:0; 
     147        z-index: 5; 
     148        text-decoration: none; 
     149        font-weight: normal; 
     150        font-size: 90%; 
     151} 
     152 
     153#breadcrumb ul#letters li{ 
     154        float: left; 
     155 
     156} 
     157#breadcrumb ul#letters li a{ 
     158        float: left; 
     159         
     160} 
     161#breadcrumb ul li a:hover{ 
     162        background: #FCF7A5; 
     163        color: #000; 
     164} 
     165#breadcrumb ul#letters li a:hover{ 
     166        background: #FCF7A5; 
     167        color: #000; 
     168} 
     169#topinfo{ 
     170         
     171        font-size: 90%; 
     172        color: #666; 
     173        text-align: left; 
     174        padding: 0 0 4px 0; 
     175         
     176} 
     177p.pad{ 
     178        padding: 0px 8px; 
     179} 
     180 
     181#wrap{ 
     182        /*background: #fff; 
     183        border: 1px solid #ccc;*/ 
     184        text-align: left; 
     185        padding: 0px; 
     186        margin:0; 
     187        position: relative; 
     188 
     189        color: #333; 
     190} 
     191 
     192#header{ 
     193        position: relative; 
     194/*      background: #0E2F58;*/ 
     195        height: 50px; 
     196        color: #fff; 
     197        padding: 8px 0 0px 15px; 
     198} 
     199#header #controls{ 
     200        float: right; 
     201        background: transparent; 
     202        height: 48px; 
     203        margin-right: 8px; 
     204        width: 48%; 
     205        font-size: 90%; 
     206        line-height: 1.1em; 
     207        color: #fff; 
     208} 
     209 
     210#header #controls .buttons{ 
     211        float: left; 
     212        margin: 3px 5px 0 5px; 
     213} 
     214#header #controls .current{ 
     215        float: left; 
     216        margin-top: 3px; 
     217         
     218} 
     219#header h1{ 
     220        color: #9ABEE5; 
     221        padding: 0; 
     222        margin:0; 
     223        font-size: 150%; 
     224} 
     225ul#nav{ 
     226        position: absolute; 
     227        bottom:0; 
     228        list-style-type: none; 
     229        margin:0; 
     230        padding:0; 
     231} 
     232ul#nav li{ 
     233        float: left; 
     234        margin-right: 5px; 
     235} 
     236ul#nav li a{ 
     237        display: block; 
     238        background: #666666; //#244A79; 
     239        padding: 4px 5px; 
     240        color: #ffffff; 
     241        text-decoration: none; 
     242        margin:0; 
     243} 
     244ul#nav li a:hover{ 
     245        background: #416899; 
     246        color: #fff; 
     247} 
     248ul#nav li a.c{ 
     249        background: #fff; 
     250        color: #F48603; 
     251        font-weight: bold; 
     252} 
     253#loading{ 
     254        display: none; 
     255        position: absolute; 
     256        top: 80px; 
     257        color: #78B855; 
     258        padding: 10px; 
     259        background: #CCFF99; 
     260        border: 1px solid #78B855; 
     261        z-index: 4; 
     262        left: 30%; 
     263} 
     264#loading h1{ 
     265  font-size: 140%; 
     266} 
     267#left{ 
     268        float: left; 
     269        width: 48%; 
     270        margin: 15px 0 25px 15px; 
     271} 
     272#right{ 
     273        float: right; 
     274        width: 45%; 
     275        margin: 15px 15px 25px 0; 
     276 
     277} 
     278.box{ 
     279        background: #E0E0E0; 
     280        border: 1px solid #ccc; 
     281        padding: 0 0 8px 0; 
     282        position: relative; 
     283} 
     284#box_extra{ 
     285        display: none; 
     286        z-index: 2; 
     287        position: absolute; 
     288        top: 25px; 
     289        left:5%; 
     290        width: 450px; 
     291        height: 190px; 
     292        background: transparent url("./img/music/libg.png"); 
     293        color: #fff; 
     294        font-size: 110%; 
     295        padding: 5px; 
     296} 
     297#box_extra h2{ 
     298        font-size: 120%; 
     299} 
     300#box_extra input{ 
     301        background: #333; 
     302        border-color: #999; 
     303        color: #fff; 
     304} 
     305 
     306#box_extra select{ 
     307        background: #333; 
     308        border-color: #999; 
     309        color: #fff; 
     310} 
     311 
     312.box ul{ 
     313        margin: 0 10px; 
     314        padding: 0px 0px; 
     315        background: #f3f3f3; 
     316        clear: both; 
     317} 
     318.box ul li{ 
     319        padding: 2px 0 1px 4px; 
     320        border: 1px solid transparent; 
     321        border-width: 1px 0px 1px 0px; 
     322        position: relative; 
     323        background: #f3f3f3;  
     324} 
     325 
     326.box ul li.alt{ 
     327        background: #DEE6EC; 
     328} 
     329.box ul li span.user{ 
     330        float: left; 
     331        width: 200px; 
     332} 
     333.box ul li small{ 
     334        color: #888; 
     335        letter-spacing: -1px; 
     336} 
     337 
     338.box ul li span.links a{ 
     339        text-decoration: underline; 
     340        color: blue; 
     341} 
     342.box ul li span.links a:hover{ 
     343        color: red; 
     344} 
     345.box ul li:hover{ 
     346        background: #FCF7A5; 
     347        color: #000; 
     348        border-color: #999; 
     349} 
     350.box ul li.currentplay{ 
     351        background: #96D1EF; 
     352        color: #000; 
     353        border-color: #666; 
     354} 
     355 
     356.box ul li p{ 
     357        z-index:5; 
     358        display: none; 
     359        position: absolute; 
     360        top: 7px; 
     361        font-size: 90%; 
     362        padding: 2px; 
     363        right: 15px; 
     364        width: 145px; 
     365        background: transparent url("./img/music/libg.png"); 
     366        color: #fff; 
     367} 
     368 
     369.box ul li:hover p{ 
     370        display: block; 
     371} 
     372 
     373.box ul li a{ 
     374        text-decoration: none; 
     375        color: #333; 
     376} 
     377.box ul li a:hover{ 
     378        color: #000; 
     379} 
     380.box ul#letters{ 
     381        height: 18px; 
     382        padding-left: 5px; 
     383} 
     384 
     385.box ul#letters li{ 
     386        float: left; 
     387        padding: 2px 2px; 
     388        background: none; 
     389        border: 1px solid transparent; 
     390} 
     391 
     392.box ul#letters li:hover{ 
     393        background: #FCF7A5; 
     394        border-color: #999; 
     395} 
     396 
     397.box p{ 
     398        padding: 0 10px; 
     399        margin: 8px 0 4px 0; 
     400 
     401} 
     402.box p img{ 
     403        display: block; 
     404        width: 60px; 
     405        float: right; 
     406        padding: 2px; 
     407        background: #f3f3f3; 
     408        border: 1px solid #999; 
     409        margin-bottom: 4px;      
     410} 
     411.box img#bigart{ 
     412        display: none; 
     413        position: absolute; 
     414        z-index: 2; 
     415        background: #f3f3f3; 
     416        padding: 3px; 
     417        border: 1px solid #666; 
     418        top:10px; 
     419        right: 80px; 
     420} 
     421.box p img:hover{ 
     422        border-color: #555; 
     423        cursor: pointer; 
     424} 
     425 
     426.box .head{ 
     427        padding: 4px; 
     428        background: #ccc; 
     429} 
     430.box .head a{ 
     431        background: #244A79; 
     432        color: #fff; 
     433        padding: 2px; 
     434        text-decoration: none; 
     435        font: normal 9px sans-serif; 
     436} 
     437.box .head a:hover{ 
     438        background: #0E2F58; 
     439} 
     440.box .head a.red{ 
     441        background: #F21518; 
     442}        
     443.box .head a.red:hover{ 
     444        background: #BE0D0F; 
     445} 
     446.box .head h2{ 
     447        font-size: 120%; 
     448        padding: 0; 
     449} 
     450.box h3{ 
     451        padding: 0 0 0 0px; 
     452        margin: 0 10px 0 10px; 
     453        font-size: 120%; 
     454        border-bottom: 1px solid #ccc; 
     455} 
     456 
     457.loginbox{ 
     458        width: 250px; 
     459        margin:0 auto; 
     460        background: #fff; 
     461        border: 1px solid #ccc; 
     462        text-align: left; 
     463} 
     464.loginbox p{ 
     465        padding: 8px 15px; 
     466        margin:0; 
     467} 
     468.noborder{ 
     469        background: transparent; 
     470        border:0; 
     471} 
  • mythweb/modules/music/mp3act_main.php

    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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/gif
    
    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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/x-png
    
    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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/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:mime-type
       + application/octet-stream
    Name: svn:mimetype
       + image/gif
    
     
     1<?php 
     2/************************************************************************* 
     3*  mp3act Digital Music System - A streaming and jukebox solution for your digital music collection 
     4*  http://www.mp3act.net 
     5*  Copyright (C) 2005 Jon Buda (www.jonbuda.com) 
     6* 
     7*  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. 
     8 
     9*  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. 
     10* 
     11*  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 
     12*************************************************************************/ 
     13 
     14require_once("modules/music/mp3act_functions.php"); 
     15require_once("modules/music/mp3act_sajax.php"); 
     16 
     17GarbageCollector(); 
     18 
     19$sajax_remote_uri = 'http://'.$_SERVER['HTTP_HOST'].substr($_SERVER['SCRIPT_NAME'],0,strlen($_SERVER['SCRIPT_NAME']) - 11).'music/'; 
     20$sajax_request_type = "POST"; 
     21sajax_init(); 
     22sajax_export("getplaylistnames","musicLookup","playlist_rem","playlist_add","playlistInfo","clearPlaylist","buildBreadcrumb","play","playlist_move","searchMusic","viewPlaylist","getDropDown","savePlaylist","getRandItems","randAdd","deletePlaylist"); 
     23sajax_handle_client_request(); 
     24 
     25require 'modules/_shared/tmpl/'.tmpl.'/header.php'; 
     26?> 
     27<link rel="Stylesheet" href="<?php echo skin_url ?>music.css" type="text/css" /> 
     28 
     29        <script type="text/javascript"> 
     30                        var page = 'search'; 
     31                        var mode = '<?php echo $_SESSION['sess_playmode']; ?>'; 
     32                        var bc_parenttype = ''; 
     33                        var bc_parentitem = ''; 
     34                        var bc_childtype = ''; 
     35                        var bc_childitem = ''; 
     36                        var prevpage = ''; 
     37                        var currentpage = 'search'; 
     38                        var nowplaying = 0; 
     39                        var isplaying = 0; 
     40                        var clearbc = 1; 
     41 
     42  function getCookie( cookieName ) { 
     43      var cookies = document.cookie; 
     44      var substr1 = cookies.split( cookieName+'=' ) 
     45          if ( substr1 == cookies ) return -1; 
     46      var substr2 = substr1[1].split( ';' ); 
     47      var len1 = substr1[0].length + cookieName.length + 1; 
     48      var len2 = substr2[0].length 
     49      return cookies.substring( len1, len1+len2 ); 
     50  } 
     51 
     52  function checkPlaylistLoad( playlistId, unsavedPlaylistId ) { 
     53    var pl_id = getCookie('mp3act_playlist_id'); 
     54    if (pl_id < 1) return true; 
     55    if (playlistId == pl_id) { 
     56        alert ('<?php echo t('This playlist is already loaded!'); ?>'); 
     57        return false; 
     58    } 
     59    if (unsavedPlaylistId == pl_id) { 
     60        return confirm('<?php echo t('This will overwrite your current, unsaved playlist. Are you sure you want to continue?'); ?>'); 
     61    } 
     62    return true; 
     63  } 
     64        <?php sajax_show_javascript(); ?></script> 
     65        <script type="text/javascript" src="<?php echo root; ?>music/mp3act_js.js.php"></script> 
     66        <script type="text/javascript" src="<?php echo root; ?>music/mp3act_fat.js"></script> 
     67 
     68<div id="wrap"> 
     69        <div id="header"> 
     70                <div id="controls"> 
     71 
     72                </div> 
     73                <h1 id="pagetitle"></h1> 
     74                <ul class="music" id="nav"> 
     75                        <li><a href="#" id="search_music" onclick="switchPage('search'); return false;" title="<?php echo t('Search the Music Database'); ?>"><?php echo t('Search'); ?></a></li> 
     76                        <li><a href="#" id="browse" onclick="switchPage('browse'); return false;"  title="<?php echo t('Browse the Music Database'); ?>" class="c"><?php echo t('Browse'); ?></a></li> 
     77                        <li><a href="#" id="random" onclick="switchPage('random'); return false;" title="Create Random Mixes"><?php echo t('Random'); ?></a></li> 
     78                        <li><a href="#" id="playlists" onclick="switchPage('playlists'); return false;" title="<?php echo t('Load Saved Playlists'); ?>"><?php echo t('Playlists'); ?></a></li> 
     79                        <li><a href="#" id="stats" onclick="switchPage('stats'); return false;" title="<?php echo t('View Server Statistics'); ?>"><?php echo t('Stats'); ?></a></li> 
     80            <!-- <li><?php echo t('Streaming Quality'); ?>: <select id="stream_quality"><option value="high"><?php echo t('High'); ?></option></select></li> --> 
     81                </ul> 
     82 
     83        </div> 
     84        <div id="loading"><h1><?php echo t("LOADING"); ?>...</h1></div> 
     85        <div id="left"> 
     86                <h2 id="breadcrumb"></h2> 
     87                <div class="box" id="info"> 
     88                </div> 
     89        </div> 
     90 
     91        <div id="right"> 
     92                        <div class="box"> 
     93                                <div class="head"> 
     94                                        <div class="right"><a href="#" onclick="play('pl',0); return false;" title="<?php echo t('Play This Playlist Now'); ?>"><?php echo t('Play'); ?></a> <a href="#" onclick="savePL('open',0); return false;" title="<?php echo t('Save or Rename the Current Playlist'); ?>"><?php echo t('Save/Rename'); ?></a> <a href="#" onclick="plclear(); return false;" class="red" title="<?php echo t('Create a New Playlist'); ?>"><?php echo t('New'); ?></a></div> 
     95                                        <h2 id="pl_title"></h2><span id="pl_info"></span> 
     96                                </div> 
     97                        <ul class="music" id="playlist"> 
     98 
     99                        </ul> 
     100 
     101                        <div id="box_extra"> </div> 
     102                        </div> 
     103        </div> 
     104        <div class="clear"></div> 
     105</div> 
     106<iframe src="<?php echo root; ?>music/mp3act_hidden.php" frameborder="0" height="0" width="0" id="hidden" name="hidden"></iframe> 
     107<? 
     108require 'modules/_shared/tmpl/'.tmpl.'/footer.php'; 
     109?> 
     110 No newline at end of file 
  • mythweb/modules/music/handler.php

     
    1313 * 
    1414/**/ 
    1515 
    16 // Make sure the music directory exists 
    17     if (file_exists('data/music')) { 
    18     // File is not a directory or a symlink 
    19         if (!is_dir('data/music') && !is_link('data/music')) { 
    20             custom_error('An invalid file exists at data/music.  Please remove it in' 
    21                         .' order to use the music portions of MythWeb.'); 
    22         } 
    23     } 
    24 // Create the symlink, if possible. 
    25 // 
    26 // NOTE:  Errors have been disabled because if I turn them on, people hosting 
    27 //        MythWeb on Windows machines will have issues.  I will turn the errors 
    28 //        back on when I find a clean way to do so. 
    29 // 
    30     else { 
    31         $dir = $db->query_col('SELECT data 
    32                                  FROM settings 
    33                                 WHERE value="MusicLocation" AND hostname=?', 
    34                               hostname 
    35                              ); 
    36         if ($dir) { 
    37             $ret = @symlink($dir, 'data/music'); 
    38             if (!$ret) { 
    39                 #custom_error("Could not create a symlink to $dir, the local MythMusic directory" 
    40                 #            .' for this hostname ('.hostname.').  Please create a symlink to your' 
    41                 #            .' MythMusic directory at data/music in order to use the music' 
    42                 #            .' portions of MythWeb.'); 
    43             } 
    44         } 
    45         else { 
    46             #custom_error('Could not find a value in the database for the MythMusic directory' 
    47             #            .' for this hostname ('.hostname.').  Please create a symlink to your' 
    48             #            .' MythMusic directory at data/music in order to use the music' 
    49             #            .' portions of MythWeb.'); 
    50         } 
    51     } 
    52  
    53 // 
    54 //  Someday, music.php will let us stream 
    55 //  entire playlists to any spot on planet earth 
    56 // 
    57 require_once tmpl_dir.'music.php'; 
    58  
    59 $mythmusic = new mythMusic(); 
    60 $mythmusic->display(); 
    61  
    62 class mythMusic { 
    63     var $filterPlaylist; 
    64     var $filterArtist; 
    65     var $filterAlbum; 
    66     var $filterGenre; 
    67     var $filterRank; 
    68     var $filterSonglist; 
    69     var $keepFilters; 
    70     var $filter; 
    71     var $totalCount; 
    72     var $offset; 
    73  
    74     var $result; 
    75  
    76  
    77     var $intid; 
    78     var $artist; 
    79     var $album; 
    80     var $title; 
    81     var $genre; 
    82     var $length; 
    83     var $rating; 
    84     var $filename; 
    85     var $urlfilename; 
    86  
    87     var $alphalink; 
    88     var $alphaoffset; 
    89  
    90     function mythMusic() 
    91     { 
    92         if($_GET['offset'] >=0 ) 
    93             $this->offset=$_GET['offset']; 
    94         else 
    95             $this->offset=0; 
    96  
    97         /**** If alphalink set, then change offset to new value ****/ 
    98         if ($_GET['alphalink']) { 
    99             $alphalink = $_GET['alphalink']; 
    100             $result=mysql_query("select count(1) from musicmetadata where upper(artist) < ".escape($alphalink)); 
    101             $alphaoffset=mysql_fetch_row($result); 
    102             $this->offset=$alphaoffset[0]; 
    103             mysql_free_result($result); 
    104         } 
    105  
    106         if($_GET['filterPlaylist']) 
    107         { 
    108             $this->filterPlaylist=$_GET['filterPlaylist']; 
    109             $_GET['filterPlaylist']; 
    110         } 
    111         else 
    112             $this->filterPlaylist="_All_"; 
    113  
    114         if($_GET['filterArtist']) 
    115         { 
    116             $this->filterArtist=$_GET['filterArtist']; 
    117         } 
    118         else 
    119             $this->filterArtist="_All_"; 
    120  
    121         if($_GET['filterAlbum']) 
    122         { 
    123             $this->filterAlbum=$_GET['filterAlbum']; 
    124         } 
    125         else 
    126             $this->filterAlbum="_All_"; 
    127         if($_GET['filterGenre']) 
    128         { 
    129             $this->filterGenre=$_GET['filterGenre']; 
    130         } 
    131         else 
    132             $this->filterGenre="_All_"; 
    133  
    134  
    135         if($_GET['filterRank']) 
    136             $this->filterRank=$_GET['filterRank']; 
    137         else 
    138             $this->filterRank="_All_"; 
    139     } 
    140  
    141     function readRow() 
    142     { 
    143  
    144             if($row=mysql_fetch_row($this->result)) 
    145             { 
    146                 $this->intid=$row[0]; 
    147                 $this->artist=$row[1]; 
    148                 $this->album=$row[2]; 
    149                 $this->title=$row[3]; 
    150                 $this->genre=$row[4]; 
    151                 $this->length=$row[5]; 
    152                 $this->rating=$row[6]; 
    153                 $this->filename=$row[7]; 
    154  
    155                 $this->urlfilename=root.'data/music'; 
    156                 global $musicdir; 
    157                 foreach (preg_split('/\//', substr($this->filename, strlen($musicdir))) as $dir) { 
    158                     if (!$dir) continue; 
    159                     $this->urlfilename .= '/'.rawurlencode(utf8tolocal($dir)); 
    160                 } 
    161  
    162                 return(true); 
    163             } 
    164             return(false); 
    165     } 
    166  
    167  
    168  
    169     function display() 
    170     { 
    171         $music = new Theme_music(); 
    172         $this->init($music->getMaxPerPage()); 
    173         $music->setOffset($this->offset); 
    174         $music->setTotalCount($this->totalCount); 
    175  
    176         $music->print_header($this->filterPlaylist,$this->filterArtist,$this->filterAlbum,$this->filterGenre); 
    177         if($this->totalCount > 0) 
    178         { 
    179             while($this->readRow()) 
    180             { 
    181                 $music->printDetail($this->title,$this->length,$this->artist,$this->album,$this->genre,$this->urlfilename); 
    182             } 
    183         } 
    184         else 
    185         { 
    186             $music->printNoDetail(); 
    187         } 
    188         if($this->result) 
    189             mysql_free_result($this->result); 
    190  
    191         $music->print_footer(); 
    192     } 
    193  
    194     function prepFilter() 
    195     { 
    196         $prevFilter=0; 
    197         $thisFilter=""; 
    198  
    199         if($this->filterPlaylist != "_All_") 
    200         { 
    201             $playlistResult = mysql_query("select playlistid,name,songlist,hostname from musicplaylist where playlistid=".escape($this->filterPlaylist)); 
    202             if($playlistResult) 
    203             { 
    204                 if(mysql_num_rows($playlistResult)==1) 
    205                 { 
    206                     $row=mysql_fetch_row($playlistResult); 
    207                     if($row) 
    208                     { 
    209  
    210                         $this->filterSonglist=$row[2]; 
    211                         if($prevFilter==1) 
    212                             $this->filter=$this->filter . "and intid in (" . $this->filterSonglist . ")"; 
    213                         else 
    214                         { 
    215                             $this->filter="intid in (" . $this->filterSonglist . ")"; 
    216                             $prevFilter=1; 
    217                         } 
    218  
    219                         $this->keepFilters="&amp;filterPlaylist=" . urlencode($this->filterPlaylist); 
    220  
    221                     } 
    222                 } 
    223             } 
    224         } 
    225  
    226         if($this->filterArtist != "_All_" ) 
    227         { 
    228             if($prevFilter==1) 
    229                 $this->filter=$this->filter . "and artist=".escape($this->filterArtist); 
    230             else 
    231             { 
    232                 $this->filter="artist=".escape($this->filterArtist); 
    233                 $prevFilter=1; 
    234             } 
    235  
    236             $this->keepFilters="&amp;filterArtist=" . urlencode($this->filterArtist); 
    237  
    238         } 
    239         if($this->filterAlbum != "_All_") 
    240         { 
    241             if($prevFilter==1) 
    242             { 
    243                 $this->filter= $this->filter . "and album=\"" . $this->filterAlbum . "\""; 
    244             } 
    245             else 
    246             { 
    247                 $this->filter="album=\"" . $this->filterAlbum . "\""; 
    248                 $prevFilter=1; 
    249             } 
    250             $this->keepFilters =$this->keepFilters . "&amp;filterAlbum=" . urlencode($this->filterAlbum) ; 
    251  
    252         } 
    253         if($this->filterGenre != "_All_") 
    254         { 
    255             if($prevFilter==1) 
    256             { 
    257                 $this->filter= $this->filter . "and genre=" . $this->filterGenre ; 
    258             } 
    259             else 
    260             { 
    261                 $this->filter="genre=\"" . $this->filterGenre . "\""; 
    262                 $prevFilter=1; 
    263             } 
    264             $this->keepFilters =$this->keepFilters . "&amp;filterGenre=" . urlencode($this->filterGenre); 
    265  
    266         } 
    267  
    268         if($this->filterRank != "_All_") 
    269         { 
    270             if($prevFilter==1) 
    271             { 
    272                 $this->filter=$this->filter . "and rank=" . $this->filterRank; 
    273             } 
    274             else 
    275             { 
    276                 $this->filter="rank=" . $this->filterRank; 
    277                 $prevFilter=1; 
    278             } 
    279             $this->keepFilters =$this->keepFilters . "&amp;filterRank=" . urlencode($this->filterRank); 
    280         } 
    281  
    282  
    283  
    284     } 
    285  
    286     function init($maxPerPage) { 
    287         global $db; 
    288         $this->prepFilter(); 
    289         if (empty($this->filter)) 
    290             $this->totalCount = $db->query_col('SELECT COUNT(*) FROM musicmetadata'); 
    291         else 
    292             $this->totalCount = $db->query_col('SELECT COUNT(*) FROM musicmetadata WHERE '.$this->filter); 
    293  
    294         if ($this->totalCount > 0) { 
    295             if($this->offset > 0) { 
    296                 $limitText='LIMIT ' . $this->offset . ',' . $maxPerPage; 
    297             } 
    298             else 
    299                 $limitText='LIMIT ' . $maxPerPage; 
    300  
    301             if (empty($this->filter)) 
    302                 $this->result=mysql_query("select intid,artist,album,title,genre,length,rating,filename from musicmetadata order by artist,album,tracknum " . $limitText); 
    303             else 
    304                 $this->result=mysql_query("select intid,artist,album,title,genre,length,rating,filename from musicmetadata where $this->filter order by artist,album,tracknum $limitText"); 
    305         } 
    306     } 
    307 } 
    308  
    309  
     16    if (tmpl == "compact") 
     17        { 
     18        require_once("modules/music/music_handler.php"); 
     19        } 
     20    else 
     21        { 
     22        if (in_array($Path[1], array('mp3act_js.js.php', 'mp3act_fat.js', 'mp3act_hidden.php'))) 
     23            { 
     24            require_once 'modules/music/'.$Path[1]; 
     25            exit(); 
     26                } 
     27        if (strstr($Path[1],"mp3act_playstream.php") != false) 
     28            { 
     29            require_once 'modules/music/mp3act_playstream.php'; 
     30            exit(); 
     31            } 
     32     
     33        require_once 'modules/music/mp3act_main.php'; 
     34        } 
     35?>     
     36 No newline at end of file 
  • mythweb/modules/music/mp3act_sajax.php

     
     1<?php 
     2if (!isset($SAJAX_INCLUDED)) { 
     3 
     4        /* 
     5         * GLOBALS AND DEFAULTS 
     6         * 
     7         */ 
     8        $sajax_debug_mode = 0; 
     9        $sajax_export_list = array(); 
     10        $sajax_request_type = "GET"; 
     11        $sajax_remote_uri = ""; 
     12 
     13        /* 
     14         * CODE 
     15         * 
     16         */ 
     17 
     18        // 
     19        // Initialize the Sajax library. 
     20        // 
     21        function sajax_init() { 
     22        } 
     23 
     24        // 
     25        // Helper function to return the script's own URI. 
     26        // 
     27        function sajax_get_my_uri() { 
     28                global $REQUEST_URI; 
     29 
     30                return $REQUEST_URI; 
     31        } 
     32        $sajax_remote_uri = sajax_get_my_uri(); 
     33 
     34        // 
     35        // Helper function to return an eval()-usable representation 
     36        // of an object in JavaScript. 
     37        // 
     38        function sajax_get_js_repr($value) { 
     39                $type = gettype($value); 
     40 
     41                if ($type == "boolean" || 
     42                        $type == "integer") { 
     43                        return "parseInt($value)"; 
     44                } 
     45                elseif ($type == "double") { 
     46                        return "parseFloat($value)"; 
     47                } 
     48                elseif ($type == "array" || $type == "object" ) { 
     49                        // 
     50                        // XXX Arrays with non-numeric indices are not 
     51                        // permitted according to ECMAScript, yet everyone 
     52                        // uses them.. We'll use an object. 
     53                        // 
     54                        $s = "{ "; 
     55                        if ($type == "object") { 
     56                                $value = get_object_vars($value); 
     57                        } 
     58                        foreach ($value as $k=>$v) { 
     59                                $esc_key = sajax_esc($k); 
     60                                if (is_numeric($k)) 
     61                                        $s .= "$k: " . sajax_get_js_repr($v) . ", "; 
     62                                else 
     63                                        $s .= "\"$esc_key\": " . sajax_get_js_repr($v) . ", "; 
     64                        } 
     65                        return substr($s, 0, -2) . " }"; 
     66                } 
     67                else { 
     68                        $esc_val = sajax_esc($value); 
     69                        $s = "\"$esc_val\""; 
     70                        return $s; 
     71                } 
     72        } 
     73 
     74        function sajax_handle_client_request() { 
     75                global $sajax_export_list; 
     76 
     77                $mode = ""; 
     78 
     79                if (! empty($_GET["rs"])) 
     80                        $mode = "get"; 
     81 
     82                if (!empty($_POST["rs"])) 
     83                        $mode = "post"; 
     84 
     85                if (empty($mode)) 
     86                        return; 
     87 
     88                $target = ""; 
     89 
     90                if ($mode == "get") { 
     91                        // Bust cache in the head 
     92                        header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past 
     93                        header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
     94                        // always modified 
     95                        header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1 
     96                        header ("Pragma: no-cache");                          // HTTP/1.0 
     97                        $func_name = $_GET["rs"]; 
     98                        if (! empty($_GET["rsargs"])) 
     99                                $args = $_GET["rsargs"]; 
     100                        else 
     101                                $args = array(); 
     102                } 
     103                else { 
     104                        $func_name = $_POST["rs"]; 
     105                        if (! empty($_POST["rsargs"])) 
     106                                $args = $_POST["rsargs"]; 
     107                        else 
     108                                $args = array(); 
     109                } 
     110 
     111                if (! in_array($func_name, $sajax_export_list)) 
     112                        echo "-:$func_name not callable"; 
     113                else { 
     114                        echo "+:"; 
     115                        $result = call_user_func_array($func_name, $args); 
     116                        echo "var res = " . sajax_get_js_repr($result) . "; res;"; 
     117                } 
     118                exit; 
     119        } 
     120 
     121        function sajax_get_common_js() { 
     122                global $sajax_debug_mode; 
     123                global $sajax_request_type; 
     124                global $sajax_remote_uri; 
     125 
     126                $t = strtoupper($sajax_request_type); 
     127                if ($t != "" && $t != "GET" && $t != "POST") 
     128                        return "// Invalid type: $t.. \n\n"; 
     129 
     130                ob_start(); 
     131                ?> 
     132 
     133                // remote scripting library 
     134                // (c) copyright 2005 modernmethod, inc 
     135                var sajax_debug_mode = <?php echo $sajax_debug_mode ? "true" : "false"; ?>; 
     136                var sajax_request_type = "<?php echo $t; ?>"; 
     137                var sajax_target_id = ""; 
     138 
     139                function sajax_debug(text) { 
     140                        if (sajax_debug_mode) 
     141                                alert("RSD: " + text) 
     142                } 
     143                function sajax_init_object() { 
     144                        sajax_debug("sajax_init_object() called..") 
     145 
     146                        var A; 
     147                        try { 
     148                                A=new ActiveXObject("Msxml2.XMLHTTP"); 
     149                        } catch (e) { 
     150                                try { 
     151                                        A=new ActiveXObject("Microsoft.XMLHTTP"); 
     152                                } catch (oc) { 
     153                                        A=null; 
     154                                } 
     155                        } 
     156                        if(!A && typeof XMLHttpRequest != "undefined") 
     157                                A = new XMLHttpRequest(); 
     158                        if (!A) 
     159                                sajax_debug("Could not create connection object."); 
     160                        return A; 
     161                } 
     162                function sajax_do_call(func_name, args) { 
     163                        var i, x, n; 
     164                        var uri; 
     165                        var post_data; 
     166                        var target_id; 
     167 
     168                        sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id); 
     169                        target_id = sajax_target_id; 
     170                        if (sajax_request_type == "") 
     171                                sajax_request_type = "GET"; 
     172 
     173                        uri = "<?php echo $sajax_remote_uri; ?>"; 
     174                        if (sajax_request_type == "GET") { 
     175 
     176                                if (uri.indexOf("?") == -1) 
     177                                        uri += "?rs=" + escape(func_name); 
     178                                else 
     179                                        uri += "&rs=" + escape(func_name); 
     180                                uri += "&rst=" + escape(sajax_target_id); 
     181                                uri += "&rsrnd=" + new Date().getTime(); 
     182 
     183                                for (i = 0; i < args.length-1; i++) 
     184                                        uri += "&rsargs[]=" + escape(args[i]); 
     185 
     186                                post_data = null; 
     187                        } 
     188                        else if (sajax_request_type == "POST") { 
     189                                post_data = "rs=" + escape(func_name); 
     190                                post_data += "&rst=" + escape(sajax_target_id); 
     191                                post_data += "&rsrnd=" + new Date().getTime(); 
     192 
     193                                for (i = 0; i < args.length-1; i++) 
     194                                        post_data = post_data + "&rsargs[]=" + escape(args[i]); 
     195                        } 
     196                        else { 
     197                                alert("Illegal request type: " + sajax_request_type); 
     198                        } 
     199 
     200                        x = sajax_init_object(); 
     201                        x.open(sajax_request_type, uri, true); 
     202 
     203                        if (sajax_request_type == "POST") { 
     204                                x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); 
     205                                x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
     206                        } 
     207 
     208                        x.onreadystatechange = function() { 
     209                                if (x.readyState != 4) 
     210                                        return; 
     211 
     212                                sajax_debug("received " + x.responseText); 
     213 
     214                                var status; 
     215                                var data; 
     216                                status = x.responseText.charAt(0); 
     217                                data = x.responseText.substring(2); 
     218                                if (status == "-") 
     219                                        alert("Error: " + data); 
     220                                else { 
     221                                        if (target_id != "") 
     222                                                document.getElementById(target_id).innerHTML = eval(data); 
     223                                        else 
     224                                                args[args.length-1](eval(data)); 
     225                                } 
     226                        } 
     227                        sajax_debug(func_name + " uri = " + uri + "/post = " + post_data); 
     228                        x.send(post_data); 
     229                        sajax_debug(func_name + " waiting.."); 
     230                        delete x; 
     231                        return true; 
     232                } 
     233 
     234                <?php 
     235                $html = ob_get_contents(); 
     236                ob_end_clean(); 
     237                return $html; 
     238        } 
     239 
     240        function sajax_show_common_js() { 
     241                echo sajax_get_common_js(); 
     242        } 
     243 
     244        // javascript escape a value 
     245        function sajax_esc($val) 
     246        { 
     247                $val = str_replace("\\", "\\\\", $val); 
     248                $val = str_replace("\r", "\\r", $val); 
     249                $val = str_replace("\n", "\\n", $val); 
     250                return str_replace('"', '\\"', $val); 
     251        } 
     252 
     253        function sajax_get_one_stub($func_name) { 
     254                ob_start(); 
     255                ?> 
     256 
     257                // wrapper for <?php echo $func_name; ?> 
     258 
     259                function x_<?php echo $func_name; ?>() { 
     260                        sajax_do_call("<?php echo $func_name; ?>", 
     261                                x_<?php echo $func_name; ?>.arguments); 
     262                } 
     263 
     264                <?php 
     265                $html = ob_get_contents(); 
     266                ob_end_clean(); 
     267                return $html; 
     268        } 
     269 
     270        function sajax_show_one_stub($func_name) { 
     271                echo sajax_get_one_stub($func_name); 
     272        } 
     273 
     274        function sajax_export() { 
     275                global $sajax_export_list; 
     276          $sajax_export_list = func_get_args(); 
     277        } 
     278 
     279        $sajax_js_has_been_shown = 0; 
     280        function sajax_get_javascript() 
     281        { 
     282                global $sajax_js_has_been_shown; 
     283                global $sajax_export_list; 
     284 
     285                $html = ""; 
     286                if (! $sajax_js_has_been_shown) { 
     287                        $html .= sajax_get_common_js(); 
     288                        $sajax_js_has_been_shown = 1; 
     289                } 
     290                foreach ($sajax_export_list as $func) { 
     291                        $html .= sajax_get_one_stub($func); 
     292                } 
     293                return $html; 
     294        } 
     295 
     296        function sajax_show_javascript() 
     297        { 
     298                echo sajax_get_javascript(); 
     299        } 
     300 
     301 
     302        $SAJAX_INCLUDED = 1; 
     303} 
     304?> 
  • mythweb/modules/music/music_handler.php

     
     1<?php 
     2/** 
     3 * MythMusic browser 
     4 * 
     5 * @url         $URL: svn+ssh://xris@cvs.mythtv.org/var/lib/svn/trunk/mythplugins/mythweb/modules/music/init.php $ 
     6 * @date        $Date: 2006-03-26 12:09:14 +0200 (So, 26 MÀr 2006) $ 
     7 * @version     $Revision: 9493 $ 
     8 * @author      $Author: xris $ 
     9 * @license     GPL 
     10 * 
     11 * @package     MythWeb 
     12 * @subpackage  Music 
     13 * 
     14/**/ 
     15 
     16// Make sure the music directory exists 
     17    if (file_exists('data/music')) { 
     18    // File is not a directory or a symlink 
     19        if (!is_dir('data/music') && !is_link('data/music')) { 
     20            custom_error('An invalid file exists at data/music.  Please remove it in' 
     21                        .' order to use the music portions of MythWeb.'); 
     22        } 
     23    } 
     24// Create the symlink, if possible. 
     25// 
     26// NOTE:  Errors have been disabled because if I turn them on, people hosting 
     27//        MythWeb on Windows machines will have issues.  I will turn the errors 
     28//        back on when I find a clean way to do so. 
     29// 
     30    else { 
     31        $dir = $db->query_col('SELECT data 
     32                                 FROM settings 
     33                                WHERE value="MusicLocation" AND hostname=?', 
     34                              hostname 
     35                             ); 
     36        if ($dir) { 
     37            $ret = @symlink($dir, 'data/music'); 
     38            if (!$ret) { 
     39                #custom_error("Could not create a symlink to $dir, the local MythMusic directory" 
     40                #            .' for this hostname ('.hostname.').  Please create a symlink to your' 
     41                #            .' MythMusic directory at data/music in order to use the music' 
     42                #            .' portions of MythWeb.'); 
     43            } 
     44        } 
     45        else { 
     46            #custom_error('Could not find a value in the database for the MythMusic directory' 
     47            #            .' for this hostname ('.hostname.').  Please create a symlink to your' 
     48            #            .' MythMusic directory at data/music in order to use the music' 
     49            #            .' portions of MythWeb.'); 
     50        } 
     51    } 
     52 
     53// 
     54//  Someday, music.php will let us stream 
     55//  entire playlists to any spot on planet earth 
     56// 
     57require_once tmpl_dir.'music.php'; 
     58 
     59$mythmusic = new mythMusic(); 
     60$mythmusic->display(); 
     61 
     62class mythMusic { 
     63    var $filterPlaylist; 
     64    var $filterArtist; 
     65    var $filterAlbum; 
     66    var $filterGenre; 
     67    var $filterRank; 
     68    var $filterSonglist; 
     69    var $keepFilters; 
     70    var $filter; 
     71    var $totalCount; 
     72    var $offset; 
     73 
     74    var $result; 
     75 
     76 
     77    var $intid; 
     78    var $artist; 
     79    var $album; 
     80    var $title; 
     81    var $genre; 
     82    var $length; 
     83    var $rating; 
     84    var $filename; 
     85    var $urlfilename; 
     86 
     87    var $alphalink; 
     88    var $alphaoffset; 
     89 
     90    function mythMusic() 
     91    { 
     92        if($_GET['offset'] >=0 ) 
     93            $this->offset=$_GET['offset']; 
     94        else 
     95            $this->offset=0; 
     96 
     97        /**** If alphalink set, then change offset to new value ****/ 
     98        if ($_GET['alphalink']) { 
     99            $alphalink = mysql_real_escape_string($_GET['alphalink']); 
     100 
     101            $result = mysql_query(sprintf("SELECT COUNT(*) FROM music_songs ". 
     102                                          "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id ". 
     103                                          "WHERE UPPER(music_artists.artist_name) < %s ". 
     104                                          "ORDER BY music_artists.artist_name;", 
     105                                          escape($_GET['alphalink']))); 
     106            if ($result) 
     107                        { 
     108                $alphaoffset=mysql_fetch_row($result); 
     109                $this->offset=$alphaoffset[0]; 
     110                mysql_free_result($result); 
     111            } 
     112        } 
     113 
     114        if($_GET['filterPlaylist']) 
     115        { 
     116            $this->filterPlaylist=$_GET['filterPlaylist']; 
     117            $_GET['filterPlaylist']; 
     118        } 
     119        else 
     120            $this->filterPlaylist="_All_"; 
     121 
     122        if($_GET['filterArtist']) 
     123        { 
     124            $this->filterArtist=$_GET['filterArtist']; 
     125        } 
     126        else 
     127            $this->filterArtist="_All_"; 
     128 
     129        if($_GET['filterAlbum']) 
     130        { 
     131            $this->filterAlbum=$_GET['filterAlbum']; 
     132        } 
     133        else 
     134            $this->filterAlbum="_All_"; 
     135        if($_GET['filterGenre']) 
     136        { 
     137            $this->filterGenre=$_GET['filterGenre']; 
     138        } 
     139        else 
     140            $this->filterGenre="_All_"; 
     141 
     142 
     143        if($_GET['filterRank']) 
     144            $this->filterRank=$_GET['filterRank']; 
     145        else 
     146            $this->filterRank="_All_"; 
     147    } 
     148 
     149    function readRow() 
     150    { 
     151 
     152            if($row=mysql_fetch_row($this->result)) 
     153            { 
     154                $this->intid=$row[0]; 
     155                $this->artist=$row[1]; 
     156                $this->album=$row[2]; 
     157                $this->title=$row[3]; 
     158                $this->genre=$row[4]; 
     159                $this->length=$row[5]; 
     160                $this->rating=$row[6]; 
     161                $this->filename=$row[7]; 
     162 
     163                $this->urlfilename=root.'data/music'; 
     164                global $musicdir; 
     165                foreach (preg_split('/\//', substr($this->filename, strlen($musicdir))) as $dir) { 
     166                    if (!$dir) continue; 
     167                    $this->urlfilename .= '/'.rawurlencode(utf8tolocal($dir)); 
     168                } 
     169 
     170                return(true); 
     171            } 
     172            return(false); 
     173    } 
     174 
     175 
     176 
     177    function display() 
     178    { 
     179        $music = new Theme_music(); 
     180        $this->init($music->getMaxPerPage()); 
     181        $music->setOffset($this->offset); 
     182        $music->setTotalCount($this->totalCount); 
     183 
     184        $music->print_header($this->filterPlaylist,$this->filterArtist,$this->filterAlbum,$this->filterGenre); 
     185        if($this->totalCount > 0) 
     186        { 
     187            while($this->readRow()) 
     188            { 
     189                $music->printDetail($this->title,$this->length,$this->artist,$this->album,$this->genre,$this->urlfilename); 
     190            } 
     191        } 
     192        else 
     193        { 
     194            $music->printNoDetail(); 
     195        } 
     196        if($this->result) 
     197            mysql_free_result($this->result); 
     198 
     199        $music->print_footer(); 
     200    } 
     201 
     202    function prepFilter() 
     203    { 
     204        $this->filter="1=1"; // A true statement that will always return everything in SQL. 
     205 
     206        if($this->filterPlaylist != "_All_") 
     207        { 
     208            $playlistResult = mysql_query("SELECT playlist_id,playlist_name,playlist_songs,hostname FROM music_playlists WHERE playlist_id=".escape($this->filterPlaylist)); 
     209            if($playlistResult) 
     210            { 
     211                if(mysql_num_rows($playlistResult)==1) 
     212                { 
     213                    $row=mysql_fetch_row($playlistResult); 
     214                    if($row && !empty($row[2])) 
     215                    { 
     216                        $this->filterSonglist=$row[2]; 
     217 
     218                        $this->filter .= " AND song_id IN (" . $this->filterSonglist . ")"; 
     219                        $this->keepFilters .= "&amp;filterPlaylist=" . urlencode($this->filterPlaylist); 
     220                    } 
     221                } 
     222            } 
     223        } 
     224 
     225        if($this->filterArtist != "_All_" ) 
     226        { 
     227            $this->filter .= " AND artist_name=".escape($this->filterArtist); 
     228            $this->keepFilters .= "&amp;filterArtist=" . urlencode($this->filterArtist); 
     229        } 
     230 
     231        if($this->filterAlbum != "_All_") 
     232        { 
     233            $this->filter .= " AND album_name=" . escape($this->filterAlbum); 
     234            $this->keepFilters .= "&amp;filterAlbum=" . urlencode($this->filterAlbum) ; 
     235        } 
     236 
     237        if($this->filterGenre != "_All_") 
     238        { 
     239            $this->filter .= " AND genre=" . escape($this->filterGenre); 
     240            $this->keepFilters .= "&amp;filterGenre=" . urlencode($this->filterGenre); 
     241        } 
     242 
     243        if($this->filterRank != "_All_") 
     244        { 
     245            $this->filter .= " AND rank=" . escape($this->filterRank); 
     246            $this->keepFilters .= "&amp;filterRank=" . urlencode($this->filterRank); 
     247        } 
     248    } 
     249 
     250    function init($maxPerPage) { 
     251        global $db; 
     252        $this->prepFilter(); 
     253        $query_base = ' FROM music_songs'. 
     254                      ' LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id'. 
     255                      ' LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id'. 
     256                      ' LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id'. 
     257                      ' WHERE '.$this->filter. 
     258                      ' ORDER BY artist_name,album_name,track'; 
     259         
     260        // Cannot use $db->query_col here as the preg_replace kills PHP when using large filterSongList queries 
     261        $this->totalCount = 0; 
     262        $result = mysql_query('SELECT COUNT(*)'.$query_base); 
     263        if ($result) 
     264        { 
     265            $row=mysql_fetch_row($result); 
     266            $this->totalCount=$row[0]; 
     267            mysql_free_result($result); 
     268        } 
     269 
     270        if ($this->totalCount > 0) { 
     271            if($this->offset > 0) 
     272                $query_base .= ' LIMIT ' . $this->offset . ',' . $maxPerPage; 
     273            else 
     274                $query_base .= ' LIMIT ' . $maxPerPage; 
     275             
     276                $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 '.$query_base); 
     277        } 
     278    } 
     279} 
     280 
     281 
  • mythweb/modules/music/mp3act_js.js.php

     
     1<?php 
     2function music_dir() 
     3{ 
     4  return 'http://'.$_SERVER['HTTP_HOST'].root."music/"; 
     5} 
     6?> 
     7        window.onload=function(){ init(); }; 
     8 
     9        function init(){ 
     10                setPageTitle(); 
     11                x_viewPlaylist(viewPlaylist_cb); 
     12                x_playlistInfo(plinfo_cb); 
     13                setPLTitle(); 
     14                setCurrentPage(); 
     15                updateBox(page,0); 
     16        } 
     17        function empty_cb(new_data){ 
     18 
     19        } 
     20 
     21        function setPageNav(){ 
     22                //document.getElementById("breadcrumb").innerHTML = prevpage; 
     23        } 
     24 
     25        function switchPage(newpage){ 
     26                prevpage = page; 
     27                page = newpage; 
     28 
     29                updateBox(page,0); 
     30                setPageTitle(); 
     31                setCurrentPage(); 
     32                //setPageNav(); 
     33        } 
     34 
     35        function setPLTitle(){ 
     36                document.getElementById("pl_title").innerHTML = " <? echo t("Playlist"); ?> "; 
     37        } 
     38 
     39        function viewPlaylist_cb(new_data){ 
     40                document.getElementById("playlist").innerHTML = new_data; 
     41        } 
     42 
     43        function setCurrentPage(){ 
     44                var x = document.getElementById('nav'); 
     45                var y = x.getElementsByTagName('a'); 
     46                for (var i=0;i < y.length;i++){ 
     47                                        y[i].removeAttribute("class"); 
     48                                        if(y[i].id == page) 
     49                                                y[i].setAttribute('class','c'); 
     50                                } 
     51        } 
     52 
     53        function getDropDown(type,id){ 
     54                x_getDropDown(type,id,getDropDown_cb); 
     55        } 
     56 
     57        function getDropDown_cb(new_data){ 
     58                ul = document.getElementById("browse_ul"); 
     59                ul.innerHTML = new_data; 
     60                ul.style.display = 'block'; 
     61        } 
     62 
     63        function closeDropDown(){ 
     64                ul = document.getElementById("browse_ul"); 
     65                ul.style.display = 'none'; 
     66                ul.innerHTML = ''; 
     67        } 
     68 
     69        function savePL_cb(data){ 
     70                        var save_form = '<h2><?php echo t('Save/Rename Playlist'); ?></h2>' + 
     71          '<form onsubmit="return savePL(\'save\',this)" method="get" action="">' + 
     72          '<strong><?php echo t('Playlist Name'); ?></strong><br/>' + 
     73          '<?php echo t('Enter a new name for your playlist'); ?><br /><br />' + 
     74          '<input type="text" name="save_pl_name" id="save_pl_name" size="25" />' + 
     75          '<input style="left: 350px; position: absolute;" type="submit" value="<?php echo t('Save/Rename'); ?>" />' + 
     76          '</form>' + 
     77          '<br /><hr /><br />' + 
     78          '<input style="left: 350px; position: absolute;" type="button"' + 
     79          ' onclick="savePL(\'close\',0); return false;" value="<?php echo t('Cancel'); ?>" />'; 
     80                        document.getElementById("box_extra").innerHTML = save_form; 
     81                        document.getElementById("box_extra").style.display = 'block'; 
     82                } 
     83 
     84        function savePL(type,data){ 
     85        if(type=='open'){ 
     86          savePL_cb(data); 
     87          return false; 
     88        } 
     89                else if(type=='save'){ 
     90                        var pl_name = data.save_pl_name.value; 
     91                            x_savePlaylist(pl_name,0,save_Playlist_cb); 
     92          x_playlistInfo(plinfo_cb); 
     93 
     94                        return false; 
     95                } 
     96                else if(type=='close') 
     97                        document.getElementById("box_extra").style.display = 'none'; 
     98        } 
     99 
     100        function save_Playlist_cb(new_data){ 
     101                box = document.getElementById("box_extra"); 
     102                box.innerHTML = new_data; 
     103                setTimeout("box.style.display='none'","1250"); 
     104        } 
     105 
     106        function movePLItem(direction,item){ 
     107                                var y; 
     108                                var temp; 
     109        var pos = 0; 
     110          temp = item; 
     111        while (temp.previousSibling) 
     112        { 
     113          pos++; 
     114          temp = temp.previousSibling; 
     115        } 
     116 
     117        if(direction == "up") 
     118                        y = item.previousSibling; 
     119                else if(direction == "down") 
     120                                        y = item.nextSibling; 
     121 
     122                                if(y && y.nodeName == 'LI'){ 
     123                        pl_move(pos, pos + ("up" == direction ? -1 : 1)); 
     124 
     125                        var temp = y.innerHTML; 
     126                        y.innerHTML = item.innerHTML; 
     127                        item.innerHTML = temp; 
     128                        Fat.fade_element(y.id,null,900,'#ffcc99','#f3f3f3'); 
     129                } 
     130        } 
     131 
     132        function setBgcolor(id, c) 
     133                        { 
     134                                if(id != ('pl'+nowplaying)){ 
     135                                var o = document.getElementById(id); 
     136                                o.style.backgroundColor = c; 
     137                                } 
     138                        } 
     139 
     140                        function setPageTitle(){ 
     141                                var pages= new Array() 
     142                                pages["browse"]="<?php echo t("Browse Music"); ?> "; 
     143                                pages["search"]="<?php echo t("Search Music"); ?> "; 
     144                                pages["random"]="<?php echo t("Create a Random Mix"); ?> "; 
     145                                pages["playlists"]="<?php echo t("Load a Saved Playlist"); ?> "; 
     146                                pages["stats"]="<?php echo t("Server Statistics"); ?> "; 
     147                                document.getElementById("pagetitle").innerHTML = pages[page]; 
     148 
     149                        } 
     150 
     151                        function getRandItems(type){ 
     152                          //document.getElementById("breadcrumb").innerHTML = ''; 
     153                          document.getElementById("rand_items").innerHTML = ''; 
     154                                x_getRandItems(type,getRandItems_cb); 
     155                        } 
     156 
     157                        function getRandItems_cb(new_data){ 
     158                                document.getElementById("rand_items").innerHTML = new_data; 
     159                        } 
     160 
     161                        function updateBox_cb(new_data){ 
     162                                document.getElementById("info").innerHTML = new_data; 
     163                                document.getElementById("loading").style.display = 'none'; 
     164 
     165                                if(clearbc==1) 
     166                                        breadcrumb(); 
     167                                clearbc = 1; 
     168 
     169                        } 
     170 
     171                        function updateBox(type,itemid){ 
     172                                document.getElementById("loading").style.display = 'block'; 
     173                                x_musicLookup(type,itemid,updateBox_cb); 
     174 
     175                                if(type == 'genre' || type == 'letter'){ 
     176                                        bc_parenttype = ''; 
     177                                        bc_parentitem = ''; 
     178                                } 
     179                                else if(type == 'album' || (type == 'artist' && bc_parenttype != '')){ 
     180                                        if(bc_childtype == 'all'){ 
     181                                                bc_parenttype = bc_childtype; 
     182                                                bc_parentitem = bc_childitem; 
     183                                        } 
     184                                } 
     185                                else if(type == 'browse' || type == 'search' || type == 'about' || type == 'prefs' || type == 'random' || type == 'admin' || type == 'playlists' || type == 'stats'){ 
     186 
     187                                        bc_parenttype = ''; 
     188                                        bc_parentitem = ''; 
     189                                        itemid=''; 
     190                                        type=''; 
     191                                } 
     192                                else{ 
     193                                        bc_parenttype = bc_childtype; 
     194                                        bc_parentitem = bc_childitem; 
     195                                } 
     196 
     197                                bc_childitem = itemid; 
     198                                bc_childtype = type; 
     199 
     200                        } 
     201 
     202                        function deletePlaylist(id){ 
     203                                if(confirm("<?php echo t('Are you sure you want to DELETE THIS SAVED PLAYLIST?'); ?>")){ 
     204                                        x_deletePlaylist(id,deletePlaylist_cb); 
     205                                } 
     206                        } 
     207 
     208                        function deletePlaylist_cb(new_data){ 
     209                                // reload saved PL page 
     210                                clearbc = 0; 
     211                                x_musicLookup('playlists',0,updateBox_cb); 
     212                                setMsgText("<?php echo t('Saved Playlist Successfully Deleted'); ?>"); 
     213        // Also reload the playlist if we've deleted the active playlist! 
     214        if (new_data){ 
     215          x_viewPlaylist(viewPlaylist_cb); 
     216          x_playlistInfo(plinfo_cb); 
     217        } 
     218                        } 
     219 
     220                        function plrem(item){ 
     221        var temp = item; 
     222        var pos = 0; 
     223        while (temp.previousSibling) 
     224        { 
     225          pos++; 
     226          temp = temp.previousSibling; 
     227        } 
     228 
     229                                x_playlist_rem(pos,plrem_cb); 
     230                        } 
     231 
     232                        function plrem_cb(rem){ 
     233                                p = document.getElementById("playlist"); 
     234                                d_nested = p.childNodes[rem]; 
     235                                throwaway_node = p.removeChild(d_nested); 
     236                                x_playlistInfo(plinfo_cb); 
     237                        } 
     238 
     239                        function pladd(type,id){ 
     240                                x_playlist_add(type,id,pladd_cb); 
     241                        } 
     242 
     243                        function pladd_cb(new_data){ 
     244 
     245                                if(new_data[0] == 1){ 
     246                                        x_viewPlaylist(viewPlaylist_cb); 
     247                        x_playlistInfo(plinfo_cb); 
     248                                } 
     249                else if (new_data[0] == 2){ 
     250                    alert(new_data[1]); 
     251                } 
     252                                else{ 
     253                                        document.getElementById("playlist").innerHTML += new_data[0]; 
     254 
     255                                        for(var i=2; i < new_data[1]+2; i++){ 
     256                                                Fat.fade_element(new_data[i],null,1400,'#B4EAA2','#f3f3f3'); 
     257                                        } 
     258                                        x_playlistInfo(plinfo_cb); 
     259                                } 
     260                        } 
     261 
     262                        function pl_move(item1,item2){ 
     263                                x_playlist_move(item1,item2,pl_move_cb); 
     264                        } 
     265 
     266                        function pl_move_cb(){ 
     267                                        // do nothing 
     268                        } 
     269 
     270                        function plclear(){ 
     271                                x_clearPlaylist(plinfo_cb); 
     272                                document.getElementById("playlist").innerHTML = ""; 
     273                        } 
     274 
     275                        function plinfo_cb(new_data){ 
     276                                document.getElementById("pl_info").innerHTML = new_data; 
     277                        } 
     278 
     279                        function breadcrumb(){ 
     280                                        x_buildBreadcrumb(page,bc_parenttype,bc_parentitem,bc_childtype,bc_childitem,breadcrumb_cb); 
     281                        } 
     282 
     283                        function breadcrumb_cb(new_data){ 
     284                                //if(new_data!="") 
     285                                        document.getElementById("breadcrumb").innerHTML = new_data; 
     286                        } 
     287 
     288                        function play(type,id){ 
     289                                        document.getElementById('hidden').src = null; 
     290                                        document.getElementById("hidden").src = "<?php echo music_dir(); ?>mp3act_hidden.php?type="+type+"&id="+id+"&quality=high"; 
     291                        } 
     292 
     293                        function randAdd(data){ 
     294                                var type = data.random_type.value; 
     295                                if(type == ""){ 
     296                                        setMsgText("You must choose a random type"); 
     297                                        return false; 
     298                                } 
     299                                var num=0; 
     300                                num = data.random_count.value; 
     301                                var items =''; 
     302                                if(type != 'all'){ 
     303                                        for(var i=0;i<data.random_items.options.length;i++){ 
     304                                                if(data.random_items.options[i].selected == true) 
     305                                                 items += ',' + data.random_items.options[i].value; 
     306                                        } 
     307 
     308                                        if(items == ""){ 
     309                                          setMsgText("You must choose at least one random item"); 
     310                                          return false; 
     311                                        } 
     312          items = items.substring(1); 
     313                                } 
     314                                x_randAdd(type,num,items,randadd_cb); 
     315                                return false; 
     316 
     317                        } 
     318 
     319                        function randadd_cb(new_data){ 
     320                                x_viewPlaylist(viewPlaylist_cb); 
     321                                x_playlistInfo(plinfo_cb); 
     322                        } 
     323 
     324                        function play_cb(new_data){ 
     325                                //refresh(); 
     326                        } 
     327 
     328                        function setMsgText(text){ 
     329                                        document.getElementById("breadcrumb").innerHTML = "<span class='error'>"+text+"</span>"; 
     330                                        Fat.fade_element('breadcrumb',null,2000,'#F5C2C2','#ffffff'); 
     331                        } 
     332 
     333                        function searchMusic(form){ 
     334                                if(form.searchbox.value == '' || form.searchbox.value == '[<? echo t("enter your search terms"); ?>]'){ 
     335                                        setMsgText("You Must Enter Something to Search For"); 
     336                                } 
     337                                else{ 
     338                                        document.getElementById("breadcrumb").innerHTML = ""; 
     339                                        x_searchMusic(form.searchbox.value,form.search_options.value,updateBox_cb); 
     340                                } 
     341                                return false; 
     342                        } 
     343 
  • mythweb/modules/music/mp3act_functions.php

     
     1<?php 
     2/** 
     3 * Common Functions for the MP3Act part of the MythWeb Music module 
     4 * 
     5 * @url         $URL: http://svn.mythtv.org/svn/trunk/mythplugins/mythweb/modules/music/mp3act_functions.php $ 
     6 * @date        $Date: 2006-03-23 08:46:57 +0100 (Do, 23 MÀr 2006) $ 
     7 * @version     $Revision: 9478 $ 
     8 * @author      $Author: jochen $ 
     9 * @license     GPL 
     10 * 
     11 * @package     MythWeb 
     12 * @subpackage  Music 
     13 * 
     14/**/ 
     15 
     16require_once('modules/music/mp3act_html_functions.php'); 
     17 
     18define('MYTH_WEB_PLAYLIST_NAME', 'MythWeb Temporary Playlist'); 
     19define('MYTH_PLAYLIST_SAVE_TIME', 60*60*24*7); 
     20 
     21/****************************************** 
     22*  mp3act functions 
     23*  http://www.mp3act.net 
     24*  Stripped, because not all this funcionality is needed in MythWEB 
     25* 
     26******************************************/ 
     27function pic_dir() 
     28{ 
     29  return 'http://'.$_SERVER['HTTP_HOST'].skin_url.'img/music/'; 
     30} 
     31 
     32function music_dir() 
     33{ 
     34  return 'http://'.$_SERVER['HTTP_HOST'].root."music/"; 
     35} 
     36 
     37 
     38function GarbageCollector() 
     39{ 
     40    // Run this occasionally to tidy up. 
     41    if (0 == mt_rand(0, 30)) 
     42    { 
     43        $query = 'DELETE FROM music_playlists '. 
     44            "WHERE playlist_name='".mysql_real_escape_string('MythWeb Temporary Playlist')."'". 
     45            ' AND (NOW() - last_accessed) > ('.MYTH_PLAYLIST_SAVE_TIME.');'; 
     46        mysql_query($query); 
     47    } 
     48} 
     49 
     50function getplaylistnames() 
     51{ 
     52  $output=''; 
     53  $query = 'SELECT playlist_name, hostname FROM music_playlists WHERE hostname=\'\';'; 
     54  $result = mysql_query($query); 
     55 
     56  if (!$result) 
     57    return ''; 
     58 
     59  while ($row = mysql_fetch_array($result)) 
     60  { 
     61    $output .= '<option>'.$row['playlist_name'].'</option>'; 
     62  } 
     63  mysql_free_result($result); 
     64  return $output; 
     65} 
     66 
     67function genreform() 
     68{ 
     69  $query = "SELECT * FROM music_genres ORDER BY genre"; 
     70  $result = mysql_query($query); 
     71 
     72  if (!$result) 
     73    return ''; 
     74 
     75  $output = '<select id="genre" name="genre" onchange="updateBox(\'genre\',this.options[selectedIndex].value); return false;"> 
     76    <option value="" selected>'.t('Choose Genre..').'</option>'; 
     77 
     78  while ($genre = mysql_fetch_array($result)) 
     79  { 
     80    $output .= '<option value="'.$genre['genre'].'">'.$genre['genre'].'</option>'; 
     81  } 
     82  $output .= '</select>'; 
     83  mysql_free_result($result); 
     84  return $output; 
     85} 
     86 
     87function letters() 
     88{ 
     89  $output = '<ul class="music" id="letters">'; 
     90  $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'); 
     91 
     92  foreach($letters as $letter) 
     93  { 
     94    $output .= '<li><a class=music href="#" onclick="updateBox(\'letter\',\''.$letter.'\'); return false;">'.strtoupper($letter).'</a></li>'; 
     95  } 
     96  $output .= '</ul>'; 
     97  return $output; 
     98} 
     99 
     100function getDropDown($type, $id) 
     101{ 
     102  return ""; 
     103} 
     104 
     105function buildBreadcrumb($page, $parent, $parentitem, $child, $childitem) 
     106{ 
     107  $childoutput=''; 
     108  $parentoutput =''; 
     109  if ($page == 'browse' && $child != '') 
     110  { 
     111    $output = '<a class="music" href="#" onclick="updateBox(\'browse\',0); return false;">'.t('Browse').'</a> &#187; '; 
     112  } 
     113  switch ($child) 
     114  { 
     115    case 'album': 
     116      $query = 'SELECT music_albums.album_name, music_artists.artist_name, music_artists.artist_id '. 
     117        'FROM music_albums '. 
     118        'LEFT JOIN music_artists ON music_albums.artist_id=music_artists.artist_id '. 
     119        'WHERE music_albums.album_id='.mysql_real_escape_string($childitem); 
     120      $result = mysql_query($query); 
     121      if (!$result) 
     122        break; 
     123 
     124      $row = mysql_fetch_array($result); 
     125      mysql_free_result($result); 
     126 
     127      $query = 'SELECT album_name, album_id '. 
     128        'FROM music_albums '. 
     129        'WHERE artist_id='.$row['artist_id'].' '. 
     130        'ORDER BY album_name'; 
     131      $result = mysql_query($query); 
     132      if (!$result) 
     133        break; 
     134 
     135      $albums = ''; 
     136      while ($row2 = mysql_fetch_array($result)) 
     137      { 
     138        $albums .= '<li><a class="music" href="#"'. 
     139          ' onclick="updateBox(\'album\','.$row2['album_id'].'); return false;"'. 
     140          ' title="'.sprintf(t('View Details of %s'), $row2['album_name']).'">'. 
     141          $row2['album_name'].'</a></li>'; 
     142      } 
     143      mysql_free_result($result); 
     144 
     145      $childoutput .= '<span><a class="music" href="#"'. 
     146        ' onclick="updateBox(\'artist\','.$row['artist_id'].'); return false;">'. 
     147        $row['artist_name'].'</a>'. 
     148        '<ul class="music">'.$albums.'</ul></span> &#187; '. 
     149        htmlentities($row['album_name']); 
     150      break; 
     151 
     152    case 'artist': 
     153      $query = 'SELECT artist_name '. 
     154        'FROM music_artists '. 
     155        'WHERE artist_id='.mysql_real_escape_string($childitem); 
     156      $result = mysql_query($query); 
     157       if (!$result) 
     158        break; 
     159      $row = mysql_fetch_array($result); 
     160      mysql_free_result($result); 
     161 
     162      $query = 'SELECT music_albums.album_id, album_name '. 
     163        'FROM music_songs '. 
     164        'LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id '. 
     165        'WHERE music_songs.artist_id='.mysql_real_escape_string($childitem).' '. 
     166        'GROUP BY music_albums.album_id;'; 
     167      $result = mysql_query($query); 
     168      if (!$result) 
     169        break; 
     170      $albums = ''; 
     171      while ($row2 = mysql_fetch_array($result)) 
     172      { 
     173        $albums .= '<li><a class="music" href="#"'. 
     174          ' onclick="updateBox(\'album\','.$row2['album_id'].'); return false;"'. 
     175          ' title="'.sprintf(t('View Details of %s'), $row2['album_name']).'">'. 
     176          $row2['album_name'].'</a></li>'; 
     177      } 
     178      mysql_free_result($result); 
     179 
     180      $childoutput .= '<span><a class="music" href="#"'. 
     181        ' onclick="updateBox(\'artist\','.$childitem.'); return false;">'. 
     182        $row['artist_name'].'</a>'. 
     183        '<ul class="music">'.$albums.'</ul></span>'; 
     184      break; 
     185 
     186    case 'letter': 
     187      $childoutput .= '<span><a class="music" href="#"'. 
     188        ' onclick="updateBox(\'letter\',\''.$childitem.'\'); return false;">'. 
     189        strtoupper($childitem).'</a>'.letters().'</span>'; 
     190      break; 
     191 
     192    case 'genre': 
     193    case 'all': 
     194      $childoutput .=  $childitem; 
     195      break; 
     196  } 
     197  switch ($parent) 
     198  { 
     199    case 'letter': 
     200      $parentoutput .= '<span><a class="music" href="#"'. 
     201        ' onclick=\"updateBox(\'letter\',\''.$parentitem.'\'); return false;">'. 
     202        strtoupper($parentitem).'</a>'.letters().'</span> &#187; '; 
     203      break; 
     204 
     205    case 'genre': 
     206    case 'all': 
     207      $parentoutput .= '<a class="music" href="#"'. 
     208        ' onclick="updateBox(\''.$parent.'\',\''.$parentitem.'\'); return false;">'. 
     209        $parentitem.'</a> &#187; '; 
     210      break; 
     211  } 
     212 
     213  if (isset($output)) 
     214  { 
     215    return $output.$parentoutput.$childoutput; 
     216  } 
     217 
     218  return ''; 
     219} 
     220 
     221function musicLookup($type, $itemid) 
     222{ 
     223  $sql_itemid = "'".mysql_real_escape_string($itemid)."'"; 
     224  switch($type) 
     225  { 
     226    case 'browse': 
     227      $output = '<div class="head"> 
     228        <h2 class="music">'.t('Browse the Music Database').'</h2></div> 
     229        <p> 
     230        <strong>'.t('By Artist Beginning With').'</strong><br/>'.letters().'<br/></p> 
     231        <p><strong>'.t('By Genre').'</strong><br/> 
     232        '.genreForm().'<br/><br/> 
     233        <input type="button" value="'.t('Browse All Albums').'" onclick="updateBox(\'all\',\'All\'); return false;" class="btn2" /> 
     234        </p>'; 
     235      break; 
     236 
     237    case 'search': 
     238      $output = '<div class="head"> 
     239        <h2 class="music">'.t('Search the Music Database').'</h2></div> 
     240        <form onsubmit="return searchMusic(this)" method="get" action=""> 
     241        <p> 
     242        <strong>'.t('Keywords').'</strong><br/> 
     243        <input type="text" onfocus="this.select()" name="searchbox" size="35" id="searchbox" value="['.t('Enter your search terms').']" /> 
     244        <br/><br/> 
     245        <strong>'.t('Narrow Your Search').'</strong> 
     246        <br/> 
     247        <select name="search_options" size="1"> 
     248          <option value="all">'.t('All Fields').'</option> 
     249          <option value="artists">'.t('Artists').'</option> 
     250          <option value="albums">'.t('Albums').'</option> 
     251          <option value="songs">'.t('Songs').'</option> 
     252        </select><br/><br/> 
     253        <input type="submit" value="'.t('Submit Search').'" class="btn" /></form> 
     254        </p>'; 
     255      break; 
     256 
     257    case 'letter': 
     258      if($itemid == "#") 
     259      { 
     260        $query = 'SELECT * FROM music_artists '. 
     261          "WHERE artist_name REGEXP '^[0-9].*' ". 
     262          'ORDER BY artist_name'; 
     263      } 
     264      else 
     265      { 
     266        $query = 'SELECT * FROM music_artists '. 
     267          'WHERE artist_name LIKE \''.mysql_real_escape_string($itemid.'%').'\' '. 
     268          'ORDER BY artist_name'; 
     269      } 
     270      $result = mysql_query($query); 
     271      if (!$result) 
     272        break; 
     273 
     274      $output = '<div class="head"> 
     275        <h2 class="music">'.sprintf(t('Artists Beginning with %s'), "'".strtoupper($itemid)."'").'</h2></div> 
     276        <p> 
     277        <strong>'.t('Artist Listing').'</strong></p> 
     278        <ul class="music">'; 
     279      $alt = false; 
     280      while ($row = mysql_fetch_array($result)) 
     281      { 
     282        $output .= '<li'.($alt ? ' class="alt"' : '').'> 
     283          <a class="music" href="#" 
     284           onclick="updateBox(\'artist\','.$row['artist_id'].'); return false;" 
     285           title="'.sprintf(t('View Albums by %s'), $row['artist_name']).'">'. 
     286          $row['artist_name'].'</a></li>'; 
     287        $alt = !$alt; 
     288      } 
     289      mysql_free_result($result); 
     290      $output .= '</ul>'; 
     291      break; 
     292 
     293    case 'all': 
     294      $output = '<div class="head"> 
     295        <h2 class="music">'.t('All Albums').'</h2></div> 
     296        <p> 
     297        <strong>'.t('Album Listing').'</strong></p> 
     298        <ul class="music">'; 
     299      $start = $itemid; 
     300      $query  = 'SELECT ma.*,mt.artist_name '. 
     301        'FROM music_albums AS ma '. 
     302        'LEFT JOIN music_artists AS mt ON ma.artist_id=mt.artist_id '. 
     303        'ORDER BY album_name, artist_name'; 
     304 
     305      $result = mysql_query($query); 
     306      if (!$result) 
     307        break; 
     308 
     309      $alt = false; 
     310      while ($row = mysql_fetch_array($result)) 
     311      { 
     312        $output .= getHtmlAlbum($row['album_id'], $row['album_name'], 
     313          $row['artist_name']); 
     314      } 
     315      mysql_free_result($result); 
     316      $output .= '</ul>'; 
     317      break; 
     318 
     319    case 'album': 
     320      // Get some statistics about the album 
     321      $query = 'SELECT COUNT(*), SEC_TO_TIME(SUM(music_songs.length)/1000) '. 
     322        'FROM music_songs '. 
     323        'WHERE music_songs.album_id='.$sql_itemid.' '. 
     324        'GROUP BY music_songs.album_id;'; 
     325      $result = mysql_query($query); 
     326      if (!$result) 
     327        break; 
     328 
     329      $row = mysql_fetch_array($result); 
     330      mysql_free_result($result); 
     331      $num_tracks = $row[0]; 
     332      $length = $row[1]; 
     333 
     334      // Attempt to find some album art. 
     335      $query='SELECT * '. 
     336        'FROM music_songs '. 
     337        'WHERE album_id='.$sql_itemid.' '. 
     338        'LIMIT 1;'; 
     339      $result = mysql_query($query); 
     340      if (!$result) 
     341        break; 
     342 
     343      $row = mysql_fetch_array($result); 
     344      mysql_free_result($result); 
     345 
     346      $album_art_arr = array(); 
     347      $path = $_SERVER['DOCUMENT_ROOT'].root.'data/music/'.dirname($row['filename']); 
     348      $dir = @dir($path); 
     349      if ($dir) 
     350      { 
     351        while ($file = $dir->read()) 
     352        { 
     353          $end = strtolower(substr($file, -3)); 
     354          switch ($end) 
     355          { 
     356            case 'jpg': 
     357            case 'gif': 
     358            case 'png': 
     359              $album_art_arr[] = $file; 
     360          } 
     361        } 
     362        $dir->close(); 
     363      } 
     364 
     365      if (!empty($album_art_arr)) 
     366      { 
     367        srand(microtime()*1000000); 
     368        $index = mt_rand(1, count($album_art_arr)) - 1; 
     369 
     370        $album_art = root.'data/music/'.dirname($row['filename']).'/'.$album_art_arr[$index]; 
     371      } 
     372 
     373      $output = '<div class="head"> 
     374        <div class="right"> 
     375        <a class="music" href="#" 
     376         onclick="play(\'album\','.$row['album_id'].'); return false;" 
     377         title="'.t('Play this Album Now').'">'.t('Play').'</a> 
     378        <a class="music" href="#" 
     379         onclick="pladd(\'album\','.$row['album_id'].'); return false;" 
     380         title="'.t('Add Album to Current Playlist').'">'.t('Add').'</a> 
     381        </div> 
     382        <h2 class="music">'.$row['album_name'].'</h2> 
     383        </div>'. 
     384        (!empty($album_art) ? '<center><img width="200" src="'.$album_art.'" /></center><br />' : ''). 
     385        '<strong>'.t('Play Time').':</strong> '.$length. 
     386        '<br /><br /> 
     387        <strong>'.t('Album Tracks').'</strong> 
     388        <ul class="music">'; 
     389 
     390      $query = 'SELECT music_songs.*, SEC_TO_TIME(music_songs.length/1000) AS length, artist_name '. 
     391        'FROM music_songs '. 
     392        'LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id '. 
     393        'WHERE album_id='.$sql_itemid.' '. 
     394        'ORDER BY track'; 
     395      $result = mysql_query($query); 
     396      if (!$result) 
     397        break; 
     398 
     399      while ($row = mysql_fetch_array($result)) 
     400      { 
     401        $output .= getHtmlSong($row['song_id'], $row['artist_name'], 
     402          '', $row['track'], $row['name'], 
     403          $row['length'], $row['numplays']); 
     404      } 
     405      mysql_free_result($result); 
     406      $output .= '</ul>'; 
     407      break; 
     408 
     409    case 'genre': 
     410      $output = '<div class="head"> 
     411        <h2 class="music">'.t('Songs for Genre')." '".$itemid."'</h2></div> 
     412        <p><strong>".t('Songs').'</strong></p> 
     413        <ul class="music">'; 
     414 
     415      $query = 'SELECT music_songs.*, music_artists.artist_name, music_genres.genre '. 
     416        'FROM music_songs '. 
     417        'LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id '. 
     418        'LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id '. 
     419        'WHERE genre='.$sql_itemid.';'; 
     420 
     421      $result = mysql_query($query); 
     422      if (!$result) 
     423        break; 
     424 
     425      while ($row = mysql_fetch_array($result)) 
     426      { 
     427        $output .= getHtmlSong($row['song_id'], $row['artist_name'], 
     428          '', '', $row['name'], 
     429          $row['length'], $row['numplays']); 
     430      } 
     431      mysql_free_result($result); 
     432      $output .= '</ul>'; 
     433      break; 
     434 
     435    case 'artist': 
     436      $query = 'SELECT artist_name '. 
     437        'FROM music_artists '. 
     438        'WHERE artist_id='.$sql_itemid; 
     439      $result = mysql_query($query); 
     440      if (!$result) 
     441        break; 
     442 
     443      $row = mysql_fetch_array($result); 
     444      mysql_free_result($result); 
     445      $artist = $row['artist_name']; 
     446 
     447      $output = '<div class="head"> 
     448        <h2 class="music">'.$artist.'</h2></div> 
     449        <p><strong>'.t('Songs').'</strong></p> 
     450        <ul class="music">'; 
     451 
     452      $query = 'SELECT music_songs.*, SEC_TO_TIME(music_songs.length/1000) AS length, music_artists.artist_name, track, music_albums.album_name '. 
     453        'FROM music_songs '. 
     454        'LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id '. 
     455        'LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id '. 
     456        'WHERE music_songs.artist_id='.$sql_itemid.';'; 
     457      $result = mysql_query($query); 
     458      if (!$result) 
     459        break; 
     460 
     461      while ($row = mysql_fetch_array($result)) 
     462      { 
     463        $output .= getHtmlSong($row['song_id'], '', 
     464          $row['album_name'], $row['track'], $row['name'], 
     465          $row['length'], $row['numplays']); 
     466      } 
     467      mysql_free_result($result); 
     468      $output .= '</ul><br /> 
     469        <p><strong>'.sprintf(t('Albums with songs by %s'),'<i>'.$artist.'</i>').'</strong></p> 
     470        <ul class="music">'; 
     471 
     472      $query = 'SELECT ma.album_id, album_name, ma.year, ma.artist_id, artist_name'. 
     473        ',SEC_TO_TIME(SUM(ms.length)/1000) AS length, COUNT(ms.song_id) AS num_tracks '. 
     474        'FROM music_songs AS ms '. 
     475        'LEFT JOIN music_albums AS ma ON ms.album_id=ma.album_id '. 
     476        'LEFT JOIN music_artists AS mt ON ma.artist_id=mt.artist_id '. 
     477        'WHERE ms.artist_id='.$sql_itemid.' '. 
     478        'GROUP BY ma.album_id;'; 
     479      $result = mysql_query($query); 
     480      if (!$result) 
     481        break; 
     482 
     483      while ($row = mysql_fetch_array($result)) 
     484      { 
     485        $artist = ''; 
     486        if ($itemid != $row['artist_id']) 
     487          $artist = $row['artist_name']; 
     488 
     489        $output .= getHtmlAlbum($row['album_id'], $row['album_name'], 
     490          $artist, $row['year'], $row['num_tracks'], $row['length']); 
     491      } 
     492      mysql_free_result($result); 
     493      $output .= '</ul>'; 
     494      break; 
     495 
     496    case 'random': 
     497      $output = '<div class="head"> 
     498        <h2 class="music">'.t('Random Mix Maker').'</h2></div> 
     499        <form onsubmit="return randAdd(this)" method="get" action=""> 
     500        <strong>'.t('Number of Songs').'</strong><br /> 
     501        <select name="random_count"> 
     502        <option>10</option> 
     503        <option>20</option> 
     504        <option>30</option> 
     505        <option>40</option> 
     506        <option>50</option> 
     507        </select><br /> 
     508        <strong>'.t('Random Type').'</strong><br /> 
     509        <select name="random_type" onchange="getRandItems(this.options[selectedIndex].value); return false;"> 
     510        <option value="">'.t('Choose Type').'...</option> 
     511        <option value="artists">'.t('Artists').'</option> 
     512        <option value="genre">'.t('Genre').'</option> 
     513        <option value="albums">'.t('Albums').'</option> 
     514        <option value="all">'.t('Everything').'</option> 
     515        </select><br /> 
     516        <strong>'.t('Random Items').'</strong> 
     517        <span id="rand_items"></span> 
     518        <br /><br /> 
     519        <input type="submit" value="'.t('Add Mix').'" class="btn" /> 
     520        </form>'; 
     521      break; 
     522 
     523    case 'playlists': 
     524      $query = 'SELECT playlist_id, playlist_name, songcount, hostname, SEC_TO_TIME(length/1000) AS length '. 
     525        'FROM music_playlists '. 
     526        'WHERE hostname=\'\''; 
     527      $result = mysql_query($query); 
     528      if (!$result) 
     529        break; 
     530 
     531      $output = '<div class="head"> 
     532        <h2 class="music">'.t('Saved Playlists').'</h2></div><br />'; 
     533 
     534      if (mysql_num_rows($result) == 0) 
     535      { 
     536        $output .= t('No Public Playlists'); 
     537      } 
     538      else 
     539      { 
     540        $unsaved_id = 0; 
     541        $pl = internalGetPlaylist(); 
     542        if (!empty($pl['playlist_name']) 
     543            && MYTH_WEB_PLAYLIST_NAME == $pl['playlist_name']) 
     544        { 
     545          $unsaved_id = $pl['playlist_id']; 
     546        } 
     547 
     548        $output .= '<ul class="music">'; 
     549        while ($row = mysql_fetch_array($result)) 
     550        { 
     551          $output .= getHtmlPlaylist($row['playlist_id'], $row['playlist_name'], 
     552            $row['songcount'], $row['length'], $unsaved_id); 
     553        } 
     554        $output .= '</ul>'; 
     555      } 
     556      mysql_free_result($result); 
     557      break; 
     558 
     559    case 'saved_pl': 
     560      $query = 'SELECT playlist_id, playlist_name, playlist_songs, songcount, SEC_TO_TIME(length/1000) AS length '. 
     561        'FROM music_playlists '. 
     562        'WHERE playlist_id='.$sql_itemid; 
     563      $result = mysql_query($query); 
     564      if (!$result) 
     565        break; 
     566 
     567      $row = mysql_fetch_array($result); 
     568      mysql_free_result($result); 
     569 
     570      $unsaved_id = 0; 
     571      $pl = internalGetPlaylist(); 
     572      if (!empty($pl['playlist_name']) 
     573          && MYTH_WEB_PLAYLIST_NAME == $pl['playlist_name']) 
     574      { 
     575        $unsaved_id = $pl['playlist_id']; 
     576      } 
     577 
     578      $output = '<div class="head"> 
     579        <div class="right"> 
     580        <a class="music" href="#" 
     581          onclick="checkPlaylistLoad(\''.$row['playlist_id'].'\', '.$unsaved_id.')'. 
     582          ' && pladd(\'loadplaylist\','.$row['playlist_id'].'); return false;" 
     583          title="'.t('Load Playlist').'">'.t('Load'). 
     584        '</a> 
     585        <a class="music" href="#" 
     586          onclick="pladd(\'playlist\','.$row['playlist_id'].'); return false;" 
     587          title="'.t('Append to Current Playlist').'">'.t('Append'). 
     588        '</a> 
     589        <a class="music" href="#" 
     590          onclick="play(\'pl\','.$row['playlist_id'].'); return false;" 
     591          title="'.t('Play this Playlist Now').'">'.t('Play'). 
     592        '</a> 
     593        </div> 
     594        <h2 class="music">'.t('View Saved Playlist').'</h2></div> 
     595        <p><strong>'.t('Playlist Info').'</strong><br />'. 
     596        sprintf('%s Songs', $row['songcount']).'<br />'.$row['length'].'</p> 
     597        <p><strong>'.t('Playlist Items').'</strong></p>'; 
     598 
     599 
     600      if (empty($row['playlist_songs'])) 
     601      { 
     602        $output = '<b>'.t('There are no items in this Playlist!').'</b>'; 
     603      } 
     604      else 
     605      { 
     606        // Load the song information 
     607        $query = 'SELECT ms.song_id, mt.artist_name, ms.name, ma.album_name, ms.track'. 
     608            ', SEC_TO_TIME(ms.length/1000) AS length '. 
     609            'FROM music_songs AS ms '. 
     610            'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     611            'LEFT JOIN music_albums AS ma ON ms.album_id=ma.album_id '. 
     612            'WHERE ms.song_id IN ('.$row['playlist_songs'].');'; 
     613        $result = mysql_query($query); 
     614        if (!$result) 
     615            return; 
     616 
     617        $song_info = array(); 
     618        while ($row2 = mysql_fetch_array($result)) 
     619        { 
     620            $song_info[$row2['song_id']] = $row2; 
     621        } 
     622        mysql_free_result($result); 
     623 
     624        // Load the sub-playlist information 
     625        // NB: MySQL 3.xx cannot use the CAST() function hense the negative number decimal 
     626        // conversion hack as outlined on: http://dev.mysql.com/doc/refman/4.1/en/cast-functions.html 
     627        $query = 'SELECT playlist_id, playlist_name, SEC_TO_TIME(length/1000) AS length, songcount '. 
     628            'FROM music_playlists '. 
     629            'WHERE (-1.0 * (playlist_id+0.0)) IN ('.$row['playlist_songs'].');'; 
     630        $result = mysql_query($query); 
     631        if (!$result) 
     632            return; 
     633 
     634        $pl_info = array(); 
     635        while ($row2 = mysql_fetch_array($result)) 
     636        { 
     637            $pl_info[$row2['playlist_id']] = $row2; 
     638        } 
     639        mysql_free_result($result); 
     640 
     641        $songs = explode(',', $row['playlist_songs']); 
     642        $output .= '<ul class="music">'; 
     643        foreach ($songs as $song_id) 
     644        { 
     645          if ($song_id > 0) 
     646          { 
     647            $row = $song_info[$song_id]; 
     648            $output .= getHtmlSong($row['song_id'], $row['artist_name'], 
     649              '', '', $row['name'], 
     650              $row['length'], $row['numplays']); 
     651          } 
     652          else if ($song_id < 0) 
     653          { 
     654            $row = $pl_info[-1 * $song_id]; 
     655            $output .= getHtmlPlaylist($row['playlist_id'], $row['playlist_name'], 
     656              $row['songcount'], $row['length'], $unsaved_id, false); 
     657          } 
     658        } 
     659        $output .= '</ul>'; 
     660      } 
     661      break; 
     662 
     663    case 'stats': 
     664      $query = 'SELECT * FROM music_stats'; 
     665      $result = mysql_query($query); 
     666      if (!$result) 
     667        break; 
     668 
     669      $row = mysql_fetch_array($result); 
     670      mysql_free_result($result); 
     671 
     672      $query = 'SELECT COUNT(*) AS songs FROM music_songs WHERE numplays>0'; 
     673      $result = mysql_query($query); 
     674      if (!$result) 
     675        break; 
     676 
     677      $row2 = mysql_fetch_array($result); 
     678      mysql_free_result($result); 
     679 
     680      $output = '<div class="head"> 
     681        <h2 class="music">'.t('Server Statistics').'</h2></div> 
     682        <p><a class="music" href="#" onclick="updateBox(\'recentadd\',0); return false;">'. 
     683        t('Recently Added Albums').'</a><br /> 
     684        <a class="music" href="#" onclick="updateBox(\'recentplay\',0); return false;">'. 
     685        t('Recently Played Songs').'</a><br /> 
     686        <a class="music" href="#" onclick="updateBox(\'topplay\',0); return false;">'. 
     687        t('Top Played Songs').'</a><br /> 
     688        </p> 
     689        <h3>'.t('Local Server Statistics').'</h3> 
     690        <p>'; 
     691 
     692      foreach (array('music_songs'   => t('Songs'), 
     693                     'music_albums'  => t('Albums'), 
     694                     'music_artists' => t('Artists'), 
     695                     'music_genres'  => t('Genres')) as $table => $title) 
     696      { 
     697        $result = mysql_query('SELECT COUNT(*) FROM '.$table.';'); 
     698        if (!$result) 
     699          continue; 
     700        $count = mysql_fetch_array($result); 
     701        mysql_free_result($result); 
     702        $output .= '<strong>'.$title.':</strong> '.$count[0].'<br />'; 
     703      } 
     704      $output .= '<br /><strong>'.t('Songs Played').':</strong> '.$row2['songs'].'<br /></p>'; 
     705      break; 
     706 
     707    case 'recentadd': 
     708      $query = 'SELECT ma.album_name, ma.album_id, mt.artist_name, UNIX_TIMESTAMP(ms.date_entered) AS pubdate '. 
     709        'FROM music_songs AS ms '. 
     710        'LEFT JOIN music_albums AS ma ON ms.album_id=ma.album_id '. 
     711        'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     712        'GROUP BY ms.album_id '. 
     713        'ORDER BY ms.date_entered DESC '. 
     714        'LIMIT 40'; 
     715      $result = mysql_query($query); 
     716      if (!$result) 
     717        break; 
     718 
     719      $output = '<div class="head"> 
     720        <div class="right"> 
     721        <a class="music" href="#" 
     722          onclick="switchPage(\'stats\'); return false;" 
     723          title="'.t('Return to Statistics Page').'">'.t('Back').'</a></div> 
     724        <h2 class="music">'.t('Recently Added Albums').'</h2></div> 
     725        <ul class="music">'; 
     726      while ($row = mysql_fetch_array($result)) 
     727      { 
     728        $output .= getHtmlAlbum($row['album_id'], $row['album_name'], 
     729          $row['artist_name'], '', '', '', date('m.d.Y', $row['pubdate'])); 
     730      } 
     731      mysql_free_result($result); 
     732      $output .= '</ul>'; 
     733      break; 
     734 
     735    case 'topplay': 
     736      $query = 'SELECT ma.album_name, ms.numplays, ms.name, mt.artist_name, ms.song_id '. 
     737        'FROM music_songs AS ms '. 
     738        'LEFT JOIN music_albums AS ma ON ms.album_id=ma.album_id '. 
     739        'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     740        'WHERE ms.numplays > 0 '. 
     741        'ORDER BY ms.numplays DESC '. 
     742        'LIMIT 40'; 
     743      $result = mysql_query($query); 
     744      if (!$result) 
     745        break; 
     746 
     747      $output = '<div class="head"> 
     748        <div class="right"> 
     749        <a class="music" href="#" 
     750          onclick="switchPage(\'stats\'); return false;" 
     751          title="'.t('Return to Statistics Page').'">'.t('Back').'</a></div> 
     752        <h2 class="music">'.t('Top Played Songs').'</h2></div> 
     753        <ul class="music">'; 
     754      while ($row = mysql_fetch_array($result)) 
     755      { 
     756        $output .= getHtmlSong($row['song_id'], $row['artist_name'], 
     757          '', '', $row['name'], 
     758          '', ''); 
     759      } 
     760      mysql_free_result($result); 
     761      $output .= '</ul>'; 
     762      break; 
     763 
     764    case 'recentplay': 
     765      $query = 'SELECT ms.name, ms.song_id, mt.artist_name, UNIX_TIMESTAMP(ms.lastplay) AS playdate '. 
     766        'FROM music_songs AS ms '. 
     767        'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     768        'ORDER BY ms.lastplay DESC '. 
     769        'LIMIT 40'; 
     770      $result = mysql_query($query); 
     771      if (!$result) 
     772        break; 
     773 
     774      $output = '<div class="head"> 
     775        <div class="right"> 
     776        <a class="music" href="#" 
     777          onclick="switchPage(\'stats\'); return false;" 
     778          title="'.t('Return to Statistics Page').'">'.t('Back').'</a></div> 
     779        <h2 class="music">'.t('Recently Played Songs').'</h2></div> 
     780        <ul class="music">'; 
     781      while ($row = mysql_fetch_array($result)) 
     782      { 
     783        $output .= getHtmlSong($row['song_id'], $row['artist_name'], 
     784          '', '', $row['name'], 
     785          '', ''); 
     786      } 
     787      $output .= '</ul>'; 
     788      break; 
     789  } 
     790 
     791  return $output; 
     792} 
     793 
     794 
     795function getRandItems($type) 
     796{ 
     797  switch ($type) 
     798  { 
     799    case 'artists': 
     800      $query = 'SELECT artist_id, artist_name FROM music_artists ORDER BY artist_name'; 
     801      break; 
     802    case 'genre': 
     803      $query = 'SELECT genre_id, genre FROM music_genres ORDER BY genre'; 
     804      break; 
     805    case 'albums': 
     806      $query = 'SELECT album_id, album_name FROM music_albums ORDER BY album_name'; 
     807      break; 
     808    default: 
     809      return '<br />'.t('All Songs'); 
     810  } 
     811 
     812  $result = mysql_query($query); 
     813  if (!$result) 
     814    return ''; 
     815 
     816  $options = ''; 
     817  while ($row = mysql_fetch_array($result)) 
     818  { 
     819    $options .= '<option value="'.$row[0].'">'. 
     820      $row[1].'</option>'; 
     821  } 
     822  mysql_free_result($result); 
     823 
     824  return '<select name="random_items" multiple="multiple" size="12" style="width: 90%;">'. 
     825    $options.'</select>'; 
     826} 
     827 
     828 
     829function searchMusic($terms, $option) 
     830{ 
     831  $sql_terms = "'%".mysql_real_escape_string($terms)."%'"; 
     832  $query = 'SELECT ms.song_id, ma.album_name, ms.track, mt.artist_name, ms.name, SEC_TO_TIME(ms.length/1000) AS length '. 
     833    'FROM music_songs AS ms '. 
     834    'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     835    'LEFT JOIN music_albums AS ma ON ms.album_id=ma.album_id '. 
     836    'WHERE 1 AND '; 
     837 
     838  if ($option == 'all') 
     839  { 
     840    $query .= '(ms.name LIKE '.$sql_terms. 
     841      ' OR mt.artist_name LIKE '.$sql_terms. 
     842      ' OR ma.album_name LIKE '.$sql_terms.')'; 
     843  } 
     844  else if ($option == 'artists') 
     845  { 
     846    $query .= '(mt.artist_name LIKE '.$sql_terms.')'; 
     847  } 
     848  else if ($option == 'albums') 
     849  { 
     850    $query .= '(ma.album_name LIKE '.$sql_terms.')'; 
     851  } 
     852  else if ($option == 'songs') 
     853  { 
     854    $query .= '(ms.name LIKE '.$sql_terms.')'; 
     855  } 
     856  $query .= ' ORDER BY mt.artist_name, ma.album_name, ms.track, ms.name'; 
     857 
     858  $result = mysql_query($query); 
     859  if (!$result) 
     860    return ''; 
     861 
     862  $count = mysql_num_rows($result); 
     863 
     864  $output = '<div class="head"> 
     865    <div class="right"> 
     866    <a class="music" href="#" 
     867      onclick="switchPage(\'search\'); return false;" 
     868      title="'.t('Begin a New Search').'">'.t('New Search').'</a></div> 
     869    <h2 class="music">'.sprintf(t("Found %s results for '%s'"), $count, $terms).'</h2></div>'; 
     870 
     871  if($count > 0) 
     872  { 
     873    $output .= '<ul class="music">'; 
     874    while ($row = mysql_fetch_array($result)) 
     875    { 
     876      $output .= getHtmlSong($row['song_id'], $row['artist_name'], 
     877        $row['album_name'], $row['track'], $row['name'], 
     878        $row['length'], ''); 
     879    } 
     880    $output .= '</ul>'; 
     881  } 
     882  return $output; 
     883} 
     884 
     885function internalGetPlaylist($plId = 0) 
     886{ 
     887  $row = array(); 
     888  if (empty($plId)) 
     889  { 
     890    if (empty($_COOKIE['mp3act_playlist_id'])) 
     891      return $row; 
     892    $plId = $_COOKIE['mp3act_playlist_id']; 
     893  } 
     894 
     895  $query = 'SELECT playlist_id, playlist_name, playlist_songs, songcount, length AS length_in_secs'. 
     896    ', SEC_TO_TIME(length/1000) AS length '. 
     897    'FROM music_playlists '. 
     898    'WHERE playlist_id='.mysql_real_escape_string($plId); 
     899 
     900  $result = mysql_query($query); 
     901  if (!$result) 
     902    return $row; 
     903 
     904  if (mysql_num_rows($result) > 0) 
     905    $row = mysql_fetch_array($result); 
     906  mysql_free_result($result); 
     907 
     908  // Set the last accessed time for Temporary playlists so that 
     909  // we can run a garbage colnctor later. 
     910  if (MYTH_WEB_PLAYLIST_NAME == $row['playlist_name']) 
     911  { 
     912    $query = 'UPDATE music_playlists'. 
     913      ' SET last_accessed=NULL '. 
     914      'WHERE playlist_id='.mysql_real_escape_string($plId); 
     915    mysql_query($query); 
     916  } 
     917 
     918  return $row; 
     919} 
     920 
     921function internalUpdatePlaylist($songs, $count, $length) 
     922{ 
     923  $plId = 0; 
     924  if (!empty($_COOKIE['mp3act_playlist_id'])) 
     925    $plId = $_COOKIE['mp3act_playlist_id']; 
     926 
     927  $songlist = implode(',', $songs); 
     928 
     929  $query = 'music_playlists SET'. 
     930    " playlist_songs='".mysql_real_escape_string($songlist)."'". 
     931    ',length='.mysql_real_escape_string($length). 
     932    ',songcount='.mysql_real_escape_string($count); 
     933 
     934  if (empty($plId)) 
     935  { 
     936    $query = 'INSERT INTO '.$query. 
     937      ",hostname='".mysql_real_escape_string('mythweb-'.$_SERVER['SERVER_NAME'])."'". 
     938      ",playlist_name='".MYTH_WEB_PLAYLIST_NAME."'"; 
     939  } 
     940  else 
     941  { 
     942    $query = 'UPDATE '.$query. 
     943      ' WHERE playlist_id='.mysql_real_escape_string($plId); 
     944  } 
     945  mysql_query($query); 
     946 
     947  if (empty($plId)) 
     948  { 
     949    $plId = mysql_insert_id(); 
     950    if ($plId) 
     951    { 
     952      setcookie('mp3act_playlist_id', $plId, time()+MYTH_PLAYLIST_SAVE_TIME); 
     953      return $plId; 
     954    } 
     955  } 
     956  return false; 
     957} 
     958 
     959function viewPlaylist() 
     960{ 
     961  $pl = internalGetPlaylist(); 
     962 
     963  if (empty($pl['playlist_songs'])) 
     964  { 
     965    return ''; 
     966  } 
     967 
     968  // Load the song information 
     969  $query = 'SELECT ms.song_id, mt.artist_name, ms.name, ma.album_name, ms.track'. 
     970    ', SEC_TO_TIME(ms.length/1000) AS length '. 
     971    'FROM music_songs AS ms '. 
     972    'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     973    'LEFT JOIN music_albums AS ma ON ms.album_id=ma.album_id '. 
     974    'WHERE ms.song_id IN ('.$pl['playlist_songs'].');'; 
     975  $result = mysql_query($query); 
     976  if (!$result) 
     977    return; 
     978 
     979  $song_info = array(); 
     980  while ($row = mysql_fetch_array($result)) 
     981  { 
     982    $song_info[$row['song_id']] = $row; 
     983  } 
     984  mysql_free_result($result); 
     985 
     986  // Load the sub-playlist information 
     987  // NB: MySQL 3.xx cannot use the CAST() function hense the negative number decimal 
     988  // conversion hack as outlined on: http://dev.mysql.com/doc/refman/4.1/en/cast-functions.html 
     989  $query = 'SELECT playlist_id, playlist_name, SEC_TO_TIME(length/1000) AS length, songcount '. 
     990    'FROM music_playlists '. 
     991    'WHERE (-1.0 * (playlist_id+0.0)) IN ('.$pl['playlist_songs'].');'; 
     992  $result = mysql_query($query); 
     993  if (!$result) 
     994    return; 
     995 
     996  $pl_info = array(); 
     997  while ($row = mysql_fetch_array($result)) 
     998  { 
     999    $pl_info[$row['playlist_id']] = $row; 
     1000  } 
     1001  mysql_free_result($result); 
     1002 
     1003 
     1004  $songs = explode(',', $pl['playlist_songs']); 
     1005  $output = ''; 
     1006  $id=0; 
     1007  foreach ($songs as $song_id) 
     1008  { 
     1009    // Create a random id for Javascript events. 
     1010    $id = md5($song_id.mt_rand()); 
     1011    if ($song_id > 0) 
     1012    { 
     1013      $row = $song_info[$song_id]; 
     1014      $output .= getHtmlPlaylistEntrySong($id, $row['artist_name'], 
     1015        $row['album_name'], $row['track'], $row['name'], $row['length']); 
     1016    } 
     1017    else 
     1018    { 
     1019      $row = $pl_info[-1 * $song_id]; 
     1020      $output .= getHtmlPlaylistEntryPlaylist($id, $row['playlist_name'], 
     1021        $row['songcount'], $row['length']); 
     1022    } 
     1023  } 
     1024  return $output; 
     1025} 
     1026 
     1027 
     1028function playlistInfo() 
     1029{ 
     1030  $pl = internalGetPlaylist(); 
     1031 
     1032  $info = ''; 
     1033 
     1034  if (!empty($pl) && MYTH_WEB_PLAYLIST_NAME != $pl['playlist_name']) 
     1035    $info = '<em>'.$pl['playlist_name'].'</em> &mdash; '; 
     1036 
     1037  if (empty($pl['playlist_songs'])) 
     1038  { 
     1039    $info .= t('Playlist is empty'); 
     1040  } 
     1041  else 
     1042  { 
     1043    if (1 == $pl['count']) 
     1044      $info .= sprintf(t('%s Song (%s)'), $pl['songcount'], $pl['length']); 
     1045    else 
     1046      $info .= sprintf(t('%s Songs (%s)'), $pl['songcount'], $pl['length']); 
     1047  } 
     1048 
     1049  return $info; 
     1050} 
     1051 
     1052 
     1053function savePlaylist($pl_name, $newpl) 
     1054{ 
     1055  $pl = internalGetPlaylist(); 
     1056 
     1057  if (!empty($pl['playlist_id'])) 
     1058    $pl_id = $pl['playlist_id']; 
     1059  else 
     1060    $pl_id = internalUpdatePlaylist(array(), 0, 0); 
     1061 
     1062  if (empty($pl_id)) 
     1063  { 
     1064    $msg = t('There was a problem saving your playlist'); 
     1065  } 
     1066  else 
     1067  { 
     1068    $query = 'UPDATE music_playlists SET'. 
     1069      ' playlist_name=\''.mysql_real_escape_string($pl_name).'\''. 
     1070      ",hostname='' ". 
     1071      'WHERE playlist_id='.mysql_real_escape_string($pl['playlist_id']); 
     1072 
     1073    mysql_query($query); 
     1074 
     1075    if (MYTH_WEB_PLAYLIST_NAME == $pl['playlist_name']) 
     1076      $msg = t('Playlist saved successfully'); 
     1077    else 
     1078      $msg = t('Playlist renamed successfully'); 
     1079  } 
     1080 
     1081  return '<h2 class="music">'.$msg.'</h2>'; 
     1082} 
     1083 
     1084function clearPlaylist() 
     1085{ 
     1086  $pl = internalGetPlaylist(); 
     1087 
     1088  // Trash the cookie (empties the playlist) 
     1089  setcookie('mp3act_playlist_id', false, time()-3600); 
     1090 
     1091  if (!empty($pl['playlist_name']) 
     1092      && MYTH_WEB_PLAYLIST_NAME == $pl['playlist_name']) 
     1093  { 
     1094    deletePlaylist($pl['playlist_id']); 
     1095  } 
     1096 
     1097  return t('Playlist is empty'); 
     1098} 
     1099 
     1100 
     1101function deletePlaylist($id) 
     1102{ 
     1103  $rv = 0; 
     1104  if ($id == $_COOKIE['mp3act_playlist_id']) 
     1105  { 
     1106    $rv = 1; 
     1107    setcookie('mp3act_playlist_id', false, time()-3600); 
     1108  } 
     1109 
     1110  $query = 'DELETE FROM music_playlists '. 
     1111    'WHERE playlist_id='.mysql_real_escape_string($id); 
     1112  mysql_query($query); 
     1113  return $rv; 
     1114} 
     1115 
     1116 
     1117function playlist_rem($itemid) 
     1118{ 
     1119  $pl = internalGetPlaylist(); 
     1120 
     1121  $songs = explode(',', $pl['playlist_songs']); 
     1122  $idx = intval($itemid); 
     1123  if (isset($songs[$idx])) 
     1124  { 
     1125    // Find the length of the song we are removing so we can update the p/l 
     1126    $id = $songs[$idx]; 
     1127    if ($id > 0) 
     1128    { 
     1129      $query = 'SELECT length, 1 AS songcount FROM music_songs '. 
     1130        'WHERE song_id='.mysql_real_escape_string($id); 
     1131    } 
     1132    else 
     1133    { 
     1134      $query = 'SELECT length, songcount FROM music_playlists '. 
     1135        'WHERE playlist_id='.mysql_real_escape_string(-1 * $id); 
     1136    } 
     1137    $result = mysql_query($query); 
     1138    $length = $count = 0; 
     1139    if ($result) 
     1140    { 
     1141      $row = mysql_fetch_array($result); 
     1142      mysql_free_result($result); 
     1143      if ($row) 
     1144      { 
     1145        $length = $row['length']; 
     1146        $count = $row['songcount']; 
     1147      } 
     1148    } 
     1149    unset($songs[$idx]); 
     1150    internalUpdatePlaylist($songs, 
     1151      ($pl['songcount'] - $count), 
     1152      ($pl['length_in_secs'] - $length)); 
     1153  } 
     1154  return $itemid; 
     1155} 
     1156 
     1157function playlist_move($item1,$item2) 
     1158{ 
     1159  $pl = internalGetPlaylist(); 
     1160 
     1161  $idx1 = intval($item1); 
     1162  $idx2 = intval($item2); 
     1163 
     1164  $songs = explode(',',$pl['playlist_songs']); 
     1165 
     1166  if (!isset($songs[$idx1]) || !isset($songs[$idx2])) 
     1167    return; 
     1168 
     1169  $tmp = $songs[$idx1]; 
     1170  $songs[$idx1] = $songs[$idx2]; 
     1171  $songs[$idx2] = $tmp; 
     1172 
     1173  $query = 'UPDATE music_playlists SET'. 
     1174    ' playlist_songs=\''.mysql_real_escape_string(implode(',', $songs)).'\' '. 
     1175    'WHERE playlist_id='.mysql_real_escape_string($pl['playlist_id']).';'; 
     1176  mysql_query($query); 
     1177} 
     1178 
     1179function internalPlaylistAddPlaylistCheck($curPlId, $addPlId, $depth = 0) 
     1180{ 
     1181  // Infinite loop protection (e.g. if the DB is messed up already) 
     1182  if ($depth > 25) 
     1183    return false; 
     1184 
     1185  // Looking to see if $addPlId playlist at any point includes $curPlId playlist 
     1186  if ($curPlId == $addPlId) 
     1187    return false; 
     1188 
     1189  $query = 'SELECT playlist_songs '. 
     1190    'FROM music_playlists '. 
     1191    'WHERE playlist_id='.mysql_real_escape_string($addPlId); 
     1192 
     1193  $result = mysql_query($query); 
     1194  if (!$result) 
     1195    return false; 
     1196 
     1197  $row = mysql_fetch_array($result); 
     1198  mysql_free_result($result); 
     1199 
     1200  if (!$row) // Not a real playlist. 
     1201    return false; 
     1202 
     1203  $songs = explode(',', $row['playlist_songs']); 
     1204  $playlists = array_filter($songs, create_function('$n','return ($n < 0);')); 
     1205 
     1206  foreach ($playlists as $playlist_id) 
     1207  { 
     1208    if ($playlist_id > 0) 
     1209      continue; // Shouldn't happen due to the filter above but I'm paranoid. 
     1210 
     1211    $playlist_id *= -1; 
     1212 
     1213    if (!internalPlaylistAddPlaylistCheck($curPlId, $playlist_id, $depth+1)) 
     1214      return false; 
     1215  } 
     1216 
     1217  return true; 
     1218} 
     1219 
     1220 
     1221function playlist_add($type, $itemid) 
     1222{ 
     1223  $output = array(0 => '', 1 => 0); 
     1224 
     1225  if ('loadplaylist' == $type) 
     1226  { 
     1227    clearPlaylist(); 
     1228    setcookie('mp3act_playlist_id', $itemid, time()+MYTH_PLAYLIST_SAVE_TIME); 
     1229    $output[0] = 1; 
     1230    return $output; 
     1231  } 
     1232 
     1233  $pl = internalGetPlaylist(); 
     1234 
     1235  if (empty($pl['playlist_songs'])) 
     1236  { 
     1237    $songs = array(); 
     1238    $new_length = 0; 
     1239    $new_songcount = 0; 
     1240  } 
     1241  else 
     1242  { 
     1243    $songs = explode(',', $pl['playlist_songs']); 
     1244    $new_length = $pl['length_in_secs']; 
     1245    $new_songcount = $pl['songcount']; 
     1246  } 
     1247 
     1248  if ('playlist' == $type) 
     1249  { 
     1250    if (!empty($pl['playlist_id'])) 
     1251    { 
     1252      if (!internalPlaylistAddPlaylistCheck($pl['playlist_id'], $itemid)) 
     1253      { 
     1254        // Some sort of nasty circular dependancy. 
     1255        $output[0] = 2; 
     1256        $output[1] = t('Sorry, but you cannot add this playlist as it would create a circular dependancy.'); 
     1257        return $output; 
     1258      } 
     1259    } 
     1260    $pl_add = internalGetPlaylist($itemid); 
     1261    if (empty($pl_add['playlist_id'])) 
     1262    { 
     1263    $output[0] = 2; 
     1264    $output[1] = t('An error occured while adding your playlist.'); 
     1265    return $output; 
     1266    } 
     1267    $new_songcount += $pl_add['songcount']; 
     1268    $new_length += $pl_add['length_in_secs']; 
     1269    $songs[] = -1 * $itemid; 
     1270 
     1271    $id = md5((-1 * $itemid).mt_rand()); 
     1272    $output[0] .= getHtmlPlaylistEntryPlaylist($id, $pl_add['playlist_name'], 
     1273    $pl_add['songcount'], $pl_add['length']); 
     1274    $output[1]++; 
     1275    $output[] = 'pl'.$id; 
     1276 
     1277    internalUpdatePlaylist($songs, $new_songcount, $new_length); 
     1278 
     1279    return $output; 
     1280  } 
     1281 
     1282  $sql_itemid = mysql_real_escape_string($itemid); 
     1283  $query = 'SELECT ms.song_id, mt.artist_name, ma.album_name,'. 
     1284    ' length AS length_in_secs, SEC_TO_TIME(ms.length/1000) AS length, ms.name, ms.track '. 
     1285    'FROM music_songs AS ms '. 
     1286    'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     1287    'LEFT JOIN music_albums AS ma ON ms.album_id=ma.album_id '. 
     1288    'WHERE '; 
     1289  switch ($type) 
     1290  { 
     1291    case 'song': 
     1292      $query .= 'ms.song_id='.$sql_itemid; 
     1293      break; 
     1294    case 'album': 
     1295      $query .= 'ms.album_id='.$sql_itemid; 
     1296      break; 
     1297    default: 
     1298      return $output; 
     1299  } 
     1300 
     1301  $result = mysql_query($query.' ORDER BY ms.track'); 
     1302  if (!$result) 
     1303    return $output; 
     1304 
     1305  while ($row = mysql_fetch_array($result)) 
     1306  { 
     1307    $id = md5($row['song_id'].mt_rand()); 
     1308    $output[0] .= getHtmlPlaylistEntrySong($id, $row['artist_name'], 
     1309      $row['album_name'], $row['track'], $row['name'], $row['length']); 
     1310    $output[1]++; 
     1311    $output[] = 'pl'.$id; 
     1312 
     1313    $songs[] = $row['song_id']; 
     1314    $new_length += $row['length_in_secs']; 
     1315    $new_songcount++; 
     1316  } 
     1317  mysql_free_result($result); 
     1318 
     1319  internalUpdatePlaylist($songs, $new_songcount, $new_length); 
     1320 
     1321  return $output; 
     1322} 
     1323 
     1324function randAdd($type,$num=0,$items='') 
     1325{ 
     1326  $output = array(0 => 1); 
     1327  // Check to see if $items matches our REGEXP. 
     1328  if (!preg_match('/^[0-9]+(,[0-9]+)*$/', $items)) 
     1329  { 
     1330    return $output; 
     1331  } 
     1332  $sql_items = mysql_real_escape_string($items); 
     1333 
     1334  $query = 'SELECT song_id, length '. 
     1335    'FROM music_songs '; 
     1336  switch($type) 
     1337  { 
     1338    case 'artists': 
     1339      $query .= 'WHERE artist_id IN ('.$sql_items.') '; 
     1340      break; 
     1341    case 'genre': 
     1342      $query .= 'WHERE genre_id IN ('.$sql_items.') '; 
     1343      break; 
     1344    case 'albums': 
     1345      $query .= 'WHERE album_id IN ('.$sql_items.') '; 
     1346      break; 
     1347  } 
     1348  $query .= 'ORDER BY RAND()+0 '. 
     1349    'LIMIT '.mysql_real_escape_string(intval($num)); 
     1350  $result = mysql_query($query); 
     1351 
     1352  if (!$result) 
     1353    return $output; 
     1354 
     1355  $pl = internalGetPlaylist(); 
     1356 
     1357  if (empty($pl['playlist_songs'])) 
     1358  { 
     1359    $songs = array(); 
     1360    $new_length = 0; 
     1361    $new_songcount = 0; 
     1362  } 
     1363  else 
     1364  { 
     1365    $songs = explode(',', $pl['playlist_songs']); 
     1366    $new_length = $pl['length_in_secs']; 
     1367    $new_songcount = $pl['songcount']; 
     1368  } 
     1369 
     1370  while ($row = mysql_fetch_array($result)) 
     1371  { 
     1372    $songs[] = $row['song_id']; 
     1373    $new_length += $row['length']; 
     1374    $new_songcount++; 
     1375  } 
     1376  mysql_free_result($result); 
     1377 
     1378  internalUpdatePlaylist($songs, $new_songcount, $new_length); 
     1379 
     1380  return $output; 
     1381} 
     1382 
     1383function getPlaylistM3u($id, $quality, $depth = 0) 
     1384{ 
     1385  $tmp = ''; 
     1386  if ($depth > 20) 
     1387    return $tmp; 
     1388 
     1389  $pl = internalGetPlaylist($id); 
     1390  if (empty($pl['playlist_songs'])) 
     1391  { 
     1392    return $tmp; 
     1393  } 
     1394 
     1395  $query = 'SELECT ms.song_id, artist_name, ms.name, (ms.length/1000) AS length '. 
     1396    'FROM music_songs AS ms '. 
     1397    'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     1398    'WHERE ms.song_id IN ('.mysql_real_escape_string($pl['playlist_songs']).')'; 
     1399 
     1400  $song_info = array(); 
     1401  $result = mysql_query($query); 
     1402  if (!$result) 
     1403    return $tmp; 
     1404 
     1405  while ($row = mysql_fetch_array($result)) 
     1406  { 
     1407    $song_info[$row['song_id']] = $row; 
     1408  } 
     1409  mysql_free_result($result); 
     1410 
     1411  $songs = explode(',', $pl['playlist_songs']); 
     1412  foreach ($songs as $song_id) 
     1413  { 
     1414    if ($song_id > 0) 
     1415    { 
     1416      $row = $song_info[$song_id]; 
     1417      $tmp .= '#EXTINF:'.intval($row['length']).','.$row['artist_name'].' - '.$row['name']."\n"; 
     1418      $tmp .= music_dir().'mp3act_playstream.php?i='.$row['song_id'].'&q='.$quality."\n"; 
     1419    } 
     1420    else if ($song_id < 1) 
     1421    { 
     1422      $tmp .= getPlaylistM3u((-1 * $song_id), $quality, $depth+1); 
     1423    } 
     1424  } 
     1425 
     1426  return $tmp; 
     1427} 
     1428 
     1429function play($type, $id, $quality = 'high') 
     1430{ 
     1431  $tmp = ''; 
     1432  $query = ''; 
     1433 
     1434  if ('pl' == $type) 
     1435  { 
     1436    $tmp .= getPlaylistM3u($id, $quality); 
     1437  } 
     1438  else 
     1439  { 
     1440    $query = 'SELECT ms.song_id, artist_name, ms.name, (ms.length/1000) AS length '. 
     1441      'FROM music_songs AS ms '. 
     1442      'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     1443      'WHERE '; 
     1444 
     1445    $sql_id = mysql_real_escape_string($id); 
     1446    switch ($type) 
     1447    { 
     1448      case 'song': 
     1449        $query .= 'ms.song_id='.$sql_id; 
     1450        break; 
     1451      case 'album': 
     1452        $query .= 'ms.album_id='.$sql_id.' '. 
     1453          'ORDER BY ms.track'; 
     1454        break; 
     1455      default: 
     1456        return ''; 
     1457    } 
     1458 
     1459    $result = mysql_query($query); 
     1460    if ($result) 
     1461    { 
     1462      while ($row = mysql_fetch_array($result)) 
     1463      { 
     1464        $tmp .= '#EXTINF:'.intval($row['length']).','.$row['artist_name'].' - '.$row['name']."\n"; 
     1465        $tmp .= music_dir().'mp3act_playstream.php?i='.$row['song_id'].'&q='.$quality."\n"; 
     1466      } 
     1467      mysql_free_result($result); 
     1468    } 
     1469  } 
     1470  session_cache_limiter('nocache'); 
     1471  header('Content-Type: audio/mpegurl;'); 
     1472  header('Content-Disposition: inline; filename="playlist.m3u"'); 
     1473  header('Expires: 0'); 
     1474  header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
     1475  header('Pragma: nocache'); 
     1476 
     1477  return "#EXTM3U\n".$tmp; 
     1478} 
     1479 
     1480 
     1481?> 
  • mythweb/modules/music/mp3act_hidden.php

     
     1<?php 
     2// hidden iframe to process streaming 
     3require_once('modules/music/mp3act_functions.php'); 
     4 
     5// Play the Music 
     6if ('' != $_GET['id']) 
     7    echo play($_GET['type'], $_GET['id'], $_GET['quality']); 
     8?> 
  • mythweb/modules/music/init.php

     
    1616// First, we should check to see that MythMusic is configured. 
    1717// Make sure to turn off fatal errors in case the table isn't there. 
    1818    $db->disable_fatal_errors(); 
    19     $has_music = $db->query_col('SELECT COUNT(*) FROM musicmetadata'); 
     19    $has_music = $db->query_col('SELECT COUNT(*) FROM music_songs'); 
    2020    $db->enable_fatal_errors(); 
    2121    $db->error(false); 
    2222 
  • mythweb/modules/music/mp3act_html_functions.php

     
     1<?php 
     2 
     3function getHtmlSong($id, $artistName, $albumName, $trackNum, $trackName, $trackLength, $numPlays) 
     4{ 
     5  static $alt = true; 
     6  $alt = !$alt; 
     7  $output = '<li'.($alt ? ' class="alt"' : ''). 
     8    ' ondblclick="pladd(\'song\','.$id.'); return false;"> 
     9    <a class="music" href="#" 
     10      onclick="pladd(\'song\','.$id.'); return false;" 
     11      title="'.t('Add Song to Current Playlist').'"> 
     12    <img src="'.pic_dir().'add.gif" /></a> 
     13    <a class="music" href="#" 
     14      onclick="play(\'song\','.$id.'); return false;" 
     15      title="'.t('Play this Song Now').'"> 
     16    <img src="'.pic_dir().'play.gif" /></a> '; 
     17 
     18  if (!empty($artistName)) 
     19    $output .= (!empty($trackNum) ? $trackNum.'. ' : '').'<em>'.$artistName.'</em> - '; 
     20 
     21  $output .= $trackName; 
     22 
     23  $sub_output = ''; 
     24 
     25  if (!empty($albumName)) 
     26    $sub_output .= sprintf(t('Track #%s from the album \'%s\''), $trackNum, $albumName).'<br />'; 
     27 
     28  if (!empty($numPlays)) 
     29  { 
     30    if (1 == $numPlays) 
     31      $sub_output .= t('Played once').'<br />'; 
     32    else 
     33      $sub_output .= sprintf(t('Played %s times'), $numPlays).'<br />'; 
     34  } 
     35 
     36  if (!empty($trackLength)) 
     37    '<em>'.$trackLength.'</em>'; 
     38 
     39  if (!empty($sub_output)) 
     40  { 
     41    $output .= '<p>'.$sub_output.'</p>'; 
     42  } 
     43 
     44  $output .= '</li>'; 
     45  return $output; 
     46} 
     47 
     48 
     49function getHtmlAlbum($id, $albumName, $artistName='', $year='', $numTracks='', $length='', $extra='') 
     50{ 
     51  static $alt = true; 
     52  $alt = !$alt; 
     53  $output = '<li'.($alt ? ' class="alt"' : '').'>'; 
     54 
     55  if (!empty($extra)) 
     56    $output .= '<small>'.$extra.'</small>'; 
     57 
     58  $output .= '<a class="music" href="#" 
     59      onclick="pladd(\'album\','.$id.'); return false;" 
     60      title="'.t('Add Album to Current Playlist').'"> 
     61    <img src="'.pic_dir().'add.gif" /></a> 
     62    <a class="music" href="#" 
     63      onclick="play(\'album\','.$id.'); return false;" 
     64      title="'.t('Play this Album Now').'"> 
     65    <img src="'.pic_dir().'play.gif" /></a> 
     66    <a class="music" href="#" 
     67      onclick="updateBox(\'album\','.$id.'); return false;" 
     68      title="'.sprintf(t('View Details of %s'), $albumName).'">'. 
     69    $albumName; 
     70 
     71  if (!empty($artistName)) 
     72    $output .= ' &mdash; <em>'.$artistName.'</em>'; 
     73 
     74  $output .= '</a>'; 
     75 
     76  $sub_output = ''; 
     77 
     78  if (!empty($year)) 
     79    $sub_output .= t('Year').': '.$year.'<br />'; 
     80 
     81  if (!empty($numTracks)) 
     82    $sub_output .= t('# Tracks').': '.$numTracks.'<br />'; 
     83 
     84  if (!empty($length)) 
     85    $sub_output .= t('Total Length').': '.$length.'<br />'; 
     86 
     87  if (!empty($sub_output)) 
     88    $output .= '<p>'.$sub_output.'</p>'; 
     89 
     90  $output .= '</li>'; 
     91  return $output; 
     92} 
     93 
     94 
     95function getHtmlPlaylist($playlistId, $playlistName, $songcount, $length, $unsavedId = 0, $blnShowDelete = true) 
     96{ 
     97  return '<li> 
     98    <a class="music" href="#" 
     99        onclick="pladd(\'playlist\','.$playlistId.'); return false;" 
     100        title="'.t('Add this Playlist as a Subplaylist').'"> 
     101        <img src="'.pic_dir().'add.gif" /></a> 
     102    <a class="music" href="#" 
     103        onclick="checkPlaylistLoad(\''.$playlistId.'\', '.$unsavedId.')'. 
     104        ' && pladd(\'loadplaylist\','.$playlistId.'); return false;" 
     105        title="'.t('Load this Saved Playlist').'"> 
     106        <img src="'.pic_dir().'add.gif" /></a> 
     107    <a class="music" href="#" 
     108        onclick="play(\'pl\','.$playlistId.'); return false;" 
     109        title="'.t('Play this Playlist Now').'"> 
     110    <img src="'.pic_dir().'play.gif" /></a> '. 
     111    ($blnShowDelete ? '<a class="music" href="#" 
     112        onclick="deletePlaylist('.$playlistId.'); return false;" 
     113        title="'.t('DELETE this Saved Playlist').'"> 
     114    <img src="'.pic_dir().'rem.gif" /></a> ' : ''). 
     115    '<a class="music" href="#" 
     116        onclick="updateBox(\'saved_pl\','.$playlistId.'); return false;" 
     117        title="'.t('Click to View Playlist').'"><em>'. 
     118    $playlistName. 
     119    '</em> - '.sprintf(t('%s Songs'), $songcount).' ('.$length.')'. 
     120    '</a></li>'; 
     121} 
     122 
     123function getHtmlPlaylistEntry($id, $contents) 
     124{ 
     125  return '<li id="pl'.$id.'" 
     126      onmouseover="setBgcolor(\'pl'.$id.'\',\'#FCF7A5\');" 
     127      onmouseout="setBgcolor(\'pl'.$id.'\',\'#F3F3F3\');"> 
     128    <a class="music" href="#" 
     129      onclick="movePLItem(\'up\',this.parentNode); return false;" 
     130      title="'.t('Move Item Up in Playlist').'"> 
     131    <img src="'.pic_dir().'up.gif" /></a> 
     132    <a class="music" href="#" 
     133      onclick="movePLItem(\'down\',this.parentNode); return false;" 
     134      title="'.t('Move Item Down in Playlist').'"> 
     135    <img src="'.pic_dir().'down.gif" /></a> 
     136    <a class="music" href="#" 
     137      onclick="plrem(this.parentNode); return false;" 
     138      title="'.t('Remove Item from Playlist').'"> 
     139    <img src="'.pic_dir().'rem.gif" /></a> '. 
     140    $contents. 
     141    '</li>'; 
     142} 
     143 
     144function getHtmlPlaylistEntrySong($id, $artistName, $albumName, $trackNum, $trackName, $trackLength) 
     145{ 
     146  return getHtmlPlaylistEntry($id, 
     147    '<em>'.$artistName.'</em> - '.$trackName. 
     148    '<p>'.sprintf(t('Track #%s from the album \'%s\''), $trackNum, $albumName). 
     149    '<br />'.$trackLength.'</p>'); 
     150} 
     151 
     152function getHtmlPlaylistEntryPlaylist($id, $playlistName, $playlistSongCount, $playlistTotalTime) 
     153{ 
     154  return getHtmlPlaylistEntry($id, 
     155    sprintf(t('Playlist: %s'), '<em>'.$playlistName.'</em>'). 
     156    '<p>'.sprintf(t('%s Songs'), $playlistSongCount). 
     157    '<br />'.sprintf(t('Total Time:  %s'), $playlistTotalTime).'</p>'); 
     158} 
     159 
     160?> 
     161 No newline at end of file 
  • mythweb/modules/music/mp3act_fat.js

     
     1var Fat = { 
     2        make_hex : function (r,g,b)  
     3        { 
     4                r = r.toString(16); if (r.length == 1) r = '0' + r; 
     5                g = g.toString(16); if (g.length == 1) g = '0' + g; 
     6                b = b.toString(16); if (b.length == 1) b = '0' + b; 
     7                return "#" + r + g + b; 
     8        }, 
     9        fade_all : function () 
     10        { 
     11                var a = document.getElementsByTagName("*"); 
     12                for (var i = 0; i < a.length; i++)  
     13                { 
     14                        var o = a[i]; 
     15                        var r = /fade-?(\w{3,6})?/.exec(o.className); 
     16                        if (r) 
     17                        { 
     18                                if (!r[1]) r[1] = ""; 
     19                                if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]); 
     20                        } 
     21                } 
     22        }, 
     23        fade_element : function (id, fps, duration, from, to)  
     24        { 
     25                if (!fps) fps = 30; 
     26                if (!duration) duration = 3000; 
     27                if (!from || from=="#") from = "#FFFF33"; 
     28                if (!to) to = this.get_bgcolor(id); 
     29                 
     30                var frames = Math.round(fps * (duration / 1000)); 
     31                var interval = duration / frames; 
     32                var delay = interval; 
     33                var frame = 0; 
     34                 
     35                if (from.length < 7) from += from.substr(1,3); 
     36                if (to.length < 7) to += to.substr(1,3); 
     37                 
     38                var rf = parseInt(from.substr(1,2),16); 
     39                var gf = parseInt(from.substr(3,2),16); 
     40                var bf = parseInt(from.substr(5,2),16); 
     41                var rt = parseInt(to.substr(1,2),16); 
     42                var gt = parseInt(to.substr(3,2),16); 
     43                var bt = parseInt(to.substr(5,2),16); 
     44                 
     45                var r,g,b,h; 
     46                while (frame < frames) 
     47                { 
     48                        r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames)); 
     49                        g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames)); 
     50                        b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames)); 
     51                        h = this.make_hex(r,g,b); 
     52                 
     53                        setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay); 
     54 
     55                        frame++; 
     56                        delay = interval * frame;  
     57                } 
     58                setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay); 
     59        }, 
     60        set_bgcolor : function (id, c) 
     61        { 
     62                var o = document.getElementById(id); 
     63                o.style.backgroundColor = c; 
     64        }, 
     65        get_bgcolor : function (id) 
     66        { 
     67                var o = document.getElementById(id); 
     68                while(o) 
     69                { 
     70                        var c; 
     71                        if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color"); 
     72                        if (o.currentStyle) c = o.currentStyle.backgroundColor; 
     73                        if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; } 
     74                        o = o.parentNode; 
     75                } 
     76                if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF"; 
     77                var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/); 
     78                if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3])); 
     79                return c; 
     80        } 
     81} 
     82 No newline at end of file 
  • mythweb/modules/music/tmpl/default/music.php

     
    4141 
    4242    function playListSelector() 
    4343    { 
    44         $query="SELECT playlistid, name from musicplaylist order by name"; 
     44        $query="SELECT playlist_id, playlist_name FROM music_playlists ORDER BY playlist_name"; 
    4545        $queryResults=mysql_query($query); 
    4646 
    4747        if($queryResults) 
  • mythweb/modules/music/tmpl/compact/music.php

     
    4141 
    4242    function playListSelector() 
    4343    { 
    44         $query="SELECT playlistid, name from musicplaylist order by name"; 
     44        $query="SELECT playlist_id, playlist_name FROM music_playlists ORDER BY playlist_name"; 
    4545        $queryResults=mysql_query($query); 
    4646 
    4747        if($queryResults) 
  • mythweb/modules/music/mp3act_playstream.php

     
     1<?php 
     2//require_once('modules/music/mp3act_functions.php'); 
     3 
     4set_time_limit(0); 
     5if (!empty($_GET['i'])) 
     6{ 
     7  $qual = 'high'; 
     8  if (!empty($_GET['q'])) 
     9    $qual = $_GET['q']; 
     10  streamPlay($_GET['i'], $qual); 
     11} 
     12 
     13 
     14function updateNumPlays($num) 
     15{ 
     16  $sql_song_id = mysql_real_escape_string($num); 
     17  $query = 'UPDATE music_songs SET numplays=numplays+1 '. 
     18    'WHERE song_id='.$sql_song_id; 
     19   mysql_query($query); 
     20} 
     21 
     22function streamPlay($id) 
     23{ 
     24  $query = 'SELECT mt.artist_name, ms.name, ms.filename '. 
     25    'FROM music_songs AS ms '. 
     26    'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '. 
     27    'WHERE ms.song_id='.mysql_real_escape_string($id); 
     28 
     29  $result = mysql_query($query); 
     30  if (!$result) 
     31    return; 
     32 
     33  $row = mysql_fetch_array($result); 
     34  updateNumPlays($id); 
     35  clearstatcache(); // flush buffer 
     36 
     37  if (false !== strpos($row['filename'], '://')) 
     38  { 
     39    header('Location: '.$row['filename']); 
     40    exit; 
     41  } 
     42 
     43  $filename = 'data/music/'.$row['filename']; 
     44 
     45  switch (substr($filename, -3)) 
     46  { 
     47    case 'mp3': 
     48      $mime = 'audio/mpeg'; break; 
     49    case 'ogg': 
     50      $mine = 'application/ogg'; break; 
     51    default: 
     52      $mime = 'application/octet-stream'; 
     53  } 
     54 
     55  header('Content-Type: '.$mime); 
     56  header('Content-Length: '.filesize($filename)); 
     57  header('Content-Disposition: filename='.$row['artist_name'].' - '.$row['name']); 
     58 
     59  $fp = fopen($filename, 'rb'); 
     60  while (!feof($fp)) 
     61    echo fread($fp, 4096); 
     62  fclose($fp); 
     63  exit; 
     64} 
     65 
     66 
     67?> 
     68 No newline at end of file