root/dev/common/includes/db.php

Revision 431, 2.3 KB (checked in by kovell, 13 years ago)

portraits are fetched from CCP using cURL and lower timeouts. mysqli-based boards use only one connection, eveapi reverted to standard 3.3

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