-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.php
64 lines (53 loc) · 2.1 KB
/
init.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
<?php
/*****************************************************************************\
+-----------------------------------------------------------------------------+
| SchoolReg |
| Copyright (c) 2010 Z. |
| Copyright (c) 2009 Sergey V. Kuzin <sergey@kuzin.name> |
| All rights reserved. |
+-----------------------------------------------------------------------------+
\*****************************************************************************/
#
# $Id: init.php 4 2010-02-02 18:52:58Z kuzmich $
#
session_start();
if (file_exists(dirname(__FILE__).'/config.php')) {
include_once 'config.php';
}
if (!isset($config)) {
$prefix = '';
if (defined('TEACHER_ZONE') or defined('ADMIN_ZONE')
or defined('TEACHER_ZONE_LOGIN') or defined('ADMIN_ZONE_LOGIN')) {
$prefix = '../';
}
header('Location: '.$prefix.'install/index.php');
}
include_once 'include/mysql_db.php';
include_once 'lib/json_encode_r.php';
include_once 'lib/utils.php';
db_connect($config['db']['db_host'], $config['db']['db_user'], $config['db']['db_passwd'], $config['db']['db_base']);
db_query('SET NAMES UTF8;');
require_once 'lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$twig_loader = new Twig_Loader_Filesystem(dirname(__FILE__).'/lib/templates');
$twig = new Twig_Environment($twig_loader, array('cache' => dirname(__FILE__).'/cache', 'trim_blocks' => true, 'auto_reload' => true));
if (defined('TEACHER_ZONE')) {
if (!isset($_SESSION['teacher_id'])) {
header('Location: login.php');
} else {
$teacher_id = $_SESSION['teacher_id'];
}
} elseif (defined('ADMIN_ZONE')) {
if (!isset($_SESSION['admin_id'])) {
header('Location: login.php');
} else {
$admin_id = $_SESSION['admin_id'];
}
} elseif (defined('STUDENT_ZONE')) {
if (!isset($_SESSION['student_id'])) {
header('Location: login.php');
} else {
$student_id = $_SESSION['student_id'];
}
}
?>