Rev 22 | Rev 36 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<?php
include_once( 'DatabaseDefinition.php' );
global $LOGFILE;
$LOGFILE='/tmp/camp.log';
define( 'VERSION', '2.0b' );
define( 'BUILD_DATE', '20130527');
function insertValuesIntoQuery( $query, $values ) {
foreach ( $values as $name => $value ) {
$query = search_replace_string($query, "<$name>", $value );
}
return $query;
}
function search_replace_string($string, $searchFor, $replaceWith ) {
$string = str_replace ( $searchFor, $replaceWith, $string );
return $string;
}
function killSession() {
// http://php.net/manual/en/function.session-destroy.php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
if ( ! isset( $_SESSION[ 'app directories' ] ) )
session_start();
// Unset all of the session variables.
$_SESSION = array();
//session_destroy();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
}
function setupSession() {
// first, build the Database Definition and load it into session variable
include_once( 'DatabaseDefinition.php' );
global $DATABASE_DEFINITION;
require_once( 'DBQuery.class.php' );
$results = new DBQuery( "select theValue from _system where group_name = 'modules' and key_name = 'Database Definition'" );
if ( $results->run() ) {
foreach ( $results->parameters['returnData'] as $key => $value ) {
$value = $_SESSION[ 'app directories' ]['file system'][ 'app root' ] . "/$value";
if ( is_file( $value ) )
include_once( $value );
}
}
include_once('DatabaseDefinition.local.php');
$_SESSION['Database Definition'] = $DATABASE_DEFINITION;
// now, load the menu into $SESSION so we don't have to reload it each time
include_once("DBMenu.class.php");
$menu = new DBMenu( '_menu', '_menu_id' );
$_SESSION['Menu'] = $menu->DBMenu2String( $_SESSION[ 'app directories' ]['url system'][ 'app root' ] . '/' );
}
function doSearch( $searchString ) {
$sql = "select
client.name 'Client',
site.name 'Site',
device_type.name 'Type',
device.name 'Device',
parent.name 'PartOf'
from
device
join device_type using (device_type_id)
join site_device using (device_id)
join site using (site_id)
join client_device using (device_id)
join client using (client_id)
left outer join
(
select
device_device.device_id,
parent.device_id 'ParentID',
parent.name
from
device_device
join device parent on ( device_device.parent_id=parent.device_id )
) parent on (parent.device_id=device.device_id)
where
device.removed_date is null
and client.removed_date is null
and site.removed_date is null
and client_device.removed_date is null
and site_device.removed_date is null
order by
client.name,
site.name,
device_type.name,
device.name";
return array( 'Search Results' );
}
?>