/
install.php
68 lines (49 loc) · 1.48 KB
/
install.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
<?php
echo "Welcome to CoOrg installation\n";
echo "We will not ask you any questions so see that your config file is already OK.";
require_once 'coorg/config.class.php';
require_once 'coorg/db.class.php';
$config = new Config('config/config.php');
// copied from PHP docs page somewhere in the comments
function uuidv4() {
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
}
$config->set('site/uuid', uuidv4());
$config->save();
DB::open($config->get('dbdsn'), $config->get('dbuser'), $config->get('dbpass'));
foreach ($config->get('enabled_plugins') as $plugin)
{
$path = 'plugins/'.$plugin.'/install.php';
if (is_file($path))
{
include_once $path;
$f = str_replace('-', '_', $plugin);
call_user_func($f.'_install_db');
}
}
foreach (scandir('app') as $plugin)
{
if ($plugin[0] == '.') continue;
$path = 'app/'.$plugin.'/install.php';
if (is_file($path))
{
include_once $path;
$f = str_replace('-', '_', $plugin);
call_user_func($f.'_install_db');
}
}
?>