Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 298deb2b6b83684c114e051202bf306275e1892e 0 parents
@sdubois authored
340 COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
78 ChangeLog
@@ -0,0 +1,78 @@
+ver 0.11.1 (2011/1/14)*
+1) Add initial PHP 5 support
+2) Add support for the latest version of MPD.
+3) Replaced "volume" command with "setvol."
+
+ver 0.11.0 (2004/6/18)
+1) Add ability to add streams
+2) Support for displaying stream names
+
+ver 0.10.1 (2004/3/25)
+1) Check that Track, Album, and Artist indexes are set for songs
+2) Fix seek bar devide by zero error when total time is 0
+
+ver 0.10.0 (2004/3/4)
+1) Add password support
+2) Add crossfade support
+3) UTF-8 Support
+4) Fix " " => "%20" for url in loast song of playlist (Hannes Reich)
+5) Link directory names instead of using [dir]
+
+ver 0.9.1 (2003/10/30)
+1) Fix flush() bugs with z-compression
+2) Check for each metadata element for songs
+
+ver 0.9.0 (2003/9/30)
+1) Add seeking support
+2) Add random mode support
+3) Add "condense" mode, so that it doesn't show all songs in the playlist for
+faster playlist processing and rendering in a browser.
+
+ver 0.8.3 (2003/8/12)
+1) Fix a bug in display playlist if some songs contain tags and some don't
+2) Fix a bug with +
+3) Fix a bug with #
+
+ver 0.8.2 (2003/7/22)
+1) Added no-cache to html headers
+2) Added nowrap on playlist title buttons
+3) Put unix time in URL to workaround metaflag refresh not works for delete
+4) refresh not working correctly
+
+ver 0.8.1 (2003/7/11)
+1) Fix \ and " bug for adding directories to playlist
+2) Fix bug for indexing music with filenames_only
+3) Rewrite playlist display, so it doesn't put songs in array, just print them
+out immediatly, should consume less ram and be faster
+
+ver 0.8.0 (2003/7/6)
+1) Remove index table, put index with corresponding table
+2) Use listall to queue all files in a directory
+3) Add frames_layout config option
+4) Fix " bug
+
+ver 0.6.0 (2003/6/19)
+1) add volume control
+2) add repeate mode
+3) bug fix in dealing with '
+
+ver 0.5.5 (2003/6/11)
+1) add "prev" and "next"
+2) new "| |" symbol for pause
+3) search by filename
+4) option to use post/js method for add_all, to handle huge numbers of songs, and avoid too long uri errors
+5) $unknown_string option to modify how unknow tag info is displayed
+
+ver 0.5.4 (2003/5/29)
+1) Fix notices/warrnings about uninitizlaed/undefined variables when
+E_NOTICE is set in php.ini (thanks to Aschwin)
+
+0.5.3
+-----
+Added theme.php, and filenames_only option
+
+0.5.0-0.5.2
+-----------
+Initial releases, not sure what changed other than bug fixes.
+
+* - Notes an unoficial release by Steven DuBois (sdubois@csh.rit.edu)
48 INSTALL
@@ -0,0 +1,48 @@
+ phpMp - INSTALL
+
+Requirements
+------------
+
+1) Music Player Daemon (MPD) - http://www.musicpd.org
+2) Web server such as apache (included with many distributions)
+3) PHP for your webserver (included with many distributions)
+
+Download
+--------
+
+Get the latest release of phpMp from http://www.musicpd.org
+
+Requirements
+------------
+
+MPD >= 0.10.0
+PHP >= 4
+
+Install
+-------
+
+1) move phpMp archive to a directory accessible by the web server
+
+$ cp phpMp-x.x.x.tar.gz public_html/
+
+2) cd to where you copied the phpMp archive
+
+$ cd public_html
+
+3) untar and unzip archive
+
+$ tar zxvf phpMp-x.x.x.tar.gz
+
+4) configure options (such as port MPD listens to and host MPD is running on)
+using your favorite text editor, edit config.php
+
+example:
+$ vi phpMp-x.x.x/config.php
+
+Using phpMp
+---------
+
+Point your favorite web browser at the location of phpMp on your web server
+
+example:
+http://my.webserver.com/~myusername/phpMp-x.x.x
17 README
@@ -0,0 +1,17 @@
+
+ phpMp
+ http://www.musicpd.org
+
+phpMp is a web interface (written in PHP 4) for the Music Player Daemon (MPD).
+
+To install phpMp, see INSTALL.
+
+This version of phpMP is modified from the original version to work with the
+latest version of MPD and PHP 5. If you find a bug or problem, contact Steven
+DuBois at sdubois@csh.rit.edu
+
+phpMp is released under the GNU Public License.
+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
+For the full license, see COPYING.
1  TODO
@@ -0,0 +1 @@
+1) add phpMp and MPD version somewhere
38 config.php
@@ -0,0 +1,38 @@
+<?php
+// NEED TO SET THESE!
+$host = "localhost";
+$port = 6600;
+
+// OPTIONAL
+$title = "phpMp";
+global $song_display_conf;
+$song_display_conf = "(artist) title";
+$use_images = "no";
+$refresh_freq = 60;
+$default_sort = "Artist,Album,Track,Title";
+global $unknown_string;
+$unknown_string = "";
+$frames_layout = "cols=\"1*,250\"";
+global $filenames_only;
+$filenames_only = "no";
+global $use_javascript_add_all;
+$use_javascript_add_all = "yes";
+$hide_threshold = 20;
+$use_cookies = "yes";
+
+// VOLUME OPTIONS
+$display_volume = "yes";
+$volume_incr = "5";
+
+
+// SHOULDN'T NEED TO TOUCH THIS
+global $song_seperator;
+$song_seperator = "rqqqrqqqr";
+
+// EXPERIMENTAL
+//no frames doesn't work!
+$frames = "yes"; // yes or no
+
+//include colors
+include "theme.php";
+?>
37 find.php
@@ -0,0 +1,37 @@
+<?php
+global $has_password;
+$has_password = 0;
+if(isset($_COOKIE["phpMp_password"])) {
+ $password = $_COOKIE["phpMp_password"];
+ $has_password = 1;
+}
+include "config.php";
+include "theme.php";
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header("Content-Type: text/html; charset=UTF-8");
+?>
+<html>
+<head>
+<META HTTP-EQUIV="Expires" CONTENT="Thu, 01 Dec 1994 16:00:00 GMT">
+<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
+<?php
+// php won't interpret inside of the style block
+print "<style type=\"text/css\">\n";
+print "* {\n";
+print " font-family: " . $fonts["all"] . ";\n";
+print "}\n";
+print "</style>\n";
+?>
+</head>
+<body link="<?php print $colors["links"]["link"]; ?>"
+ vlink="<?php print $colors["links"]["visual"]; ?>"
+ alink="<?php print $colors["links"]["active"]; ?>"
+ bgcolor="<?php print $colors["background"]; ?>">
+<?php
+include "find_body.php";
+?>
+</body>
+</html>
46 find_body.php
@@ -0,0 +1,46 @@
+<?php
+include "info.php";
+include "config.php";
+include "utils.php";
+include "info2html.php";
+$dir = "";
+$find = "";
+$arg = "";
+$sort = $default_sort;
+EXTRACT($_GET);
+$sort_array = split(",",$sort);
+$fp = fsockopen($host,$port,$errno,$errstr,10);
+if(!$fp) {
+ echo "$errstr ($errno)<br>\n";
+}
+else {
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ if(isset($password)) {
+ fputs($fp,"password \"$password\"\n");
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ }
+ $dir_url = sanitizeForURL($dir);
+ displayDirectory($dir,$sort,"Back to Directory",0,0);
+ $lsinfo = getLsInfo($fp,"find $find \"$arg\"\n");
+ list($mprint,$mindex,$add_all) = lsinfo2musicTable($lsinfo,$sort,$dir_url);
+ $arg_url = sanitizeForURL($arg);
+ printMusicTable($mprint,"find.php?find=$find&arg=$arg_url&dir=$dir_url",$add_all,$mindex);
+ fclose($fp);
+ displayStats($dir,$sort);
+ displayUpdate($dir,$sort);
+}
+?>
33 index.php
@@ -0,0 +1,33 @@
+<?php
+include "config.php";
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+<head>
+<title><?php print $title?></title>
+</head>
+<?php
+if(0==strcmp($frames,"yes")) {
+ print "<frameset border=3 $frames_layout>\n";
+ print "<frame name=\"main\" src=\"main.php\">\n";
+ print "<frame name=\"playlist\" src=\"playlist.php\">\n";
+ print "<noframes>NO FRAMES :-(</noframes>\n";
+ print "</frameset>\n";
+}
+else {
+ print "<body bgcolor=\"" . $colors["background"] . "\">\n";
+ print "<table border=0 cellspacing=0 width=\"100%\">\n";
+ print "<tr valign=top><td>\n";
+ include "main_body.php";
+ print "</td>\n";
+ print "<td width=250>\n";
+ include "playlist_body.php";
+ print "</td></tr>\n";
+ print "</table>";
+ print "</body>\n";
+}
+?>
+</html>
185 info.php
@@ -0,0 +1,185 @@
+<?php
+function getStatusInfo($conn) {
+ fputs($conn,"status\n");
+ while(!feof($conn)) {
+ $got = fgets($conn,1024);
+ $got = preg_replace("/\n/","",$got);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ if(strncmp("ACK",$got,strlen("ACK"))==0) {
+ print "$got<br>";
+ break;
+ }
+ $el = strtok($got,":");
+ $ret["$el"] = strtok("\0");
+ $ret["$el"] = preg_replace("/^ /","",$ret["$el"]);
+ }
+ if(!isset($ret)) $ret = array();
+ return $ret;
+}
+
+function setNotSetSongFields($song) {
+ if(isset($song["Title"])) {
+ if(!isset($song["Track"])) $song["Track"] = "";
+ if(!isset($song["Album"])) $song["Album"] = "";
+ if(!isset($song["Artist"])) $song["Artist"] = "";
+ }
+
+ return $song;
+}
+
+function getPlaylistInfo($conn,$song) {
+ global $unknown_string;
+ fputs($conn,"playlistinfo $song\n");
+ $count = -1;
+ while(!feof($conn)) {
+ $got = fgets($conn,1024);
+ $got = preg_replace("/\n/","",$got);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ $el = strtok($got,":");
+ if(0==strcmp($el,"file")) {
+ if($count>=0) $ret[$count] = setNotSetSongFields($ret[$count]);
+ $count++;
+ }
+ $ret[$count]["$el"] = strtok("\0");
+ $ret[$count]["$el"] = preg_replace("/^ /","",$ret[$count]["$el"]);
+ }
+ if(!isset($ret)) $ret = array();
+ return $ret;
+}
+
+function printPlaylistInfo($conn,$num,$hide,$spread,$length) {
+ global $colors,$filenames_only;
+ $tm = time();
+ $start = 0;
+ $end = $length-1;
+ if($hide) {
+ $start = $num-$spread/2;
+ $end = $num+$spread/2;
+ if($start<0) {
+ $end-=$start;
+ $start = 0;
+ }
+ if($end>=$length) {
+ $start-=$end-$length+1;
+ if($start<0) $start = 0;
+ $end = $length-1;
+ }
+ if($start>0) {
+ print "<tr bgcolor=\"" . $colors["playlist"]["body"] . "\">";
+ print "<td colspan=2 align=center><small>";
+ print "<a href=\"playlist.php?hide=0\">...</a>";
+ print "</small></td></tr>";
+ }
+ fputs($conn,"command_list_begin\n");
+ for($i=$start;$i<=$end;$i++) fputs($conn,"playlistinfo $i\n");
+ fputs($conn,"command_list_end\n");
+ }
+ else {
+ if($length>$spread+1) {
+ print "<tr bgcolor=\"" . $colors["playlist"]["body"] . "\">";
+ print "<td colspan=2 align=center><small>";
+ print "(<a href=\"playlist.php?hide=1\">condense</a>)";
+ print "</small></td></tr>";
+ }
+ fputs($conn,"playlistinfo -1\n");
+ }
+ $count = $start-1;
+ while(!feof($conn)) {
+ $got = fgets($conn,1024);
+ $got = preg_replace("/\n/","",$got);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ $el = strtok($got,":");
+ if(0==strcmp($el,"file")) {
+ if($count>=$start) {
+ if($count>$start) $goto = $count-1;
+ else $goto = $count;
+ if($filenames_only!="yes" && isset($ret["Name"]) && $ret["Name"]) {
+ $display = $ret["Name"];
+ }
+ else $display = songInfo2Display($ret);
+ $id = $ret["Id"];
+ unset($ret);
+ if(isset($num) && $num==$count)
+ print "<tr bgcolor=\"". $colors["playlist"]["current"] . "\">";
+ else
+ print "<tr bgcolor=\"" . $colors["playlist"]["body"] . "\">";
+ print "<td valign=top><a name=$count><small><a href=\"playlist.php?hide=$hide&command=deleteid $id&time=$tm#$goto\">d</a></small></td>\n";
+ print "<td width=\"100%\"><a href=\"playlist.php?hide=$hide&command=playid%20$id\">$display</a></td></tr>\n";
+ }
+ $count++;
+ }
+ $ret["$el"] = strtok("\0");
+ $ret["$el"] = preg_replace("/^ /","",$ret["$el"]);
+ }
+ if($count>=$start) {
+ if($count>$start) $goto = $count-1;
+ else $goto = $count;
+ if($filenames_only!="yes" && isset($ret["Name"]) && $ret["Name"]) {
+ $display = $ret["Name"];
+ }
+ else $display = songInfo2Display($ret);
+ $id = $ret["Id"];
+ if(isset($num) && $num==$count)
+ print "<tr bgcolor=\"". $colors["playlist"]["current"] . "\">";
+ else
+ print "<tr bgcolor=\"" . $colors["playlist"]["body"] . "\">";
+ print "<td valign=top><a name=$count><small><a href=\"playlist.php?hide=$hide&command=delete $count&time=$tm#$goto\">d</a></small></td>\n";
+ print "<td width=\"100%\"><a href=\"playlist.php?hide=$hide&command=play%20$count\">$display</a></td></tr>\n";
+ }
+ if($hide) {
+ if($end<$length-1) {
+ print "<tr bgcolor=\"" . $colors["playlist"]["body"] . "\">";
+ print "<td colspan=2 align=center><small>";
+ print "<a href=\"playlist.php?hide=0\">...</a>";
+ print "</small></td></tr>";
+ }
+ }
+}
+
+function getLsInfo($conn,$command) {
+ fputs($conn,$command);
+ $mcount = -1;
+ $dcount = 0;
+ $pcount = 0;
+ while(!feof($conn)) {
+ $got = fgets($conn,1024);
+ $got = preg_replace("/\n/","",$got);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ if(strncmp("ACK",$got,strlen("ACK"))==0) {
+ print "$got<br>\n";
+ break;
+ }
+ $el = strtok($got,":");
+ if(0==strcmp($el,"directory")) {
+ $dir[$dcount] = preg_replace("/^$el: /","",$got);
+ $dcount++;
+ continue;
+ }
+ if(0==strcmp($el,"playlist")) {
+ $playlist[$pcount] = preg_replace("/^$el: /","",$got);
+ $pcount++;
+ continue;
+ }
+ if(0==strcmp($el,"file")) {
+ if($mcount>=0) $music[$mcount] = setNotSetSongFields($music[$mcount]);
+ $mcount++;
+ }
+ $music[$mcount]["$el"] = preg_replace("/^$el: /","",$got);
+ }
+ if(!isset($dir)) $dir = array();
+ if(!isset($music)) $music = array();
+ if(!isset($playlist)) $playlist = array();
+ $ret["dir"] = $dir;
+ $ret["music"] = $music;
+ $ret["playlist"] = $playlist;
+ return $ret;
+}
+?>
236 info2html.php
@@ -0,0 +1,236 @@
+<?php
+include "sort.php";
+
+function lsinfo2playlistTable($lsinfo,$sort) {
+ $pic = 0;
+ $pcount = count($lsinfo["playlist"]);
+ if($pcount) usort($lsinfo["playlist"],"strcasecmp");
+ for($i=0;$i<$pcount;$i++) {
+ $dirent = $lsinfo["playlist"][$i];
+ $dirstr = $dirent;
+ $dirss = split("/",$dirstr);
+ if(count($dirss)==0)
+ $dirss[0] = $dirstr;
+ $dirss[0] = $dirss[count($dirss)-1];
+ $dirstr = sanitizeForURL($dirstr);
+ $fc = strtoupper(mbFirstChar($dirss[0]));
+ if($pic==0 || $pindex[$pic-1]!=$fc) {
+ $pindex[$pic] = $fc;
+ $foo = $pindex[$pic];
+ $pic++;
+ $pprint[$i] = "<a name=p$foo>";
+ }
+ else {
+ $pprint[$i] = "";
+ }
+ $pprint[$i].="[<a target=\"playlist\" href=\"playlist.php?command=load&arg=$dirstr\">load</a>] $dirss[0] (<small><a href=\"main.php?sort=$sort&command=rm&arg=$dirstr\">d</a>elete</small>)<br>\n";
+ }
+ if(!isset($pprint)) $pprint = array();
+ if(!isset($pindex)) $pindex = array();
+ return array($pprint,$pindex);
+}
+
+function lsinfo2musicTable($lsinfo,$sort,$dir_url) {
+ global $sort_array, $song_seperator, $filenames_only,$colors;
+ global $unknown_string;
+ $color = $colors["music"]["body"];
+ $mic = 0;
+ $mcount = count($lsinfo["music"]);
+ if($mcount) usort($lsinfo["music"],"msort");
+ $add_all = "";
+ for($i=0;$i<$mcount;$i++) {
+ $dirent = $lsinfo["music"][$i]["file"];
+ $dirstr = $dirent;
+ $dirss = split("/",$dirstr);
+ if(count($dirss)==0)
+ $dirss[0] = $dirstr;
+ $dirss[0] = $dirss[count($dirss)-1];
+ if($i<$mcount-1) $add_all .= addslashes($dirstr) . $song_seperator;
+ else $add_all .= $dirstr;
+ $dirstr = sanitizeForURL($dirstr);
+ $col = $color[$i%2];
+ if($filenames_only!="yes" && isset($lsinfo["music"][$i]["Title"]) && $lsinfo["music"][$i]["Title"]) {
+ if(strcmp($sort_array[0],"Track")) {
+ if(isset($lsinfo["music"][$i][$sort_array[0]]) && strlen($lsinfo["music"][$i][$sort_array[0]]) && ($mic==0 || $mindex[$mic-1]!=strtoupper(mbFirstChar($lsinfo["music"][$i][$sort_array[0]])))) {
+ $mindex[$mic] = strtoupper(mbFirstChar($lsinfo["music"][$i][$sort_array[0]]));
+ $foo = $mindex[$mic];
+ $mic++;
+ $mprint[$i] = "<a name=m$foo>";
+ }
+ else {
+ $mprint[$i] = "";
+ }
+ }
+ else {
+ if(isset($foo)) unset($foo);
+ if(isset($lsinfo["music"][$i][$sort_array[0]])) {
+ $foo = strtok($lsinfo["music"][$i][$sort_array[0]],"/");
+ }
+ if(isset($foo) && ($mic==0 || 0!=strcmp($mindex[$mic-1],$foo))) {
+ $mindex[$mic] = $foo;
+ $mic++;
+ $mprint[$i] = "<a name=m$foo>";
+ }
+ else {
+ $mprint[$i] = "";
+ }
+ }
+ $mprint[$i] = "<tr bgcolor=$col><td width=0>$mprint[$i][<a target=\"playlist\" href=\"playlist.php?command=add&arg=$dirstr\">add</a>]</td><td>";
+ if(!isset($lsinfo["music"][$i]["Artist"])) {
+ $mprint[$i].= $unknown_string . "</td><td>";
+ }
+ else {
+ $artist_url = sanitizeForURL($lsinfo["music"][$i]["Artist"]);
+ $mprint[$i].= "<a href=\"find.php?find=artist&arg=$artist_url&sort=$sort&dir=$dir_url\">";
+ $mprint[$i].= $lsinfo["music"][$i]["Artist"] . "</a></td><td>";
+ }
+ $mprint[$i].= $lsinfo["music"][$i]["Title"] . "</td><td>";
+ if(!isset($lsinfo["music"][$i]["Album"])) {
+ $mprint[$i].= $unknown_string . "</td><td>";
+ }
+ else {
+ $album_url = sanitizeForURL($lsinfo["music"][$i]["Album"]);
+ $mprint[$i].= "<a href=\"find.php?find=album&arg=$album_url&sort=$sort&dir=$dir_url\">";
+ $mprint[$i].= $lsinfo["music"][$i]["Album"] . "</a></td><td>";
+ }
+ if(!isset($lsinfo["music"][$i]["Track"])) {
+ $mprint[$i].= $unknown_string . "</td></tr>";
+ }
+ else {
+ $mprint[$i].= $lsinfo["music"][$i]["Track"] . "</td></tr>\n";
+ }
+ }
+ else {
+ if($mic==0 || $mindex[$mic-1]!=strtoupper($dirss[0][0])) {
+ $mindex[$mic] = strtoupper($dirss[0][0]);
+ $foo = $mindex[$mic];
+ $mic++;
+ $mprint[$i] = "<a name=m$foo>";
+ }
+ else {
+ $mprint[$i] = "";
+ }
+ $mprint[$i] = "<tr bgcolor=$col><td>$mprint[$i][<a target=\"playlist\" href=\"playlist.php?command=add&arg=$dirstr\">add</a>]</td><td colspan=4>$dirss[0]</td></tr>\n";
+ }
+ }
+ if(!isset($mprint)) $mprint = array();
+ if(!isset($mindex)) $mindex = array();
+ return array($mprint,$mindex,$add_all);
+}
+
+function printIndex($index,$title,$anc) {
+ if(count($index)) {
+ print "$title: [ ";
+ for($i=0;$i<count($index);$i++) {
+ $foo = $index[$i];
+ print "<a href=\"#$anc$foo\">$foo</a>\n";
+ }
+ print "]<br>\n";
+ }
+}
+
+function printMusicTable($mprint,$url,$add_all,$mindex) {
+ global $filenames_only, $colors, $use_javascript_add_all,$sort_array;
+ if(count($mprint)>0) {
+ print "<br>\n";
+ if($use_javascript_add_all=="yes") {
+ $add_all = sanitizeForPost($add_all);
+ print "<form style=\"padding:0;margin:0;\" name=\"add_all\" method=\"post\" action=\"playlist.php\" target=\"playlist\">";
+ print "<input type=hidden name=\"add_all\" value=\"$add_all\">";
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["music"]["title"];
+ print "\" width=\"100%\">\n";
+ print "<tr><a name=music><td colspan=4 nowrap><b>Music</b>\n";
+ print "(<a href=\"javascript:document.add_all.submit()\">";
+ print "add all</a>)\n";
+ printIndex($mindex,"","m");
+ print "</td></tr>\n";
+ }
+ else {
+ $add_all = sanitizeForUrl($add_all);
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["music"]["title"];
+ print "\" width=\"100%\">\n";
+ print "<tr><td colspan=4><b>Music</b>\n";
+ print "(<a target=\"playlist\" href=\"playlist.php?add_all=$add_all\">";
+ print "add all</a>)\n";
+ printIndex($mindex,"","m");
+ print "</td></tr>\n";
+ }
+ print "<tr><td>\n";
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["music"]["body"][1];
+ print "\" width=\"100%\">\n";
+ if($filenames_only!="yes") {
+ print "<tr bgcolor=\"";
+ print $colors["music"]["sort"];
+ print "\"><td width=0></td>";
+ $cols[0] = "Artist";
+ $cols[1] = "Title";
+ $cols[2] = "Album";
+ $cols[3] = "Track";
+ for($i=0;$i<count($cols);$i++) {
+ $new_sort = pickSort("$cols[$i]");
+ if($cols[$i]==$sort_array[0])
+ $cols[$i] = "<b>$cols[$i]</b>";
+ print "<td><a href=\"$url&sort=$new_sort\">$cols[$i]</a></td>";
+ }
+ print "</tr>\n";
+ }
+ for($i=0;$i<count($mprint);$i++) print $mprint[$i];
+ print "</td></tr></table>\n";
+ print "</table>\n";
+ if($use_javascript_add_all=="yes")
+ print "</form>";
+ }
+}
+
+function printPlaylistTable($pprint,$pindex) {
+ global $colors;
+ if(count($pprint)) {
+ print "<br>\n";
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["playlist"]["title"];
+ print "\" width=\"100%\">\n";
+
+ print "<tr><a name=playlists><td nowrap><b>Playlists</b>";
+ printIndex($pindex,"","p");
+ print "</td></tr>\n";
+ print "<tr bgcolor=\"";
+ print $colors["playlist"]["body"];
+ print "\"><td>\n";
+ for($i=0;$i<count($pprint);$i++) print $pprint[$i];
+ print "</td></tr></table>\n";
+ }
+}
+
+function songInfo2Display($song_info) {
+ global $song_display_conf, $filenames_only;
+ if(preg_match("/^[a-z]*:\/\//",$song_info["file"])) {
+ $song = $song_info["file"];
+ }
+ else {
+ $song_array = split("/",$song_info["file"]);
+ $song = $song_array[count($song_array)-1];
+ }
+ if($filenames_only!="yes" && isset($song_info["Title"]) && $song_info["Title"]) {
+ if(isset($song_info["Artist"])) $artist = $song_info["Artist"];
+ else $artist = "";
+ if(isset($song_info["Title"])) $title = $song_info["Title"];
+ else $title = "";
+ if(isset($song_info["Album"])) $album = $song_info["Album"];
+ else $album = "";
+ if(isset($song_info["Track"])) $track = $song_info["Track"];
+ else $track = "";
+ $trans = array("artist" => $artist, "title" => $title, "album" => $album, "track" => $track);
+ $song_display = strtr($song_display_conf, $trans);
+ }
+ else if($filenames_only!="yes" && isset($song_info["Name"]) && $song_info["Name"]) {
+ $song_display = $song_info["Name"];
+ }
+ else {
+ $song_display = $song;
+ }
+ return $song_display;
+}
+?>
38 login.php
@@ -0,0 +1,38 @@
+<?php
+ob_start();
+global $has_password;
+$has_password = 0;
+if(isset($_COOKIE["phpMp_password"])) {
+ $password = $_COOKIE["phpMp_password"];
+ $has_password = 1;
+}
+include "config.php";
+include "theme.php";
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header("Content-Type: text/html; charset=UTF-8");
+?>
+<html>
+<head>
+<META HTTP-EQUIV="Expires" CONTENT="Thu, 01 Dec 1994 16:00:00 GMT">
+<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
+<?php
+// php won't interpret inside of the style block
+print "<style type=\"text/css\">\n";
+print "* {\n";
+print " font-family: " . $fonts["all"] . ";\n";
+print "}\n";
+print "</style>\n";
+?>
+</head>
+<body link="<?php print $colors["links"]["link"]; ?>"
+ vlink="<?php print $colors["links"]["visual"]; ?>"
+ alink="<?php print $colors["links"]["active"]; ?>"
+ bgcolor="<?php print $colors["background"]; ?>">
+<?php
+include "login_body.php";
+?>
+</body>
+</html>
91 login_body.php
@@ -0,0 +1,91 @@
+<?php
+include "info.php";
+include "config.php";
+include "utils.php";
+include "info2html.php";
+$dir = "";
+$search = "";
+$arg = "";
+$sort = $default_sort;
+EXTRACT($_GET);
+EXTRACT($HTTP_POST_VARS);
+$dir = decodeHTML($dir);
+$sort_array = split(",",$sort);
+$fp = fsockopen($host,$port,$errno,$errstr,10);
+if(!$fp) {
+ echo "$errstr ($errno)<br>\n";
+}
+else {
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ if(isset($logout) && $logout=="logout") {
+ setcookie("phpMp_password","");
+ $has_password = 0;
+ }
+ $dir_url = sanitizeForURL($dir);
+ displayDirectory($dir,$sort,"Back to Directory",0,0);
+ print "<br>\n";
+ if(isset($arg) && $arg) {
+ $arg = decodeHTML($arg);
+ fputs($fp,"password \"$arg\"\n");
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0) {
+ print "Login Successful<br>\n";
+ if(isset($remember) && $remember=="true")
+ setcookie("phpMp_password",$arg,time()+60*60*24*365);
+ else
+ setcookie("phpMp_password",$arg);
+ break;
+ }
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ }
+ else if(!isset($logout) && isset($_COOKIE["phpMp_password"])) {
+ print "<form style=\"padding:0;margin:0;\" action=login.php? method=get>\n";
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["password"]["title"];
+ print "\" width=\"100%\">\n";
+ print "<tr><td><b>Logout</b></td></tr>\n";
+ print "<tr bgcolor=\"";
+ print $colors["password"]["body"];
+ print "\"><td>\n";
+ $dir_url = sanitizeForURL($dir);
+ print "<input type=hidden value=\"logout\" name=logout>\n";
+ print "<input type=hidden value=\"$dir_url\" name=dir>\n";
+ print "<input type=hidden value=\"$sort\" name=sort>\n";
+ print "<input type=submit value=logout name=foo>\n";
+ print "\n";
+ print "</td></tr></table></form>\n";
+ }
+ else {
+ print "<form style=\"padding:0;margin:0;\" action=login.php? method=post>\n";
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["password"]["title"];
+ print "\" width=\"100%\">\n";
+ print "<tr><td><b>Password</b></td></tr>\n";
+ print "<tr bgcolor=\"";
+ print $colors["password"]["body"];
+ print "\"><td>\n";
+ $dir_url = sanitizeForURL($dir);
+ print "<input type=password name=arg value=\"$arg\" size=20>\n";
+ print "<input type=hidden value=\"$dir_url\" name=dir>\n";
+ print "<input type=hidden value=\"$sort\" name=sort>\n";
+ print "<input type=submit value=login name=foo><br>";
+ print "<small><input type=checkbox name=remember value=true>";
+ print "remember password</small>";
+ print "\n";
+ print "</td></tr></table></form>\n";
+ }
+ fclose($fp);
+}
+ob_end_flush();
+?>
38 main.php
@@ -0,0 +1,38 @@
+<?php
+global $has_password;
+$has_password = 0;
+if(isset($_COOKIE["phpMp_password"])) {
+ $password = $_COOKIE["phpMp_password"];
+ $has_password = 1;
+}
+include "config.php";
+include "theme.php";
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header("Content-Type: text/html; charset=UTF-8");
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<META HTTP-EQUIV="Expires" CONTENT="Thu, 01 Dec 1994 16:00:00 GMT">
+<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
+<?php
+// php won't interpret inside of the style block
+print "<style type=\"text/css\">\n";
+print "* {\n";
+print " font-family: " . $fonts["all"] . ";\n";
+print "}\n";
+print "</style>\n";
+?>
+</head>
+<body link="<?php print $colors["links"]["link"]; ?>"
+ vlink="<?php print $colors["links"]["visual"]; ?>"
+ alink="<?php print $colors["links"]["active"]; ?>"
+ bgcolor="<?php print $colors["background"]; ?>">
+<?php
+include "main_body.php";
+?>
+</body>
+</html>
133 main_body.php
@@ -0,0 +1,133 @@
+<?php
+include "info.php";
+include "utils.php";
+include "info2html.php";
+$arg = "";
+$dir = "";
+$sort = $default_sort;
+EXTRACT($_GET);
+$sort_array = split(",",$sort);
+$fp = fsockopen($host,$port,$errno,$errstr,10);
+if(!$fp) {
+ echo "$errstr ($errno)<br>\n";
+}
+else {
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ if(isset($password)) {
+ fputs($fp,"password \"$password\"\n");
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ }
+ if(isset($command)) {
+ if(strlen($arg)>0) $command.=" \"$arg\"";
+ fputs($fp,"$command\n");
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ preg_replace("/\n/","\n<br>",$got);
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ }
+ $dir_url = sanitizeForURL($dir);
+ if(strlen($dir)>0) $lsinfo = getLsInfo($fp,"lsinfo \"$dir\"\n");
+ else $lsinfo = getLsInfo($fp,"lsinfo\n");
+
+ # lsinfo2musicTable should start here
+
+ $dcount = count($lsinfo["dir"]);
+ if($dcount) usort($lsinfo["dir"],"strcasecmp");
+ $dic = 0;
+ for($i=0;$i<$dcount;$i++) {
+ $dirent = $lsinfo["dir"][$i];
+ $dirstr = $dirent;
+ $dirss = split("/",$dirstr);
+ if(count($dirss)==0)
+ $dirss[0] = $dirstr;
+ $dirss[0] = $dirss[count($dirss)-1];
+ $dirstr = sanitizeForURL($dirstr);
+ $dcol = $colors["directories"]["body"][$i%2];
+ $dprint[$i] = "<tr bgcolor=\"$dcol\"><td>";
+ $fc = strtoupper(mbFirstChar($dirss[0]));
+ if($dic==0 || $dindex[$dic-1]!=$fc) {
+ $dindex[$dic] = $fc;
+ $foo = $dindex[$dic];
+ $dic++;
+ $dprint[$i].="<a name=d$foo>";
+ }
+ $dprint[$i].="[<a href=\"playlist.php?add_dir=$dirstr\" target=playlist>add</a>] <a href=\"main.php?sort=$sort&dir=$dirstr\">$dirss[0]</a></td></tr>\n";
+ # $dprint[$i].="[<a href=\"main.php?sort=$sort&dir=$dirstr\">dir</a>] [<a href=\"playlist.php?add_dir=$dirstr\" target=playlist>add</a>] $dirss[0]</td></tr>\n";
+ }
+ if(!isset($dindex)) $dindex = array();
+
+ # end of lsinfo2directoryTable
+
+ list($pprint,$pindex) = lsinfo2playlistTable($lsinfo,$sort);
+ list($mprint,$mindex,$add_all) = lsinfo2musicTable($lsinfo,$sort,$dir_url);
+ displayDirectory($dir,$sort,"Current Directory",count($mprint),count($pprint));
+ if(isset($save) && $save) {
+ print "<br><form style=\"padding:0;margin:0;\" action=main.php? method=get>\n";
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["playlist"]["title"];
+ print "\" width=\"100%\">\n";
+ print "<tr><td><b>Save Playlist</b></td></tr>\n";
+ print "<tr bgcolor=\"";
+ print $colors["playlist"]["body"];
+ print "\"><td>\n";
+ print "<input name=arg size=40>\n";
+ print "<input type=hidden value=save name=command>\n";
+ print "<input type=submit value=save name=foo>\n";
+ print "</td></tr></table>\n";
+ print "</form>\n";
+ $dir = "";
+ }
+
+ # begin printDirectoryTable
+ # dcount -> is the number of directories
+ # dprint -> array, has dcount elements, just do print $dprint[$i]
+ # to print output for that directory, it was formatted
+ # in lsinfo2directoryTable (this parses input from
+ # lsinfo and make the $dprint's for output)
+ # dindex -> these are the links etc for the index elements point too
+ # printIndex -> function that takes $dinex and prints all the links
+ # for the indexes
+
+ if($dcount) {
+ print "<br>\n";
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["directories"]["title"];
+ print "\" width=\"100%\">\n";
+ print "<tr><td nowrap><b>Directories</b>\n";
+ printIndex($dindex,"","d");
+ print "</td></tr>\n";
+ print "<tr><td><table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["directories"]["body"][1];
+ print "\" width=\"100%\">\n";
+ for($i=0;$i<$dcount;$i++) print $dprint[$i];
+ print "</table></td></tr></table>\n";
+ }
+
+ # end of printDirectoryTable
+
+ printMusicTable($mprint,"main.php?dir=$dir_url",$add_all,$mindex);
+ printPlaylistTable($pprint,$pindex);
+ fclose($fp);
+ displayStats($dir,$sort);
+ displayUpdate($dir,$sort);
+}
+?>
55 playlist.php
@@ -0,0 +1,55 @@
+<?php
+include "config.php";
+include "theme.php";
+
+if($use_cookies=="yes" && isset($_COOKIE["phpMp_playlist_hide"])) {
+ $hide = $_COOKIE["phpMp_playlist_hide"];
+}
+
+if(isset($_COOKIE["phpMp_password"])) {
+ $password = $_COOKIE["phpMp_password"];
+}
+
+#extract($_GET);
+#extract($HTTP_POST_VARS);
+
+extract($_GET);
+extract($_POST);
+
+if(!isset($hide)) $hide = 1;
+else if($use_cookies=="yes") {
+ setcookie("phpMp_playlist_hide", $hide);
+}
+
+
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header("Content-Type: text/html; charset=UTF-8");
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<META HTTP-EQUIV="Expires" CONTENT="Thu, 01 Dec 1994 16:00:00 GMT">
+<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
+<META HTTP-EQUIV="REFRESH" CONTENT="<?php print $refresh_freq;?>;URL=playlist.php">
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
+<?php
+// php won't interpret inside of the style block
+print "<style type=\"text/css\">\n";
+print "* {\n";
+print " font-family: " . $fonts["all"] . ";\n";
+print "}\n";
+print "</style>\n";
+?>
+</head>
+<body link="<?php print $colors["links"]["link"]; ?>"
+ vlink="<?php print $colors["links"]["visual"]; ?>"
+ alink="<?php print $colors["links"]["active"]; ?>"
+ bgcolor="<?php print $colors["background"]; ?>">
+<?php
+include "playlist_body.php"
+?>
+
+</body>
+</html>
343 playlist_body.php
@@ -0,0 +1,343 @@
+<?php
+
+if(!isset($arg)) $arg="";
+
+include "info.php";
+include "info2html.php";
+include "utils.php";
+
+if(isset($add_dir)) $add_dir = decodeHTML($add_dir);
+if(isset($add_all)) {
+ $add_all = decodeHTML($add_all);
+ $add_all = stripslashes($add_all);
+}
+$fp = fsockopen($host,$port,$errno,$errstr,10);
+if(!$fp) {
+ echo "$errstr ($errno)<br>\n";
+}
+else {
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["playing"]["title"];
+ print "\" width=\"100%\">\n";
+ print "<tr valign=middle><td>\n";
+ print "<b>Playing</b>\n";
+ print "<small>(<a href=playlist.php?hide=$hide>refresh</a>)</small>\n";
+ print "</td></tr>\n";
+ print "<tr bgcolor=\"";
+ print $colors["playing"]["body"];
+ print "\"><td>\n";
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ if(isset($password)) {
+ fputs($fp,"password \"$password\"\n");
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ }
+ if(isset($HTTP_POST_FILES['playlist_file']['name'])) {
+ $name = $HTTP_POST_FILES['playlist_file']['name'];
+ $file = $HTTP_POST_FILES['playlist_file']['tmp_name'];
+ if(!is_uploaded_file($file)) {
+ print "Problems uploading file<br>";
+ }
+ else if(!($pls_fp = fopen($file, "r"))) {
+ print "Problems opening file<br>";
+ }
+ else if(preg_match("/\.m3u/",$name)) {
+ $add = readM3uFile($pls_fp);
+ }
+ else if(preg_match("/\.pls/",$name)) {
+ $add = readPlsFile($pls_fp);
+ }
+ else {
+ print "NOT a m3u or pls file!<br>";
+ }
+ }
+ if(isset($stream)) {
+ if(preg_match("/^[a-z]*:\/\//",$stream) && !preg_match("/^file:/",$stream)) {
+ if(preg_match("/\.m3u/",$stream)) {
+ $pls_fp = fopen($stream,"r");
+ $add = readM3uFile($pls_fp);
+ }
+ else if(preg_match("/\.pls/",$stream)) {
+ $pls_fp = fopen($stream,"r");
+ $add = readPlsFile($pls_fp);
+ }
+ else {
+ $command = "add";
+ $arg = $stream;
+ }
+ }
+ else {
+ print "Doesn't appear to be a url<br>";
+ }
+ }
+ if(isset($command)) {
+ $arg = preg_replace("/\"/","\\\"",$arg);
+ if(strlen($arg)>0)
+ $command.=" \"$arg\"";
+ $command = preg_replace("/\\\\\"/","\"",$command);
+ fputs($fp,"$command\n");
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ preg_replace("/\n/","\n<br>",$got);
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ }
+ else if(isset($add_all) && $add_all) {
+ global $song_seperator;
+ $add = explode($song_seperator,$add_all);
+ }
+ else if(isset($add_dir)) {
+ $add = array();
+ $i = 0;
+ fputs($fp,"listall \"$add_dir\"\n");
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ if(strncmp("ACK",$got,strlen("ACK"))==0) {
+ print "$got<br>";
+ break;
+ }
+ if(strncmp($got,"file: ",strlen("file: "))==0) {
+ $got = preg_replace("/\n/","",$got);
+ $got = preg_replace("/^file\: /","",$got);
+ $add[$i] = addslashes($got);
+ $i++;
+ }
+ }
+ }
+ if(isset($add) && count($add)>0) {
+ fputs($fp,"command_list_begin\n");
+ for($i=0;$i<count($add);$i++) {
+ fputs($fp,"add \"$add[$i]\"\n");
+ }
+ fputs($fp,"command_list_end\n");
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0) {
+ break;
+ }
+ }
+ }
+ $status = getStatusInfo($fp);
+ if(isset($status["error"])) {
+ print "Error: " . $status["error"] . "<br>\n";
+ }
+ if(isset($status["state"])) {
+ $vol = $status["volume"];
+ $repeat = $status["repeat"];
+ $random = $status["random"];
+ $xfade = $status["xfade"];
+ if(strcmp($status["state"],"play")==0 || 0==strcmp($status["state"],"pause")) {
+ $num = $status["song"];
+ $songid = $status["songid"];
+ $time = split(":",$status["time"]);
+ $time_min = (int)($time[0]/60);
+ $time_sec = (int)($time[0]-$time_min*60);
+ if($time_sec<0) {
+ $time_sec*=-1;
+ $time_min = "-$time_min";
+ }
+ if($time_sec<10) $time_sec = "0$time_sec";
+ $song_info = getPlaylistInfo($fp,$num);
+ print "<table border=0 cellpadding=0 cellspacing=0>";
+ print "<tr><td colspan=6>";
+ print "<a href=#$num>";
+ print songInfo2Display($song_info[0]);
+ print "</a><br>\n";
+ print "($time_min:$time_sec)\n";
+ if($time[1] > 0) {
+ $time_min = (int)($time[1]/60);
+ $time_sec = (int)($time[1]-$time_min*60);
+ if($time_sec<10) $time_sec = "0$time_sec";
+ print "[$time_min:$time_sec]\n";
+ }
+ else {
+ print "[" . $status["bitrate"] . " kbs]\n";
+ }
+ if($time[1]>0)
+ $time_perc = $time[0]*100/$time[1];
+ else $time_perc = 100.0;
+ $time_div = 4;
+ $do = round($time_perc/$time_div);
+ print "<table border=0 cellspacing=0 cellpadding=0 height=\"8\"><tr>";
+ $col = $colors["time"]["foreground"];
+ $col = $colors["time"]["background"];
+ for($i=0; $i<round(100/$time_div); $i++) {
+ if($i>=$do-1 && $i<=$do+1) {
+ $col = $colors["time"]["foreground"];
+ }
+ $seek = round($i*$time_div*$time[1]/100);
+ $min = (int)($seek/60);
+ $sec= $seek-$min*60;
+ if($sec<10) $sec = "0$sec";
+ print "<td width=8 bgcolor=\"$col\"><a href=\"playlist.php?hide=$hide&command=seekid $songid $seek\" title=\"$min:$sec\"><img border=0 width=8 height=8 src=transparent.gif></a></td>";
+ $col = $colors["time"]["background"];
+ }
+ print "</tr></table>\n";
+ print "</td></tr><tr>";
+ if($repeat) {
+ print "<td bgcolor=\"";
+ print $colors["playing"]["on"];
+ print "\">";
+ }
+ else print "<td>";
+ print "<small>[<a href=\"playlist.php?hide=$hide&command=repeat%20";
+ print (int)(!$repeat) . "\">repeat</a>]</small>";
+ print "</td><td>&nbsp</td>";
+ if($random) {
+ print "<td bgcolor=\"";
+ print $colors["playing"]["on"];
+ print "\">";
+ }
+ else print "<td>";
+ print "<small>[<a href=\"playlist.php?hide=$hide&command=random%20";
+ print (int)(!$random) . "\">random</a>]</small>";
+ print "</td><td>&nbsp</td>";
+ if($xfade) {
+ print "<td bgcolor=\"";
+ print $colors["playing"]["on"];
+ print "\">";
+ }
+ else print "<td>";
+ print "<small>[<a href=\"playlist.php?hide=$hide&command=crossfade%20";
+ print 10*(int)(!$xfade) . "\">xfade</a>]</small>";
+ print "</td><td width=\"100%\"></td></tr></table>\n";
+ print "</td></tr>\n";
+ print "<tr><td nowrap>\n";
+ if(strcmp($status["state"],"play")==0) {
+ print $display["playing"]["prev"]["active"];
+ print $display["playing"]["play"]["inactive"];
+ print $display["playing"]["next"]["active"];
+ print $display["playing"]["pause"]["active"];
+ print $display["playing"]["stop"]["active"];
+ }
+ else {
+ print $display["playing"]["prev"]["active"];
+ print $display["playing"]["play"]["pause"];
+ print $display["playing"]["next"]["active"];
+ print $display["playing"]["pause"]["inactive"];
+ print $display["playing"]["stop"]["active"];
+ }
+ }
+ else {
+ print "<table border=0 cellpadding=0 cellspacing=0>";
+ print "<tr><td colspan=6>";
+ print "<br><br>\n";
+ $col = $colors["time"]["background"];
+ print "<table border=0 cellspacing=0 cellpadding=0 height=\"8\" width=200 bgcolor=\"$col\"><tr><td></td></tr></table>";
+ print "</td></tr><tr>";
+ if($repeat) {
+ print "<td bgcolor=\"";
+ print $colors["playing"]["on"];
+ print "\">";
+ }
+ else print "<td>";
+ print "<small>[<a href=\"playlist.php?hide=$hide&command=repeat%20";
+ print (int)(!$repeat) . "\">repeat</a>]</small>";
+ print "</td><td>&nbsp</td>";
+ if($random) {
+ print "<td bgcolor=\"";
+ print $colors["playing"]["on"];
+ print "\">";
+ }
+ else print "<td>";
+ print "<small>[<a href=\"playlist.php?hide=$hide&command=random%20";
+ print (int)(!$random) . "\">random</a>]</small>";
+ print "</td><td>&nbsp</td>";
+ if($xfade) {
+ print "<td bgcolor=\"";
+ print $colors["playing"]["on"];
+ print "\">";
+ }
+ else print "<td>";
+ print "<small>[<a href=\"playlist.php?hide=$hide&command=crossfade%20";
+ print 10*(int)(!$xfade) . "\">xfade</a>]</small>";
+ print "</td><td width=\"100%\"></td></tr></table>\n";
+ print "</td></tr>\n";
+ print "<tr><td nowrap>\n";
+ if($status["playlistlength"]>0) {
+ print $display["playing"]["prev"]["inactive"];
+ print $display["playing"]["play"]["active"];
+ print $display["playing"]["next"]["inactive"];
+ print $display["playing"]["pause"]["inactive"];
+ print $display["playing"]["stop"]["inactive"];
+ }
+ else {
+ print $display["playing"]["prev"]["inactive"];
+ print $display["playing"]["play"]["inactive"];
+ print $display["playing"]["next"]["inactive"];
+ print $display["playing"]["pause"]["inactive"];
+ print $display["playing"]["stop"]["inactive"];
+ }
+ }
+ print "<br>\n";
+ }
+ print "</td></tr></table><br>\n";
+ # begin volume display
+ if(isset($vol) && $vol>=0 && $display_volume=="yes") {
+ $minus_vol = $vol-$volume_incr;
+ $plus_vol = $vol+$volume_incr;
+ print "<table width=\"100%\" border=0 cellspacing=0 bgcolor=\"";
+ print $colors["volume"]["body"];
+ print "\"><tr><td>\n";
+ print "<table border=0 cellspacing=0><tr><td nowrap><b>Volume</b> ";
+ $vol_div = 5;
+ $do = round($vol/$vol_div);
+ print "[<a href=\"playlist.php?hide=$hide&command=setvol%20 $minus_vol\">-</a>]</td>";
+ print "<td valign=middle><table border=0 cellspacing=0 cellpadding=0 height=\"8\"><tr>";
+ $col = $colors["volume"]["foreground"];
+ for($i=0; $i<$do; $i++) print "<td width=5 bgcolor=\"$col\"></td>";
+ $col = $colors["volume"]["background"];
+ for(; $i<round(100/$vol_div); $i++) {
+ print "<td width=5 bgcolor=\"$col\"></td>";
+ }
+ print "</tr></table></td>\n";
+ print "<td>[<a href=\"playlist.php?hide=$hide&command=setvol%20$plus_vol\">+</a>]</td>\n";
+ print "</td></tr></table>\n";
+ print "</td></tr></table><br>\n";
+ }
+ # end of volume display
+ /* display playlist */
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["playlist"]["title"];
+ print "\" width=\"100%\">\n";
+ print "<tr valign=middle><td width=\"0\"><b>Playlist</b>\n";
+ print "<small>";
+ print "[<a href=\"playlist.php?hide=$hide&command=shuffle\">shuffle</a>]";
+ print "[<a target=main href=main.php?save=yes>save</a>]";
+ print "[<a href=\"playlist.php?hide=$hide&command=clear\">clear</a>]";
+ print "</small>";
+ print "</td></tr>\n";
+ print "<tr><td>\n";
+ print "<table border=0 cellspacing=0 width=\"100%\">\n";
+ if(!isset($num)) $num = -1;
+ if(isset($status["playlistlength"])) {
+ printPlaylistInfo($fp,$num,$hide,$hide_threshold,$status["playlistlength"]);
+ }
+ print "</table>\n";
+ print "</tr></td>\n";
+ print "</table>\n";
+ fclose($fp);
+}
+?>
37 search.php
@@ -0,0 +1,37 @@
+<?php
+global $has_password;
+$has_password = 0;
+if(isset($_COOKIE["phpMp_password"])) {
+ $password = $_COOKIE["phpMp_password"];
+ $has_password = 1;
+}
+include "config.php";
+include "theme.php";
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header("Content-Type: text/html; charset=UTF-8");
+?>
+<html>
+<head>
+<META HTTP-EQUIV="Expires" CONTENT="Thu, 01 Dec 1994 16:00:00 GMT">
+<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
+<?php
+// php won't interpret inside of the style block
+print "<style type=\"text/css\">\n";
+print "* {\n";
+print " font-family: " . $fonts["all"] . ";\n";
+print "}\n";
+print "</style>\n";
+?>
+</head>
+<body link="<?php print $colors["links"]["link"]; ?>"
+ vlink="<?php print $colors["links"]["visual"]; ?>"
+ alink="<?php print $colors["links"]["active"]; ?>"
+ bgcolor="<?php print $colors["background"]; ?>">
+<?php
+include "search_body.php";
+?>
+</body>
+</html>
85 search_body.php
@@ -0,0 +1,85 @@
+<?php
+include "info.php";
+include "config.php";
+include "utils.php";
+include "info2html.php";
+$dir = "";
+$search = "";
+$arg = "";
+$sort = $default_sort;
+EXTRACT($_GET);
+$dir = decodeHTML($dir);
+$sort_array = split(",",$sort);
+$fp = fsockopen($host,$port,$errno,$errstr,10);
+if(!$fp) {
+ echo "$errstr ($errno)<br>\n";
+}
+else {
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ if(isset($password)) {
+ fputs($fp,"password \"$password\"\n");
+ while(!feof($fp)) {
+ $got = fgets($fp,1024);
+ if(strncmp("OK",$got,strlen("OK"))==0)
+ break;
+ print "$got<br>";
+ if(strncmp("ACK",$got,strlen("ACK"))==0)
+ break;
+ }
+ }
+ $dir_url = sanitizeForURL($dir);
+ displayDirectory($dir,$sort,"Back to Directory",0,0);
+ print "<br>\n";
+ print "<form style=\"padding:0;margin:0;\" action=search.php? method=get>\n";
+ print "<table border=0 cellspacing=1 bgcolor=\"";
+ print $colors["music"]["title"];
+ print "\" width=\"100%\">\n";
+ print "<tr><td><b>Search</b></td></tr>\n";
+ print "<tr bgcolor=\"";
+ print $colors["music"]["body"][1];
+ print "\"><td>\n";
+ print "<select name=search>\n";
+ function printFileNameOption($which_search) {
+ if(0==strcmp($which_search,"filename"))
+ print "<option value=\"filename\" selected>file name</option>\n";
+ else print "<option value=\"filename\">file name</option>\n";
+ }
+ if($filenames_only=="yes") printFileNameOption($search);
+ if(0==strcmp($search,"title"))
+ print "<option selected>title</option>\n";
+ else print "<option>title</option>\n";
+ if(0==strcmp($search,"album"))
+ print "<option selected>album</option>\n";
+ else print "<option>album</option>\n";
+ if(0==strcmp($search,"artist"))
+ print "<option selected>artist</option>\n";
+ else print "<option>artist</option>\n";
+ if($filenames_only!="yes") printFileNameOption($search);
+ print "</select>\n";
+ $dir_url = sanitizeForURL($dir);
+ print "<input name=arg value=\"$arg\" size=40>\n";
+ print "<input type=hidden value=\"$dir_url\" name=dir>\n";
+ print "<input type=hidden value=\"$sort\" name=sort>\n";
+ print "<input type=submit value=search name=foo>\n";
+ print "\n";
+ print "</td></tr></table></form>\n";
+ if($search && $arg) {
+ $lsinfo = getLsInfo($fp,"search $search \"$arg\"\n");
+ list($mprint,$mindex,$add_all) = lsinfo2musicTable($lsinfo,$sort,$dir_url);
+ }
+ $arg_url = sanitizeForURL($arg);
+ if(isset($mprint)) {
+ printMusicTable($mprint,"search.php?search=$search&arg=$arg_url&dir=$dir_url",$add_all,$mindex);
+ }
+ fclose($fp);
+ displayStats($dir,$sort);
+ displayUpdate($dir,$sort);
+}
+?>
43 sort.php
@@ -0,0 +1,43 @@
+<?php
+function msort($a,$b) {
+ global $sort_array,$filenames_only;
+ $i=0;
+ $ret = 0;
+ while($filenames_only!="yes" && $i<4 && $ret==0) {
+ if(!isset($a[$sort_array[$i]])) {
+ if(isset($b[$sort_array[$i]])) {
+ $ret = -1;
+ }
+ }
+ else if(!isset($b[$sort_array[$i]])) {
+ $ret = 1;
+ }
+ else if(strcmp($sort_array[$i],"Track")==0) {
+ $ret = strnatcmp($a[$sort_array[$i]],$b[$sort_array[$i]]);
+ }
+ else {
+ $ret = strcasecmp($a[$sort_array[$i]],$b[$sort_array[$i]]);
+ }
+ $i++;
+ }
+ if($ret==0)
+ $ret = strcasecmp($a["file"],$b["file"]);
+ return $ret;
+}
+
+function picksort($pick) {
+ global $sort_array;
+ if(0==strcmp($pick,$sort_array[0])) {
+ return "$sort_array[0],$sort_array[1],$sort_array[2],$sort_array[3]";
+ }
+ else if(0==strcmp($pick,$sort_array[1])) {
+ return "$pick,$sort_array[0],$sort_array[2],$sort_array[3]";
+ }
+ else if(0==strcmp($pick,$sort_array[2])) {
+ return "$pick,$sort_array[0],$sort_array[1],$sort_array[3]";
+ }
+ else if(0==strcmp($pick,$sort_array[3])) {
+ return "$pick,$sort_array[0],$sort_array[1],$sort_array[2]";
+ }
+}
+?>
37 stats.php
@@ -0,0 +1,37 @@
+<?php
+global $has_password;
+$has_password = 0;
+if(isset($_COOKIE["phpMp_password"])) {
+ $password = $_COOKIE["phpMp_password"];
+ $has_password = 1;
+}
+include "config.php";
+include "theme.php";
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header("Content-Type: text/html; charset=UTF-8");
+?>
+<html>
+<head>
+<META HTTP-EQUIV="Expires" CONTENT="Thu, 01 Dec 1994 16:00:00 GMT">
+<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
+<?php
+// php won't interpret inside of the style block
+print "<style type=\"text/css\">\n";
+print "* {\n";
+print " font-family: " . $fonts["all"] . ";\n";
+print "}\n";
+print "</style>\n";
+?>
+</head>
+<body link="<?php print $colors["links"]["link"]; ?>"
+ vlink="<?php print $colors["links"]["visual"]; ?>"
+ alink="<?php print $colors["links"]["active"]; ?>"
+ bgcolor="<?php print $colors["background"]; ?>">
+<?php
+include "stats_body.php";
+?>
+</body>
+</html>
68 stats_body.php
@@ -0,0 +1,68 @@
+<?php
+include "config.php";
+include "utils.php";
+
+function secondsToDHMS($seconds) {
+ $days=floor($seconds/86400);
+ $remaining_seconds=$seconds-$days*86400;