/includes/ -> init_inc.php
1 <?php
2
3 // init_inc.php - sets up database connection
4 // init_inc.php - author: Nico Stuurman <nicost@sourceforge.net>
5 /***************************************************************************
6 * Copyright (c) 2001 by Nico Stuurman *
7 * ------------------------------------------------------------------------ *
8 * Part of phplabware, a web-driven groupware suite for research labs *
9 * *
10 * This program is free software; you can redistribute it and/or modify it *
11 * under the terms of the GNU General Public License as published by the *
12 * Free Software Foundation; either version 2 of the License, or (at your *
13 * option) any later version. *
14 \**************************************************************************/
15
16 // set php parameters here
17 set_magic_quotes_runtime(0); // seems to interfere with system settings
18
19 // register global really kills some stuff, so let's kill them first
20 if (ini_get("register_globals")) {
21 reset($HTTP_POST_VARS);
22 while (list($key,$val)=each($HTTP_POST_VARS)) {
23 unset (${$key});
24 }
25 }
26 reset($HTTP_POST_VARS);
27
28 // essential includes
29 include ('includes/config_inc.php');
30 include ('adodb/adodb.inc.php');
31 // be compatible with adodb version 1.80
32 $ADODB_FETCH_MODE=ADODB_FETCH_DEFAULT;
33
34 // Open connection to the database
35 $db = NewADOConnection ($db_type);
36 if (!@$db->Connect($db_host, $db_user, $db_pwd, $db_name)) {
37 echo "<h3 color='red'>Fatal Error</h3>";
38 echo "Could not connect to the database server.<br>";
39 echo "Please report this problem to your system administrator.";
40 exit();
41 }
42
43 // read in the database settings
44 $version=get_cell($db,"settings","version","id",1);
45 $system_settings=unserialize(get_cell($db,"settings","settings","id",1));
46 // set up temp dir for adodb
47 $ADODB_CACHE_DIR=$system_settings["tmpdir"];
48
49 $httptitle="PhpLabware: ";
50 ?>