Changeset 154


Ignore:
Timestamp:
03/09/2006 08:07:26 AM (6 years ago)
Author:
cirrus
Message:

Add: google suggest-like search input. Closes #93
Add: show_map=no option to not display the map. Closes #47

Location:
trunk
Files:
6 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/globals/functions.php

    r151 r154  
    238238} 
    239239 
     240function correct_ip_min($ip, $ret_null=TRUE, $pad=3) { 
     241        if ($ip == '' && $ret_null === TRUE) return ''; 
     242        $t = explode(".", $ip, 4); 
     243        for ($i=0;$i<4;$i++) { 
     244                if(!isset($t[$i+1]) && $t[$i] != null) { 
     245                        switch (substr($t[$i], 0, 1)) { 
     246                        case '0': 
     247                                break; 
     248                        case '1': 
     249                        case '2': 
     250                                $t[$i] = intval(str_pad($t[$i], (substr($t[$i], 1, 1) >= 6?2:$pad), "0")); 
     251                                break; 
     252                        default: 
     253                                $t[$i] = intval(str_pad($t[$i], ($pad==3?2:$pad), "0")); 
     254                        } 
     255                }elseif($t[$i] == null) { 
     256                        $t[$i] = 0; 
     257                }else{ 
     258                        $t[$i] = (integer)($t[$i]); 
     259                } 
     260        } 
     261        return implode(".", $t); 
     262} 
     263 
     264function correct_ip_max($ip, $ret_null=TRUE, $pad=3) { 
     265        if ($ip == '' && $ret_null === TRUE) return ''; 
     266        $t = explode(".", $ip, 4); 
     267        for ($i=0;$i<4;$i++) { 
     268                if(!isset($t[$i+1]) && $t[$i] != null) { 
     269                        switch (substr($t[$i], 0, 1)) { 
     270                        case '0': 
     271                                break; 
     272                        case '1': 
     273                        case '2': 
     274                                $t[$i] = intval(str_pad($t[$i], (substr($t[$i], 1, 1) >= 6?2:$pad), "9")); 
     275                                break; 
     276                        default: 
     277                                $t[$i] = intval(str_pad($t[$i], ($pad==3?2:$pad), "9")); 
     278                        } 
     279                        if ($t[$i] > 255) $t[$i] = 255; 
     280                }elseif($t[$i] == null) { 
     281                        $t[$i] = 255; 
     282                }else{ 
     283                        $t[$i] = (integer)($t[$i]); 
     284                } 
     285        } 
     286        return implode(".", $t); 
     287} 
     288 
    240289function generate_account_code() { 
    241290        for ($i=1;$i<=20;$i++) { 
     
    377426} 
    378427 
     428function replace_sql_wildcards($str) { 
     429        $str = str_replace("*", "%", $str); 
     430        $str = str_replace("?", "_", $str); 
     431        return $str; 
     432} 
     433 
    379434?> 
  • trunk/globals/language/english.php

    r152 r154  
    7373        'dns_zones_search' => "Search for DNS zones", 
    7474        'dns_zones_found' => "DNS zones found", 
    75          
     75        'not_found' => "No results found",       
    7676        'all_services' => "Network services", 
    7777        'active_services' => "Active services", 
  • trunk/globals/language/greek.php

    r151 r154  
    8585        'dns_zones_found' => "ΖώΜες DNS ποϠ
    8686 Î²ÏÎ­ÎžÎ·ÎºÎ±Îœ", 
    87  
     87        'not_found' => "ΔεΜ βρέΞηκαΜ αποτελέσΌατα", 
    8888        'all_services' => "Υπηρεσίες ΎικτύοϠ
    8989", 
  • trunk/includes/main_menu.php

    r152 r154  
    155155                                                '' 
    156156                                                ); 
     157                $main->html->head->add_script("text/javascript", makelink(array("page" => "search", "subpage" => "suggest_js"))); 
    157158                return template($this->tpl, __FILE__); 
    158159        } 
  • trunk/includes/pages/nodes/nodes_search.php

    r140 r154  
    105105                $this->tpl['link_fullmap'] = makelink(array("page" => "gmap", "node" => get('node'))); 
    106106                $this->tpl['link_gearth'] = makelink(array("page" => "gearth", "subpage" => "download", "node" => get('node'), "show_p2p" => "1", "show_aps" => "1", "show_clients" => "1", "show_unlinked" => "1", "show_links_p2p" => "1", "show_links_client" => "1")); 
    107                 $this->tpl['gmap_key_ok'] = include_gmap("?page=gmap&subpage=js&node=".get('node')); 
     107                if(get('show_map') == "no") $this->tpl['gmap_key_ok'] = "nomap"; 
     108                else $this->tpl['gmap_key_ok'] = include_gmap("?page=gmap&subpage=js&node=".get('node')); 
    108109 
    109110                return template($this->tpl, __FILE__); 
  • trunk/includes/pages/nodes/nodes_view.php

    r152 r154  
    316316                $this->tpl['link_fullmap'] = makelink(array("page" => "gmap", "node" => get('node'))); 
    317317                $this->tpl['link_gearth'] = makelink(array("page" => "gearth", "subpage" => "download", "node" => get('node'), "show_p2p" => "1", "show_aps" => "1", "show_clients" => "1", "show_unlinked" => "1", "show_links_p2p" => "1", "show_links_client" => "1")); 
    318                 $this->tpl['gmap_key_ok'] = include_gmap("?page=gmap&subpage=js&node=".get('node')); 
     318                if(get('show_map') == "no") $this->tpl['gmap_key_ok'] = "nomap"; 
     319                else $this->tpl['gmap_key_ok'] = include_gmap("?page=gmap&subpage=js&node=".get('node')); 
    319320                return template($this->tpl, __FILE__); 
    320321        } 
  • trunk/includes/pages/ranges/ranges_search.php

    r71 r154  
    4242                $where = $form_search_ranges->db_data_where(array('ip' => 'exclude')); 
    4343                $table_ip_ranges = new table(array('TABLE_NAME' => 'table_ip_ranges', 'FORM_NAME' => 'table_ip_ranges')); 
    44                 $s_ip = correct_ip($form_search_ranges->data[0]['value']); 
    45                 $where = ($where !=''?"(".$where.") AND ":""). 
    46                                 ($s_ip !=''?"ip_ranges.ip_start <= ".ip2long($s_ip)." AND ip_ranges.ip_end >= ".ip2long($s_ip)." AND ":""); 
     44                $s_ip = $form_search_ranges->data[0]['value']; 
     45                $where = ($where !=''?"(".$where.") AND ":""); 
     46                if ($s_ip !='') $where .= '(ip_ranges.ip_start >= '.ip2long(correct_ip_min($s_ip, TRUE, 1)).' AND ip_ranges.ip_start <= '.ip2long(correct_ip_max($s_ip, TRUE, 1)).") OR ". 
     47                                                '(ip_ranges.ip_start >= '.ip2long(correct_ip_min($s_ip, TRUE, 2)).' AND ip_ranges.ip_start <= '.ip2long(correct_ip_max($s_ip, TRUE, 2)).") OR ". 
     48                                                '(ip_ranges.ip_start >= '.ip2long(correct_ip_min($s_ip, TRUE, 3)).' AND ip_ranges.ip_start <= '.ip2long(correct_ip_max($s_ip, TRUE, 3)).") AND "; 
     49                //$where =  
     50                //              ($s_ip !=''?"ip_ranges.ip_start <= ".ip2long($s_ip)." AND ip_ranges.ip_end >= ".ip2long($s_ip)." AND ":""); 
    4751                if ($where!='') $where = substr($where, 0, -5); 
    4852                $table_ip_ranges->db_data( 
     
    7478                $this->tpl['link_ranges_allocation'] = makelink(array("page" => "ranges", "subpage" => "allocation")); 
    7579                $form_search_ranges = $this->form_search_ranges(); 
    76                 if ($form_search_ranges->data[0]['value'] != '') $form_search_ranges->data[0]['value'] = correct_ip($form_search_ranges->data[0]['value']); 
     80                //if ($form_search_ranges->data[0]['value'] != '') $form_search_ranges->data[0]['value'] = correct_ip($form_search_ranges->data[0]['value']); 
    7781                $this->tpl['form_search_ranges'] = $construct->form($form_search_ranges, __FILE__); 
    7882                $this->tpl['table_ranges'] = $construct->table($this->table_ip_ranges(), __FILE__); 
  • trunk/includes/pages/search/search.php

    r122 r154  
    2020 */ 
    2121 
     22if (get('subpage') != '') { 
     23        include_once(ROOT_PATH."includes/pages/search/search_".get('subpage').".php"); 
     24} else { 
     25        include_once(ROOT_PATH."includes/pages/search/search_query.php"); 
     26} 
     27 
     28 
    2229class search { 
    2330 
    2431        var $tpl; 
     32        var $page; 
    2533         
    2634        function search() { 
    27                  
     35                if (get('subpage') != '') { 
     36                        $p = "search_".get('subpage'); 
     37                        $this->page = new $p; 
     38                } else { 
     39                        $this->page = new search_query; 
     40                } 
    2841        } 
    2942         
    3043        function output() { 
    31                 global $db, $vars; 
    32                 $q = get('q'); 
    33                 if (is_numeric($q) && strpos($q, ".") === FALSE) { 
    34                         $page = array("page" => "nodes", "node" => $q); 
    35                 } elseif ($db->cnt('', 'nodes', "name = '".$q."'") == 1) { 
    36                         $node = $db->get('id', 'nodes', "name = '".$q."'"); 
    37                         $page = array("page" => "nodes", "node" => $node[0]['id']); 
    38                 } elseif (is_ip($q, FALSE)) { 
    39                         $page = array("page" => "ranges", 
    40                                                   "subpage" => "search", 
    41                                                   "form_search_ranges_search" => serialize(array("ip" => $q)) 
    42                                                   ); 
    43                 } elseif (substr($q, -strlen(".".$vars['dns']['root_zone'])) == ".".$vars['dns']['root_zone']) { 
    44                         $page = array("page" => "dnszones", 
    45                                                   "form_search_dns_search" => serialize(array("dns_zones__name" => $q)) 
    46                                                   ); 
    47                 } else { 
    48                         $page = array("page" => "nodes", 
    49                                                   "form_search_nodes_search" => serialize(array("nodes__name" => $q)) 
    50                                                   ); 
    51                 } 
    52                 redirect( makelink($page, '', '', FALSE) ); 
     44                return $this->page->output(); 
    5345        } 
    5446 
  • trunk/templates/basic/includes/main_menu.tpl

    r152 r154  
    8282                                                                                </tr> 
    8383                                                                                <tr> 
    84                                                                                         <td> 
    85                                                                                                 <input type="text" name="q" /> 
     84                                                                                        <td>                     
     85                                                                                                <input type="text" id="q" name="q" autocomplete="off" onfocus="hover('',this.value);" onkeyup="hover(event.keyCode,this.value);"  onblur="setTimeout('hideSearch()',500); hov=0;" /> 
     86                                                                                                <div align="left" id="searchResult" name="searchResult" style="font-family:Arial; font-size:12px; width:140px; background-color: white; border:#000000 dashed 1px; padding:0px; display: none; position: absolute;  "></div> 
    8687                                                                                        </td> 
    8788                                                                                </tr> 
  • trunk/templates/basic/includes/pages/nodes/nodes_search.tpl

    r140 r154  
    2222{include file=generic/page-title.tpl title="`$lang.all_nodes`" right="$help"} 
    2323<table width="100%"  border="0" cellpadding="0" cellspacing="0" class="table-page"> 
    24 <tr> 
    25 <td class="table-page-split"> 
    26 <table align="center" bgcolor="#DBE0D7" cellpadding="0" cellspacing="2"> 
    27 <tr><td align="left">{include file=generic/link.tpl link=$link_gearth content="`$lang.google_earth`"}</td><td align="right">{include file=generic/link.tpl link=$link_fullmap content="`$lang.new_window`" target="_blank"}</td></tr> 
    28 <tr><td style="font-size:12px; text-align:center;" colspan="2">{if $gmap_key_ok} 
    29 <div id="map" style="width: 500px; height: 500px;"></div> 
    30 {else} 
    31 {$lang.message.error.gmap_key_failed.body|wordwrap:40|nl2br} 
    32 {/if} 
    33 </td></tr><tr><td style="font-size:12px;"> 
    34 <input type="checkbox" name="p2p" checked="checked" onclick="gmap_refresh();" />{html_image file="`$img_dir`/gmap/mm_20_orange.png" alt=$lang.backbone}{$lang.backbone} 
    35 <input type="checkbox" name="aps" checked="checked" onclick="gmap_refresh();" />{html_image file="`$img_dir`/gmap/mm_20_green.png" alt=$lang.aps}{$lang.aps} 
    36 <input type="checkbox" name="clients" onclick="gmap_refresh();" />{html_image file="`$img_dir`/gmap/mm_20_blue.png" alt=$lang.clients}{$lang.clients} 
    37 <input type="checkbox" name="unlinked" onclick="gmap_refresh();" />{html_image file="`$img_dir`/gmap/mm_20_red.png" alt=$lang.unlinked}{$lang.unlinked} 
    38 </td> 
     24        <tr> 
     25                <td class="table-page-split"> 
     26                {if $gmap_key_ok!=="nomap"} 
     27                        <table align="center" bgcolor="#DBE0D7" cellpadding="0" cellspacing="2"> 
     28                                <tr> 
     29                                        <td align="left">{include file=generic/link.tpl link=$link_gearth content="`$lang.google_earth`"}</td><td align="right">{include file=generic/link.tpl link=$link_fullmap content="`$lang.new_window`" target="_blank"}</td> 
     30                                </tr> 
     31                                <tr> 
     32                                        <td style="font-size:12px; text-align:center;" colspan="2"> 
     33                                        {if $gmap_key_ok} 
     34                                                <div id="map" style="width: 500px; height: 500px;"></div> 
     35                                        {else} 
     36                                                {$lang.message.error.gmap_key_failed.body|wordwrap:40|nl2br} 
     37                                        {/if} 
     38                                        </td> 
     39                                </tr> 
     40                                <tr> 
     41                                        <td style="font-size:12px;"> 
     42                                                <input type="checkbox" name="p2p" checked="checked" onclick="gmap_refresh();" />{html_image file="`$img_dir`/gmap/mm_20_orange.png" alt=$lang.backbone}{$lang.backbone} 
     43                                                <input type="checkbox" name="aps" checked="checked" onclick="gmap_refresh();" />{html_image file="`$img_dir`/gmap/mm_20_green.png" alt=$lang.aps}{$lang.aps} 
     44                                                <input type="checkbox" name="clients" onclick="gmap_refresh();" />{html_image file="`$img_dir`/gmap/mm_20_blue.png" alt=$lang.clients}{$lang.clients} 
     45                                                <input type="checkbox" name="unlinked" onclick="gmap_refresh();" />{html_image file="`$img_dir`/gmap/mm_20_red.png" alt=$lang.unlinked}{$lang.unlinked} 
     46                                        </td> 
     47                                </tr> 
     48                        </table> 
     49                {/if} 
     50                </td> 
     51        </tr> 
     52        <tr> 
     53                <td class="table-page-split"> 
     54                        {include file=generic/title1.tpl title="`$lang.nodes_search`" content=$form_search_nodes} 
     55                </td> 
     56        </tr> 
     57        <tr> 
     58                <td class="table-page-pad"> 
     59                        {include file=generic/title2.tpl title="`$lang.nodes_found`" content=$table_nodes} 
     60                </td> 
     61        </tr> 
    3962</table> 
    40 </td> 
    41 </tr> 
    42 <tr> 
    43 <td class="table-page-split"> 
    44 {include file=generic/title1.tpl title="`$lang.nodes_search`" content=$form_search_nodes} 
    45 </td> 
    46 </tr> 
    47 <tr> 
    48 <td class="table-page-pad"> 
    49 {include file=generic/title2.tpl title="`$lang.nodes_found`" content=$table_nodes} 
    50 </td> 
    51 </tr> 
    52 </table> 
  • trunk/templates/basic/includes/pages/nodes/nodes_view.tpl

    r152 r154  
    3434        </td> 
    3535        <td class="table-page-split"> 
     36        {if $gmap_key_ok!=="nomap"} 
    3637                <table bgcolor="#DBE0D7" cellpadding="0" cellspacing="2"> 
    3738                        <tr> 
     
    5758                        </tr> 
    5859                </table> 
     60        {/if} 
    5961        </td> 
     62         
    6063</tr> 
    6164<tr> 
Note: See TracChangeset for help on using the changeset viewer.