-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
57 lines (45 loc) · 1.39 KB
/
install.php
File metadata and controls
57 lines (45 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
echo PHP_EOL;
echo "======================================" . PHP_EOL;
echo " Localhost Explorer Installer" . PHP_EOL;
echo "======================================" . PHP_EOL;
$repoDir = realpath(__DIR__);
$docRoot = realpath(dirname($repoDir));
if (!$docRoot) {
exit("❌ Unable to detect Apache document root" . PHP_EOL);
}
echo "📁 Repository : $repoDir" . PHP_EOL;
echo "📁 Doc Root : $docRoot" . PHP_EOL;
// Safety check
if (basename($repoDir) !== 'localhost-explorer') {
exit("❌ Please place this repository inside Apache document root" . PHP_EOL);
}
$timestamp = date('Ymd_His');
$files = [
'index.php' => <<<PHP
<?php
header('Location: localhost-explorer/');
exit;
PHP,
'.htaccess' => <<<HT
RewriteEngine On
# Redirect root to localhost-explorer
RewriteRule ^$ localhost-explorer/ [L]
HT
];
foreach ($files as $file => $content) {
$target = $docRoot . DIRECTORY_SEPARATOR . $file;
if (file_exists($target)) {
rename($target, $target . ".bak_$timestamp");
echo "📦 Backup created: $file" . PHP_EOL;
}
file_put_contents($target, $content);
echo "✅ Created: $file" . PHP_EOL;
}
echo PHP_EOL;
echo "⚠️ IMPORTANT:" . PHP_EOL;
echo "Ensure Apache DirectoryIndex prioritizes index.php" . PHP_EOL;
echo PHP_EOL;
echo "DirectoryIndex index.php index.html index.htm" . PHP_EOL;
echo PHP_EOL;
echo "🌐 Open http://localhost/" . PHP_EOL;