-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
62 lines (49 loc) · 1.77 KB
/
install.php
File metadata and controls
62 lines (49 loc) · 1.77 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
58
59
60
61
62
<?php
$dirs = array('plugins');
$files = array('.htaccess', 'config.php');
$dir_current = dirname(__FILE__);
$dir_install = $dir_current . '/install';
if(!is_dir($dir_install)) {
die('Both your <code>config.php</code> and <code>install</code> directory seem to be missing. You may want to reinstall Felix entirely.');
} else if(!is_writable($dir_install)) {
die('Please add writing permissions to the <code>install</code> directory. It will be deleted after completion.');
} else {
if(!is_writable($dir_current)) {
die('Please add writing permissions to the root directory. You can change it back when no messages pop up.');
} else {
$path_root = $_SERVER['REQUEST_URI'];
if(substr($path_root, strlen($path_root) - 1) !== '/') $path_root .= '/';
// Gather data for URI_ROOT
$protocol = isset($_SERVER['HTTPS']) ? 'https' : 'http';
$uri_root = sprintf('%s://%s', $protocol, $_SERVER['SERVER_NAME']);
$uri_root .= (intval($_SERVER['SERVER_PORT']) !== 80) ? ':' . $_SERVER['SERVER_PORT'] : null;
$uri_root .= rtrim($path_root, '/');
/* Gather data it needs */
$data = array(
'__URI_ROOT__' => $uri_root,
'__PATH_ROOT__' => $path_root
);
foreach($dirs as $dir) {
$adir = $dir_current . '/' . $dir;
if(is_dir($adir)) continue;
mkdir($adir);
}
foreach($files as $file) {
$oldfile = $dir_install . '/' . $file;
$newfile = $dir_current . '/' . $file;
// Get file content
$content = file_get_contents($oldfile);
// Loop through variables
foreach($data as $key => $value) {
$content = str_replace($key, $value, $content);
}
// Save file to new location
file_put_contents($newfile, $content);
@unlink($oldfile);
}
// Delete install directory
@rmdir($dir_install);
}
}
// Goodbye world!
unlink($dir_current . '/install.php');