open($targetzip); if ($x === true) { $zip->extractTo('.'); $zip->close(); unlink($targetzip); } } else { echo nl2br("Une erreur vient de se produire lors du téléversement de votre fichier.\r\n"); exit(); } // Download latest CMS zip with cURL $ch = curl_init(); $source = "https://ouvaton.coop/oci/framagrav-themes.zip"; curl_setopt($ch, CURLOPT_URL, $source); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); // If any cURL error stop processing if(curl_errno($ch)) { echo 'Erreur cURL : '.curl_error($ch); curl_close($ch); exit; } // Check HTTP code switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE)) { case 200: // Create CMS zip $destination = "themes.zip"; $file = fopen($destination, "w+"); fputs($file, $data); fclose($file); curl_close($ch); // Unzip archive file $file = 'themes.zip'; $zip = new ZipArchive; if ($zip->open($file) === TRUE) { $zip->extractTo('.'); $zip->close(); } else { echo nl2br("Une erreur lors de la décompression de l'archive vient de se produire, contactez l'assistance !\r\n"); exit; } // Zip archive is not needed anymore unlink('themes.zip'); // Website URI $host = $_SERVER['HTTP_HOST']; // Set URI $grav_custom = "custom_base_url: 'https://".$host."'"; $set_grav_custom = file_put_contents('user/config/system.yaml', $grav_custom.PHP_EOL , FILE_APPEND | LOCK_EX); // Remove scripts unlink('oci-framagrav.php'); unlink(__FILE__); echo "L'installation est terminée !"; exit; default: // If any HTTP error stop processing echo nl2br("Code HTTP : ".$http_code."\r\n"); curl_close($ch); exit; } ?>