-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathheader.php
102 lines (85 loc) · 3.33 KB
/
header.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
96
97
98
99
100
101
102
<?php
require dirname(__FILE__) . '/includes/fix.inc.php';
require 'class.flyspray.php';
require 'constants.inc.php';
require 'i18n.inc.php';
// Get the translation for the wrapper page (this page)
setlocale(LC_ALL, str_replace('-', '_', L('locale')) . '.utf8');
// If it is empty,take the user to the setup page
if (!$conf) {
Flyspray::Redirect('setup/index.php');
}
require 'class.gpc.php';
require 'utf8.inc.php';
require 'class.database.php';
require 'class.backend.php';
require 'class.project.php';
require 'class.user.php';
require 'class.tpl.php';
require 'class.do.php';
require_once 'authplugins/class.flysprayauth.php';
$db = NewDatabase($conf['database']);
$fs = new Flyspray;
// If version number of database and files do not match, run upgrader
if (Flyspray::base_version($fs->version) != Flyspray::base_version($fs->prefs['fs_ver'])) {
Flyspray::Redirect('setup/upgrade.php');
}
if (is_readable(BASEDIR . '/setup/index.php') && strpos($fs->version, 'dev') === false) {
die('Please empty the folder "' . BASEDIR . DIRECTORY_SEPARATOR . "setup\" before you start using Flyspray.\n".
"If you are upgrading, please go to the setup directory and launch upgrade.php");
}
// Get available do-modes and include the classes
$modes = str_replace('.php', '', array_map('basename', glob_compat(BASEDIR ."/scripts/*.php")));
// yes, we need all of them for now
foreach ($modes as $mode) {
require_once(BASEDIR . '/scripts/' . $mode . '.php');
}
$do = Req::val('do');
// Any "do" mode that accepts a task_id or id field should be added here.
if (Req::num('task_id')) {
$project_id = $db->x->GetOne('SELECT project_id
FROM {tasks}
WHERE task_id = ?', null,
Req::num('task_id'));
$do = Filters::enum($do, array('details', 'depends', 'editcomment'));
} else {
if ($do == 'admin' && Get::has('switch') && Get::val('project') != '0') {
$do = 'pm';
} elseif ($do == 'pm' && Get::has('switch') && Get::val('project') == '0') {
$do = 'admin';
} elseif (Get::has('switch') && ($do == 'details')) {
$do = 'index';
}
if ($do && class_exists('FlysprayDo' . ucfirst($do)) &&
!call_user_func(array('FlysprayDo' . ucfirst($do), 'is_projectlevel'))) {
$project_id = 0;
}
}
if (!isset($project_id)) {
// Determine which project we want to see
if (($project_id = Cookie::val('flyspray_project')) == '') {
$project_id = $fs->prefs['default_project'];
}
$project_id = Req::val('project', Req::val('project_id', $project_id));
}
$proj = new Project($project_id);
// reset do for default project level entry page
if (!in_array($do, $modes)) {
$do = ($do) ? Req::enum('do', $modes, $proj->prefs['default_entry']) : $proj->prefs['default_entry'];
}
$proj->setCookie();
$user = new User($uid = 0);
// verify and initiate user
$auth = new FlysprayAuth();
if (Post::val('user_name') && Post::has('password')) {
$uid = $auth->checkLogin(Post::val('user_name'), Post::val('password'));
if (is_array($uid)) {
FlysprayDo::error($uid);
}
} else if (Cookie::val('flyspray_userid') && $auth->checkCookie(Cookie::val('flyspray_userid'), Cookie::val('flyspray_passhash'))) {
$uid = Cookie::val('flyspray_userid');
}
$user = new User($uid);
// Load translations
load_translations();
?>