Project

General

Profile

Download (6.03 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * system_register.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2013-2016 Electric Sheep Fencing
7
 * Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
8
 * All rights reserved.
9
 *
10
 * originally based on m0n0wall (http://m0n0.ch/wall)
11
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
 * All rights reserved.
13
 *
14
 * Licensed under the Apache License, Version 2.0 (the "License");
15
 * you may not use this file except in compliance with the License.
16
 * You may obtain a copy of the License at
17
 *
18
 * http://www.apache.org/licenses/LICENSE-2.0
19
 *
20
 * Unless required by applicable law or agreed to in writing, software
21
 * distributed under the License is distributed on an "AS IS" BASIS,
22
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
 * See the License for the specific language governing permissions and
24
 * limitations under the License.
25
 */
26

    
27
##|+PRIV
28
##|*IDENT=page-system-register
29
##|*NAME=System: Register
30
##|*DESCR=Allow access to the 'System: Register' page.
31
##|*MATCH=system_register.php*
32
##|-PRIV
33

    
34
require_once("guiconfig.inc");
35
require_once("system_register.inc");
36

    
37
include("head.inc");
38

    
39
if  (strpos($g['product_label'], 'Plus') !== false) {
40
	header("Location: /");
41
}
42

    
43
// Possible helpblock messages
44
$pgtitle = array(gettext("System"), gettext("Register"));
45

    
46
$pghelp = sprintf(gettext('Thank you for choosing %1s%2s'), $g['product_label_html'], '<br /><br />');
47

    
48
$pghelp_notrequired = gettext("Your device does not require registration, we recognize it already." .
49
   " You may have already registered, or it may be a pre-registered Netgate appliance.");
50

    
51
$pghelp_offline = gettext("The registration system is not currently available. Please check your network connection and try again.");
52

    
53
$pghelp_ok = gettext('pfSense<sup>&reg;</sup> Community Edition software may be upgraded to pfSense<sup>&reg;</sup> Plus software by purchasing an upgrade from the Netgate store here: ' .
54
'<a href="https://redirects.netgate.com/upgrade">Upgrade</a>' .
55
'<br />Once your upgrade purchase is complete, you will receive an activation token by email.' .
56
'Please paste that token into the field below, then click “Register”.' .
57
'<br /><br>Registration ensures you have access to the services included with pfSense<sup>&reg;</sup> Plus software.' .
58
'<br />If you do not receive the activation token email within a few minutes of placing the order, please contact <a href="https://go.netgate.com">Netgate TAC</a>.');
59

    
60
$pghelp_exists = sprintf(gettext("This device has already been registered. " .
61
   "If you believe that to be incorrect, please contact Netgate TAC support for assistance by visiting %1s."),
62
   '<a href="https://go.netgate.com", target="_blank">https://go.netgate.com</a>');
63

    
64
$pghelp_notready = sprintf(gettext("The registration service is not available yet. Please watch %1s, %2s, %3s,  for updates."),
65
   '<a href="https://www.netgate.com/blog/" target="_blank">our blog</a>',
66
   '<a href="https://twitter.com/NetgateUSA" target="_blank">Twitter</a>',
67
   '<a href="https://www.reddit.com/r/Netgate/" target="_blank">Reddit</a>'
68
);
69

    
70
$pghelp_success = gettext("Your firewall has been successfully registered. On your next visit to the System/Update page, select pfSense<sup>&reg;</sup> Plus software from the list of repositories.");
71

    
72
$pghelp_notfound = sprintf(gettext("This activation token is not valid. " .
73
   "Please contact Netgate TAC support for assistance by visiting %1s"), '<a href="https://go.netgate.com" target="_blank">https://go.netgate.com</a>');
74

    
75
$disabled = "disabled";
76
$activation_token = "";
77
$alert_color = 'info';
78

    
79
// On registration (POST), call the activate_plus() function to register the token and NDI with the server.
80
// Otherwise call check_plus() to determine if this device is suitable for registration.
81
// Choose from one of the above messages on return
82
if ($_POST && $_REQUEST['Submit'] == 'Register') {
83
	$activation_token = $_REQUEST['activation_token'];
84

    
85
	if ( !empty($activation_token)) {
86
		unset($input_errors);
87

    
88
		$activation_token = str_replace(' ', '', trim($activation_token));
89
		$activation_token = str_replace("\n", '', $activation_token);
90
		$activation_token = str_replace("\r", '', $activation_token);
91

    
92
		if (preg_match('/(^[A-Za-z0-9-_]*\.[A-Za-z0-9-_]*\.[A-Za-z0-9-_]*$)/', $activation_token)) {
93
			makehelp(activate_plus("register", $activation_token));
94
		} else {
95
			$input_errors[] = $activation_token . ' ' . gettext('is not a valid activation token!');
96
		}
97
	} else {
98
		$input_errors[] = gettext('An activation token must be provided.');
99
	}
100
} else {
101
	makeHelp(activate_plus("check", ""));
102
}
103

    
104

    
105

    
106
if ($input_errors) {
107
	print_input_errors($input_errors);
108
	$disabled = "";
109
}
110

    
111
print('<div class="infoblock blockopen">');
112
print_info_box($pghelp,$alert_color, false);
113
print('</div>');
114

    
115
$form = new Form(false);
116

    
117
$section = new Form_Section('Register ' . $g['product_label']);
118

    
119
$section->addInput(new Form_Textarea(
120
	'activation_token',
121
	'*Activation token',
122
	$activation_token
123
))->setAttribute($disabled, true)
124
  ->setAttribute('rows', '10')
125
  ->removeClass('form-control')
126
  ->addClass('row-fluid col-sm-8');
127

    
128
$form->add($section);
129

    
130
$form->addGlobal(new Form_Button(
131
	'Submit',
132
	'Register',
133
	null,
134
	'fa-registered'
135
))->addClass('btn-primary')->setAttribute($disabled, true);
136

    
137
print $form;
138

    
139
// Display the appropriate message, color and input activation based on the web service response
140
function makeHelp($res) {
141
	global $pghelp, $disabled, $pghelp_ok, $pghelp_offline, $alert_color;
142
	global $pghelp_notrequired, $pghelp_notready, $pghelp_success, $pghelp_notfound;
143

    
144
	switch ($res) {
145
		case "OK" :
146
			$pghelp .= $pghelp_ok;
147
			$disabled = "";
148
		break;
149

    
150
		case "FAIL" :
151
			$pghelp .= $pghelp_offline;
152
			$alert_color = 'danger';
153
		break;
154

    
155
		case "EXISTS" :
156
			$pghelp .= $pghelp_notrequired;
157
			$alert_color = 'warning';
158
		break;
159

    
160
		case "NOTREADY" :
161
			$pghelp .= $pghelp_notready;
162
			$alert_color = 'warning';
163
		break;
164

    
165
		case "REGOK" :
166
			$pghelp .= $pghelp_success;
167
			$alert_color = 'success';
168
		break;
169

    
170
		case "NOTFOUND" :
171
			$pghelp .= $pghelp_notfound;
172
			$disabled = false;
173
			$alert_color = 'danger';
174
		break;
175
	}
176
}
177

    
178
include("foot.inc");
179
?>
(203-203/228)