root/dev/common/includes/db.php @ 382

Revision 382, 1.9 KB (checked in by kovell, 13 years ago)

Admin setting clarifications, autoupgrade uses existing kill settings.

Line 
1<?php
2// cached query class will be loaded additionally once we received the config
3// see common/index.php for details
4require_once('common/includes/class.db.php');
5require_once('common/includes/class.config.php');
6
7if(DB_TYPE == 'mysqli' and function_exists('mysqli_connect')) define('DB_TYPE_USED', 'mysqli');
8if(DB_TYPE_USED == 'mysqli') require_once('common/includes/class.db.mysqli.php');
9
10// get mysql server info and store it in a define so we know if its
11// safe to use subquerys or not. (mysqli only works on 4.1+)
12if(DB_TYPE == 'mysqli') define('KB_MYSQL41', true);
13else
14{
15        $conn = new DBConnection;
16        $value = (float) mysql_get_server_info($conn->id_);
17        if ($value > 4.1)
18        {
19                define('KB_MYSQL41', true);
20        }
21        else
22        {
23                define('KB_MYSQL41', false);
24        }
25}
26
27if(!$config) $config = new Config(KB_SITE);
28define('DB_HALTONERROR', (bool)config::get('cfg_sqlhalt'));
29define('DB_USE_QCACHE', (bool)config::get('cfg_qcache'));
30
31if (((bool)config::get('cfg_memcache')) == true && !strstr($_SERVER['REQUEST_URI'], "admin"))
32{
33    // mysqli version already loaded
34    if(DB_TYPE_USED != 'mysqli') require_once('common/includes/class.db_memcache.php');
35    $mc = new Memcache();
36    if(!@$mc->pconnect(config::get('cfg_memcache_server'), config::get('cfg_memcache_port'))) {
37       print "ERROR: Unable to connect to memcached server, disabling memcached. Please check your settings (server, port) and make sure the memcached server is running";
38       define("DB_USE_MEMCACHE", false);
39    } else {
40       define("DB_USE_MEMCACHE", true);
41    }
42} else {
43    define("DB_USE_MEMCACHE", false);
44}
45
46// mysqli version already loaded
47if (DB_USE_QCACHE && DB_TYPE_USED != 'mysqli')
48{
49    // the object overloading system will switch to cached queries now
50    require_once('common/includes/class.db_cache.php');
51}
52if (!$dir = config::get('cache_dir'))
53{
54    $dir = 'cache/data';
55}
56define('KB_CACHEDIR', $dir);
57
58?>
Note: See TracBrowser for help on using the browser.