本文整理匯總了PHP中is_hostname函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_hostname函數的具體用法?PHP is_hostname怎麽用?PHP is_hostname使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_hostname函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: pfSenseHeader
} else {
if ($config['openvpn']['openvpn-server'][$srvid]['mode'] != "server_user" && ($usrid === false || $crtid === false)) {
pfSenseHeader("vpn_openvpn_export.php");
exit;
}
}
if ($config['openvpn']['openvpn-server'][$srvid]['mode'] == "server_user") {
$nokeys = true;
} else {
$nokeys = false;
}
$useaddr = '';
if (isset($_GET['useaddr']) && !empty($_GET['useaddr'])) {
$useaddr = trim($_GET['useaddr']);
}
if (!(is_ipaddr($useaddr) || is_hostname($useaddr) || in_array($useaddr, array("serveraddr", "servermagic", "servermagichost", "serverhostname")))) {
$input_errors[] = "You need to specify an IP or hostname.";
}
$advancedoptions = $_GET['advancedoptions'];
$openvpnmanager = $_GET['openvpnmanager'];
$verifyservercn = $_GET['verifyservercn'];
$randomlocalport = $_GET['randomlocalport'];
$usetoken = $_GET['usetoken'];
if ($usetoken && substr($act, 0, 10) == "confinline") {
$input_errors[] = "You cannot use Microsoft Certificate Storage with an Inline configuration.";
}
if ($usetoken && ($act == "conf_yealink_t28" || $act == "conf_yealink_t38g" || $act == "conf_yealink_t38g2" || $act == "conf_snom")) {
$input_errors[] = "You cannot use Microsoft Certificate Storage with a Yealink or SNOM configuration.";
}
$password = "";
if ($_GET['password']) {
示例2: gettext
$pconfig = $_POST;
/* input validation */
if ($_POST['webguiport']) {
if (!is_port($_POST['webguiport'])) {
$input_errors[] = gettext("You must specify a valid webConfigurator port number");
}
}
if ($_POST['max_procs']) {
if (!is_numericint($_POST['max_procs']) || $_POST['max_procs'] < 1 || $_POST['max_procs'] > 500) {
$input_errors[] = gettext("Max Processes must be a number 1 or greater");
}
}
if ($_POST['althostnames']) {
$althosts = explode(" ", $_POST['althostnames']);
foreach ($althosts as $ah) {
if (!is_hostname($ah)) {
$input_errors[] = sprintf(gettext("Alternate hostname %s is not a valid hostname."), htmlspecialchars($ah));
}
}
}
if ($_POST['sshport']) {
if (!is_port($_POST['sshport'])) {
$input_errors[] = gettext("You must specify a valid port number");
}
}
if ($_POST['sshdkeyonly'] == "yes") {
$config['system']['ssh']['sshdkeyonly'] = "enabled";
} else {
if (isset($config['system']['ssh']['sshdkeyonly'])) {
unset($config['system']['ssh']['sshdkeyonly']);
}
示例3: gettext
if ($_POST['pppoe_resethour'] != "" && !is_numericint($_POST['pppoe_resethour']) && $_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <= 23) {
$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
}
if ($_POST['pppoe_resetminute'] != "" && !is_numericint($_POST['pppoe_resetminute']) && $_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <= 59) {
$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
}
if ($_POST['pppoe_resetdate'] != "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
}
if ($_POST['pptp_local0'] && !is_ipaddrv4($_POST['pptp_local0'])) {
$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
}
if ($_POST['pptp_subnet0'] && !is_numeric($_POST['pptp_subnet0'])) {
$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
}
if ($_POST['pptp_remote0'] && !is_ipaddrv4($_POST['pptp_remote0']) && !is_hostname($_POST['gateway'][$iface])) {
$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
}
if ($_POST['pptp_idletimeout'] != "" && !is_numericint($_POST['pptp_idletimeout'])) {
$input_errors[] = gettext("The idle timeout value must be an integer.");
}
if ($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])) {
$input_errors[] = gettext("A valid MAC address must be specified.");
}
if ($_POST['mtu']) {
if (!is_numericint($_POST['mtu'])) {
$input_errors[] = "MTU must be an integer.";
}
if (substr($wancfg['if'], 0, 3) == 'gif') {
$min_mtu = 1280;
$max_mtu = 8192;
示例4: array
$reqdfieldsn = array(gettext("Existing Certificate Choice"));
}
$altnames = array();
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
if (isset($pconfig['altname_value']) && $pconfig['certmethod'] != "import" && $pconfig['certmethod'] != "existing") {
/* subjectAltNames */
foreach ($pconfig['altname_type'] as $altname_seq => $altname_type) {
if (!empty($pconfig['altname_value'][$altname_seq])) {
$altnames[] = array("type" => $altname_type, "value" => $pconfig['altname_value'][$altname_seq]);
}
}
/* Input validation for subjectAltNames */
foreach ($altnames as $altname) {
switch ($altname['type']) {
case "DNS":
if (!is_hostname($altname['value'])) {
$input_errors[] = gettext("DNS subjectAltName values must be valid hostnames or FQDNs");
}
break;
case "IP":
if (!is_ipaddr($altname['value'])) {
$input_errors[] = gettext("IP subjectAltName values must be valid IP Addresses");
}
break;
case "email":
if (empty($altname['value'])) {
$input_errors[] = gettext("You must provide an e-mail address for this type of subjectAltName");
}
if (preg_match("/[\\!\\#\$\\%\\^\\(\\)\\~\\?\\>\\<\\&\\/\\\\,\"\\']/", $altname['value'])) {
$input_errors[] = gettext("The e-mail provided in a subjectAltName contains invalid characters.");
}
示例5: gettext
if ($numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535)) {
$input_errors[] = gettext("Unsigned 16-bit integer type must be a number in the range 0 to 65535.");
} else {
if ($numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295)) {
$input_errors[] = gettext("Unsigned 32-bit integer type must be a number in the range 0 to 4294967295.");
} else {
if ($numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127)) {
$input_errors[] = gettext("Signed 8-bit integer type must be a number in the range -128 to 127.");
} else {
if ($numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767)) {
$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
} else {
if ($numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647)) {
$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
} else {
if ($numberoption['type'] == 'ip-address' && !is_ipaddrv4($numberoption['value']) && !is_hostname($numberoption['value'])) {
$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
}
}
}
}
}
}
}
}
}
}
}
}
if (!$input_errors) {
/* make sure the range lies within the current subnet */
示例6: trim
$_POST["address{$x}"] = trim($_POST["address{$x}"]);
if (is_alias($_POST["address{$x}"])) {
if (!alias_same_type($_POST["address{$x}"], $_POST['type'])) {
// But alias type network can include alias type urltable. Feature#1603.
if (!($_POST['type'] == 'network' && preg_match("/urltable/i", alias_get_type($_POST["address{$x}"])))) {
$wrongaliases .= " " . $_POST["address{$x}"];
}
}
} else {
if ($_POST['type'] == "port") {
if (!is_port($_POST["address{$x}"]) && !is_portrange($_POST["address{$x}"])) {
$input_errors[] = $_POST["address{$x}"] . " " . gettext("is not a valid port or alias.");
}
} else {
if ($_POST['type'] == "host" || $_POST['type'] == "network") {
if (is_subnet($_POST["address{$x}"]) || !is_ipaddr($_POST["address{$x}"]) && !is_hostname($_POST["address{$x}"]) && !is_iprange($_POST["address{$x}"])) {
$input_errors[] = sprintf(gettext('%1$s is not a valid %2$s alias.'), $_POST["address{$x}"], $_POST['type']);
}
}
}
}
if (is_iprange($_POST["address{$x}"])) {
list($startip, $endip) = explode('-', $_POST["address{$x}"]);
$rangesubnets = ip_range_to_subnet_array($startip, $endip);
$address = array_merge($address, $rangesubnets);
} else {
$tmpaddress = $_POST["address{$x}"];
if ($_POST['type'] != "host" && is_ipaddr($_POST["address{$x}"]) && $_POST["address_subnet{$x}"] != "") {
if (!is_subnet($_POST["address{$x}"] . "/" . $_POST["address_subnet{$x}"])) {
$input_errors[] = sprintf(gettext('%s/%s is not a valid subnet.'), $_POST["address{$x}"], $_POST["address_subnet{$x}"]);
} else {
示例7: gettext
$input_errors[] = gettext("A valid PPPoE reset month must be specified (1-12) in the Custom PPPoE Periodic reset fields.");
}
if ($date_nums[1] < 1 || $date_nums[1] > 31) {
$input_errors[] = gettext("A valid PPPoE reset day of month must be specified (1-31) in the Custom PPPoE Periodic reset fields. No checks are done on valid # of days per month");
}
if ($date_nums[2] < date("Y")) {
$input_errors[] = gettext("A valid PPPoE reset year must be specified. Don't select a year in the past!");
}
}
$port_data = array();
if (is_array($_POST['interfaces'])) {
foreach ($_POST['interfaces'] as $iface) {
if ($_POST['localip'][$iface] && !is_ipaddr($_POST['localip'][$iface])) {
$input_errors[] = sprintf(gettext("A valid local IP address must be specified for %s."), $iface);
}
if ($_POST['gateway'][$iface] && !is_ipaddr($_POST['gateway'][$iface]) && !is_hostname($_POST['gateway'][$iface])) {
$input_errors[] = sprintf(gettext("A valid gateway IP address OR hostname must be specified for %s."), $iface);
}
if ($_POST['bandwidth'][$iface] && !is_numericint($_POST['bandwidth'][$iface])) {
$input_errors[] = sprintf(gettext("The bandwidth value for %s must be an integer."), $iface);
}
if ($_POST['mtu'][$iface] && $_POST['mtu'][$iface] < 576) {
$input_errors[] = sprintf(gettext("The MTU for %s must be greater than 576 bytes."), $iface);
}
if ($_POST['mru'][$iface] && $_POST['mru'][$iface] < 576) {
$input_errors[] = sprintf(gettext("The MRU for %s must be greater than 576 bytes."), $iface);
}
}
// Loop through fields associated with an individual link/port and make an array of the data
$port_fields = array("localip", "gateway", "subnet", "bandwidth", "mtu", "mru", "mrru");
foreach ($_POST['interfaces'] as $iface) {
示例8: elseif
} elseif (!substr_compare('aliasdescription', $key, 0, 16)) {
$entry = substr($key, 16);
$field = 'description';
}
if (ctype_digit($entry)) {
$aliases[$entry][$field] = $value;
}
}
$pconfig['aliases']['item'] = $aliases;
/* validate aliases */
foreach ($aliases as $idx => $alias) {
$aliasreqdfields = array('aliasdomain' . $idx);
$aliasreqdfieldsn = array(gettext("Alias Domain"));
var_dump(array('fields' => $aliasreqdfields, 'names' => $aliasreqdfieldsn, 'alias' => $alias));
do_input_validation($_POST, $aliasreqdfields, $aliasreqdfieldsn, $input_errors);
if ($alias['host'] && !is_hostname($alias['host'])) {
$input_errors[] = gettext("Hostnames in alias list can only contain the characters A-Z, 0-9 and '-'.");
}
if ($alias['domain'] && !is_domain($alias['domain'])) {
$input_errors[] = gettext("A valid domain must be specified in alias list.");
}
}
/* check for overlaps */
foreach ($a_hosts as $hostent) {
if (isset($id) && $a_hosts[$id] && $a_hosts[$id] === $hostent) {
continue;
}
if ($hostent['host'] == $_POST['host'] && $hostent['domain'] == $_POST['domain'] && (is_ipaddrv4($hostent['ip']) && is_ipaddrv4($_POST['ip']) || is_ipaddrv6($hostent['ip']) && is_ipaddrv6($_POST['ip']))) {
$input_errors[] = gettext("This host/domain already exists.");
break;
}
示例9: array
##|*NAME=Diagnostics: Test Port
##|*DESCR=Allow access to the 'Diagnostics: Test Port' page.
##|*MATCH=diag_testport.php*
##|-PRIV
$allowautocomplete = true;
$pgtitle = array(gettext("Diagnostics"), gettext("Test Port"));
require "guiconfig.inc";
define('NC_TIMEOUT', 10);
if ($_POST || $_REQUEST['host']) {
unset($input_errors);
unset($do_testport);
/* input validation */
$reqdfields = explode(" ", "host port");
$reqdfieldsn = array(gettext("Host"), gettext("Port"));
do_input_validation($_REQUEST, $reqdfields, $reqdfieldsn, $input_errors);
if (!is_ipaddr($_REQUEST['host']) && !is_hostname($_REQUEST['host'])) {
$input_errors[] = gettext("Please enter a valid IP or hostname.");
}
if (!is_port($_REQUEST['port'])) {
$input_errors[] = gettext("Please enter a valid port number.");
}
if (!is_numeric($_REQUEST['srcport']) || !is_port($_REQUEST['srcport'])) {
$input_errors[] = gettext("Please enter a valid source port number, or leave the field blank.");
}
if (is_ipaddrv4($_REQUEST['host']) && $_REQUEST['ipprotocol'] == "ipv6") {
$input_errors[] = gettext("You cannot connect to an IPv4 address using IPv6.");
}
if (is_ipaddrv6($_REQUEST['host']) && $_REQUEST['ipprotocol'] == "ipv4") {
$input_errors[] = gettext("You cannot connect to an IPv6 address using IPv4.");
}
if (!$input_errors) {
示例10: gettext
if (!empty($pconfig['pppoe-reset-type'])) {
if (!empty($pconfig['pppoe_resethour']) && (!is_numericint($pconfig['pppoe_resethour']) || $pconfig['pppoe_resethour'] < 0 || $pconfig['pppoe_resethour'] > 23)) {
$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
}
if (!empty($pconfig['pppoe_resetminute']) && (!is_numericint($pconfig['pppoe_resetminute']) || $pconfig['pppoe_resetminute'] < 0 || $pconfig['pppoe_resetminute'] > 59)) {
$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
}
if (!empty($pconfig['pppoe_resetdate']) && !is_numeric(str_replace("/", "", $pconfig['pppoe_resetdate']))) {
$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
}
}
foreach ($pconfig['ports'] as $iface_idx => $iface) {
if (!empty($pconfig['localip'][$iface_idx]) && !is_ipaddr($pconfig['localip'][$iface_idx])) {
$input_errors[] = sprintf(gettext("A valid local IP address must be specified for %s."), $iface);
}
if (!empty($pconfig['gateway'][$iface_idx]) && !is_ipaddr($pconfig['gateway'][$iface_idx]) && !is_hostname($pconfig['gateway'][$iface_idx])) {
$input_errors[] = sprintf(gettext("A valid gateway IP address OR hostname must be specified for %s."), $iface);
}
if (!empty($pconfig['bandwidth'][$iface_idx]) && !is_numericint($pconfig['bandwidth'][$iface_idx])) {
$input_errors[] = sprintf(gettext("The bandwidth value for %s must be an integer."), $iface);
}
if (!empty($pconfig['mtu'][$iface_idx]) && $pconfig['mtu'][$iface_idx] < 576) {
$input_errors[] = sprintf(gettext("The MTU for %s must be greater than 576 bytes."), $iface);
}
if (!empty($pconfig['mru'][$iface_idx]) && $pconfig['mru'][$iface_idx] < 576) {
$input_errors[] = sprintf(gettext("The MRU for %s must be greater than 576 bytes."), $iface);
}
}
if (count($input_errors) == 0) {
$ppp = array();
$ppp['ptpid'] = $pconfig['ptpid'];
示例11: redirectHeader
redirectHeader("vpn_openvpn_export.php");
exit;
}
if ($config['openvpn']['openvpn-server'][$srvid]['mode'] == "server_user") {
$nokeys = true;
} else {
$nokeys = false;
}
$useaddr = '';
if (isset($_GET['useaddr']) && !empty($_GET['useaddr'])) {
$useaddr = trim($_GET['useaddr']);
}
if (!(is_ipaddr($useaddr) || is_hostname($useaddr) ||
in_array($useaddr, array("serveraddr", "servermagic", "servermagichost", "serverhostname")))) {
$input_errors[] = "You need to specify an IP or hostname.";
}
$advancedoptions = $_GET['advancedoptions'];
$openvpnmanager = $_GET['openvpnmanager'];
$verifyservercn = $_GET['verifyservercn'];
$randomlocalport = $_GET['randomlocalport'];
$usetoken = $_GET['usetoken'];
if ($usetoken && (substr($act, 0, 10) == "confinline")) {
$input_errors[] = "You cannot use Microsoft Certificate Storage with an Inline configuration.";
}
if ($usetoken && (($act == "conf_yealink_t28") || ($act == "conf_yealink_t38g") || ($act == "conf_yealink_t38g2") || ($act == "conf_snom"))) {
$input_errors[] = "You cannot use Microsoft Certificate Storage with a Yealink or SNOM configuration.";
示例12: array
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// set form defaults
$pconfig = array();
$pconfig['ipprotocol'] = 'ipv4';
$pconfig['host'] = null;
$pconfig['port'] = null;
$pconfig['showtext'] = null;
$pconfig['sourceip'] = null;
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pconfig = $_POST;
$input_errors = array();
/* input validation */
$reqdfields = explode(" ", "host port");
$reqdfieldsn = array(gettext("Host"), gettext("Port"));
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
if (!is_ipaddr($pconfig['host']) && !is_hostname($pconfig['host'])) {
$input_errors[] = gettext("Please enter a valid IP or hostname.");
}
if (!is_port($pconfig['port'])) {
$input_errors[] = gettext("Please enter a valid port number.");
}
if ($pconfig['srcport'] != "" && (!is_numeric($pconfig['srcport']) || !is_port($pconfig['srcport']))) {
$input_errors[] = gettext("Please enter a valid source port number, or leave the field blank.");
}
if (is_ipaddrv4($pconfig['host']) && $pconfig['ipprotocol'] == "ipv6") {
$input_errors[] = gettext("You cannot connect to an IPv4 address using IPv6.");
}
if (is_ipaddrv6($pconfig['host']) && $pconfig['ipprotocol'] == "ipv4") {
$input_errors[] = gettext("You cannot connect to an IPv6 address using IPv4.");
}
if (count($input_errors) == 0) {
示例13: elseif
} else {
}
} else {
}
}
}
$subnet = $config['interfaces']['lan']['ipaddr'] . "/" . $config['interfaces']['lan']['subnet'];
if (is_ipaddr($_POST['ipadress'])) {
if (false == ($cnif = ip_in_subnet($_POST['ipadress'], $subnet))) {
$input_errors[] = "Value \"IP address\" is not belongs to the subnet LAN";
goto out;
} else {
}
}
} elseif (empty($_POST['macaddr']) && empty($_POST['ipadress']) && !empty($_POST['hostname'])) {
if (FALSE == is_hostname($_POST['hostname'])) {
$input_errors[] = "Wrong Host name.";
goto out;
} else {
$pconfig['leasetime'] = "60";
$nas4frehosts =& $config['system']['hosts'];
if (false !== ($cnin = array_search_ex($_POST['hostname'], $nas4frehosts, "name"))) {
$warning_mess = "Host defined on <a href=system_hosts.php>/etc/hosts</a>";
} else {
if ($_POST['hostname'] == $config['system']['hostname']) {
$input_errors[] = "You can not define main host as DHCP client";
goto out;
} else {
$warning_mess = "Host NOT defined on <a href=system_hosts.php>/etc/hosts</a>, please define it";
}
}
示例14: gettext
if ($_POST["address{$x}"] != "") {
if (is_alias($_POST["address{$x}"])) {
if (!alias_same_type($_POST["address{$x}"], $_POST['type'])) {
// But alias type network can include alias type urltable. Feature#1603.
if (!($_POST['type'] == 'network' && alias_get_type($_POST["address{$x}"]) == 'urltable')) {
$wrongaliases .= " " . $_POST["address{$x}"];
}
}
} else {
if ($_POST['type'] == "port") {
if (!is_port($_POST["address{$x}"])) {
$input_errors[] = $_POST["address{$x}"] . " " . gettext("is not a valid port or alias.");
}
} else {
if ($_POST['type'] == "host" || $_POST['type'] == "network") {
if (!is_ipaddr($_POST["address{$x}"]) && !is_hostname($_POST["address{$x}"]) && !is_iprange($_POST["address{$x}"])) {
$input_errors[] = sprintf(gettext('%1$s is not a valid %2$s alias.'), $_POST["address{$x}"], $_POST['type']);
}
}
}
}
if (is_iprange($_POST["address{$x}"])) {
list($startip, $endip) = explode('-', $_POST["address{$x}"]);
$rangesubnets = ip_range_to_subnet_array($startip, $endip);
$address = array_merge($address, $rangesubnets);
} else {
$tmpaddress = $_POST["address{$x}"];
if (is_ipaddr($_POST["address{$x}"]) && $_POST["address_subnet{$x}"] != "") {
$tmpaddress .= "/" . $_POST["address_subnet{$x}"];
}
$address[] = $tmpaddress;
示例15: elseif
} elseif (!substr_compare('altname_value', $key, 0, 13)) {
$entry = substr($key, 13);
$field = 'value';
}
if (ctype_digit($entry)) {
$entry++;
// Pre-bootstrap code is one-indexed, but the bootstrap code is 0-indexed
$altnames[$entry][$field] = $value;
}
}
$pconfig['altnames']['item'] = $altnames;
/* Input validation for subjectAltNames */
foreach ($altnames as $idx => $altname) {
switch ($altname['type']) {
case "DNS":
if (!is_hostname($altname['value'], true)) {
array_push($input_errors, "DNS subjectAltName values must be valid hostnames, FQDNs or wildcard domains.");
}
break;
case "IP":
if (!is_ipaddr($altname['value'])) {
array_push($input_errors, "IP subjectAltName values must be valid IP Addresses");
}
break;
case "email":
if (empty($altname['value'])) {
array_push($input_errors, "You must provide an e-mail address for this type of subjectAltName");
}
if (preg_match("/[\\!\\#\$\\%\\^\\(\\)\\~\\?\\>\\<\\&\\/\\\\,\"\\']/", $altname['value'])) {
array_push($input_errors, "The e-mail provided in a subjectAltName contains invalid characters.");
}