summaryrefslogtreecommitdiff
path: root/web/include/Namespace.inc
blob: 51542f177cdf8241b09fd4b22ef84a1e946e131d (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
<?
/* Global Variables and Stuff for remsaint
 *
 * (c) 2002 Peter Palfrader <pp@3node.com>
 */

require_once("../include/Config.inc");
#require_once("../include/DB.inc");
require_once("../include/Messages.inc");
require_once("../include/Session.inc");
require_once("../include/User.inc");

class Namespace {
	var $have_database = false;
	var $have_session = false;
	var $have_user = false;

	var $config = false;
	var $database = false;
	var $messages = false;
	var $session = false;
	var $user = false;

	function Namespace($options = array()) {
		if ($options['have_database'])
			$this->have_database = $options['have_database'];
		if ($options['have_session'])
			$this->have_session = $options['have_session'];
		if ($options['have_user'])
			$this->have_user = $options['have_user'];

		$this->config = new Config() or
			die("Count not create config object");
		$this->messages = new Messages or
			die("Could not create messages object");

		if ($this->have_database)
			$this->database = new Database (
				$this->config->db_type,
				$this->config->db_host,
				$this->config->db_user,
				$this->config->db_password,
				$this->config->db_name) or
				die("Could not create database object");
		if ($this->have_session)
			$this->session = new Session( $this->database, $this->config->session_cookie_name, $this->messages ) or
				die("Could not create session object");
		if ($this->have_user)
			$this->user = new User( $this->database, $this->session, $this->config->auth_timeout ) or
				die("Could not create user object");
	}

	function stop() {
		if ($this->have_session) {
			assert($this->session);
			$this->session->close();
		}
	}
}

# vim:set ts=4:
# vim:set shiftwidth=4:
?>