<?php
/*
********************************************************
Name: initHunterDB.php
Author: Rob Hunter
Date 1/3/11
Description: All the code that needs to be loaded in order to run HunterDB.
Loads up two common ground functions, but otherwise everything should be in
it's own object. Also loads the objects and various config files.
********************************************************
*/
session_start();
//includes
require_once('../lib/hdb_query.php');
require_once('../lib/hdb_content.php');
require_once('../lib/hdb_shape.php');
require_once('../lib/loginTools.php');
require_once('../lib/setupTools.php');
require_once('../config/dbConf.php');
require_once('../config/devConfig.php');
//connect to database
$link = mysql_connect($dbServer, $dbUser, $dbPass);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
if (doesTableExist($contentTable)){
//load shapes
updateShapeList();
//get user (if logged in)
getUser();
}
function updateShapeList(){
//get shapes
global $link, $dbName, $shapesTable, $shapes, $shapeObs;
mysql_select_db($dbName, $link) ;
$sql = 'SELECT * from '.$shapesTable;
$userQuery = mysql_query($sql)
or die('SELECT FAILED: '.mysql_error());
if(mysql_num_rows($userQuery) > 0){
while ($row = mysql_fetch_array( $userQuery )){
$tempShapes[$row['type']] = $row;
}
}
//clean up shapes
if (!empty($tempShapes)){
foreach ($tempShapes as $shape){
$shapes[$shape['type']] = new HDB_Shape($shape);
foreach ($shape as $key => $value){
if ((is_numeric($key)) || (empty($value))){
unset($shape[$key]);
}else{
if (substr($key, 0, 2) == 'my'){
$shape['reverse'][$value] = $key;
}
}
}
}
}
}
function getMyDataType($myAttribute){
global $numRange, $strRange, $txtRange;
//trim string if necessary
if (substr($myAttribute, 0, 2) == 'my'){
$my = substr($myAttribute, 2);
}else{
$my = $myAttribute;
}
//figure out the dataType from the Range arrays
if ( ($my >= $numRange['start']) && ($my <= $numRange['end']) ){
$dataType = 'num';
}
elseif( ($my >= $strRange['start']) && ($my <= $strRange['end']) ){
$dataType = 'str';
}
elseif( ($my >= $txtRange['start']) && ($my <= $txtRange['end']) ){
$dataType = 'text';
}
return $dataType;
}
/*
Copyright 2011 Oversee.net. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY OVERSEE.NET ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OVERSEE.NET OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of Oversee.net.
*/
?>