Installation Script - gtbu/Typesetter5.2 GitHub Wiki
Transferring individual files via FTP is time-consuming and somewhat cumbersome. It's easier to create a "tmpdir" directory in the domain root and copy the entire CMS zip file into it. Running the installation from this directory using example.com/tmpdir/inst.php is easier:
Here's a sample script, which remames the zip-file after extraction :
<?php
// instmp/inst.php and master.zip
$zipFile = __DIR__ . '/master.zip';
$rootDir = dirname(__DIR__) . DIRECTORY_SEPARATOR;
if (!file_exists($zipFile)) {
die("Error: master.zip not found in " . __DIR__);
}
$zip = new ZipArchive();
if ($zip->open($zipFile) === TRUE) {
if ($zip->extractTo($rootDir)) {
// Generate a random 25-character string for the new filename
$random = bin2hex(random_bytes(13)); // produces 26 chars (from 13 bytes), but close enough;
$random = substr($random, 0, 25); // trim to 25 chars if needed
$newName = __DIR__ . '/master-' . $random . '.zip';
if (rename($zipFile, $newName)) {
echo "Unzip and rename successful!<br>";
echo "core.zip now renamed to: " . basename($newName) . "<br>";
} else {
echo "Unzip successful, but could not rename file.<br>";
}
} else {
echo "Unzip failed: could not extract to root directory.<br>";
}
$zip->close();
} else {
echo "Failed to open zip file.<br>";
}
?>
--------------------------------------------------------------------------
# .htaccess file in the protected instmp - directory - after installation - better remove the whole directory or script !
<FilesMatch "\.(php|json|txt|cfg)$">
Require all denied
</FilesMatch>