This repository was archived by the owner on Jun 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.php
More file actions
172 lines (147 loc) · 4.8 KB
/
Copy pathinstall.php
File metadata and controls
172 lines (147 loc) · 4.8 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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/**
* Install script
*
* @package Install
* @copyright (c) Cotonti Team
* @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
*/
// Environment setup
const COT_CODE = true;
const COT_INSTALL = true;
//define('COT_ADMIN', TRUE);
if (file_exists('./datas/config.php')) {
require_once './datas/config.php';
} else {
require_once './datas/config-sample.php';
}
if (empty($cfg['modules_dir'])) {
$cfg['modules_dir'] = './modules';
}
if (empty($cfg['lang_dir'])) {
$cfg['lang_dir'] = './lang';
}
// Force config options
$cfg['display_errors'] = true;
$cfg['debug_mode'] = true;
$cfg['customfuncs'] = false;
$cfg['cache'] = false;
$cfg['xtpl_cache'] = false;
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);
require_once $cfg['system_dir'] . '/functions.php';
require_once './lib/autoload.php';
require_once './system/debug.php';
date_default_timezone_set('UTC');
$sys['now'] = time();
$env['location'] = 'install';
$env['ext'] = 'install';
if (isset($cfg['new_install']) && $cfg['new_install']) {
// A Few basics from common.php
if (version_compare(PHP_VERSION, '6.0.0', '<=')) {
if (get_magic_quotes_gpc()) {
function cot_disable_mqgpc(&$value, $key) {
$value = stripslashes($value);
}
$gpc = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
array_walk_recursive($gpc, 'cot_disable_mqgpc');
}
}
define('MQGPC', FALSE);
error_reporting(E_ALL ^ E_NOTICE);
session_start();
Cot::init();
// It will be needed when we start to install extensions
// Getting the server-relative path
$url = parse_url($cfg['mainurl']);
$sys['secure'] = $url['scheme'] == 'https' ? true : false;
$sys['scheme'] = $url['scheme'];
$sys['site_uri'] = isset($url['path']) ? $url['path'] : '';
$sys['host'] = $url['host'];
$sys['domain'] = preg_replace('#^www\.#', '', $url['host']);
$sys['site_uri'] = rtrim($sys['site_uri'], '/').'/';
$sys['port'] = empty($url['port']) ? '' : ':' . $url['port'];
$sys['abs_url'] = $url['scheme'] . '://' . $sys['host'] . $sys['port'] . $sys['site_uri'];
$sys['site_id'] = 'install';
// Installer language selection support
if (empty($_SESSION['cot_inst_lang'])) {
$lang = cot_import('lang', 'P', 'ALP');
if (empty($lang)) {
$lang = cot_lang_determine();
}
} else {
$lang = $_SESSION['cot_inst_lang'];
}
require_once cot_langfile('main', 'core');
require_once $cfg['system_dir'] . '/resources.rc.php';
} else {
$branch = 'siena';
$prev_branch = 'genoa';
$db = new CotDB([
'host' => $cfg['mysqlhost'],
'port' => !empty($cfg['mysqlport']) ? $cfg['mysqlport'] : null,
'tablePrefix' => $db_x,
'user' => $cfg['mysqluser'],
'password' => $cfg['mysqlpassword'],
'dbName' => $cfg['mysqldb'],
'charset' => !empty($cfg['mysqlcharset']) ? $cfg['mysqlcharset'] : null,
'collate' => !empty($cfg['mysqlcollate']) ? $cfg['mysqlcollate'] : null,
]);
Cot::init();
if (!$db->tableExists(Cot::$db->updates)) {
define('COT_UPGRADE', true);
$cfg['defaulttheme'] = 'nemesis';
$cfg['defaultscheme'] = 'default';
}
require_once $cfg['system_dir'] . '/common.php';
}
require_once cot_incfile('forms');
require_once cot_incfile('extensions');
require_once cot_incfile('install', 'module');
require_once cot_langfile('install', 'module');
require_once cot_langfile('users', 'core');
require_once cot_langfile('admin', 'core');
require_once cot_incfile('install', 'module', 'resources');
// Various Generic Vars needed to operate as Normal
$theme = $cfg['defaulttheme'];
$scheme = $cfg['defaultscheme'];
$out['meta_lastmod'] = gmdate('D, d M Y H:i:s');
$file['config'] = './datas/config.php';
$file['config_sample'] = './datas/config-sample.php';
$file['sql'] = './setup/install.sql';
// Check if another install process is running
$processFile = cot_installProcessFile();
$processFileDir = dirname($processFile);
$anotherProcessRunning = false;
if (is_writable($processFileDir)) {
if (file_exists($processFile)) {
$anotherProcessStarted = (int) file_get_contents($processFile);
if (time() - $anotherProcessStarted < 30) {
// Another process was recently started
cot_die_message(
101,
true,
$L['install_another_process'],
sprintf($L['install_another_process2'], date('Y-m-d H:i:s', $anotherProcessStarted))
);
exit;
}
}
file_put_contents($processFile, $sys['now']);
}
$processError = '';
try {
if (!$cfg['new_install']) {
include cot_incfile('install', 'module', 'update');
} else {
include cot_incfile('install', 'module', 'install');
}
} catch (\Exception $e) {
$processError .= $e->getMessage();
}
if (file_exists($processFile)) {
unlink($processFile);
}
if ($processError) {
cot_diefatal('Error: ' . $processError);
}