inc/dns.inc.php
author rejo
Fri, 16 May 2008 10:43:57 +0000
changeset 167 0b992665ac4d
parent 164 4c6adb48dcfd
child 173 6d0e4e6bedad
permissions -rw-r--r--
[feladat @ 273] Renamed error ERR_DNS_MX_NS_TO_CNAME to more generic ERR_DNS_NON_ALIAS_TARGET. See also r270.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
     1
<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 97
diff changeset
     3
/*  Poweradmin, a friendly web-based admin tool for PowerDNS.
47
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 16
diff changeset
    21
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    22
function validate_input($zid, $type, &$content, &$name, &$prio, &$ttl) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    23
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    24
	$zone = get_zone_name_from_id($zid);				// TODO check for return
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    26
	if (!(preg_match("/$zone$/i", $name))) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    27
		if (isset($name) && $name != "") {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    28
			$name = $name . "." . $zone;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
    29
		} else {
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    30
			$name = $zone;
97
090be08858db [feladat @ 197]
rejo
parents: 96
diff changeset
    31
		}
96
35cd9e082b90 [feladat @ 196]
rejo
parents: 95
diff changeset
    32
	}
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    33
	
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    34
	switch ($type) {
96
35cd9e082b90 [feladat @ 196]
rejo
parents: 95
diff changeset
    35
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    36
		case "A":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    37
			if (!is_valid_ipv4($content)) return false;
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    38
			if (!is_valid_hostname_fqdn($name,1)) return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    39
			break;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    40
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    41
		case "AAAA":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    42
			if (!is_valid_ipv6($content)) return false;
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    43
			if (!is_valid_hostname_fqdn($name,1)) return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    44
			break;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    46
		case "CNAME":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    47
			if (!is_valid_rr_cname_name($name)) return false;
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    48
			if (!is_valid_hostname_fqdn($name,1)) return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    49
			if (!is_valid_hostname_fqdn($content,0)) return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    50
			break;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    52
		case "HINFO":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    53
			if (!is_valid_rr_hinfo_content($content)) return false;
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    54
			if (!is_valid_hostname_fqdn($name,1)) return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    55
			break;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    56
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    57
		case "MX":
158
30a7f897aaf0 [feladat @ 264]
rejo
parents: 148
diff changeset
    58
			if (!is_valid_hostname_fqdn($content,0)) return false;
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    59
			if (!is_valid_hostname_fqdn($name,1)) return false;
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    60
			if (!is_valid_non_alias_target($content)) return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    61
			break;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    62
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    63
		case "NS":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    64
			if (!is_valid_hostname_fqdn($content,0)) return false;
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    65
			if (!is_valid_hostname_fqdn($name,1)) return false;
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    66
			if (!is_valid_non_alias_target($content)) return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    67
			break;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    68
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    69
		case "PTR":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    70
			if (!is_valid_hostname_fqdn($content,0)) return false;
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    71
			if (!is_valid_hostname_fqdn($name,1)) return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    72
			break;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    73
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    74
		case "SOA":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    75
			if (!is_valid_rr_soa_name($name,$zone)) return false;
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    76
			if (!is_valid_hostname_fqdn($name,1)) return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    77
			if (!is_valid_rr_soa_content($content)) return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    78
			break;
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    79
		
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    80
		case "SRV":
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    81
			if (!is_valid_rr_srv_name($name)) return false;
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    82
			if (!is_valid_rr_srv_content($content)) return false;
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    83
			break;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    85
		case "TXT":
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    86
			if (!is_valid_printable($name)) return false;
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
    87
			if (!is_valid_printable($content)) return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    88
			break;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    89
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    90
		case "MBOXFW":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    91
		case "NAPTR":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    92
		case "URL":
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    93
			// These types are supported by PowerDNS, but there is not
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    94
			// yet code for validation. Validation needs to be added 
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    95
			// for these types. One Day Real Soon Now. [tm]
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    96
			break;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    97
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    98
		default:
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
    99
			error(ERR_DNS_RR_TYPE);
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   100
			return false;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   103
	if (!is_valid_rr_prio($prio,$type)) return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   104
	if (!is_valid_rr_ttl($ttl)) return false;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
	return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   109
function is_valid_hostname_fqdn($hostname, $wildcard) {
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   111
	global $dns_strict_tld_check;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   112
	global $valid_tlds;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   113
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   114
	$hostname = ereg_replace("\.$","",$hostname);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   115
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   116
	if (strlen($hostname) > 255) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   117
		error(ERR_DNS_HN_TOO_LONG);
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   118
		return false;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   119
	}
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   120
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   121
        $hostname_labels = explode ('.', $hostname);
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   122
        $label_count = count($hostname_labels);
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   123
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   124
	foreach ($hostname_labels as $hostname_label) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   125
		if ($wildcard == 1 && !isset($first)) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   126
			if (!preg_match('/^(\*|[\w-\/]+)$/',$hostname_label)) { error(ERR_DNS_HN_INV_CHARS); return false; }
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   127
			$first = 1;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   128
		} else {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   129
			if (!preg_match('/^[\w-\/]+$/',$hostname_label)) { error(ERR_DNS_HN_INV_CHARS); return false; }
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   130
		}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   131
		if (substr($hostname_label, 0, 1) == "-") { error(ERR_DNS_HN_DASH); return false; }
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   132
		if (substr($hostname_label, -1, 1) == "-") { error(ERR_DNS_HN_DASH); return false; }
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   133
		if (strlen($hostname_label) < 1 || strlen($hostname_label) > 63) { error(ERR_DNS_HN_LENGTH); return false; }
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   134
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   135
	
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   136
	if ($hostname_labels[$label_count-1] == "arpa" && (substr_count($hostname_labels[0], "/") == 1 XOR substr_count($hostname_labels[1], "/") == 1)) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   137
		if (substr_count($hostname_labels[0], "/") == 1) { 
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   138
			$array = explode ("/", $hostname_labels[0]);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   139
		} else {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   140
			$array = explode ("/", $hostname_labels[1]);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   141
		}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   142
		if (count($array) != 2) { error(ERR_DNS_HOSTNAME) ; return false; }
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   143
		if (!is_numeric($array[0]) || $array[0] < 0 || $array[0] > 255) { error(ERR_DNS_HOSTNAME) ; return false; }
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   144
		if (!is_numeric($array[1]) || $array[1] < 25 || $array[1] > 31) { error(ERR_DNS_HOSTNAME) ; return false; }
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   145
	} else {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   146
		if (substr_count($hostname, "/") > 0) { error(ERR_DNS_HN_SLASH) ; return false; }
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   147
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   148
	
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   149
	if ($dns_strict_tld_check == "1" && !in_array($hostname_labels[$label_count-1], $valid_tlds)) {
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   150
		error(ERR_DNS_INV_TLD); return false;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   151
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   152
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   153
	return true;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   154
}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   155
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   156
function is_valid_ipv4($ipv4) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   157
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   158
// 20080424/RZ: The current code may be replaced by the following if() 
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   159
// statement, but it will raise the required PHP version to ">= 5.2.0". 
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   160
// Not sure if we want that now.
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   161
//
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   162
//	if(filter_var($ipv4, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   163
//		error(ERR_DNS_IPV4); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   164
//	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   165
162
e109f389316c [feladat @ 268]
rejo
parents: 158
diff changeset
   166
	if (!preg_match("/^[0-9\.]{7,15}$/", $ipv4)) {
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   167
		error(ERR_DNS_IPV4); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   168
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   169
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   170
	$quads = explode('.', $ipv4);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   171
	$numquads = count($quads);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   172
	
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   173
	if ($numquads != 4) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   174
		error(ERR_DNS_IPV4); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   175
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   176
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   177
	for ($i = 0; $i < 4; $i++) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   178
		if ($quads[$i] > 255) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   179
			error(ERR_DNS_IPV4); return false;
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   180
		}
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   181
	}
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   182
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   183
	return true;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   184
}
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   185
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   186
function is_valid_ipv6($ipv6) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   187
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   188
// 20080424/RZ: The current code may be replaced by the following if() 
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   189
// statement, but it will raise the required PHP version to ">= 5.2.0". 
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   190
// Not sure if we want that now.
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   191
//
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   192
//	if(filter_var($ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   193
//		error(ERR_DNS_IPV6); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   194
//	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   195
162
e109f389316c [feladat @ 268]
rejo
parents: 158
diff changeset
   196
	if (!preg_match("/^[0-9a-f]{0,4}:([0-9a-f]{0,4}:){0,6}[0-9a-f]{0,4}$/i", $ipv6)) {
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   197
		error(ERR_DNS_IPV6); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   198
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   199
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   200
	$quads = explode(':', $ipv6);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   201
	$numquads = count ($quads);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   202
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   203
	if ($numquads > 8 || $numquads < 3) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   204
		error(ERR_DNS_IPV6); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   205
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   206
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   207
	$emptyquads = 0;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   208
	for ($i = 1; $i < $numquads-1; $i++) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   209
		if ($quads[$i] == "") $emptyquads++;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   210
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   211
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   212
	if ($emptyquads > 1) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   213
		error(ERR_DNS_IPV6); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   214
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   215
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   216
	if ($emptyquads == 0 && $numquads != 8) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   217
		error(ERR_DNS_IPV6); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   218
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   219
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   220
	return true;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   221
}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   222
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   223
function is_valid_printable($string) {
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   224
	if (!ereg('^[[:print:]]+$', trim($string))) { error(ERR_DNS_PRINTABLE); return false; }
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   225
	return true;
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   226
}
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   227
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   228
function is_valid_rr_cname_name($name) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   229
	global $db;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   230
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   231
	$query = "SELECT type, content 
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   232
			FROM records 
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   233
			WHERE content = " . $db->quote($name) . "
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   234
			AND (type = 'MX' OR type = 'NS')";
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   235
	
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   236
	$response = $db->query($query);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   237
	if (PEAR::isError($response)) { error($response->getMessage()); return false; };
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   238
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   239
	if ($response->numRows() > 0) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   240
		error(ERR_DNS_CNAME); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   241
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   242
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   243
	return true;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   244
}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   245
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   246
function is_valid_non_alias_target($target) {
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   247
	global $db;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   248
	
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   249
	$query = "SELECT type, name
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   250
			FROM records
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   251
			WHERE name = " . $db->quote($target) . "
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   252
			AND TYPE = 'CNAME'";
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   253
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   254
	$response = $db->query($query);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   255
	if (PEAR::isError($response)) { error($response->getMessage()); return false; };
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   256
	if ($response->numRows() > 0) {
167
0b992665ac4d [feladat @ 273]
rejo
parents: 164
diff changeset
   257
		error(ERR_DNS_NON_ALIAS_TARGET); return false;
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   258
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   259
	return true;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   260
}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   261
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   262
function is_valid_rr_hinfo_content($content) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   263
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   264
	if ($content[0] == "\"") {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   265
		$fields = preg_split('/(?<=") /', $content, 2);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   266
	} else {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   267
		$fields = preg_split('/ /', $content, 2);
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   268
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   269
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   270
	for ($i = 0; ($i < 2); $i++) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   271
		if (!preg_match("/^([^\s]{1,1000}|\"([^\"]{1,998}\")$/i", $fields[$i])) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   272
			error(ERR_DNS_HINFO_INV_CONTENT); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   273
		}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   274
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   275
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   276
	return true;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   277
}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   278
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   279
function is_valid_rr_soa_content(&$content) {
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   280
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   281
	$fields = preg_split("/\s+/", trim($content));
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   282
        $field_count = count($fields);
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   283
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   284
	if ($field_count == 0 || $field_count > 7) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   285
		return false;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   286
	} else {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   287
		if (!is_valid_hostname_fqdn($fields[0]) || preg_match('/\.arpa\.?$/',$fields[0])) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   288
			return false;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   289
		}
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   290
		$final_soa = $fields[0];
121
90cab8725693 [feladat @ 224]
rejo
parents: 119
diff changeset
   291
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   292
		if (isset($fields[1])) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   293
			$addr_input = $fields[1];
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   294
		} else {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   295
			global $dns_hostmaster;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   296
			$addr_input = $dns_hostmaster;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   297
		}
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   298
		if (!preg_match("/@/", $addr_input)) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   299
			$addr_input = preg_split('/(?<!\\\)\./', $addr_input, 2);
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   300
			$addr_to_check = str_replace("\\", "", $addr_input[0]) . "@" . $addr_input[1];
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   301
		} else {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   302
			$addr_to_check = $addr_input;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   303
		}
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   304
		
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   305
		if (!is_valid_email($addr_to_check)) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   306
			return false;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   307
		} else {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   308
			$addr_final = explode('@', $addr_to_check, 2);
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   309
			$final_soa .= " " . str_replace(".", "\\.", $addr_final[0]) . "." . $addr_final[1];
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   310
		}
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   311
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   312
		if (isset($fields[2])) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   313
			if (!is_numeric($fields[2])) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   314
				return false;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   315
			}
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   316
			$final_soa .= " " . $fields[2];
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   317
		} else {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   318
			$final_soa .= " 0";
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   319
		}
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   320
		
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   321
		if ($field_count == 7) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   322
			for ($i = 3; ($i < 7); $i++) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   323
				if (!is_numeric($fields[$i])) {
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   324
					return false;
121
90cab8725693 [feladat @ 224]
rejo
parents: 119
diff changeset
   325
				} else {
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   326
					$final_soa .= " " . $fields[$i];
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   327
				}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   328
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   329
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   330
	}
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   331
	$content = $final_soa;
3e36ebbfe048 [feladat @ 244]
rejo
parents: 136
diff changeset
   332
	return true;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   333
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   334
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   335
function is_valid_rr_soa_name($name, $zone) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   336
	if ($name != $zone) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   337
		error(ERR_DNS_SOA_NAME); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   338
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   339
	return true;
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   340
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   341
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   342
function is_valid_rr_prio(&$prio, $type) {
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   343
	if ($type == "MX" || $type == "SRV" ) {
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   344
		if (!is_numeric($prio) || $prio < 0 || $prio > 65535 ) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   345
			error(ERR_DNS_INV_PRIO); return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   346
		}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   347
	} else {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   348
		$prio = "";
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   349
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   350
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   351
	return true;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   352
}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   353
164
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   354
function is_valid_rr_srv_name($name){
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   355
	$fields = explode('.', $name, 3);
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   356
	if (!preg_match('/^_[a-z0-9]+$/i', $fields[0])) { error(ERR_DNS_SRV_NAME) ; return false; }
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   357
	if (!preg_match('/^_[a-z0-9]+$/i', $fields[1])) { error(ERR_DNS_SRV_NAME) ; return false; }
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   358
	if (!is_valid_hostname_fqdn($fields[2],0)) { error(ERR_DNS_SRV_NAME) ; return false ; }
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   359
	return true ;
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   360
}
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   361
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   362
function is_valid_rr_srv_content($content) {
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   363
	$fields = preg_split("/\s+/", trim($content), 3);
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   364
	if (!is_numeric($fields[0]) || $fields[0] < 0 || $fields[0] > 65535) { error(ERR_DNS_SRV_WGHT) ; return false; } 
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   365
	if (!is_numeric($fields[1]) || $fields[1] < 0 || $fields[1] > 65535) { error(ERR_DNS_SRV_PORT) ; return false; } 
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   366
	if ($fields[2] == "" || ($fields[2] != "." && !is_valid_hostname_fqdn($fields[2],0))) {
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   367
		error(ERR_DNS_SRV_TRGT) ; return false; 
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   368
	} 
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   369
	return true;
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   370
}
4c6adb48dcfd [feladat @ 270]
rejo
parents: 162
diff changeset
   371
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   372
function is_valid_rr_ttl(&$ttl) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   373
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   374
	if (!isset($ttl) || $ttl == "" ) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   375
		global $dns_ttl;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   376
		$ttl = $dns_ttl;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   377
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   378
	
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   379
	if (!is_numeric($ttl) ||  $prio < 0 || $prio > 2147483647 ) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   380
		error(ERR_DNS_INV_TTL);	return false;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   381
	}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   382
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   383
	return true;
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   384
}
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   385
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   386
function is_valid_search($holygrail) {
e68c3d6094d1 [feladat @ 246]
rejo
parents: 138
diff changeset
   387
62
ce4919f37489 [feladat @ 109]
rejo
parents: 55
diff changeset
   388
	// Only allow for alphanumeric, numeric, dot, dash, underscore and 
ce4919f37489 [feladat @ 109]
rejo
parents: 55
diff changeset
   389
	// percent in search string. The last two are wildcards for SQL.
ce4919f37489 [feladat @ 109]
rejo
parents: 55
diff changeset
   390
	// Needs extension probably for more usual record types.
ce4919f37489 [feladat @ 109]
rejo
parents: 55
diff changeset
   391
ce4919f37489 [feladat @ 109]
rejo
parents: 55
diff changeset
   392
	return preg_match('/^[a-z0-9.\-%_]+$/i', $holygrail);
ce4919f37489 [feladat @ 109]
rejo
parents: 55
diff changeset
   393
}
ce4919f37489 [feladat @ 109]
rejo
parents: 55
diff changeset
   394
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   395
?>