Project

General

Profile

« Previous | Next » 

Revision 618e43ca

Added by Jim Pingle about 15 years ago

Do some more strict validation on hostname, domain, and DNS servers. Ticket #464

View differences:

usr/local/www/wizards/setup_wizard.xml
59 59
			<type>input</type>
60 60
			<bindstofield>system->hostname</bindstofield>
61 61
			<description>EXAMPLE: myserver</description>
62
			<validate>^[a-z0-9.|-]+$</validate>
63
			<message>Invalid Hostname</message>
62 64
		</field>
63 65
		<field>
64 66
			<name>Domain</name>
......
75 77
			<!-- we must unset the fields because this is an array. -->
76 78
			<unsetfield>yes</unsetfield>
77 79
			<arraynum>0</arraynum>
80
			<validate>^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$</validate>
81
			<message>Primary DNS Server field is invalid</message>
78 82
		</field>
79 83
		<field>
80 84
			<name>Secondary DNS Server</name>
81 85
			<type>input</type>
82 86
			<bindstofield>system->dnsserver</bindstofield>
83 87
			<arraynum>1</arraynum>
88
			<validate>^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$</validate>
89
			<message>Secondary DNS Server field is invalid</message>
84 90
		</field>
85 91
		<field>
86 92
			<name>Override DNS</name>
......
93 99
			<type>submit</type>
94 100
		</field>
95 101
	</fields>
102
	<stepsubmitphpaction>
103
		<![CDATA[
104
		if(empty($_POST['hostname']) || !is_hostname($_POST['hostname'])) {
105
			print_info_box_np("Hostname is invalid. Please press back in your browser window and correct.");
106
			die;
107
		}
108
		if(empty($_POST['domain']) || !is_domain($_POST['domain'])) {
109
			print_info_box_np("Domain is invalid. Please press back in your browser window and correct.");
110
			die;
111
		}
112
		if(!empty($_POST['primarydnsserver']) && !is_ipaddr($_POST['primarydnsserver'])) {
113
			print_info_box_np("Primary DNS server is invalid. Please press back in your browser window and correct.");
114
			die;
115
		}
116
		if(!empty($_POST['secondarydnsserver']) && !is_ipaddr($_POST['secondarydnsserver'])) {
117
			print_info_box_np("Second DNS server is invalid. Please press back in your browser window and correct.");
118
			die;
119
		}
120
		]]>
121
	</stepsubmitphpaction>
96 122
</step>
97 123
<step>
98 124
	<id>3</id>

Also available in: Unified diff