<?php
/**
* (c) 2000, 2001, 2002 Remistech Sdn Bhd. All Rights Reserved.
*  Developed by John Lim
*  Licensed to Natsoft (M) Sdn Bhd to distribute and support. Refer to LICENSE document.
*/
srand((integer)microtime());
define('PHPLENSAPPLET',1);
define('PHPLENSGRIDBUILDER',2);
$PHPLENSGRIDBUILDER = 2;

@include_once("../builder-config.inc.php");


include_once(dirname(__FILE__).'/lib.php');
if (!defined('PHPLENS_DIR'))  define('PHPLENS_DIR','../..');
include_once(PHPLENS_DIR."/phplens.inc.php");


if (!defined('PHPLENS_MENU_COLOR')) {
	define('PHPLENS_MENU_COLOR','#FF9933');
	define('PHPLENS_MENUFONT_COLOR','white');
	define('PHPLENS_BKGD_COLOR','white');
	define('PHPLENS_SIDE_COLOR','#FFFFCC');
	define('PHPLENS_MENU2_COLOR','#FFCC99');
}
//===============================================================================

start_sessions();

$ADODB_COUNTRECS = false;

// for 4.1.0 compat with track_globals off
$lens_qb_id = &$HTTP_SESSION_VARS['lens_qb_id'];
$lens_qb_drivername = &$HTTP_SESSION_VARS['lens_qb_drivername'];
$lens_qb_driver = &$HTTP_SESSION_VARS['lens_qb_driver'];
$lens_qb_database = &$HTTP_SESSION_VARS['lens_qb_database'];
$lens_qb_user = &$HTTP_SESSION_VARS['lens_qb_user'];
$lens_qb_pwd = &$HTTP_SESSION_VARS['lens_qb_pwd'];

/* 
# sample
$PHPLENS_DATABASES = 
array(			//driver, server, userid, pwd, database
	'logos' => array('odbc','logos','','',''),
	'logos2' => array('odbc','logos2','','',''),
	'nwind' => array('access','nwind','','',''),
	'mysqlnwind' => array('mysql','192.168.0.1','root','','northwind')
);
*/
if (empty($PHPLENS_DATABASES)) {
	die("You must define the array PHPLENS_DATABASES to use the Grid Builder");
}
if (isset($HTTP_GET_VARS['driver'])) {
	$lens_qb_drivername = $HTTP_GET_VARS['driver'];
}
if (empty($lens_qb_drivername) || empty($PHPLENS_DATABASES[$lens_qb_drivername])) {
	$lens_qb_arr = reset($PHPLENS_DATABASES);
	$lens_qb_drivername = key($PHPLENS_DATABASES);
} else
	$lens_qb_arr = $PHPLENS_DATABASES[$lens_qb_drivername];
	
$lens_qb_driver = $lens_qb_arr[0];
$lens_qb_server =  $lens_qb_arr[1];
$lens_qb_user =  @$lens_qb_arr[2];
$lens_qb_pwd =  @$lens_qb_arr[3];
$lens_qb_database =  @$lens_qb_arr[4];
		
if (empty($lens_qb_id)) {
	$lens_qb_id = lens_qb_gen_id();
}

#putenv('ORACLE_HOME=/u01/app/oracle/product/8.1.7');
$gDB = NewADOConnection($lens_qb_driver);
if (!$gDB->Connect($lens_qb_server,$lens_qb_user,$lens_qb_pwd,$lens_qb_database)) {
	$lens_qb_drivername='';
}
?>