Using a public/shared server is a real hassle. I’ve found that my GoDaddy account is a pain to upload lots of files at once. It would not be so bad if all of the files were downloaded at once but ftp requires multiple communication on every file.
The obvious solution would be to create some kind of archive such as a .tgz (tar gzip) file which could be downloaded. However, without a shell to decompress things, what can you do? After a little research, I found phpzip, from
PhpConcept, which does the entire archival process through a collection of JavaScript/PHP scripts which are supported by GoDaddy on their shared Linux servers.
1) The
program was good enough. However, there were a couple of issues for me. The most serious flaw in the program that I found was security. Anyone who knows the address of the .php file could Unzip over something of yours. They also might be able to upload stuff that they shouldn’t. To fix that problem, I just added .htaccess to require a password.
My .htaccess file looked like:
AuthUserFile …/private/.htpasswd
AuthGroupFile /dev/null
AuthName
"Restricted Stuff"
AuthType "Basic"
require valid-user
My .htpassword was created on my Linux machine using htpasswd:
name:2mDQofxXPsyP6
2) My next concern was “is that really enough security?” I decided to modify the program to support an encrypted password. This required the modification of the main PHP file to ensure that on every access a matching password existed. To do this, we added a session variable to keep track of things. Thus, even if I messed up the .htaccess, there would still be another password. The only problem that I had was that I don’t speak French. While the code is commented in English, the code uses French to English translations for the User output. So, I had to make the translator understand my “French”.
3) The program did not support the file upload. I could just live with ftp’ing the .tgz or .zip file. However, I wanted to do it all from my browser. So, I added an upload capability.
4) My version of phpzip is
here. It works for Firefox at the moment.
Labels: php, upload, webhosting