i was wondering how i can, for example, overwrite my "index.php" so i can update my page automatically.
What I'm trying to do is communicate 2 servers, the server 1 tells the server 2 when there's a new update and the server 2 download it:
*Upload the new webpage "content.zip" to my webserver1: (i do this because this way i can backup my content)
form
<form action="uploader.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="Upload" />
</form>
uploader.php
<?php
$folder = "content/";
opendir($folder);
$destiny = $folder.$_FILES['file']['name'];
copy($_FILES['file']['tmp_name'],$destiny);
echo "Successful";
?>
*Then tell the webserver2 to download the new content and replace the old.
if(somevariable == true){
file_put_contents("newcontent.zip", file_get_contents("http://someurl/fsadasd.zip"));
}
And then:
<?php
$zip = new ZipArchive;
$res = $zip->open('newcontent.zip');
if ($res === TRUE) {
$zip->extractTo('var/www/');
$zip->close();
echo 'woot!';
} else {
echo 'doh!';
}
?>
Also, do i have to stop the LAMP process then modify the files and start it again?
If someone knows a better way to do this, please tell me. Thanks.