-
Notifications
You must be signed in to change notification settings - Fork 0
/
rminstall.php
55 lines (52 loc) · 1.43 KB
/
rminstall.php
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
<?php
// get the application root folder
define('APP_ROOT', getcwd());
// perform delete operation only if the install is complete
if ( @file_exists(APP_ROOT . '/config.php') && @file_exists(APP_ROOT . '/admin/config.php') ) {
// install directory path
$install_dir = APP_ROOT . '/install';
if ( is_dir($install_dir) ) {
// delete the install directory
$deleted = del_dir($install_dir);
// after removing the install folder redirect to home page.
if ( $deleted ) {
header('Location: ./');
}
else {
echo "Can't delete the install directory. Please check the permissions of install directory.";
}
} else {
header('Location: ./');
}
}
else {
echo "Something wrong with your phpBB installation, please make sure that phpBB is installed completely";
}
/**
* Delete a directory recursively
*
* @param $dir String Directory to be removed
*
* @return Boolean true on success
*/
function del_dir($dir) {
$fp = opendir($dir);
if ( $fp ) {
while ( $current_file = readdir($fp) ) {
$full_file = $dir . "/" . $current_file;
// if the curent path is a directory call the del_dir again, else delete the file directly
if ( $current_file == "." || $current_file == ".." ) {
continue;
}
else if ( is_dir($full_file) ) {
del_dir($full_file);
}
else {
unlink($full_file);
}
}
closedir($fp);
// after making the directory empty call the rmdir to delete the empty root directory
return rmdir($dir);
}
}