initial checkin of first beta mp3db
authorhackbard <hackbard>
Sun, 13 Apr 2003 02:51:37 +0000 (02:51 +0000)
committerhackbard <hackbard>
Sun, 13 Apr 2003 02:51:37 +0000 (02:51 +0000)
INSTALL [new file with mode: 0644]
README [new file with mode: 0644]
main.shtml [new file with mode: 0644]
make_mp3dbcompat [new file with mode: 0755]
mp3db.conf [new file with mode: 0644]
mp3user [new file with mode: 0644]
playsong.shtml [new file with mode: 0644]

diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..95c1883
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,32 @@
+INSTALL
+-------
+
+1)
+
+include main.shtml in your existing webpage.
+it needs physical contact to the mp3 data.
+
+2)
+
+copy playsong.shtml somewhere in your htdocs root of your playing host.
+
+3)
+
+copy mp3db.conf and mp3user to your /etc directory.
+(on the host where you also copied main.shtml)
+adjust the examples !! important, defaults won't work !!
+
+4)
+
+make your mp3 data is mp3db compatible.
+that means, no special character and small letters.
+you may test ./make_mp3dbcompat script to do so.
+this will definetly fuck your system, i mean it :)
+
+5) 
+
+additionaly secure your mp3s using .htaccess files!
+! do it !
+
+
+have fun, hackbard
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..6a96d56
--- /dev/null
+++ b/README
@@ -0,0 +1,20 @@
+mp3db
+#####
+
+WARNING: first beta, and probably no more development as it fits my needs
+
+wtf?
+----
+mp3 database search and remote play tool using server side includes
+
+author
+------
+hackbard@hackdaworld.dyndns.org
+
+requirements
+------------
+- SSI supporting webbrowser (actually two times: 1. mp3 server 2.playing host)
+- mplayer installed on playing host
+
+
+regards, hackbard
diff --git a/main.shtml b/main.shtml
new file mode 100644 (file)
index 0000000..41feac5
--- /dev/null
@@ -0,0 +1,123 @@
+<h2 align="center">m - p - 3 <> d - a - t - a - b - a - s - e</h2>
+
+<!-- are you allowed to connect? -->
+
+<!--#exec cmd="
+
+allowed=0
+if [ ! -f /etc/mp3db.conf ]; then
+ echo \"error: no /etc/mp3db.conf file found, aborting.\"
+ exit 1
+else
+ mp3_server_name=`grep MP3_SERVER_NAME /etc/mp3db.conf | awk '{ print $2 }'`
+ mp3_srcdir=`grep MP3_SRCDIR /etc/mp3db.conf | awk '{ print $2 }'`
+ http_root=`grep HTTP_ROOT /etc/mp3db.conf | awk '{ print $2 }'`
+ http_offset=`grep HTTP_OFFSET /etc/mp3db.conf | awk '{ print $2 }'`
+ local_net=`grep LOCAL_NET /etc/mp3db.conf | awk '{ print $2 }'`
+ mp3_http_loc=`grep MP3_HTTP_LOC /etc/mp3db.conf | awk '{ print $2 }'`
+ local_player_ip=`grep LOCAL_PLAYER_IP /etc/mp3db.conf | awk '{ print $2 }'`
+ playerfile_dir=`grep PLAYFILE_DIR /etc/mp3db.conf | awk '{ print $2 }'`
+ my_user_name=`grep USR_NAME /etc/mp3db.conf | awk '{ print $2 }'`
+ user_passwd=`grep USER_PASSWD /etc/mp3db.conf | awk '{ print $2 }'`
+fi
+
+if [ ! -f /etc/mp3user ]; then
+ echo \"error: no /etc/mp3user file found, aborting.\"
+ exit 1
+fi
+for allowed_ip in `cat /etc/mp3user | awk '{ print $2 }'`; do
+ [ \"$allowed_ip\" = \"$REMOTE_ADDR\" ] && allowed=1
+done
+
+if [ \"$allowed\" = \"1\" ]; then
+if [ ! -z \"`echo $REMOTE_ADDR | grep ^$local_net`\" ]; then
+ computer_name=`grep $REMOTE_ADDR /etc/hosts | awk '{ print $3 }'`
+else
+ computer_name=`host $REMOTE_ADDR | awk '{ print $5 }'`
+fi
+echo \"hi `grep $REMOTE_ADDR /etc/mp3user | awk '{ print $1 }'`!<br><br>your connection from $computer_name is authorized. have fun!<br>\"
+
+#mp3 parsing
+
+#call myself and see what songs to present
+echo \"
+<form action=\"$http_offset/index.shtml\" method=\"get\">
+<p>artist(s):
+<br>
+<input name=\"artist\" type=\"text\" size=\"30\" maxlength=\"30\">
+</p>
+<input type=\"radio\" name=\"und_oder\" value=\"und\">and
+<input type=\"radio\" name=\"und_oder\" value=\"oder\" checked>or
+<br>
+<p>song:
+<br>
+<input name=\"song\" type=\"text\" size=\"30\" maxlength=\"30\">
+</p>
+<input type=\"submit\" value=\"search\">
+</form>
+\"
+
+if [ ! -z \"$QUERY_STRING\" ]; then 
+
+ echo \"<h4>results:</h4>\";
+
+ artist=`echo '$QUERY_STRING' | awk -F\& '{ gsub(\"artist=\",\"\"); print $1 }'`;
+ if [ \"`echo '$QUERY_STRING' | awk -F\& '{ gsub(\"und_oder=\",\"\"); print $2 }'`\" = \"oder\" ]; then
+  und_oder=\"-o\";
+ else 
+  und_oder=\"-a\";
+ fi;
+ song=`echo '$QUERY_STRING' | awk -F\& '{ gsub(\"song=\",\"\"); print $3 }'`;
+ echo \"searching for: $artist $song (mode: $und_oder)<br><br>\";
+
+ if [ \"$und_oder\" != \"-a\" ]; then
+  echo \"-> artists found:<br>\";
+  if [ ! -z \"$artist\" ]; then
+   for found_artists in `ls -A $mp3_srcdir/ | grep $artist`; do
+    echo \"<br>`echo $found_artists | sed 's/_/\ /g'`:<br>\";
+    echo \"<table border=1 cellpadding=5 cellspacing=0>\";
+    for dir_song in $mp3_srcdir/$found_artists/*; do
+     mp3=`basename $dir_song`;
+     echo \"<tr><td><a href=\"$mp3_http_loc/$found_artists/$mp3\">$mp3</a></td><td><a href=\"http://${local_player_ip}${playerfile_dir}/playsong.shtml\?url=http://${mp3_server_name}${mp3_http_loc}/$found_artists/$mp3\&user=$my_user_name\&passwd=$user_passwd\">play ($local_player_ip)</a></td></tr>\";
+    done;
+   echo \"</table>\";
+   done;
+  fi;
+  if [ ! -z \"$song\" ]; then
+   echo \"<br>-> songs found:<br>\";
+   echo \"<table border=1 cellpadding=5 cellspacing=0>\";
+   for single_song in $mp3_srcdir/*/*; do
+    if [ ! -z \"`echo $single_song | grep $song`\" ]; then
+     dir=`echo $single_song | awk -F/ '{ print $(NF-1) }'`
+     s_name=`echo $single_song | awk -F/ '{ print $(NF) }'`
+     echo \"<tr><td><a href=\"$mp3_http_loc/$dir/$s_name\">$s_name</a></td><td><a href=\"http://${local_player_ip}${playerfile_dir}/playsong.shtml\?url=http://${mp3_server_name}${mp3_http_loc}/$dir/$s_name\&user=$my_user_name\&passwd=$user_passwd\">play ($local_player_ip)</a></td></tr>\";
+    fi;
+   done;
+   echo \"</table>\";
+  fi;
+
+ else
+
+  search_paths=`ls -A $mp3_srcdir | grep $artist`;
+  for search_path in $search_paths; do
+   echo \"-> artist: $search_path:<br>\";
+   echo \"<table border=1 cellpadding=5 cellspacing=0>\";
+   for dir_song in $mp3_srcdir/$search_path/*; do
+    mp3=`basename $dir_song`;
+    if [ ! -z \"`echo $mp3 | grep $song`\" ]; then
+     echo \"<tr><td><a href=\"$mp3_http_loc/$search_path/$mp3\">$mp3</a></td><td><a href=\"http://${local_player_ip}${playerfile_dir}/playsong.shtml\?url=http://${mp3_server_name}${mp3_http_loc}/$search_path/$mp3\&user=$my_user_name\&passwd=$user_passwd\">play ($local_player_ip)</a></td></tr>\";
+    fi ;
+   done;
+  done;
+
+ fi;
+
+fi
+
+else
+
+echo \"sorry,<br><br>you, `echo $REMOTE_ADDR` are not authorized. you probably never will! :)<br>please don't mail asking for access. i am willing to share all my knowledge *) and code, but not mp3's as this might be illegal.<br><br>regards, hackbard<br><br><h5>*) i don't know nothig!</h5>\"
+
+fi
+" -->
+
diff --git a/make_mp3dbcompat b/make_mp3dbcompat
new file mode 100755 (executable)
index 0000000..9bca3e6
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+for i in *; do
+       if [ -d $i ]; then
+               echo "renaming content of $i ..."
+               cd $i
+               for j in *; do
+               if [ -f "$j" ]; then
+                       dst_file="`echo $j | sed 's/\ /\\ /g' | sed 's/(/\\(/g' | sed s'/)/\\)/g' | sed 's/&/\\&/g' | sed 's/!/\\!/g'`"
+                       trg_file="`echo $j | sed 's/\ /_/g' | sed 's/&/_/g'| sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ()-,!/abcdefghijklmnopqrstuvwxyz_____/'`"
+                       if [ "$dst_file" != "$trg_file" ]; then
+                               mv "$dst_file" $trg_file
+                               chmod 644 $trg_file
+                       fi
+               fi
+               # assume albums
+               if [ -d "$j" ]; then
+                       cd $j
+                       album="`echo $j | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ()-,/abcdefghijklmnopqrstuvwxyz____/'`"
+                       for song in *; do
+                               dst_file="`echo $song | sed 's/\ /\\ /g' | sed 's/(/\\(/g' | sed s'/)/\\)/g' | sed 's/&/\\&/g' | sed 's/!/\\!/g'`"
+                               trg_file="`echo $song | sed 's/\ /_/g' | sed 's/&/_/g'| sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ()-,!/abcdefghijklmnopqrstuvwxyz_____/'`"
+                               if [ ! -f ../${album}__${trg_file} ]; then
+                                       mv "$dst_file" ../${album}__${trg_file}
+                                       chmod 644 ../${album}__${trg_file}
+                               fi
+                       done
+                       cd ..
+                       rm -rf $j
+               fi
+               
+               done
+               cd ..
+       fi
+done
+
diff --git a/mp3db.conf b/mp3db.conf
new file mode 100644 (file)
index 0000000..d255f44
--- /dev/null
@@ -0,0 +1,15 @@
+# /etc/mp3db.conf
+
+MP3_SERVER_NAME foobar.org
+MP3_SRCDIR /www/htdocs/download/mp3db
+MP3_HTTP_LOC /download/mp3db
+HTTP_ROOT /www/htdocs
+HTTP_OFFSET /mp3db
+LOCAL_NET 192.168
+
+LOCAL_PLAYER_IP 192.168.10.20
+PLAYFILE_DIR /mp3db
+
+USR_NAME foo
+USER_PASSWD bar
+
diff --git a/mp3user b/mp3user
new file mode 100644 (file)
index 0000000..4a7dbe8
--- /dev/null
+++ b/mp3user
@@ -0,0 +1,5 @@
+hans           192.168.10.20
+hans           192.168.10.24
+tina           192.168.10.33
+udo            192.168.10.70
+
diff --git a/playsong.shtml b/playsong.shtml
new file mode 100644 (file)
index 0000000..13fde32
--- /dev/null
@@ -0,0 +1,23 @@
+<!-- play music on hackstation ... -->
+
+<!--#exec cmd="
+
+if [ ! -z \"`echo $REMOTE_ADDR | grep '^192.168.10'`\" ]; then
+ echo \"connection from $REMOTE_ADDR allowed.<br><br>\";
+ if [ ! -z \"$QUERY_STRING\" ]; then
+  url=`echo '$QUERY_STRING' | awk -F\& '{ gsub(\"url=\",\"\"); print $1 }'`;
+  user=`echo '$QUERY_STRING' | awk -F\& '{ gsub(\"user=\",\"\"); print $2 }'`;
+  passwd=`echo '$QUERY_STRING' | awk -F\& '{ gsub(\"passwd=\",\"\"); print $3 }'`;
+  if [ -z \"`ps -ef | grep [m]player | grep -v 'bin\/sh'`\" ]; then
+   play_cmd=\"/usr/bin/mplayer -user $user -passwd $passwd $url\";
+   echo \"trying: $play_cmd<br><br>\";
+   /usr/bin/mplayer -user $user -passwd $passwd $url > /dev/null 2>&1;
+  else
+   echo \"mplayer allready running ...\";
+  fi;
+ fi;
+else
+ echo \"sorry, connection from $REMOTE_ADDR not authorized! go away.<br><br>\";
+fi
+
+" -->