summaryrefslogtreecommitdiffstats
path: root/frontends/php/setup.php
blob: 5e2b40424a962f5e4049a6dd27b7ec31d2d3bd2a (plain)
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
<?php
/* 
** ZABBIX
** Copyright (C) 2000-2005 SIA Zabbix
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
?>
<?php
	require_once "include/config.inc.php";
	require_once "include/setup.inc.php";

        $page["title"] = "S_INSTALLATION";
        $page["file"] = "setup.php";

	define('ZBX_PAGE_NO_MENU', false);

?>
<?php
	$fields=array(
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION

		"agree"=>	array(T_ZBX_STR, O_OPT,	null,	null,			null),
		"distributed"=>	array(T_ZBX_STR, O_OPT,	null,	null,			null),
		"trouble"=>	array(T_ZBX_STR, O_OPT,	null,	null,			null),

		"type"=>	array(T_ZBX_STR, O_OPT,	null,	IN('"MYSQL","POSTGRESQL","ORACLE"'),	null),
		"server"=>	array(T_ZBX_STR, O_OPT,	null,	NOT_EMPTY,		null),
		"database"=>	array(T_ZBX_STR, O_OPT,	null,	NOT_EMPTY,		null),
		"user"=>	array(T_ZBX_STR, O_OPT,	null,	NOT_EMPTY,		null),
		"password"=>	array(T_ZBX_STR, O_OPT,	null,	null, 			null),
		
		"nodename"=>	array(T_ZBX_STR, O_OPT,	null,	NOT_EMPTY,		null),
		"nodeid"=>	array(T_ZBX_INT, O_OPT,	null,	BETWEEN(0,999),		null),
/* actions */
		"save_config"=>		array(T_ZBX_STR, O_OPT, P_SYS|P_ACT,	NULL,	NULL),
		"retry"=>		array(T_ZBX_STR, O_OPT, P_SYS|P_ACT,	NULL,	NULL),
		"cancel"=>		array(T_ZBX_STR, O_OPT, P_SYS|P_ACT,	NULL,	NULL),
		"finish"=>		array(T_ZBX_STR, O_OPT, P_SYS|P_ACT,	NULL,	NULL),
		"next"=>		array(T_ZBX_STR, O_OPT, P_SYS|P_ACT,	NULL,	NULL),
		"back"=>		array(T_ZBX_STR, O_OPT, P_SYS|P_ACT,	NULL,	NULL),
/* other */
		"form"=>		array(T_ZBX_STR, O_OPT, P_SYS,	NULL,	NULL),
		"form_refresh"=>	array(T_ZBX_INT, O_OPT,	NULL,	NULL,	NULL)
	);

	check_fields($fields, false);
?>
<?php
	global $ZBX_CONFIG, $_COOKIE;

	$ZBX_CONFIG = array();

	if(isset($_REQUEST['cancel']) || isset($_REQUEST['finish']))
	{
		setcookie('ZBX_CONFIG', null, time()-3600);
		unset($_COOKIE['ZBX_CONFIG']);
		Redirect('index.php');
	}
	
	if(isset($_COOKIE['ZBX_CONFIG']))
	{
		$ZBX_CONFIG = unserialize($_COOKIE['ZBX_CONFIG']);
	}

	if(!isset($ZBX_CONFIG['step'])) $ZBX_CONFIG['step'] = 0;
	if(!isset($ZBX_CONFIG['agree'])) $ZBX_CONFIG['agree'] = false;

	$ZBX_CONFIG['allowed_db'] = array();
	/* MYSQL */	if(zbx_is_callable(array('mysql_pconnect', 'mysql_select_db', 'mysql_error', 'mysql_select_db',
		'mysql_query', 'mysql_fetch_array', 'mysql_fetch_row', 'mysql_data_seek','mysql_insert_id'
		)))
	{
		$ZBX_CONFIG['allowed_db']['MYSQL'] = 'MySQL';
	}
	/* POSTGRESQL */if(zbx_is_callable(array('pg_pconnect', 'pg_fetch_array', 'pg_fetch_row', 'pg_exec', 'pg_getlastoid')))
	{
		$ZBX_CONFIG['allowed_db']['POSTGRESQL'] = 'PostgreSQL';
	}
	/* ORACLE */	if(zbx_is_callable(array('ocilogon', 'ocierror', 'ociparse', 'ociexecute', 'ocifetchinto')))
	{
		$ZBX_CONFIG['allowed_db']['ORACLE'] = 'Oracle';
	}
	if(count($ZBX_CONFIG['allowed_db']) == 0)
	{
		$ZBX_CONFIG['allowed_db']['no'] = array('No');
	}

?>
<?php

	$wizard = new CSetupWizard($ZBX_CONFIG);

	setcookie('ZBX_CONFIG', serialize($ZBX_CONFIG), time()+3600);

include_once "include/page_header.php";

	insert_showhint_javascript();

	echo BR;
	$wizard->Show();

	//SDI($ZBX_CONFIG);

	global $_POST;
	unset($_POST);
?>
<?php

include_once "include/page_footer.php"

?>