LONTE SHELL EDITION


Dashboard -*- SHOW INFO -*- HASH identify -*- Config -*- Jumping

You Are Here : /var/www/virtual/tvarditsa.org/classes/
Upload File :
Current File : /var/www/virtual/tvarditsa.org/classes/adodb.class.php

<?php
/**
 * VSite Framework for PHP
 * 
 * This product includes PHP, freely available from 
 * <{@link http://www.php.net/ http://www.php.net/}>
 * 
 * @package VSite_Framework
 * @subpackage DataBase
 * @copyright Copyright (c) 2003, Valentin Sheiretsky
 * @license http://www.vsite.org/license.txt BSD-style license
 */

if (!defined("_ADODB_CLASS_")) {
/**
 * @ignore
 */
define("_ADODB_CLASS_", 1);
/**
 * Force Nulls
 */
define("ADODB_FORCE_NULLS", 1);

$this_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
if (!defined("_VSITECONF_CLASS_")) {
	include ($this_dir . 'vsiteconf.class.php');
}
require ($this_dir . 'adodb/adodb.inc.php');

$c = new VsiteConf();
$cfg = $c->read_conf ('adodb');

if (
	!isset($cfg['driver']) ||
	!is_file($this_dir . 'adodb/drivers/adodb-' . $cfg['driver'] . '.inc.php')
) {
	$cfg['driver'] = 'mysql';
}

include($this_dir . 'adodb/drivers/adodb-' . $cfg['driver'] . '.inc.php');

$GLOBALS['ADODB_DRIVER'] = $cfg['driver'];
$GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_ASSOC;
$GLOBALS['ADODB_FORCE_TYPE'] = ADODB_FORCE_VALUE;

eval ("class ADODB_vsiteauto extends ADODB_" . $GLOBALS['ADODB_DRIVER'] . " { } ");
/**
 * ADODB auto connection class with accounting
 *
 * @version 2.0.13
 * @author Valentin Sheiretsky <valio@vsite.org>
 * @package VSite_Framework
 */
class ADODB extends ADODB_vsiteauto {

	/**#@+
	 * @access private
	 */
	var $_cfg = null;
	var $_cfg_ADODB = array (
		'host'			=> 'localhost',
		'user'			=> 'root',
		'password'		=> '',
		'database'		=> '',
		'language'		=> 'en',
		'cache'			=> 0,
		'magic_quotes'	=> 'auto',
	);
	var $_query_counter = 0;
	var $_magic_quotes_gpc = false;
	/**#@-*/

	/**
	 * Constructor
	 */
	function __construct($cfname = 'adodb') {
		$c = new VsiteConf();
		$this->_cfg = $c->join_conf ($this->_cfg, $this->_cfg_ADODB);
		$this->_cfg = $c->read_conf ($cfname, $this->_cfg);
		
		$GLOBALS['ADODB_CONNECT']	= $this->_cfg['host'];
		$GLOBALS['ADODB_USER']		= $this->_cfg['user'];
		$GLOBALS['ADODB_PWD']		= $this->_cfg['password'];
		$GLOBALS['ADODB_DB']		= $this->_cfg['database'];
		$GLOBALS['ADODB_LANG']		= $this->_cfg['language'];
		
		$this->Connect(
			$this->_cfg['host'],
			$this->_cfg['user'],
			$this->_cfg['password'],
			$this->_cfg['database']
		);
		
		if (isset($this->_cfg['cache']))
			$this->cacheSecs = (int)$this->_cfg['cache'];
		
		if (!isset($GLOBALS['adodb_class_query_counter']))
			$GLOBALS['adodb_class_query_counter'] = 0;
		
		if ($this->_cfg['magic_quotes'] == 'auto')
			$this->_magic_quotes_gpc = get_magic_quotes_gpc();
		else
			$this->_magic_quotes_gpc = (boolean)$this->_cfg['magic_quotes'];
	}

	/**
	 * @ignore
	 */
	function ADODB ($cfname = 'adodb') {
		$this->__construct($cfname);
	}

	/**
	 * Execute SQL Query
	 */
	function Execute ($sql) {
		GLOBAL $adodb_class_query_counter;
		$adodb_class_query_counter++;
		$this->_query_counter++;
		return parent::Execute($sql);
	}

	/**
	 * Escape Query String
	 */
	function qstr($s, $mqgpc = null) {
		if ($mqgpc == null)
			return parent::qstr($s, $this->_magic_quotes_gpc);
		return parent::qstr($s, $mqgpc);
	}

	/**
	 * Return Query counters (global and local)
	 */
	function get_query_counter () {
		return array(
			'global' => $GLOBALS['adodb_class_query_counter'],
			'local' => $this->_query_counter
		);
	}

	/**
	 * Destructor
	 */
	function __destruct() {
		return $this->Close(); // Close active connection
	}
}

} // END ADODB_CLASS
?>