/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
<?php
    error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
    date_default_timezone_set("UTC");

    $SETUP_MULTI_MODE = true;
    
    $ADEI_RELEASE = true;

    $TITLE = "ADEI";

        // INNODB is required for replication, MyISAM in other case especially on the systems with low IOPS
        // MyISAM tables are significantly smaller and less disk intensive
        // Compression with Katrin dataset give 35% of data savings, but results 50-70% performance degradation
        // There is more CPU usage, but systems are not bound by CPU, so reason is not completely clear
    $ADEI_CACHE_ENGINE = "MYISAM";		// "INNODB"
    $ADEI_TRANSACTION_SIZE = 0;	                // 0 to disable
    $ADEI_CONTINUOUS_TRANSACTION = true;        // required unless we have a perfectly tuned configuration
    $ADEI_CACHE_COMPRESSION = "None";		// "zlib"

        // This does not help much to performance and may create problems under some circumstances. Don't turn on.
    $ADEI_DELAYED_KEYS = false;			

    $ADEI_CACHE_SCHEDULER = false;
    $ADEI_CONTINUOUS_CACHING = false;
    $ADEI_DEFAULT_MODE = false;
    $DEFAULT_MODULE = "wiki";

    $MODULES = array(/*"slowcontrol", "alarms",*/ "infopage", "graph", "download", "wiki");
    $POPUPS = array("source", "controls");

    $CONTROLS = array("infotab", "searchtab", "virtual", false, "export", "aggregator", "plot"); // false/null indicates line break
    
    $ADEI_SRCTREE_EXTRA = array();
    $ADEI_INFO_MODULES = array(
        "legend" => array(
            'title' => _("Channel Overview"),
            'handler' => "CHANNELView",
            'opts' => array()
        ),
        "scatter" => array(
            'title' => _("Scatter Plot"),
            'handler' => "SCATTERView",
            'opts' => array()
        ),
        "spectrum" => array(
            'title' => _("Spectrum"),
            'handler' => "spectrumview",
            'opts' => array()
        ),
        "histogram" => array(
            'title' => _("Histogram"),
            'handler' => "histogramview",
            'opts' => array(
		'bins' => array(0, 5, 10, 20, 50)
            )
        ),
    );


	/* more specific configs should go after less specific ones */
    $OPTIONS = array (
	"default" => array( 
	    "min_resolution" => 600, 		// in db config could be array by id
//	    "cache_config" => $ADEI_CACHE	// alter default cache timing configuration
	    "ignore_subseconds" => true,	// Timestamps with second precision
	    "omit_raw_cache" => false,		// Use data source instead of cache0 tables
	    "fill_raw_first" => false,		// Fill RAW cache table completely prior to processing agregating cache tables
	    "optimize_empty_cache" => false,	// Do not fill lower resolution cache intervals if encompassing one is empty
	    "use_cache_timewindow" => true,	// Shrink time window to currently cached data
	    "use_cache_reader" => false,	// Do not access data source while reading cache
	    "overcome_reader_faults" => false,	// Use CACHE if connection to reader is failed
	    "optimize_time_axes" => false,	// Limit window size by available data
	    "use_md5_postfix" => false,		// Use md5 for table name postfixes
	    "null_value" => 0,			// The numeric value to use instead of NULL (missing data) when needed
	    "disable_caching" => false,		// The CACHE should not be generated, Item for RT display only
	    "channel_uids" => false,		// If channels have unique identifactors within ADEI setup
	    "private_axes" => false,            // The READER has his own set of axes which shall not be mixed with global ones
	)
    );
    

    $ADEI_DB = array (
	"host" => "localhost",
	"port" => 0,
	"database" => "adei",
	"user" => "adei",
	"password" => "adei"
    );
    
/*
    The TSQLFile support in ROOT is not mature enough    
    $ROOT_DB = array (
	"driver" => "mysql",
	"host" => "localhost",
	"port" => 0,
	"user" => "zeus",
	"password" => "zeus"
    );
*/
    
    $BACKUP_DB = array (
	"driver" => "mysql",
	"host" => "localhost",
	"port" => 0,
	"user" => "zeus",
	"password" => "zeus"
    );

    $ADEI_TIMINGS = array (
	_("1 Year") => 31536000,
	_("1 Month") => 2592000,
	_("1 Week") => 604800,
	_("1 Day") => 86400,
	_("6 Hours") => 21600,
	_("1 Hour") => 3600,
	_("15 Min") => 900,
	_("5 Min") => 300
    );
    
    
    $ADEI_CACHE = array (
	array("min" => 31536000, "res" => 43200), /* year - 12 hour data, 730 points min */
	array("min" => 2592000, "res" => 3600), /* month - 1 hour data, 720 - 8760 data points */
	array("min" => 604800, "res" => 600), /* week - 10 min data, 1008 - 4320 data points */
	array("min" => 86400, "res" => 60), /* day - 1 min data, 1440 - 10080 data points */
	array("min" => 7200, "res" => 10), /* 2 hours - 10 s, 720 - 8640 data points */
	/* 1 - 7200 data points */
    );
    
    
    $ADEI_VIRTUAL_READERS = array(
/*	"virtual_vg" => array(
	    "title" => _("User Groups"),
	    "reader"=> "VGReader"
	),*/
	"virtual" => array(
	    "title" => _("Virtual"),
	    "reader" => "VIRTUALReader"
	)
    );

    $ADEI_AXES = array(
/*	"0" => array(
	),*/
	"countrate" => array(
	    "axis_name" => _("Count Rate"),
	    "axis_units" => false,
	    "axis_mode" => "STD",
	    "axis_range" => false
	),    
	"percent" => array(
	    "axis_name" => false,
	    "axis_units" => _("%"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),    
	"temperature" => array(
	    "axis_units" => _("C"),
	    "axis_name" => _("Temperature"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"temperature/kelvin" => array(
	    "axis_units" => _("K"),
	    "axis_name" => _("Temperature"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"voltage" => array(
	    "axis_units" => _("V"),
	    "axis_name" => _("Voltage"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"voltage/kilo" => array(
	    "axis_units" => _("kV"),
	    "axis_name" => _("Voltage"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"current" => array(
	    "axis_units" => _("A"),
	    "axis_name" => _("Current"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"current/micro" => array(
	    "axis_units" => _("uA"),
	    "axis_name" => _("Current"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"current/nano" => array(
	    "axis_units" => _("nA"),
	    "axis_name" => _("Current"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"resistance" => array(
	    "axis_units" => _("Ohm"),
	    "axis_name" => _("Resistance"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	), 
	"pressure" => array(
	    "axis_units" => _("bar"),
	    "axis_name" => _("Pressure"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"pressure/psi" => array(
	    "axis_units" => _("psi"),
	    "axis_name" => _("Pressure"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"pressure/milli" => array(
	    "axis_units" => _("millibar"),
	    "axis_name" => _("Pressure"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"pressure/hpa" => array(
	    "axis_units" => _("hPa"),
	    "axis_name" => _("Pressure"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"mass" => array(
	    "axis_units" => _("kg"),
	    "axis_name" => _("Mass"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"rpm" => array(
	    "axis_units" => _("rpm"),
	    "axis_name" => _("RPM"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"volume-flow" => array(
	    "axis_units" => _("m3/s"),
	    "axis_name" => _("Flow"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"mass-flow" => array(
	    "axis_units" => _("g/s"),
	    "axis_name" => _("Mass-flow"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"power" => array(
	    "axis_units" => _("W"),
	    "axis_name" => _("Power"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	),
	"magnetic_field" => array(
	    "axis_units" => _("T"),
	    "axis_name" => _("Magnetic field"),
	    "axis_mode" => "STD",
	    "axis_range" => false
	)
    );

    $DEFAULT_MISSING_VALUE = NULL;	/* Value to use instead of NULL values */

    $EXPORT_DEFAULT_FORMAT = "csv";
    
    /* Joiner/Filter: Joiner is a filter supporting multiple groups. From the
    software point of view there is no difference and both are implemented 
    using the same base class. It is possible to have arbitrary sequence of
    enclosed filters/joiners within format configuration.
    Only joiner or filter should be specified on the one level, if both
    are specified the filter will be used.
    
	@PROP@ 			- replaced by passed value
	?{@PROP@?@PROP@:nothing}

      Default:
	@TMPFILE@
	@BLOCK_TITLE@
	@EXPECTED_BLOCKS@
	@BLOCK_NUMBER@


	@ROOT__COMBHIST@	
    */
    
    $ADEI_SYSTEM_FORMATS = array (
	"labview32" => array(
	    'title' => "LabVIEW array",
	    'handler' => "LABVIEW",
	    'hidden' => true,
	    'type' => "streamarray"
	)
    );
    
    $EXPORT_FORMATS = array (
	"csv" => array(
	    'title' => "CSV",
	    'accept_null_values' => true
	),
     	"image" => array(
    	    'title' => "PNG Image",
            'handler' => 'Image',
 	    'type' => 'image'
     	),
	"xls" => array(
	    'title' => "Excel",
	    'handler' => "EXCEL",
//	    subsec_format => "DD.MM.YYYY hh:mm:ss.000;@"
//	    subsec_format => "text()" /* Use text (CSV) */
//	    subsec_format => "text(format)" /* Use text (format) */
//	    subsec_format => "DD.MM.YYYY hh:mm:ss.000000;@" /* HP, OpenOffice */
//	    subsec_width => 26
//	    date_format => "DD.MM.YYYY hh:mm:ss"
//	    date_width => 20
//	    value_format => "0.0000E+##"
//	    value_width => 12
/*	    filter => array (
		"type" => "ZIP"
	    )*/
        ),
/*
	"nc" => array(
	    'title' => "netCDF4",
	    'filter' => array (
		'app' => "csv2netcdf",
		'opts' => "--file @TMPFILE@ ?{@BLOCK_NUMBER@===0?--overwrite} ?{@EXPECTED_BLOCKS@!=1?--group @BLOCK_TITLE@}",
		'joiner' => true,
		'groupmode' => true,	// Run filter app for each group
	        'extension' => "nc"
	    )
	),
	"root" => array(
	    'title' => "ROOT",
	    'filter' => array (
		'app' => "csv2root",
		'opts' => "--file @TMPFILE@ ?{@BLOCK_NUMBER@===0?--overwrite} ?{@EXPECTED_BLOCKS@!=1?--group @BLOCK_TITLE@}",
		'joiner' => true,
		'groupmode' => true,	// Run filter app for each group
	        'extension' => "root"
	    )
	),
	"root_hist" => array(
	    'title' => "ROOT+Hist",
	    'filter' => array(
		'app' => "csv2root",
		'opts' => "--file @TMPFILE@ ?{@BLOCK_NUMBER@===0?--overwrite} ?{@EXPECTED_BLOCKS@!=1?--group @BLOCK_TITLE@} --save-histograms ?{@ROOT__COMBHIST@?--combined-histogram}",
		'joiner' => true,
		'groupmode' => true,	// Run filter app for each block
		'extension' => "root"
	    )
	),*/
	"tdms" => array(
	    'title' => "TDMS",
	    'handler' => "LABVIEW",
	)
    );
    
    $EXPORT_SAMPLING_RATES = array (
	_("Hourly") => 3600,
	_("Minutely") => 60,
	_("1 Hz") => 1,
	_("1000 Hz") => 0.001
    );
    
    $SEARCH_ENGINES = array (
	"ITEMSearch" => array(),
	"INTERVALSearch" => array(),
	"PROXYSearch" => array()
    );
    
    
    $ADEI_ID_DELIMITER = "__";
    
    $LOGGER_LOG_REQUESTS = false;	/* Log all ADEI requests */
    $LOGGER_LOG_OUTPUT = false;		/* Log output of ADEI requests */
    $LOGGER_STORE_OBJECTS = false;	/* Will produce big, but very detailed logs */

/* This forces MySQL to use INDEXes while SELECT queries returning huge 
rowsets are executed. After certain threshold, MySQL optimizator stops
using INDEXes what bringing to huge slowdown. This option is intended
to fix this behaviour. */
    
    $MYSQL_FORCE_INDEXES = true;	
    
    $CACHE_PRECISE_GAPS = false;	/* Enables more precise maxgap calculation in DATAInterval */
    
    $AJAX_UPDATE_RATE = 60; 		/* in seconds */
    $AJAX_WINDOW_BORDER = 10; 		/* in pixels */
    $AJAX_PARSE_DELAY = 100; 		/* html, in milliseconds */

    $SOURCE_KEEP_WINDOW = false;	/* Preserve time range when group is changed */
    

    $DHTMLX_SKIN = "standard";
//    $DHTMLX_SKIN="dhx_blue";
    $DHTMLX_ICONSET = "csh_bluefolders";
    $MENU_SHOW_ITEMS = false;		/* Show separate items in popup menu */
    $MENU_SCROLL_LIMIT = 10;		/* Add scrolling if more than that items present */
    
    $PHP_BINARY = "/usr/bin/php";
    $DOWNLOAD_DECAY_TIME = 72000;       /*  Time after unused download is removed from server*/
  
    $JPGRAPH_PATH = "/usr/share/php5/jpgraph";
    $EXCEL_WRITER_PATH ="";
    $TMP_PATH=$ADEI_ROOTDIR . "tmp";

    $ADEI_ROOT_STORAGE = "$ADEI_ROOTDIR/storage/";
    
    $ADEI_APP_PATH = array (
	"default" => "/usr/bin/"
    );
    
    $CSV_SEPARATOR = ",";
    $CSV_DATE_FORMAT = "d-M-y H:i:s";
    $EXCEL_DATE_FORMAT = "DD.MM.YYYY hh:mm:ss";
    $EXCEL_SUBSEC_FORMAT = "DD.MM.YYYY hh:mm:ss.000;@"; /* 
	    Unfortunately Excel doesn't support more than 3 digits,
	    OpenOffice does */
    $ROOT_COMBIHIST_LIMIT = 604800; /* No more, than 1 week */


    $STATUS_DEFAULT_DURATION = 2000;	/* in milliseconds */


    $GRAPH_DEFAULT_HEIGHT = 768; /* in pixels */
    $GRAPH_DEFAULT_WIDTH = 1024; /* in pixels */
    $GRAPH_MAX_AXES = 6;
/* Maximal number of points (all plots) on Graph, this allows us to produce 
rough multiplots to sustain high update rate (most of resources are used to 
graph->Stroke()) */
    $GRAPH_MAX_POINTS_PER_GRAPH = 5000;
/* Maximal approximation interval (in pixels). I.e. maximal distance between
to approximation points. This option have a priority over MAX_POINTS_PER_GRAPH
option. */
    $GRAPH_MAX_APPROXIMATION_INTERVAL = 10; /* in pixels */

    $GRAPH_AUTOAGGREGATION_MINMAX_THRESHOLD = 10; /* in precision, approx. px/2 */

    $GRAPH_INTERPOLATE_DATA_GAPS = false; /* Do not indicate missing data */

/* Maximal distance between currently CACHEd data and the data available in the
data source, measured in seconds. 0 means - unlimited */
    $GRAPH_MAX_CACHE_GAP = 0;

    
    $GRAPH_ZOOM_RATIO = 2.;	// This coeficent defines product of division of original window by zoomed window
    $GRAPH_DEEPZOOM_AREA = 10;	// In pixels (actual interval is 2x)
    $GRAPH_STEP_RATIO = 5.;	// This coeficent defines product of division of original window by step
    $GRAPH_EDGE_RATIO = 6;	// Product of division of while window by edge size

    $GRAPH_DELTA_SIZE = 10; /* delta neighborhood size, in pixels */
    $GRAPH_MARGINS = array (
	"left" => 0,
	"top" => 20,
	"right" => 20,
	"bottom" => 30,
	"axis" => 80
    );
    $GRAPH_SELECTION = array (
	"min_width" => 20,
	"min_height" => 20
    );


    $GRAPH_LINE_WEIGHT = 2;
/* Enables approximation point marks starting with accuracy greater than the
specified number of pixels. 0 - to disable. Significatly degradate performance
if used */
    $GRAPH_ACCURACY_MARKS_OUTSET = 14;
    $GRAPH_ACCURACY_MARKS_MULTIOUTSET = 49;
    $GRAPH_ACCURACY_MARKS_IF_GAPS = false;	// Force if data gaps are found
    $GRAPH_ACCURACY_MARKS_COLOR = "blue";
#   $GRAPH_ACCURACY_MARKS_TYPE = MARK_FILLEDCIRCLE;
    $GRAPH_ACCURACY_MARKS_SIZE = 3;
    
/* Display a bar on top of the graph, indicating the density of the data. The
four modes are supported:
    SHOW_NONE: do not show
    SHOW_EMPTY: show only if missing (due to inavalability of the data) points 
    are available on the graph
    SHOW_POINTS: Indicate all set points on the graph (somehow duplicates 
    'GRAPH_ACCURACY_MARKS' functionality, but displayed even if precision is 
    high and GRAP_ACCURACY_MARKS are disable by OUTSET
    SHOW_GAPS: Will display information on data gaps. Even if point placed on
    the graph, but there is less data than expected, all such points will be
    indicated on the bar 
*/

    $GRAPH_INDICATE_DATA_DENSITY = 'SHOW_NONE';
//    $GRAPH_INDICATE_DATA_DENSITY = SHOW_POINTS;//SHOW_GAPS;

    $GRAPH_DENSITY_PLOT_INVALID_SIZE = 3;
    $GRAPH_DENSITY_PLOT_INVALID_COLOR = 'red';

    $GRAPH_DENSITY_PLOT_VALID_SIZE = 0;
    $GRAPH_DENSITY_PLOT_VALID_COLOR = 'green';
    
    $GRAPH_DENSITY_POINTS_TYPE = 'MARK_FILLEDCIRCLE';
    $GRAPH_DENSITY_POINTS_SIZE = 1;
    $GRAPH_DENSITY_POINTS_COLOR = 'green';
    $GRAPH_DENSITY_POINTS_OUTLINE = 'black';
    
    $GRAPH_FAST_LEGEND = false;		// Inpricese in rapidly changing data    

    $GRAPH_LOWPRECISION_UPDATE_RATE = 10800; // How often we should update low precision graphs
    
    $GRAPH_SUBSECOND_THRESHOLD = 5;	/* in seconds, for shorter intervals the subsecond handling is performed */

/* This option defines a plot colors (used sequently), comment out to use black
only */
    $GRAPH_COLORS =  array("black", "blue", "orange", "brown",
	    "#90EE90", "#ADD8E6", "#FFC0CB", "#A020F0", "#1E90FF");

    $AXES_COLORS = array(
	array("black"),
	array("blue"),
	array("#f800e9"),
	array("green"),
	array("yellow")
    );
/*
    $GRAPH_COLORS =  array("black", "#483D8B","#2F4F4F","#00CED1","#9400D3","#FF1493","#00BFFF","#696969","#1E90FF","#D19275","#B22222","#FFFAF0","#228B22","#FF00FF","#DCDCDC",
	    "#808080","#008000","#ADFF2F","#F0FFF0","#FF69B4","#CD5C5C","#4B0082","#FFFFF0","#F0E68C","#E6E6FA","#FFF0F5","#7CFC00","#FFFACD","#ADD8E6",
	    "#D3D3D3","#90EE90","#FFB6C1","#FFA07A","#20B2AA","#87CEFA","#8470FF","#778899","#B0C4DE","#FFFFE0","#00FF00","#32CD32","#FAF0E6","#FF00FF",
	    "#BA55D3","#9370D8","#3CB371","#7B68EE","#00FA9A","#48D1CC","#C71585","#191970","#F5FFFA","#FFE4E1","#FFE4B5","#FFDEAD","#000080","#FDF5E6",
	    "#FF4500","#DA70D6","#EEE8AA","#98FB98","#AFEEEE","#D87093","#FFEFD5","#FFDAB9","#CD853F","#FFC0CB","#DDA0DD","#B0E0E6","#800080","#FF0000",
	    "#FA8072","#F4A460","#2E8B57","#FFF5EE","#A0522D","#C0C0C0","#87CEEB","#6A5ACD","#708090","#FFFAFA","#00FF7F","#4682B4","#D2B48C","#008080");
*/

    if ($ADEI_SETUP)
        $SAVED_ADEI_SETUP = $ADEI_SETUP;
    else
        $SAVED_ADEI_SETUP = false;
        
    if (getenv("ADEI_SETUP")) {
        require("config.env.php");
    }
    if (file_exists("config.actual.php")) {
        require("config.actual.php");
    } else {
	$ADEI_SETUP = "all";
    }
    
    if ($SAVED_ADEI_SETUP)
        $ADEI_SETUP = $SAVED_ADEI_SETUP;


    if ($SETUP_MULTI_MODE) {
	if ($_GET['setup']) {
	    $ADEI_SETUP = $_GET['setup'];
	    unset($_GET['setup']);
	} else {
	    $params = sizeof($_SERVER['argv']);
    	    if ($params>1) {
		$pos = array_search("-setup", $_SERVER['argv']);
		if (($pos)&&(($pos + 1) < $params)) $ADEI_SETUP =  $_SERVER['argv'][$pos + 1];
		else $SETUP_MULTI_MODE = 0;
	    } else $SETUP_MULTI_MODE = 0;
	}
    }

    $ADEI_SETUP_STRING = $ADEI_SETUP;
    
    if (!isset($ADEI_SETUP_ARGS)) {
	$ADEI_SETUP_ARGS = array();
	
	if (preg_match("/^([^\/]+)\/(.*)$/",$ADEI_SETUP, $m)) {
	    $ADEI_SETUP = $m[1];
	    $ADEI_SETUP_ARGS['subset'] = $m[2];
		// we can also parse key:value pairs instead if ':' are in
	}
    }

    $SETUP_CONFIG = "setups/$ADEI_SETUP/config.php";
    $SETUP_CSS = "setups/$ADEI_SETUP/config.css";
    $LEGACY_SETUP_CSS = "setups/$ADEI_SETUP/$ADEI_SETUP.css";
    
    if (!file_exists("config.php")) {
        $curdir = getcwd();
	if (preg_match("/(services|admin|system|test)$/", $curdir)) chdir("..");
	if (!file_exists("config.php")) {
	    if (preg_match("/tmp\/admin$/", $curdir)) chdir("..");
	}
    }
    
    if (file_exists($SETUP_CONFIG)) require($SETUP_CONFIG);
    
    if (file_exists("config.override.php")) require("config.override.php");

	// The option should be unset in setup if subsetting is handled inside
    if (isset($ADEI_SETUP_ARGS['subset'])) {
	$subset = $ADEI_SETUP_ARGS['subset'];
	foreach (array_keys($READER_DB) as $key) {
	    if (!preg_match("/^{$subset}([_\-\\/]|$)/", $key))
		unset($READER_DB[$key]);
	}
    }

    if ($ADEI_CACHE_ENGINE != "INNODB") {
	$ADEI_CACHE_COMPRESSION = "None";
	$ADEI_TRANSACTION_SIZE = false;
    }

?>