generalized both scripts with adding variables, improved php script
PHP: checking for presence of file-key of the supplied file-object
PHP: create recursive folders for work-directory of keyfiles and share-keys