1 |
rodolico |
1 |
<?php
|
20 |
rodolico |
2 |
include_once( 'DatabaseDefinition.php' );
|
1 |
rodolico |
3 |
global $LOGFILE;
|
|
|
4 |
$LOGFILE='/tmp/camp.log';
|
|
|
5 |
define( 'VERSION', '2.0b' );
|
|
|
6 |
define( 'BUILD_DATE', '20130527');
|
|
|
7 |
|
|
|
8 |
function insertValuesIntoQuery( $query, $values ) {
|
|
|
9 |
foreach ( $values as $name => $value ) {
|
|
|
10 |
$query = search_replace_string($query, "<$name>", $value );
|
|
|
11 |
}
|
|
|
12 |
return $query;
|
|
|
13 |
}
|
|
|
14 |
|
|
|
15 |
function search_replace_string($string, $searchFor, $replaceWith ) {
|
|
|
16 |
$string = str_replace ( $searchFor, $replaceWith, $string );
|
|
|
17 |
return $string;
|
|
|
18 |
}
|
20 |
rodolico |
19 |
|
|
|
20 |
function killSession() {
|
|
|
21 |
// http://php.net/manual/en/function.session-destroy.php
|
|
|
22 |
// Initialize the session.
|
|
|
23 |
// If you are using session_name("something"), don't forget it now!
|
|
|
24 |
if ( ! isset( $_SESSION[ 'app directories' ] ) )
|
|
|
25 |
session_start();
|
|
|
26 |
|
|
|
27 |
// Unset all of the session variables.
|
|
|
28 |
$_SESSION = array();
|
|
|
29 |
|
|
|
30 |
//session_destroy();
|
|
|
31 |
|
|
|
32 |
// If it's desired to kill the session, also delete the session cookie.
|
|
|
33 |
// Note: This will destroy the session, and not just the session data!
|
|
|
34 |
if (ini_get("session.use_cookies")) {
|
|
|
35 |
$params = session_get_cookie_params();
|
|
|
36 |
setcookie(session_name(), '', time() - 42000,
|
|
|
37 |
$params["path"], $params["domain"],
|
|
|
38 |
$params["secure"], $params["httponly"]
|
|
|
39 |
);
|
|
|
40 |
}
|
22 |
rodolico |
41 |
}
|
|
|
42 |
|
|
|
43 |
function setupSession() {
|
|
|
44 |
// first, build the Database Definition and load it into session variable
|
|
|
45 |
include_once( 'DatabaseDefinition.php' );
|
|
|
46 |
global $DATABASE_DEFINITION;
|
|
|
47 |
require_once( 'DBQuery.class.php' );
|
|
|
48 |
$results = new DBQuery( "select theValue from _system where group_name = 'modules' and key_name = 'Database Definition'" );
|
|
|
49 |
if ( $results->run() ) {
|
|
|
50 |
foreach ( $results->parameters['returnData'] as $key => $value ) {
|
|
|
51 |
$value = $_SESSION[ 'app directories' ]['file system'][ 'app root' ] . "/$value";
|
|
|
52 |
if ( is_file( $value ) )
|
|
|
53 |
include_once( $value );
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
include_once('DatabaseDefinition.local.php');
|
20 |
rodolico |
57 |
|
22 |
rodolico |
58 |
$_SESSION['Database Definition'] = $DATABASE_DEFINITION;
|
|
|
59 |
|
|
|
60 |
// now, load the menu into $SESSION so we don't have to reload it each time
|
|
|
61 |
include_once("DBMenu.class.php");
|
|
|
62 |
$menu = new DBMenu( '_menu', '_menu_id' );
|
|
|
63 |
$_SESSION['Menu'] = $menu->DBMenu2String( $_SESSION[ 'app directories' ]['url system'][ 'app root' ] . '/' );
|
|
|
64 |
}
|
1 |
rodolico |
65 |
|
22 |
rodolico |
66 |
function doSearch( $searchString ) {
|
|
|
67 |
$sql = "select
|
|
|
68 |
client.name 'Client',
|
|
|
69 |
site.name 'Site',
|
|
|
70 |
device_type.name 'Type',
|
|
|
71 |
device.name 'Device',
|
|
|
72 |
parent.name 'PartOf'
|
|
|
73 |
from
|
|
|
74 |
device
|
|
|
75 |
join device_type using (device_type_id)
|
|
|
76 |
join site_device using (device_id)
|
|
|
77 |
join site using (site_id)
|
|
|
78 |
join client_device using (device_id)
|
|
|
79 |
join client using (client_id)
|
|
|
80 |
left outer join
|
|
|
81 |
(
|
|
|
82 |
select
|
|
|
83 |
device_device.device_id,
|
|
|
84 |
parent.device_id 'ParentID',
|
|
|
85 |
parent.name
|
|
|
86 |
from
|
|
|
87 |
device_device
|
|
|
88 |
join device parent on ( device_device.parent_id=parent.device_id )
|
|
|
89 |
) parent on (parent.device_id=device.device_id)
|
|
|
90 |
where
|
|
|
91 |
device.removed_date is null
|
|
|
92 |
and client.removed_date is null
|
|
|
93 |
and site.removed_date is null
|
|
|
94 |
and client_device.removed_date is null
|
|
|
95 |
and site_device.removed_date is null
|
|
|
96 |
order by
|
|
|
97 |
client.name,
|
|
|
98 |
site.name,
|
|
|
99 |
device_type.name,
|
|
|
100 |
device.name";
|
|
|
101 |
|
|
|
102 |
return array( 'Search Results' );
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
1 |
rodolico |
107 |
?>
|