diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 2b11427f897a4cd98b93514f9cc0fb1def7fe76b..fe02f14a8d31c4928d570fc0c9cc0cf9e2576320 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -113,7 +113,7 @@ class functions { return $url; } - function json_encode($data) { + public function json_encode($data) { if(!function_exists('json_encode')){ if(is_array($data) || is_object($data)){ $islist = is_array($data) && (empty($data) || array_keys($data) === range(0,count($data)-1)); @@ -177,6 +177,105 @@ class functions { return json_encode($data); } } + + public function suggest_ips($type = 'IPv4'){ + global $app; + + if($type == 'IPv4'){ + $regex = "/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/"; + } else { + // IPv6 + $regex = "/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i"; + } + + $ips = array(); + $results = $app->db->queryAllRecords("SELECT ip_address AS ip FROM server_ip WHERE ip_type = '".$type."'"); + if(!empty($results) && is_array($results)){ + foreach($results as $result){ + if(preg_match($regex, $result['ip'])) $ips[] = $result['ip']; + } + } + $results = $app->db->queryAllRecords("SELECT ip_address AS ip FROM openvz_ip"); + if(!empty($results) && is_array($results)){ + foreach($results as $result){ + if(preg_match($regex, $result['ip'])) $ips[] = $result['ip']; + } + } + $results = $app->db->queryAllRecords("SELECT data AS ip FROM dns_rr WHERE type = 'A' OR type = 'AAAA'"); + if(!empty($results) && is_array($results)){ + foreach($results as $result){ + if(preg_match($regex, $result['ip'])) $ips[] = $result['ip']; + } + } + $results = $app->db->queryAllRecords("SELECT ns AS ip FROM dns_slave"); + if(!empty($results) && is_array($results)){ + foreach($results as $result){ + if(preg_match($regex, $result['ip'])) $ips[] = $result['ip']; + } + } + + $results = $app->db->queryAllRecords("SELECT xfer FROM dns_slave WHERE xfer != ''"); + if(!empty($results) && is_array($results)){ + foreach($results as $result){ + $tmp_ips = explode(',', $result['xfer']); + foreach($tmp_ips as $tmp_ip){ + $tmp_ip = trim($tmp_ip); + if(preg_match($regex, $tmp_ip)) $ips[] = $tmp_ip; + } + } + } + $results = $app->db->queryAllRecords("SELECT xfer FROM dns_soa WHERE xfer != ''"); + if(!empty($results) && is_array($results)){ + foreach($results as $result){ + $tmp_ips = explode(',', $result['xfer']); + foreach($tmp_ips as $tmp_ip){ + $tmp_ip = trim($tmp_ip); + if(preg_match($regex, $tmp_ip)) $ips[] = $tmp_ip; + } + } + } + $results = $app->db->queryAllRecords("SELECT also_notify FROM dns_soa WHERE also_notify != ''"); + if(!empty($results) && is_array($results)){ + foreach($results as $result){ + $tmp_ips = explode(',', $result['also_notify']); + foreach($tmp_ips as $tmp_ip){ + $tmp_ip = trim($tmp_ip); + if(preg_match($regex, $tmp_ip)) $ips[] = $tmp_ip; + } + } + } + $results = $app->db->queryAllRecords("SELECT remote_ips FROM web_database WHERE remote_ips != ''"); + if(!empty($results) && is_array($results)){ + foreach($results as $result){ + $tmp_ips = explode(',', $result['remote_ips']); + foreach($tmp_ips as $tmp_ip){ + $tmp_ip = trim($tmp_ip); + if(preg_match($regex, $tmp_ip)) $ips[] = $tmp_ip; + } + } + } + $ips = array_unique($ips); + sort($ips, SORT_NUMERIC); + + $result_array = array('cheader' => array(), 'cdata' => array()); + + if(!empty($ips)){ + $result_array['cheader'] = array('title' => 'IPs', + 'total' => count($ips), + 'limit' => count($ips) + ); + + foreach($ips as $ip){ + $result_array['cdata'][] = array( 'title' => $ip, + 'description' => $type, + 'onclick' => '', + 'fill_text' => $ip + ); + } + } + + return $result_array; + } diff --git a/interface/web/dns/ajax_get_json.php b/interface/web/dns/ajax_get_json.php index 410bc77f0a737f41d1cc86a7f5df3ded479d3123..3be847c25894bdce95b9ee00dc36d2252967b9e0 100644 --- a/interface/web/dns/ajax_get_json.php +++ b/interface/web/dns/ajax_get_json.php @@ -34,7 +34,7 @@ require_once('../../lib/app.inc.php'); //* Check permissions for module $app->auth->check_module_permissions('dns'); -$app->uses('tform'); +//$app->uses('tform'); $type = $_GET["type"]; @@ -42,34 +42,37 @@ $type = $_GET["type"]; if($type == 'get_ipv4'){ - $q = $app->db->quote(trim($_GET["q"])); - $authsql = " AND ".$app->tform->getAuthSQL('r'); - $modules = explode(',', $_SESSION['s']['user']['modules']); + //$q = $app->db->quote(trim($_GET["q"])); + //$authsql = " AND ".$app->tform->getAuthSQL('r'); + //$modules = explode(',', $_SESSION['s']['user']['modules']); $result = array(); // ipv4 - $result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")"); + //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")"); + $result[] = $app->functions->suggest_ips('IPv4'); $json = $app->functions->json_encode($result); } if($type == 'get_ipv6'){ - $q = $app->db->quote(trim($_GET["q"])); - $authsql = " AND ".$app->tform->getAuthSQL('r'); - $modules = explode(',', $_SESSION['s']['user']['modules']); + //$q = $app->db->quote(trim($_GET["q"])); + //$authsql = " AND ".$app->tform->getAuthSQL('r'); + //$modules = explode(',', $_SESSION['s']['user']['modules']); $result = array(); - // ipv4 - $result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")"); - + // ipv6 + //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")"); + $result[] = $app->functions->suggest_ips('IPv6'); + $json = $app->functions->json_encode($result); } //} -function _search($module, $section, $additional_sql = ''){ +/* +function _search($module, $section, $additional_sql = '', $unique = false){ global $app, $q, $authsql, $modules; $result_array = array('cheader' => array(), 'cdata' => array()); @@ -143,11 +146,16 @@ function _search($module, $section, $additional_sql = ''){ 'onclick' => '', 'fill_text' => $result[$title_key] ); - } + } + if($unique === true){ + $result_array['cdata'] = array_unique($result_array['cdata']); + $result_array['cheader']['total'] = $result_array['cheader']['limit'] = count($result_array['cdata']); + } } } return $result_array; } +*/ header('Content-type: application/json'); echo $json; diff --git a/interface/web/dns/templates/dns_slave_edit.htm b/interface/web/dns/templates/dns_slave_edit.htm index 4cc0fde05c261d72c8fbd9fcee963f32cb0be08f..52e0af2250b08fc25d2d7eac3fe30adae2e060cd 100644 --- a/interface/web/dns/templates/dns_slave_edit.htm +++ b/interface/web/dns/templates/dns_slave_edit.htm @@ -67,3 +67,31 @@ </div> </div> +<script language="JavaScript" type="text/javascript"> + jQuery('#ns').ispconfigSearch({ + dataSrc: '/dns/ajax_get_json.php?type=get_ipv4', + resultsLimit: '$ <tmpl_var name="globalsearch_resultslimit_of_txt"> % <tmpl_var name="globalsearch_resultslimit_results_txt">', + ResultsTextPrefix: '<tmpl_var name="globalsearch_suggestions_text_txt">', + noResultsText: '<tmpl_var name="globalsearch_noresults_text_txt">', + noResultsLimit: '<tmpl_var name="globalsearch_noresults_limit_txt">', + minChars: 0, + cssPrefix: 'df-', + fillSearchField: true, + fillSearchFieldWith: 'fill_text', + searchFieldWatermark: '', + resultBoxPosition: 'e' + }); + jQuery('#xfer').ispconfigSearch({ + dataSrc: '/dns/ajax_get_json.php?type=get_ipv4', + resultsLimit: '$ <tmpl_var name="globalsearch_resultslimit_of_txt"> % <tmpl_var name="globalsearch_resultslimit_results_txt">', + ResultsTextPrefix: '<tmpl_var name="globalsearch_suggestions_text_txt">', + noResultsText: '<tmpl_var name="globalsearch_noresults_text_txt">', + noResultsLimit: '<tmpl_var name="globalsearch_noresults_limit_txt">', + minChars: 0, + cssPrefix: 'df-', + fillSearchField: true, + fillSearchFieldWith: 'fill_text', + searchFieldWatermark: '', + resultBoxPosition: 'e' + }); +</script> \ No newline at end of file diff --git a/interface/web/dns/templates/dns_soa_edit.htm b/interface/web/dns/templates/dns_soa_edit.htm index fa8312304047f65e978917d8dbc56ca34c0198ab..6b7ced0c11ff3ffd9458469d61f84c963e7fd21b 100644 --- a/interface/web/dns/templates/dns_soa_edit.htm +++ b/interface/web/dns/templates/dns_soa_edit.htm @@ -101,3 +101,31 @@ </div> </div> +<script language="JavaScript" type="text/javascript"> + jQuery('#xfer').ispconfigSearch({ + dataSrc: '/dns/ajax_get_json.php?type=get_ipv4', + resultsLimit: '$ <tmpl_var name="globalsearch_resultslimit_of_txt"> % <tmpl_var name="globalsearch_resultslimit_results_txt">', + ResultsTextPrefix: '<tmpl_var name="globalsearch_suggestions_text_txt">', + noResultsText: '<tmpl_var name="globalsearch_noresults_text_txt">', + noResultsLimit: '<tmpl_var name="globalsearch_noresults_limit_txt">', + minChars: 0, + cssPrefix: 'df-', + fillSearchField: true, + fillSearchFieldWith: 'fill_text', + searchFieldWatermark: '', + resultBoxPosition: 'e' + }); + jQuery('#also_notify').ispconfigSearch({ + dataSrc: '/dns/ajax_get_json.php?type=get_ipv4', + resultsLimit: '$ <tmpl_var name="globalsearch_resultslimit_of_txt"> % <tmpl_var name="globalsearch_resultslimit_results_txt">', + ResultsTextPrefix: '<tmpl_var name="globalsearch_suggestions_text_txt">', + noResultsText: '<tmpl_var name="globalsearch_noresults_text_txt">', + noResultsLimit: '<tmpl_var name="globalsearch_noresults_limit_txt">', + minChars: 0, + cssPrefix: 'df-', + fillSearchField: true, + fillSearchFieldWith: 'fill_text', + searchFieldWatermark: '', + resultBoxPosition: 'e' + }); +</script> \ No newline at end of file diff --git a/interface/web/sites/ajax_get_json.php b/interface/web/sites/ajax_get_json.php index 887f5dae26f06037bfdb84b61cd4968117b9c063..14eb44081efcca839208d774909a90d62b916229 100644 --- a/interface/web/sites/ajax_get_json.php +++ b/interface/web/sites/ajax_get_json.php @@ -99,8 +99,29 @@ $type = $_GET["type"]; unset($php); $json .= '"}'; } + + if($type == 'get_ipv4'){ + $result = array(); + + // ipv4 + //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")"); + $result[] = $app->functions->suggest_ips('IPv4'); + + $json = $app->functions->json_encode($result); + } + + if($type == 'get_ipv6'){ + $result = array(); + + // ipv6 + //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")"); + $result[] = $app->functions->suggest_ips('IPv6'); + + $json = $app->functions->json_encode($result); + } //} + header('Content-type: application/json'); echo $json; ?> \ No newline at end of file diff --git a/interface/web/sites/lib/lang/de_database.lng b/interface/web/sites/lib/lang/de_database.lng index 0e10a09f804ba0f53d3e09204725b9c26ffe5543..f919586b16e32eb60b36b05fa76b22f605030fa6 100644 --- a/interface/web/sites/lib/lang/de_database.lng +++ b/interface/web/sites/lib/lang/de_database.lng @@ -21,11 +21,17 @@ $wb['database_name_change_txt'] = 'Der Datenbankname kann nicht geändert werden $wb['database_charset_change_txt'] = 'Der Zeichensatz der Datenbank kann nicht geändert werden.'; $wb['password_strength_txt'] = 'Passwortkomplexität'; $wb['database_name_error_len'] = 'Datenbank Name - {db} - zu lang. Die max. Datenbank Namen Länge inkl. Präfix ist 64 Zeichen.'; -$wb['database_user_error_len'] = 'Datenbank Benutzername - {user}- zu lang. Die max. Datenbank Benutzernamen Länge inkl. Präfix ist 16 Zeichen.'; +$wb['database_user_error_len'] = 'Datenbank Benutzername - {user} - zu lang. Die max. Datenbank Benutzernamen Länge inkl. Präfix ist 16 Zeichen.'; $wb['generate_password_txt'] = 'Passwort erzeugen'; $wb["btn_save_txt"] = 'Speichern'; $wb["btn_cancel_txt"] = 'Abbrechen'; $wb["parent_domain_id_txt"] = 'Website'; $wb["database_site_error_empty"] = 'Wählen Sie ein Website aus, zu der die Datenbank gehört.'; $wb["select_site_txt"] = '- Website wählen -'; +$wb['globalsearch_resultslimit_of_txt'] = "von"; +$wb['globalsearch_resultslimit_results_txt'] = "Treffern"; +$wb['globalsearch_noresults_text_txt'] = "Keine Treffer."; +$wb['globalsearch_noresults_limit_txt'] = "0 Treffer"; +$wb['globalsearch_searchfield_watermark_txt'] = "Suche"; +$wb['globalsearch_suggestions_text_txt'] = "Vorschläge"; ?> diff --git a/interface/web/sites/lib/lang/en_database.lng b/interface/web/sites/lib/lang/en_database.lng index 3d21df9d0e45b956eef160a4efad67916467c4e7..8a470c708a14ca8c0118b38393d33d9c03b1e17b 100644 --- a/interface/web/sites/lib/lang/en_database.lng +++ b/interface/web/sites/lib/lang/en_database.lng @@ -21,7 +21,7 @@ $wb["limit_database_txt"] = 'The max. number of databases is reached.'; $wb["database_name_change_txt"] = 'The database name can not be changed'; $wb["database_charset_change_txt"] = 'The database charset can not be changed'; $wb["database_name_error_len"] = 'Database name - {db} - too long. The max. database name length incl. prefix is 64 chars.'; -$wb["database_user_error_len"] = 'Database username - {user}- too long. The max. database username length incl. prefix is 16 chars.'; +$wb["database_user_error_len"] = 'Database username - {user} - too long. The max. database username length incl. prefix is 16 chars.'; $wb["parent_domain_id_txt"] = 'Site'; $wb["database_site_error_empty"] = 'Select the site to which the database belongs.'; $wb["select_site_txt"] = '- Select Site -'; @@ -31,4 +31,10 @@ $wb['generate_password_txt'] = 'Generate Password'; $wb['repeat_password_txt'] = 'Repeat Password'; $wb['password_mismatch_txt'] = 'The passwords do not match.'; $wb['password_match_txt'] = 'The passwords do match.'; +$wb['globalsearch_resultslimit_of_txt'] = "of"; +$wb['globalsearch_resultslimit_results_txt'] = "results"; +$wb['globalsearch_noresults_text_txt'] = "No results."; +$wb['globalsearch_noresults_limit_txt'] = "0 results"; +$wb['globalsearch_searchfield_watermark_txt'] = "Search"; +$wb['globalsearch_suggestions_text_txt'] = "Suggestions"; ?> diff --git a/interface/web/sites/templates/database_edit.htm b/interface/web/sites/templates/database_edit.htm index 558e31110f7481606ee643d0365825fc61cefd90..01dfe034817b1426130396826276df9460a986d1 100644 --- a/interface/web/sites/templates/database_edit.htm +++ b/interface/web/sites/templates/database_edit.htm @@ -104,3 +104,18 @@ </div> </div> +<script language="JavaScript" type="text/javascript"> + jQuery('#remote_ips').ispconfigSearch({ + dataSrc: '/sites/ajax_get_json.php?type=get_ipv4', + resultsLimit: '$ <tmpl_var name="globalsearch_resultslimit_of_txt"> % <tmpl_var name="globalsearch_resultslimit_results_txt">', + ResultsTextPrefix: '<tmpl_var name="globalsearch_suggestions_text_txt">', + noResultsText: '<tmpl_var name="globalsearch_noresults_text_txt">', + noResultsLimit: '<tmpl_var name="globalsearch_noresults_limit_txt">', + minChars: 0, + cssPrefix: 'df-', + fillSearchField: true, + fillSearchFieldWith: 'fill_text', + searchFieldWatermark: '', + resultBoxPosition: 'e' + }); +</script> \ No newline at end of file