summaryrefslogtreecommitdiff
blob: 032597f700ccc9eed4d5f60f76e33fd835fab826 (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
<?php

$CONFIG_DIR='/etc/scire';

# Validate the path if it exists.
if (isset($path)) {
  if ($path != "../") {
    header('Content-type: text/html; charset=UTF-8');
    $smarty->assign('title', 'Path Error');
    $smarty->assign('message', 'invalid path.  stop trying to hack me you mofo!');
    $smarty->display('message.tpl');
    exit(0);
  }
} else {
  $path = "";
}

# Configuration

require_once($CONFIG_DIR.'/config.php');

# Functions
require_once('functions.php');

# Clean config
$basedir = normalize_path($basedir);
$baseurl = normalize_path($baseurl);
$smarty_dir = normalize_path($smarty_dir);

# Smarty
require_once('smarty.php');

# Database class
require_once('DB.php');
$db = new DB($db_host, $db_username, $db_password, $db_name, $db_type);
if (isset($db->error)) {
  header('Content-type: text/html; charset=UTF-8');
  $smarty->assign('title', 'Database Error');
  $smarty->assign('message', $db->error);
  $smarty->display('message.tpl');
  exit(0);
}

# Database functions
require_once('DB_functions.php');

# Session class
require_once('Session.php');
$session = new Session($db, $db_sessions_table);
if (isset($session->error)) {
  header('Content-type: text/html; charset=UTF-8');
  $smarty->assign('title', 'Session Error');
  $smarty->assign('message', $session->error);
  $smarty->display('message.tpl');
  exit(0);
}

# ACL class
require_once('phpGACL.php');

# Check login
if (!isset($_SESSION['username'])) {
  header('Location: ' . $baseurl . 'login.php?afterlogin=' . urlencode($_SERVER['REQUEST_URI']));
  exit(0);
} else {
  $smarty->assign('userid', $_SESSION['userid']);
  $smarty->assign('username', $_SESSION['username']);
  $smarty->assign('useremail', $_SESSION['useremail']);
  #Set Theme
  $smarty->assign('theme', $_SESSION['settings']['theme']);
}

?>