[ZendTo] Re: Disable random generator for files and folders

Der PCFreak mailinglists at pcfreak.de
Thu Oct 22 12:48:50 BST 2015


Hi Joe,

if you just need something that allows you to show the files correctly, 
you can try the attached
Bash Script that I use on my ZendTo Server.
It is called "dropls".

Open the script, add your SQL-Credentials for the zendto database and 
copy it to folder that is reachable
by your PATH variable.

cd into /var/zendto/dropoffs, then type dropls.

The output looks like this:

700 drwx------ 2 apache apache 4096 October 15 07:56 wbwqMmcCGKoxfrtP 
from: tester1 at test.com to: external1 at external.com
700 drwx------ 2 apache apache 4096 October 15 13:34 3rEjNhKoKTz2D2s4 
from: tester2 at test.com to: external2 at external.com
700 drwx------ 2 apache apache 4096 October 15 13:49 rxUHtmsZ23yohCFt 
from: tester3 at test.com to: external3 at external.com

You can then cd into the subfolder, e.g.

cd wbwqMmcCGKoxfrtP

and type dropls again to see:

644 -rw-r--r-- 1 apache apache 25378460 October 15 07:56 phph0AW21 
"Project Documentation No 1234567.zip"  uploaded by: tester1 at test.com

The output is also a little bit colored.

I hope you find the script useful.

Kind regards

PCFreak

On 21.10.2015 23:19, joekane at gmail.com wrote:
> Hi,
>
> First thank you Julian for your excellent work on this, I'm using 
> zendto for an internal project and need to remove the random key 
> that's generated for the file name and directory.
>
> I would like to keep the file-name the same as 'basename' and the 
> directory name to use the 'senderOrganization' name.
>
> I believe its setup currently,
>
> Folder = 'claimID'
> Filename = 'tmpname'
>
> I would like
>
> Folder = 'senderOrganization'
> Filename = 'basename'
>
> I understand this negates the security feature that comes with hashing 
> the folder/file names.
> I am digging around NSSDropoff.php and NSSUtils.php to change the 
> random file/folder name generation but maybe someone can point me in 
> the right direction. I am by no means a php expert.
>
> Thanks again, Joe
>
>
>
>
> _______________________________________________
> ZendTo mailing list
> ZendTo at zend.to
> http://mailman.ecs.soton.ac.uk/mailman/listinfo/zendto

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/zendto/attachments/20151022/2c67dbd5/attachment.html 
-------------- next part --------------
#!/bin/bash
#
##############################################################
# dropls command by PCFreak
# This script will list files and folders in the ZendTo
# dropopff location in color and shows additional information
##############################################################
# changes
# 26-May-2014 initial release                               PM
# 27-May-2014 added sorting by date with printf/sort/awk    PM
#             added String [LIB] when filename is numeric   
#              --> this means it is from the library        PM
##############################################################
sqlu="zendto"                             #sql user
sqld="zendto"                             #sql database
sqlp="yourSQLPasswordhere"                   #sql password
dropoffbase="/var/zendto/dropoffs"        #dropoff folder

# don't change below here
colorstart="\E[36m$3" # string for colorcode start
colorgreenstart="\E[1;32m" # string for green color start
colorredstart="\E[1;31m"   # string for red color start
colorend="\E[0m"      # string for all colorcodes end
banner="\n\tOutput of dropoff folder(s) or file(s) by date in current directory\n\tby PCFreak pcfreak at pcfreak.de\n"

if [ $# -eq 0 ] # if no argument supplied
  then
   folder="$PWD"         #put current dir into var folder
  else
   folder="$1"            #use parameter 1 as a folder/file
fi
# Check if we are in the dropoff folder
if [[ $PWD != $dropoffbase* ]];then   # True if $a starts with an "$dropoffbase" (wildcard matching).
 echo "This command only works in $dropoffbase or subfolders below!"
 #echo "Will exit"
 exit 1 # exit with errorlevel 1
fi

echo -e "$banner" # output the banner


# get files/folders and sort them by date using printf/sort/awk
for a in $(find $folder/* -maxdepth 0 -printf "%T+\t%p\n" | sort | echo "$(awk '{print $NF}')"); do
 bname=$(basename "$a") # get basename only

 # for dropoff folders
 if [[ -d "$PWD/$bname" ]]; then # if current item is a folder
  cdate=$(stat -c "%z" "$bname")
  mydate=$(date -d "$cdate" +"%B %d %H:%M")
  changed=$(stat -c "%A %h %G %U %o" "$bname")
  hrights=$(stat -c "%a" "$bname")
  email=$(echo select senderEmail from dropoff where claimID=\'$bname\' | mysql -B -N --user=$sqlu --password=$sqlp $sqld;)
  rowID=$(echo select rowID from dropoff where claimID=\'$bname\' | mysql -B -N --user=$sqlu --password=$sqlp $sqld;) # we need that later
  # get recipients per Dropoff using rowID
  recipients='to:'
  for a in $(echo select recipEmail from recipient where dID=\'$rowID\'| mysql -B -N --user=$sqlu --password=$sqlp $sqld;); do
    recipients="$recipients $a"
  done
  echo -e "$hrights $changed $mydate ""$colorstart"$bname"$colorend"" from: $(echo -e "$colorgreenstart$email$colorend $colorredstart$recipients$colorend"|tr '[:upper:]' '[:lower:]')"
 fi

 # for dropoffs in dropoff folders
 if [[ -f "$PWD/$bname" ]]; then # if current item is a file
  cdate=$(stat -c "%z" "$bname")
  mydate=$(date -d "$cdate" +"%B %d %H:%M")
  changed=$(stat -c "%A %h %G %U %s" "$bname")
  hrights=$(stat -c "%a" "$bname")
  #email=$(echo select senderEmail from dropoff where claimID=\'$bname\' \
  email=$(echo select senderEmail from dropoff where claimID=\'$(basename $PWD)\' \
  | mysql -B -N --user=$sqlu --password=$sqlp $sqld;)
  filename=$(echo select basename from file where tmpname=\'$bname\' \
  | mysql -B -N --user=$sqlu --password=$sqlp $sqld;)
   if [ $bname -eq $bname 2>/dev/null ]; then # if $bname is numeric
    echo -e "$hrights $changed\t$mydate ""$colorstart"$bname" [LIB]$colorend"" \"$filename\"\tuploaded by: $(echo $colorgreenstart$email$colorend|tr '[:upper:]' '[:lower:]')"
   else # if not numeric
    echo -e "$hrights $changed\t$mydate ""$colorstart"$bname"$colorend"" \"$filename\"\tuploaded by: $(echo $colorgreenstart$email$colorend|tr '[:upper:]' '[:lower:]')"
   fi
 fi
done


More information about the ZendTo mailing list