Archive for December, 2004

getFTPDir, PHP Class that downloads a ftp directory

December 13th, 2004

This little php class connects to a ftp server and downloads an entire directory, including subdirectories.
Useful for syncronizing files between servers, using ftp.

Documentation here.

Download here.

Post suggestions for improvements.

php forminsert

December 1st, 2004

Well- I’m sure everyone here has used formmail or some derivative to the glee of many a client. But beyond just emailing the contents of a form to someone… I wanted something different — I wanted to insert the form data into a database (usually mySQL). While this is easily accomplished, it was becoming time consuming for me to write out the code again and again to insert the data into the database, and if the client needed a change in the form I had to sit down and modify the SQL and the database in addition to the form.

So I sat down to write a script that would take all the information posted, and place it in a database table with corresponding fields… and it worked well for little ol’ me – Until the client wanted me to add more fields to the form – which required modifying the database.

So I sat down again, and modified the script to invoke ALTER table statements to accomodate the data…. and it worked well enough for little ol’ me – Until the client wanted me to handle files posted through the form.

So I sat down again, and modified the script to create another table to hold files and store the binary data, returning a key as a reference for the main table. And it worked well enough for little ol’ me – Until I thought about anyone else that might have clients like I do.

So here you go… It’s a hack-job, insecure, and dangerous some might say. But it works well enough for little ol’ me… and with your help, it might work well enough for you too.

It’s built in php, connects to mySQL, I called it forminsert.

Feel free to check it out, post your comments, send me fixes. It’s under the usual license of free to use, modify, distribute – but don’t blame me if anything goes wrong.

To do: make it more secure (check referrer at least), do a proper job of checking existing fields (instead of field count comparison), modify to use adodb, return the insert id on success, clean up the code – remove un-necessary vars, and make it work for YOU.

Download:http://www.saltybeagle.com/tech/forminsert.tar.gz

-Salty