]>
src.bluestatic.org Git - bugdar.git/blob - includes/init.php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # [#]app[#] [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2003-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2003 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 error_reporting(E_ALL
& ~E_NOTICE
);
16 set_magic_quotes_runtime(0);
18 // ###################################################################
19 // Initialize the database
20 if (!file_exists('./includes/config.php'))
22 echo 'includes/config.php needs to be present!';
26 require_once('./includes/config.php');
27 require_once('./includes/db_mysql.php');
29 $DB_sql = new DB_Sql();
30 $DB_sql->appname
= '[#]app[#]';
31 $DB_sql->database
= $database;
32 $DB_sql->connect($servername, $username, $password, $usepconnect);
33 define('DEVDEBUG', $debug);
34 define('TABLE_PREFIX', $tableprefix);
35 define('COOKIE_PREFIX', $cookieprefix);
36 unset($database, $servername, $username, $password, $usepconnect, $tableprefix, $cookieprefix);
38 // ###################################################################
39 // Initialize our environment
40 require_once('./includes/functions_datastore.php');
41 require_once('./includes/functions.php');
44 var $options = array();
45 var $userinfo = array();
46 var $language = array();
47 var $datastore = array();
51 global $DB_sql, $vars;
53 // Fetch all the datastore caches
54 $datastoretemp = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "datastore");
55 while ($store = $DB_sql->fetch_array($datastoretemp))
57 $this->datastore
["$store[title]"] = unserialize($store['data']);
60 // Assign options and fetch the userinfo
61 $this->options
= $this->datastore
['setting'];
62 unset($this->datastore
['setting']);
63 $this->userinfo
= (array)$this->fetch_userinfo(-1, true);
65 // Pull our languageid
66 if ($this->userinfo
['userid'])
68 $languageid = $this->userinfo
['languageid'];
69 $language = $this->datastore
['language']["$languageid"];
73 foreach ($this->datastore['language'] AS $language)
75 if ($language['default'])
77 $languageid = $language['languageid'];
78 $language = $this->datastore['language']["$languageid"];
84 // Load language system
85 if (file_exists("./locale/$language[filename]"))
87 require_once("./locale/$language[filename]");
88 $this->language
= $language;
89 $this->options
['lang_charset'] = $cfg['charset'];
90 $this->options
['lang_dir'] = $cfg['direction'];
91 $this->options
['lang_code'] = $cfg['languagecode'];
96 echo "language file (locale/$language[filename]) could not be loaded!";
101 function fetch_userinfo($userid = -1, $verify_password = false)
105 // Get the userid if not specified
108 $userid = intval($_COOKIE[COOKIE_PREFIX
. 'userid']);
111 // Set the falseinfo stuff
117 'permissions' => $this->datastore
['usergroup'][1]['permissions'],
118 'displaytitle' => $this->datastore
['usergroup'][1]['displaytitle'],
119 'mdisplayname' => $this->datastore
['usergroup'][1]['opentag'] . '' . $this->datastore
['usergroup'][1]['closetag']
123 $userinfo = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = $userid");
124 if (is_array($userinfo))
126 $userinfo['permissions'] = (int)$this->datastore['usergroup']["$userinfo[usergroupid
]"]['permissions'];
127 $userinfo['displaytitle'] = $this->datastore['usergroup']["$userinfo[usergroupid
]"]['displaytitle'];
128 fetch_user_display_name($userinfo);
129 $userinfo['mdisplayname'] = $this->datastore['usergroup']["$userinfo[usergroupid
]"]['opentag'] . $userinfo['displayname'] . $this->datastore['usergroup']["$userinfo[usergroupid
]"]['closetag'];
130 // Verify that the cookie isn't fake
131 if ($verify_password)
133 if ($_COOKIE[COOKIE_PREFIX . 'authkey'] == $userinfo['authkey'])
139 mysetcookie(COOKIE_PREFIX . 'userid');
140 mysetcookie(COOKIE_PREFIX . 'authkey');
151 mysetcookie(COOKIE_PREFIX . 'userid');
152 mysetcookie(COOKIE_PREFIX . 'authkey');
158 $bugsys = new BugTracker();
160 // ###################################################################
161 // Initialize usergroup system
162 $_PERMISSION = array(
167 'cansubmitbugs' => 16, // 5
168 'canpostcomments' => 32,
169 'cangetattach' => 64,
170 'canputattach' => 128,
172 'caneditothers' => 512, // 10
173 'caneditinfo' => 1024,
175 'canchangestatus' => 4096,
176 'canadminpanel' => 8192,
177 'canadminbugs' => 16384, // 15
178 'canadminversions' => 32768,
179 'canadminusers' => 65536,
180 'canadmingroups' => 131072,
181 'canadmintools' => 262144,
182 'canadminfields' => 524288, // 20
183 'canbeassignedto' => 1048576
186 foreach ($_PERMISSION AS $name => $maskvalue)
188 define(strtoupper($name), $maskvalue);
191 /*=====================================================================*\
192 || ###################################################################
195 || ###################################################################
196 \*=====================================================================*/