I have never tried interaction with a secure server in PHP but, like most things in PHP, it is probably a common enough task that there are some easy functions written for it. For instance, GZIP compression used to be difficult and now it's built into the output buffering functions. Anyway...
The fopen() command is supposed to try to find a wrapper for whatever protocol you use. Therefore it should be able to handle the HTTPS protocol fine, though my server is down currently and I can't test this myself.
I am in the process of writing you a script, and (though it's not hard or complicated) it takes a few minutes to write. I'll have to finish it up tomorrow and post it for you.
If you want to try it yourself in the mean time, here is some algorithm for you:
- get a list of files to sync in an array
- foreach() item in that array, find the equivalent on the server and use filemtime() to check the modification dates of both files
- convert both modification dates to Unix timestamps using mktime() and then use regular integer comparison (>, <, etc) to check which file is older
- if the file on the sync server is newer, use fopen() and fread() to download it
- use fopen() and fwrite() on your own server to create the file if it does not exist, and overwrite it if it does
- close connections
If this is too difficult, wait a bit and I'll write this all up in nice, commented PHP for you.