summaryrefslogtreecommitdiffstats
path: root/usr/local/www/wizards/openvpn_wizard.inc
blob: 7ec7cfaf14b894cba34cb90905baa685ce165c0d (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
125
126
127
128
129
130
131
132
133
<?php

function step2_submitphpaction() {
	if ($_POST['authtype'] == "local") {
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3");
		exit;
	} else if ($_POST['authtype'] == "ldap") {
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1");
		exit;
	} else if ($_POST['authtype'] == "radius") {
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=2");
		exit;
	}
}

function step3_stepbeforeformdisplay() {
	global $pkg;

	$fields =& $pkg['step'][1]['fields']['field'];
	
	$authlist = auth_get_authserver_list();

	$fields[2]['options']['option'] = array();
	foreach ($authlist as $i => $auth) {
		if ($auth['type'] != "ldap")
			continue;
                $opts = array();
                $opts['name'] = $auth['name'];
                $opts['value'] = $auth['name'];
                $fields[2]['options']['option'][] = $opts;
	}
}

function step3_submitphpaction() {
	if (!$_POST['uselist'] && empty($_POST['authserv'])) {
		$message = "Please choose an authentication server or create a new one.";
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}");
		exit;
	} else if (!$_POST['uselist'] && !empty($_POST['authserv'])) {
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3");
		exit;
	}
		
	if (empty($_POST['name']) || empty($_POST['ip']) || empty($_POST['port']) ||
	    empty($_POST['transport']) || empty($_POST['scope']) || empty($_POST['authscope']) || empty($_POST['nameattr'])) {
		$message = "Please enter all information for authentication server.";
		header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=1&message={$message}");
		exit;
	}
		
}

function step4_stepbeforeformdisplay() {
        global $pkg;

        $fields =& $pkg['step'][2]['fields']['field'];

        $authlist = auth_get_authserver_list();

        $fields[2]['options']['option'] = array();
        foreach ($authlist as $i => $auth) {
                if ($auth['type'] != "radius")
                        continue;
                $opts = array();
                $opts['name'] = $auth['name'];
                $opts['value'] = $auth['name'];
                $fields[2]['options']['option'][] = $opts;
        }
}

function step4_submitphpaction() {
        if ($_POST['uselist'] == "yes" && !empty($_POST['authserv'])) {
                $message = "Please choose an authentication server or create a new one.";
                header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=2&message={$message}");
                exit;
        } else if (!$_POST['uselist'] && !empty($_POST['authserv'])) {
                header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3");
                exit;
        }

        if (empty($_POST['name']) || empty($_POST['ip']) || empty($_POST['port']) ||
            empty($_POST['passowrd'])) {
                $message = "Please enter all information for authentication server.";
                header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=2&message={$message}");
                exit;
        }

}

function step5_submitphpaction() {
        if ($_POST['uselist'] == "yes" && !empty($_POST['certca'])) {
                $message = "Please choose an certificate authority or create a new one.";
                header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3&message={$message}");
                exit;
        } else if (!$_POST['uselist'] && !empty($_POST['certca'])) {
                header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=4");
                exit;
        }

        if (empty($_POST['name']) || empty($_POST['keylength']) || empty($_POST['lifetime']) ||
	    empty($_POST['country']) || empty($_POST['state']) || empty($_POST['city']) ||
	    empty($_POST['organization']) || empty($_POST['email']) || empty($_POST['cn'])) {
                $message = "Please enter all information for the new CA authority.";
                header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=3&message={$message}");
                exit;
        }

}

function step6_submitphpaction() {
        if ($_POST['uselist'] == "yes" && !empty($_POST['cert'])) {
                $message = "Please choose an certificate or create a new one.";
                header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=4&message={$message}");
                exit;
        } else if (!$_POST['uselist'] && !empty($_POST['cert'])) {
                header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=5");
                exit;
        }

        if (empty($_POST['name']) || empty($_POST['keylength']) || empty($_POST['lifetime']) ||
            empty($_POST['country']) || empty($_POST['state']) || empty($_POST['city']) ||
            empty($_POST['organization']) || empty($_POST['email']) || empty($_POST['cn'])) {
                $message = "Please enter all information for the new certificate.";
                header("Location:wizard.php?xml=openvpn_wizard.xml&stepid=4&message={$message}");
                exit;
        }

}

function step7_submitphpaction() {

}
?>
OpenPOWER on IntegriCloud