Projekt

Allgemein

Profil

GX-Abgewiesen #47507 » xtc_db_connect.inc.php

Till Tepelmann, 15.07.2016 10:11

 
1
<?php
2
/* --------------------------------------------------------------
3
  xtc_db_connect.inc.php 2016-03-07
4
  Gambio GmbH
5
  http://www.gambio.de
6
  Copyright (c) 2016 Gambio GmbH
7
  Released under the GNU General Public License (Version 2)
8
  [http://www.gnu.org/licenses/gpl-2.0.html]
9
  --------------------------------------------------------------
10

    
11

    
12
  based on:
13
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
14
  (c) 2002-2003 osCommerce(database.php,v 1.19 2003/03/22); www.oscommerce.com
15
  (c) 2003	 nextcommerce (xtc_db_connect.inc.php,v 1.3 2003/08/13); www.nextcommerce.org
16
  (c) 2003 XT-Commerce - community made shopping http://www.xt-commerce.com ($Id: xtc_db_connect.inc.php 1248 2005-09-27 10:27:23Z gwinger $)
17

    
18
  Released under the GNU General Public License
19
  --------------------------------------------------------------------------------------- */
20

    
21
function xtc_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
22
	global $$link;
23

    
24
		$t_db_port = ini_get("mysqli.default_port");
25
		$t_db_socket = ini_get("mysqli.default_socket");
26

    
27
			if(strstr($server,':'))
28
			{
29
				$server = explode(':', $server);
30
				if(is_numeric($server[1]))
31
				{
32
					$t_db_port = $server[1];
33
				}
34
				else
35
				{
36
					$t_db_socket = $server[1];
37
				}
38
				$server = $server[0];
39
			}
40

    
41
			// Port and Socket variables must not be an empty string (refs #41773). 
42
			if($t_db_port == '')
43
			{
44
				$t_db_port = null;
45
			}
46

    
47
			if($t_db_socket == '')
48
			{
49
				$t_db_socket = null;
50
			}
51
	
52
	if (USE_PCONNECT == 'true') {
53
		$$link = ($GLOBALS["___mysqli_ston"] = mysqli_connect($server,  $username,  $password, $database, $t_db_port, $t_db_socket));
54
	} else {
55
		$$link = ($GLOBALS["___mysqli_ston"] = mysqli_connect($server,  $username,  $password, $database, $t_db_port, $t_db_socket));
56
	}
57

    
58
	if ($$link) {
59
		$t_mysql_version = @((is_null($___mysqli_res = mysqli_get_server_info($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
60
		if (!empty($t_mysql_version) && version_compare($t_mysql_version, '5', '>=')) @mysqli_query( $$link, "SET SESSION sql_mode=''");
61

    
62
		@mysqli_query( $$link, "SET SQL_BIG_SELECTS=1");
63

    
64
		((bool)mysqli_select_db($$link, $database));
65

    
66
		if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
67
			mysqli_set_charset($$link, 'utf8');
68
		} else {
69
			mysqli_query( $$link, "SET NAMES utf8");
70
		}
71
	}
72

    
73
	return $$link;
74
}
    (1-1/1)