increased filename length from 32 to 256, we need this.
[my-code/mp3db.git] / main.shtml
1 <h2 align="center">m - p - 3 <> d - a - t - a - b - a - s - e</h2>
2
3 <!-- are you allowed to connect? -->
4
5 <!--#exec cmd="
6
7 allowed=0
8 if [ ! -f /etc/mp3db.conf ]; then
9  echo \"error: no /etc/mp3db.conf file found, aborting.\"
10  exit 1
11 else
12  mp3_server_name=`grep MP3_SERVER_NAME /etc/mp3db.conf | awk '{ print $2 }'`
13  mp3_srcdir=`grep MP3_SRCDIR /etc/mp3db.conf | awk '{ print $2 }'`
14  http_root=`grep HTTP_ROOT /etc/mp3db.conf | awk '{ print $2 }'`
15  http_offset=`grep HTTP_OFFSET /etc/mp3db.conf | awk '{ print $2 }'`
16  local_net=`grep LOCAL_NET /etc/mp3db.conf | awk '{ print $2 }'`
17  mp3_http_loc=`grep MP3_HTTP_LOC /etc/mp3db.conf | awk '{ print $2 }'`
18  local_player_ip=`grep LOCAL_PLAYER_IP /etc/mp3db.conf | awk '{ print $2 }'`
19  playerfile_dir=`grep PLAYFILE_DIR /etc/mp3db.conf | awk '{ print $2 }'`
20  my_user_name=`grep USR_NAME /etc/mp3db.conf | awk '{ print $2 }'`
21  user_passwd=`grep USER_PASSWD /etc/mp3db.conf | awk '{ print $2 }'`
22 fi
23
24 if [ ! -f /etc/mp3user ]; then
25  echo \"error: no /etc/mp3user file found, aborting.\"
26  exit 1
27 fi
28 for allowed_ip in `cat /etc/mp3user | awk '{ print $2 }'`; do
29  [ \"$allowed_ip\" = \"$REMOTE_ADDR\" ] && allowed=1
30 done
31
32 if [ \"$allowed\" = \"1\" ]; then
33 if [ ! -z \"`echo $REMOTE_ADDR | grep ^$local_net`\" ]; then
34  computer_name=`grep $REMOTE_ADDR /etc/hosts | awk '{ print $3 }'`
35 else
36  computer_name=`host $REMOTE_ADDR | awk '{ print $5 }'`
37 fi
38 echo \"hi `grep $REMOTE_ADDR /etc/mp3user | awk '{ print $1 }'`!<br><br>your connection from $computer_name is authorized. have fun!<br>\"
39
40 #mp3 parsing
41
42 #call myself and see what songs to present
43 echo \"
44 <form action=\"$http_offset/index.shtml\" method=\"get\">
45 <p>artist(s):
46 <br>
47 <input name=\"artist\" type=\"text\" size=\"30\" maxlength=\"30\">
48 </p>
49 <input type=\"radio\" name=\"und_oder\" value=\"und\">and
50 <input type=\"radio\" name=\"und_oder\" value=\"oder\" checked>or
51 <br>
52 <p>song:
53 <br>
54 <input name=\"song\" type=\"text\" size=\"30\" maxlength=\"30\">
55 </p>
56 <input type=\"submit\" value=\"search\">
57 </form>
58 \"
59
60 if [ ! -z \"$QUERY_STRING\" ]; then 
61
62  echo \"<h4>results:</h4>\";
63
64  artist=`echo '$QUERY_STRING' | awk -F\& '{ gsub(\"artist=\",\"\"); print $1 }' | sed 's/+/_/g'`;
65  if [ \"`echo '$QUERY_STRING' | awk -F\& '{ gsub(\"und_oder=\",\"\"); print $2 }'`\" = \"oder\" ]; then
66   und_oder=\"-o\";
67  else 
68   und_oder=\"-a\";
69  fi;
70  song=`echo '$QUERY_STRING' | awk -F\& '{ gsub(\"song=\",\"\"); print $3 }' | sed 's/+/_/g'`;
71  echo \"searching for: $artist $song (mode: $und_oder)<br><br>\";
72
73  if [ \"$und_oder\" != \"-a\" ]; then
74   echo \"-> artists found:<br>\";
75   if [ ! -z \"$artist\" ]; then
76    for found_artists in `ls -A $mp3_srcdir/ | grep $artist`; do
77     echo \"<br>`echo $found_artists | sed 's/_/\ /g'`:<br>\";
78     echo \"<table border=1 cellpadding=5 cellspacing=0>\";
79     for dir_song in $mp3_srcdir/$found_artists/*; do
80      mp3=`basename $dir_song`;
81      echo \"<tr><td><a href=\"$mp3_http_loc/$found_artists/$mp3\">$mp3</a></td><td>`du -h $mp3_srcdir/$found_artists/$mp3 | awk '{ print $1 }'`</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><td>`readtag.sh $mp3_srcdir/$found_artists/$mp3`</td></tr>\";
82     done;
83    echo \"</table>\";
84    done;
85   fi;
86   if [ ! -z \"$song\" ]; then
87    echo \"<br>-> songs found:<br>\";
88    echo \"<table border=1 cellpadding=5 cellspacing=0>\";
89    for single_song in $mp3_srcdir/*/*; do
90     if [ ! -z \"`echo $single_song | grep $song`\" ]; then
91      dir=`echo $single_song | awk -F/ '{ print $(NF-1) }'`
92      s_name=`echo $single_song | awk -F/ '{ print $(NF) }'`
93      echo \"<tr><td><a href=\"$mp3_http_loc/$dir/$s_name\">$s_name</a></td><td>`du -h $mp3_srcdir/$dir/$s_name | awk '{ print $1 }'`</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><td>`readtag.sh $mp3_srcdir/$dir/$s_name`</tr>\";
94     fi;
95    done;
96    echo \"</table>\";
97   fi;
98
99  else
100
101   search_paths=`ls -A $mp3_srcdir | grep $artist`;
102   for search_path in $search_paths; do
103    echo \"-> artist: $search_path:<br>\";
104    echo \"<table border=1 cellpadding=5 cellspacing=0>\";
105    for dir_song in $mp3_srcdir/$search_path/*; do
106     mp3=`basename $dir_song`;
107     if [ ! -z \"`echo $mp3 | grep $song`\" ]; then
108      echo \"<tr><td><a href=\"$mp3_http_loc/$search_path/$mp3\">$mp3</a></td><td>`du -h $mp3_srcdir/$search_path/$mp3 | awk '{ print $1 }'`</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><td>`readtag.sh $mp3_srcdir/$search_path/$mp3`</tr>\";
109     fi ;
110    done;
111   done;
112
113  fi;
114
115 fi
116
117 else
118
119 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>\"
120
121 fi
122 " -->
123