tags:

views:

72

answers:

3

hey guys i know how to write a update script for my project , the easiest way is to write a file and give it to the user and ask him to go for it . but i want to update his website automatically .

exactly like wordpress as u can see user can click on a button and the script will do next steps.

problem is how to Downloading a zip file from a target server extract it on user host and install it automatically

maybe i can write this script on my own but i thought maybe currently we have some classes to do so in php

thanks in advance

A: 

you could use cURL to download the file and PHP's Zip-function to unzip

Natrium
Why not file_get_contents('http://example.com/file.zip'); ? Is there an advantage in using curl?
Niteriter
hmm lets try cURL , hope to make it happen , but mostly i was looking for a ready class to do these things , however i can write my own class ( takes time )
farshad Ghazanfari
A: 

As you can see, if you use the downloadabe wordpress version (i mean, the one you donload and place on your hosting), it ask you the FTP user and password: wp use the php FTP functions.

I found a good tutorial to use FTP throught curl: here is it.

Then, you'll need to unpack it: php has the zip extension ready for you

DaNieL
hmm . thanks . what about security issues , as u know some hosts using safe mode on , and other things would be disabled on their hosts , how to get around of these problems in downloading and unzipping and then running my script
farshad Ghazanfari
cUrl should be enabled in most of hoster (even in the cheapest one), if not so, try the ftp functions (but if curl is disabled, probably the ftp functions are disabled too).
DaNieL
Who's the fool that came here just for downvote 2 ansers without provide a explanation? If I wrote something wrong its ok ti downvote my answer, but please let me know what i said wrong (you know, `learning from mistake`, and stuff like that?)
DaNieL
+1  A: 

The new and shiny php-5.3 offers the .phar extension, which rocks. And you don't even have to "unzip" it.

Flavius
+1 I would personally also look into .phar . Extracting ZIP (or any other archive) will probably lead to security issues (depending on what you do exactly it could be that your complete webroot needs to be world writable, and that's something you don't want).
wimvds