Advertisement
jaalto

Untitled

Feb 1st, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. Header ()
  4. {
  5. echo -en "Content-Type: text/html\r\n\r\n"
  6. echo "<html><head><title>test</title></head><body>"
  7. }
  8.  
  9. IsDirectoryMatch ()
  10. {
  11. case "$1" in
  12. */) return 0 ;;
  13. *) return 1 ;;
  14. esac
  15. }
  16.  
  17. IsDirectory ()
  18. {
  19. result=$(ls -dp $1)
  20. IsDirectoryMatch "$result"
  21. }
  22.  
  23. Main ()
  24. {
  25. for file in "../$QUERY_STRING"/*
  26. do
  27. b=${file##*/}
  28. #echo "<a href='../$b'>$b</a><br/>"
  29.  
  30. if IsDirectory "$file" ; then
  31. echo "<a href='test.cgi?$QUERY_STRING/$b'>$b</a><br/>"
  32. else
  33. echo "<a href='$QUERY_STRING/$b'>$b</a><br/>"
  34. fi
  35. done
  36.  
  37. echo "</body></html>";
  38. }
  39.  
  40. Header
  41. Main
  42.  
  43. # End of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement