summaryrefslogtreecommitdiff
path: root/common.php
blob: f40c83ae545bb30c8f5b5efc717208d5095f7eaa (plain)
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
<?php

require __DIR__.'/core/registry.php';
require __DIR__.'/core/helper.php';
require __DIR__.'/core/translator.php';

$registry = new Core\Registry;

$registry->db_version = 12;

$registry->db = function() use ($registry) {
    require __DIR__.'/vendor/PicoDb/Database.php';

    if (DB_DRIVER === 'sqlite') {

        require __DIR__.'/schemas/sqlite.php';

        $db = new \PicoDb\Database(array(
            'driver' => 'sqlite',
            'filename' => DB_FILENAME
        ));
    }
    elseif (DB_DRIVER === 'mysql') {

        require __DIR__.'/schemas/mysql.php';

        $db = new \PicoDb\Database(array(
            'driver'   => 'mysql',
            'hostname' => DB_HOSTNAME,
            'username' => DB_USERNAME,
            'password' => DB_PASSWORD,
            'database' => DB_NAME,
            'charset'  => 'utf8',
        ));
    }
    else {
        die('Database driver not supported');
    }

    if ($db->schema()->check($registry->db_version)) {
        return $db;
    }
    else {
        die('Unable to migrate database schema!');
    }
};

$registry->event = function() use ($registry) {
    require __DIR__.'/core/event.php';
    return new \Core\Event;
};

$registry->action = function() use ($registry) {
    require_once __DIR__.'/models/action.php';
    return new \Model\Action($registry->shared('db'), $registry->shared('event'));
};

$registry->config = function() use ($registry) {
    require_once __DIR__.'/models/config.php';
    return new \Model\Config($registry->shared('db'), $registry->shared('event'));
};

$registry->acl = function() use ($registry) {
    require_once __DIR__.'/models/acl.php';
    return new \Model\Acl($registry->shared('db'), $registry->shared('event'));
};

$registry->user = function() use ($registry) {
    require_once __DIR__.'/models/user.php';
    return new \Model\User($registry->shared('db'), $registry->shared('event'));
};

$registry->comment = function() use ($registry) {
    require_once __DIR__.'/models/comment.php';
    return new \Model\Comment($registry->shared('db'), $registry->shared('event'));
};

$registry->task = function() use ($registry) {
    require_once __DIR__.'/models/task.php';
    return new \Model\Task($registry->shared('db'), $registry->shared('event'));
};

$registry->board = function() use ($registry) {
    require_once __DIR__.'/models/board.php';
    return new \Model\Board($registry->shared('db'), $registry->shared('event'));
};

$registry->project = function() use ($registry) {
    require_once __DIR__.'/models/project.php';
    return new \Model\Project($registry->shared('db'), $registry->shared('event'));
};

$registry->action = function() use ($registry) {
    require_once __DIR__.'/models/action.php';
    return new \Model\Action($registry->shared('db'), $registry->shared('event'));
};

$registry->rememberMe = function() use ($registry) {
    require_once __DIR__.'/models/remember_me.php';
    return new \Model\RememberMe($registry->shared('db'), $registry->shared('event'));
};

$registry->lastLogin = function() use ($registry) {
    require_once __DIR__.'/models/last_login.php';
    return new \Model\LastLogin($registry->shared('db'), $registry->shared('event'));
};

if (file_exists('config.php')) require 'config.php';

// Auto-refresh frequency in seconds for the public board view
defined('AUTO_REFRESH_DURATION') or define('AUTO_REFRESH_DURATION', 60);

// Custom session save path
defined('SESSION_SAVE_PATH') or define('SESSION_SAVE_PATH', '');

// Application version
defined('APP_VERSION') or define('APP_VERSION', 'master');

// Base directory
define('BASE_URL_DIRECTORY', dirname($_SERVER['PHP_SELF']));

// Database driver: sqlite or mysql
defined('DB_DRIVER') or define('DB_DRIVER', 'sqlite');

// Sqlite configuration
defined('DB_FILENAME') or define('DB_FILENAME', 'data/db.sqlite');

// Mysql configuration
defined('DB_USERNAME') or define('DB_USERNAME', 'root');
defined('DB_PASSWORD') or define('DB_PASSWORD', '');
defined('DB_HOSTNAME') or define('DB_HOSTNAME', 'localhost');
defined('DB_NAME') or define('DB_NAME', 'kanboard');