-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·96 lines (78 loc) · 2.63 KB
/
index.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
$path = dirname(__FILE__);
define('EXT', '.php');
define('CLER', 'Controller_');
define('ML', 'Model_');
define('HR', 'Helper_');
$core = 'core';
$controllers = 'controllers';
$views = 'views';
$models = 'models';
$helper = 'helper';
$config = 'config';
$lib = 'library';
$install = 'install';
define('CORE_PATH', $path . DIRECTORY_SEPARATOR . $core . DIRECTORY_SEPARATOR);
define('CPATH', $path . DIRECTORY_SEPARATOR . $controllers . DIRECTORY_SEPARATOR);
define('VPATH', $path . DIRECTORY_SEPARATOR . $views . DIRECTORY_SEPARATOR);
define('MPATH', $path . DIRECTORY_SEPARATOR . $models . DIRECTORY_SEPARATOR);
define('HPATH', $path . DIRECTORY_SEPARATOR . $helper . DIRECTORY_SEPARATOR);
define('CONFIG_PATH', $path . DIRECTORY_SEPARATOR . $config . DIRECTORY_SEPARATOR);
define('LPATH', $path . DIRECTORY_SEPARATOR . $lib . DIRECTORY_SEPARATOR);
define('IPATH', $path . DIRECTORY_SEPARATOR . $install . DIRECTORY_SEPARATOR);
set_include_path(get_include_path() . PATH_SEPARATOR . CPATH . PATH_SEPARATOR . VPATH . PATH_SEPARATOR . MPATH . PATH_SEPARATOR . CONFIG_PATH . PATH_SEPARATOR . CORE_PATH);
// if isset directory setup run it
if (!is_file(CONFIG_PATH . 'config' . EXT))
{
if (isset($_POST['remove']) && $_POST['remove'] == '1')
{
RemoveDir(IPATH);
unset($_SESSION['site_name']);
unset($_SESSION['db']);
}
require_once IPATH . 'install' . EXT;
exit();
}
session_start();
require_once LPATH . 'sec_lib/Security' . EXT;
Security::run();
require_once CORE_PATH . 'core' . EXT;
Core::run();
function RemoveDir($path)
{
if (file_exists($path) && is_dir($path))
{
$dirHandle = opendir($path);
while (false !== ($file = readdir($dirHandle)))
{
if ($file != '.' && $file != '..')// исключаем папки с назварием '.' и '..'
{
$tmpPath = $path . '/' . $file;
chmod($tmpPath, 0777);
if (is_dir($tmpPath))
{ // если папка
RemoveDir($tmpPath);
}
else
{
if (file_exists($tmpPath))
{
// удаляем файл
unlink($tmpPath);
}
}
}
}
closedir($dirHandle);
// удаляем текущую папку
if (file_exists($path))
{
rmdir($path);
}
}
else
{
echo "Удаляемой папки не существует или это файл!";
}
}
?>