Document Library - Current Location $PRINTLOCAT


No description



Onion Details



Page Clicks: 0

First Seen: 03/12/2024

Last Indexed: 10/23/2024

Domain Index Total: 98



Onion Content



#!/bin/bash echo Content-Type: text/html echo HOSTNAME=$( hostname ) CURRLOCATION=$( echo "$REQUEST_URI" | sed -n 's/^.*DIR=\([^&]*\).*$/\1/p' | sed s/+/\ /g ) if [ "$CURRLOCATION" == "" ] then PRINTLOCAT="/" else PRINTLOCAT="$CURRLOCATION" fi WEBDIR="/var/www/localhost/htdocs/Library" # Work out what the parent directory is cd "$WEBDIR/$CURRLOCATION" cd .. pwd > /tmp/dir.parent.1 sed s/"\/var\/www\/localhost\/htdocs\/Library\/"//g /tmp/dir.parent.1 > /tmp/dir.parent.2 PARENTDIR=$( cat /tmp/dir.parent.2 ) # We can't return to the root directory without some extra work! if [ "$PARENTDIR" == "/var/www/localhost/htdocs/Library" ] then PARENTDIR="/" fi # We also get errors if we are already in the root directory if [ "$PARENTDIR" == "/var/www/localhost/htdocs" ] then SHOWPARENT="N" fi # Return to the temporary directory cd /tmp ls -l "/var/www/localhost/htdocs/Library/$CURRLOCATION" > /tmp/dir.list.test2 LINECOUNT=$( wc -l /tmp/dir.list.test2 | awk -F\ '{print $1}' ) RETRIEVECOUNT=$(( $LINECOUNT - 1 )) tail -n $RETRIEVECOUNT /tmp/dir.list.test2 > /tmp/dir.list.test /bin/cat /tmp/dir.list.test1 LOCATION=$( awk -F\ '{print $9}' /tmp/dir.list.test1 ) UPDATED1=$( awk -F\ '{print $6}' /tmp/dir.list.test1 ) UPDATED2=$( awk -F\ '{print $7}' /tmp/dir.list.test1 ) UPDATED3=$( awk -F\ '{print $8}' /tmp/dir.list.test1 ) UPDATED="$UPDATED1 $UPDATED2 $UPDATED3" SIZE=$( awk -F\ '{print $5}' /tmp/dir.list.test1 ) ATTRIBS=$( awk -F\ '{print $1}' /tmp/dir.list.test1 ) # Need to check if it's a symbolic link, cos if it is it won't work as expected if [ -h $LOCATION ] then DIR_CHECK="d" else # Check if it's a proper directory DIR_CHECK=$( echo ${ATTRIBS:0:1} ) fi if [ "$DIR_CHECK" == "d" ] then # It's a Directory, use a custom link /bin/cat /dev/null if [ "$?" == "0" ] then ICONTEXT="adobereader.jpg" ICONTITLE="Adobe PDF Format" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]txt > /dev/null if [ "$?" == "0" ] then ICONTEXT="Text-Icon.png" ICONTITLE="Standard Text File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]jpg > /dev/null if [ "$?" == "0" ] then ICONTEXT="JPEG.bmp" ICONTITLE="JPEG Image File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]png > /dev/null if [ "$?" == "0" ] then ICONTEXT="JPEG.bmp" ICONTITLE="Image File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]pnm > /dev/null if [ "$?" == "0" ] then ICONTEXT="JPEG.bmp" ICONTITLE="Image File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]gif > /dev/null if [ "$?" == "0" ] then ICONTEXT="JPEG.bmp" ICONTITLE="Image File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]odt > /dev/null if [ "$?" == "0" ] then ICONTEXT="ODF.png" ICONTITLE="Open Document Format File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]ods > /dev/null if [ "$?" == "0" ] then ICONTEXT="ODF.png" ICONTITLE="Open Document Format File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]odg > /dev/null if [ "$?" == "0" ] then ICONTEXT="ODF.png" ICONTITLE="Open Document Format File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]doc > /dev/null if [ "$?" == "0" ] then ICONTEXT="Office-icon.png" ICONTITLE="Microsoft Office Format File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]xls > /dev/null if [ "$?" == "0" ] then ICONTEXT="Office-icon.png" ICONTITLE="Microsoft Office Format File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]ppt > /dev/null if [ "$?" == "0" ] then ICONTEXT="Office-icon.png" ICONTITLE="Microsoft Office Format File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]mdb > /dev/null if [ "$?" == "0" ] then ICONTEXT="Office-icon.png" ICONTITLE="Microsoft Office Format File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]rtf > /dev/null if [ "$?" == "0" ] then ICONTEXT="Office-icon.png" ICONTITLE="Microsoft Office Rich Text Format File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]sh > /dev/null if [ "$?" == "0" ] then ICONTEXT="shellscript-icon.png" ICONTITLE="Shell Script" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]html > /dev/null if [ "$?" == "0" ] then ICONTEXT="html-icon.png" ICONTITLE="HTML Web Page" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]zip > /dev/null if [ "$?" == "0" ] then ICONTEXT="Archive-icon.png" ICONTITLE="ZIP File Archive" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]gz > /dev/null if [ "$?" == "0" ] then ICONTEXT="Archive-icon.png" ICONTITLE="Gzipped File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]tar > /dev/null if [ "$?" == "0" ] then ICONTEXT="Archive-icon.png" ICONTITLE="Tarball Archive" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]bz > /dev/null if [ "$?" == "0" ] then ICONTEXT="Archive-icon.png" ICONTITLE="Bzipped File" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]tar[.]gz > /dev/null if [ "$?" == "0" ] then ICONTEXT="Archive-icon.png" ICONTITLE="Gzipped Tarball Archive" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]tar[.]bz > /dev/null if [ "$?" == "0" ] then ICONTEXT="Archive-icon.png" ICONTITLE="Bzipped Tarball Archive" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]msg > /dev/null if [ "$?" == "0" ] then ICONTEXT="email_icon.jpg" ICONTITLE="Exported E-mail" KNOWN="Y" fi echo "$LOCATION" | grep -i [.]url > /dev/null if [ "$?" == "0" ] then ICONTEXT="external_link.png" ICONTITLE="Link to another location" KNOWN="Y" LINKY="Y" fi if [ "$KNOWN" != "Y" ] then # Couldn't Identify the filetype ICONTEXT="icon_unknown.png" ICONTITLE="Couldn't Identify Format" fi # If the item is a .url file we need to process slightly differently /bin/cat /dev/null rm -f /tmp/dir.list.test1 2> /dev/null rm -f /tmp/dir.list.test2 2> /dev/null rm -f /tmp/dir.parent.1 2> /dev/null rm -f /tmp/dir.parent.2> /dev/null exit