punbb/include/dblayer/common_db.php
author Dan
Thu, 12 Jul 2007 01:04:01 -0400
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
permissions -rw-r--r--
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     1
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     2
/***********************************************************************
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     3
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     5
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     7
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    12
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    17
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    22
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    23
************************************************************************/
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    24
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    25
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    26
// Make sure no one attempts to run this script "directly"
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    27
if (!defined('PUN'))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    28
	exit;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    29
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    30
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    31
//
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    32
// Return current timestamp (with microseconds) as a float (used in dblayer)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    33
//
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    34
if (defined('PUN_SHOW_QUERIES'))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    35
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    36
	function get_microtime()
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    37
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
		list($usec, $sec) = explode(' ', microtime());
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
		return ((float)$usec + (float)$sec);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
// Load the appropriate DB layer class
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
switch ($db_type)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
	case 'mysql':
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
		require PUN_ROOT.'include/dblayer/mysql.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
		break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    50
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
	case 'mysqli':
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    52
		require PUN_ROOT.'include/dblayer/mysqli.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
		break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
	case 'pgsql':
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
		require PUN_ROOT.'include/dblayer/pgsql.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
		break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
	case 'sqlite':
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
		require PUN_ROOT.'include/dblayer/sqlite.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
		break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
	default:
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
		error('\''.$db_type.'\' is not a valid database type. Please check settings in config.php.', __FILE__, __LINE__);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
		break;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
// Create the database adapter object (and open/connect to/select db)
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    70
$pun_db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect);