89 lines
3.9 KiB
PHP
89 lines
3.9 KiB
PHP
<?php
|
|
// Check if directory is empty but ignore install script
|
|
function dir_is_empty($dirname)
|
|
{
|
|
if (!is_dir($dirname)) return false;
|
|
foreach (scandir($dirname) as $file) {
|
|
if (!in_array($file, array('.','..','oci-framagrav.php','oci-uploader.php'))) return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// If install directory is not empty stop processing
|
|
$dest = dirname(__FILE__).'/';
|
|
if (dir_is_empty($dest) === false) {
|
|
echo nl2br("Le dossier httpdocs/ doit être vide pour y migrer votre Framasite.\r\n");
|
|
exit();
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
<title>Migration de votre Framasite chez Ouvaton</title>
|
|
</head>
|
|
<body>
|
|
<style>
|
|
body{background:#f0f0f0;font-family:Arial,sans-serif;text-align:center}.vert{color:#6c7e31;fill:#889e3a}.violet{color:#725794;fill:#977ac2}header img{display:block;margin-left:auto;margin-right:auto}main article p{width:80%;margin-left:10%;margin-bottom:2%}input[type=submit]{background-color:#4caf50;border:none;color:#fff;padding:10px 24px;text-decoration:none;margin:16px 2px 0;border-radius:16px;cursor:pointer;outline:0}.loader{border-top:16px solid #f59501;border-right:16px solid #224f9b;border-bottom:16px solid #5aa120;border-left:16px solid #bb000b;border-radius:50%;width:60px;height:60px;margin:0 auto;animation:spin 2s linear infinite}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@media screen and (min-width:600px){main article p{width:50%;margin-left:25%}}@media screen and (min-width:1200px){main article p{width:30%;margin-left:35%}}
|
|
</style>
|
|
<header>
|
|
<img alt="Logo Ouvaton" src="https://ouvaton.coop/wp-content/uploads/2018/04/cropped-logo-ouvaton-hd-refill-3.png">
|
|
<h1>Importation de votre <b class="violet">Frama</b><b class="vert">site</b></a> sur la plateforme Ouvaton</h1>
|
|
</header>
|
|
<main>
|
|
<article>
|
|
<p>
|
|
<form id="upload-form" enctype="multipart/form-data" method="post" action="oci-framagrav-uploader.php">
|
|
<label>Sélectionnez l'archive ZIP de votre site :<br />
|
|
<input id="upload-file" type="file" name="zip_file" /></label>
|
|
<br />
|
|
<input id="upload-submit" type="submit" name="submit" value="Envoyer" />
|
|
</form>
|
|
</p>
|
|
<div id="spinner"></div>
|
|
<div id="status"></div>
|
|
</article>
|
|
</main>
|
|
</body>
|
|
<script>
|
|
var myForm = document.getElementById('upload-form');
|
|
var archive = document.getElementById('upload-file');
|
|
var statusDIV = document.getElementById('status');
|
|
var spinnerDIV = document.getElementById('spinner');
|
|
|
|
myForm.onsubmit = function(event) {
|
|
event.preventDefault();
|
|
spinnerDIV.innerHTML = '<p class="loader"></p>';
|
|
statusDIV.innerHTML = '<p>Il faut plusieurs dizaines de secondes pour mettre en place votre site.<br /><strong>Ne rechargez ou ne quittez pas la page</strong> avant que votre site ne s\'affiche !</p>'
|
|
|
|
var files = archive.files;
|
|
var formData = new FormData();
|
|
var file = files[0];
|
|
|
|
if (!file.type.match('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed')) {
|
|
spinnerDIV.innerHTML = '';
|
|
statusDIV.innerHTML = "Votre fichier n'est pas une archive ZIP.";
|
|
return;
|
|
}
|
|
|
|
formData.append('zip_file', file, file.name);
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('POST', 'oci-uploader.php', true);
|
|
xhr.onload = function() {
|
|
statusDIV.innerHTML = xhr.responseText;
|
|
};
|
|
xhr.onreadystatechange = function() {
|
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
|
window.location.replace("/");
|
|
} else {
|
|
spinnerDIV.innerHTML = '';
|
|
statusDIV.innerHTML = xhr.responseText;
|
|
}
|
|
};
|
|
xhr.send(formData);
|
|
}
|
|
</script>
|
|
</html>
|