1 |
rodolico |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
$common_cgi = '';
|
|
|
4 |
switch ($_SERVER['SERVER_NAME']) {
|
|
|
5 |
case 'zoe.dailydata.net' : mysql_connect("localhost", "dailydata", "sachemic") or die(mysql_error());
|
|
|
6 |
mysql_select_db("camp") or die(mysql_error());
|
|
|
7 |
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/home/www/common-cgi' );
|
|
|
8 |
break;
|
|
|
9 |
default : mysql_connect("localhost", "test", "test") or die(mysql_error());
|
|
|
10 |
mysql_select_db("camp") or die(mysql_error());
|
|
|
11 |
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/home/www/common-cgi' );
|
|
|
12 |
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] . '/includes' );
|
|
|
13 |
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] . '/includes/library' );
|
|
|
14 |
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/home/rodolico/Desktop/wip/common-cgi' );
|
|
|
15 |
break;
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
define(VERSION,'0.2');
|
|
|
19 |
define(BUILD_DATE,'20081104');
|
|
|
20 |
|
|
|
21 |
session_start(); // use sessions throughout
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
global $DATABASE_DEFINITION;
|
|
|
25 |
$DATABASE_DEFINITION = array(
|
|
|
26 |
'client' => array(
|
|
|
27 |
'table name' => 'client',
|
|
|
28 |
'key field' => 'client_id',
|
|
|
29 |
'display columns' => array('client_id','name'),
|
|
|
30 |
'display query' => 'select client_id,name from article',
|
|
|
31 |
'field info' => array(
|
|
|
32 |
'client_id' => array('keyfield' => 1 , 'required' => true , 'readonly' => true , 'type' => 'int' , 'width' => 10),
|
|
|
33 |
'name' => array('type' => 'string' , 'width' => 64),
|
|
|
34 |
'notes' => array('type' => 'text', 'width'=> 80 ),
|
|
|
35 |
'internal_notes' => array('type' => 'text', 'width'=> 80 ),
|
|
|
36 |
'added_date' => array('type' => 'date'),
|
|
|
37 |
'removed_date' => array('type' => 'date')
|
|
|
38 |
)
|
|
|
39 |
),
|
|
|
40 |
'site' => array(
|
|
|
41 |
'table name' => 'site',
|
|
|
42 |
'key field' => 'site_id',
|
|
|
43 |
'display columns' => array('site_id','name'),
|
|
|
44 |
'display query' => 'select site_id,name from site',
|
|
|
45 |
'field info' => array(
|
|
|
46 |
'site_id' => array('keyfield' => 1 , 'required' => true , 'readonly' => true , 'type' => 'int' , 'width' => 10),
|
|
|
47 |
'client_id' => array( 'type' => 'lookup', // this is the field type, and must be ints
|
|
|
48 |
'table' => 'client', // remote table name
|
|
|
49 |
'keyfield' => 'client_id', // keyfield in remote table, ie category.category_id
|
|
|
50 |
'display_field' => 'name' // this is the column displayed to the user
|
|
|
51 |
),
|
|
|
52 |
'name' => array('type' => 'string' , 'width' => 64),
|
|
|
53 |
'notes' => array('type' => 'text', 'width'=> 80 ),
|
|
|
54 |
'added_date' => array('type' => 'date'),
|
|
|
55 |
'removed_date' => array('type' => 'date')
|
|
|
56 |
)
|
|
|
57 |
),
|
|
|
58 |
'device' => array(
|
|
|
59 |
'table name' => 'device',
|
|
|
60 |
'key field' => 'device_id',
|
|
|
61 |
'display columns' => array('name'),
|
|
|
62 |
'display query' => 'select device_id,name from device',
|
|
|
63 |
'field info' => array(
|
|
|
64 |
'device_id' => array('keyfield' => 1 , 'required' => true , 'readonly' => true , 'type' => 'int' , 'width' => 10),
|
|
|
65 |
'name' => array('required' => true , 'default' => '' , 'type' => 'string' , 'width' => 255),
|
|
|
66 |
'part_of' => array( 'type' => 'lookup', // this is the field type, and must be ints
|
|
|
67 |
'table' => 'device', // remote table name
|
|
|
68 |
'keyfield' => 'device_id', // keyfield in remote table, ie category.category_id
|
|
|
69 |
'display_field' => 'name', // this is the column displayed to the user
|
|
|
70 |
'null_ok' => true
|
|
|
71 |
),
|
|
|
72 |
'device_type_id' => array( 'type' => 'lookup', // this is the field type, and must be ints
|
|
|
73 |
'table' => 'device_type', // remote table name
|
|
|
74 |
'keyfield' => 'device_type_id', // keyfield in remote table, ie category.category_id
|
|
|
75 |
'display_field' => 'name' // this is the column displayed to the user
|
|
|
76 |
),
|
|
|
77 |
|
|
|
78 |
'site_id' => array( 'type' => 'lookup', // this is the field type, and must be ints
|
|
|
79 |
'query' => "select site_id,concat(client.name, ' - ', site.name) from site join client on site.client_id = client.client_id order by client.name,site.name",
|
|
|
80 |
'table' => 'site', // remote table name
|
|
|
81 |
'keyfield' => 'site_id', // keyfield in remote table, ie category.category_id
|
|
|
82 |
'display_field' => 'name' // this is the column displayed to the user
|
|
|
83 |
),
|
|
|
84 |
'notes' => array('type' => 'text', 'width'=> 80 ),
|
|
|
85 |
'name' => array('required' => true , 'default' => '' , 'type' => 'string' , 'width' => 64),
|
|
|
86 |
'added_date' => array('type' => 'date'),
|
|
|
87 |
'removed_date' => array('type' => 'date')
|
|
|
88 |
),
|
|
|
89 |
'children' => array(
|
|
|
90 |
array( 'table' => 'device', 'update_field' => 'site_id','keyfield'=>'part_of' )
|
|
|
91 |
)
|
|
|
92 |
)
|
|
|
93 |
);
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
include_once('functions.php');
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
?>
|