<?php
// geoip_hostname.php
// RJM Programming
// September, 2024
// Thanks to GeoIP

  $colsnine='';
  $colsaltnine='';
  $altfile='';
  $hostn='';
  $cst='';
  $ctz='';
  $ctwo='';
  $cname='';
  $city='';
  $country='';
  $state='';
  $ccode='';
  $tzplace='';
  $continent='';
  $newhname='';
  $urlifsuffix='';
  $urlifsuffixmore='';
  $preresults='';
  $results='';
  $hname='';
  $via='';
  $honesel="";
  $thislang="";
  $midfs="*";
  $langfs="*";
  $langnamelook='';
  if (file_exists('HTMLCSS/experimental_drag_and_drop.htm')) {
      $langnamelook=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'HTMLCSS' . DIRECTORY_SEPARATOR . 'experimental_drag_and_drop.htm');
  }
  foreach (glob('/tmp/GeoLite2-City-CSV_' . $midfs . '/GeoLite2-City-Locations-' . $langfs . '.csv') as $fname) {
       if ($midfs == "*" || $midfs < explode('/', explode('/tmp/GeoLite2-City-CSV_', $fname)[1])[0]) {
          if ($midfs == '*') {
            if ($honesel == "") {
              $honesel=' <font size=1> via <select id=langsel onchange=" langfs=this.value;  document.getElementById(' . "'lang'" . ').value=langfs; "><option value="*">All Languages below ...</option></select></font>';
            }
          }
          $midfs=explode('/', explode('/tmp/GeoLite2-City-CSV_', $fname)[1])[0];
       }
       $thismore='';
       $thislang=explode('.', explode('/GeoLite2-City-Locations-', $fname)[1])[0];
       if (strpos($langnamelook, "['" . $thislang) !== false) {
         $thismore=' ' . explode("'", explode("['", explode("['" . $thislang, $langnamelook)[0])[-1 + sizeof( explode("['", explode("['" . $thislang, $langnamelook)[0]))])[0];
       } else if (strpos($langnamelook, "['" . str_replace('zh-CN','cmn-Hans-CN',$thislang)) !== false) {  
         $thismore=' ' . explode("'", explode("['", explode("['" . str_replace('zh-CN','cmn-Hans-CN',$thislang), $langnamelook)[0])[-1 + sizeof( explode("['", explode("['" . str_replace('zh-CN','cmn-Hans-CN',$thislang), $langnamelook)[0]))])[0];
       }
       if (strpos($honesel, ' value="' . $thislang . '"') === false) {
         $honesel=str_replace('</select>', '<option value="' . $thislang . '">' . $thislang . $thismore . '</option></select>', $honesel);
  //echo str_replace('<','&lt;',str_replace('>','&gt;',$honesel)) . '';
  //exit;
       }
  }
  //echo str_replace('<','&lt;',str_replace('>','&gt;',$honesel));
  //exit;
  if (isset($_GET['via']) || isset($_POST['via'])) {
      $via='' . (isset($_GET['via']) ? str_replace('+',' ',urldecode($_GET['via'])) : '') . (isset($_POST['via']) ? str_replace('+',' ',urldecode($_POST['via'])) : '');
  }
  if (isset($_GET['lang']) || isset($_POST['lang'])) {
      $langfs='' . (isset($_GET['lang']) ? str_replace('+',' ',urldecode($_GET['lang'])) : '') . (isset($_POST['lang']) ? str_replace('+',' ',urldecode($_POST['lang'])) : '');
  }
  if (isset($_GET['hostname']) || isset($_POST['hostname'])) {
      $hname='' . (isset($_GET['hostname']) ? str_replace('+',' ',urldecode($_GET['hostname'])) : '') . (isset($_POST['hostname']) ? str_replace('+',' ',urldecode($_POST['hostname'])) : '');
      if ($via == $hname) { $via=''; }
  }
  
  if (trim($hname) != '') {
    if (substr(trim($hname),0,1) < '0' || substr(trim($hname),0,1) > '9') {
    if (strpos($hname, '//') === false) {
       $hname='http://' . $hname;
    } else if (strpos($hname, ':') === false) {
       $hname='http:' . $hname;
    }
    //$bigcont=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'ip_example.py');
    //file_put_contents('/tmp/ip_example_ours.py', str_replace(explode("'", explode("url = '", $bigcont)[1])[0], $hname, $bigcont));  
    //echo    '/usr/bin/python ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'test_geoip.py --hostname=' . $hname;
    //exit;  
    if (1 == 1) {
    $results=shell_exec('ping -c 4 ' . explode('/', str_replace('http://','',$hname))[0]);
    } else {                                                                                                     
    $results=shell_exec('/usr/bin/python ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'test_geoip.py --hostname=' . explode('/', str_replace('http://','',$hname))[0]);
    }
    if (strpos($results, 'PING ' . str_replace('http://','',$hname) . ' (') !== false) {
      $newhname=explode(" ",explode(")",trim(explode('PING ' . str_replace('http://','',$hname) . ' (', $results)[1]))[0])[0];
      $results='';
    } else if (strpos($results, 'IP address:') !== false) {
      $newhname=explode(" ",explode("\n",trim(explode('IP address:', $results)[1]))[0])[0];
      $results='';
    }
  } else if ($hname != '') {
    if ($via != '' && (substr(trim($via),0,1) < '0' || substr(trim($via),0,1) > '9')) {
    $preresults='Looking up ' . $via . " ( " . $hname . " ) ";
    } else {
    $preresults='Looking up ' . $hname;
    }
    $gnames=',';
    //foreach (glob('/tmp/GeoLite2-City-CSV_20240920/GeoLite2-City-Blocks-IP*.csv') as $fname) {
    foreach (glob('/tmp/GeoLite2-City-CSV_' . $midfs . '/GeoLite2-City-Blocks-IP*.csv') as $fname) {
       $fgc='';
       if (1 == 1) {
         $fgc="\n" . shell_exec('fgrep "' . $hname . '/" ' . $fname) . "\n";
       } else {
         $fgc="\n" . file_get_contents($fname) . "\n";
       }
       $listis="\n" . $fgc . "\n";
       if (strpos($listis, "\n" . $hname . "/") !== false) {
         $lis=explode("\n" . $hname . "/", $listis);
         for ($ii=1; $ii<sizeof($lis); $ii++) {
           $cols=explode(',',$lis[$ii]);
           if ($cols[1] != '') {
            if (strpos($gnames, ',' . $cols[1] . ',') === false) {
             $gnames.=$cols[1] . ',';
            }
           }
         }
       }
    }
    // /tmp/GeoLite2-ASN-CSV_20240921/GeoLite2-ASN-Blocks-IPv4.csv
    if ($gnames == ',') {
    //echo "huh";
    //exit;
    foreach (glob('/tmp/GeoLite2-ASN-CSV_*/GeoLite2-ASN-Blocks-IP*.csv') as $fname) {
       $fgc='';
       //echo "" . $hname . " " . $fname;
       //exit;
       if (1 == 1) {
         $fgc="\n" . shell_exec('fgrep "' . $hname . '/" ' . $fname) . "\n";
       } else {
         $fgc="\n" . file_get_contents($fname) . "\n";
       }
       $listis="\n" . $fgc . "\n";
       if (strpos($listis, "\n" . $hname . "/") !== false) {
         $lis=explode("\n" . $hname . "/", $listis);
         for ($ii=1; $ii<sizeof($lis); $ii++) {
           $cols=explode(',',$lis[$ii]);
           if ($cols[1] != '') {
            if (strpos($gnames, ',' . $cols[1] . ',') === false) {
             $gnames.=$cols[1] . ',';
             $hostn=$cols[2];
            }
           }
         }
       }
    }
    }
    if ($gnames != ',') {
    $garr=explode(',', substr($gnames,1,(-2 + strlen($gnames))));
    //foreach (glob('/tmp/GeoLite2-City-CSV_20240920/GeoLite2-City-Locations-*.csv') as $fname) {
    //$altfile='';
    if ($langfs != '*' && $langfs != 'en') {
       $altfile=' ';
    }
    foreach (glob('/tmp/GeoLite2-City-CSV_' . $midfs . '/GeoLite2-City-Locations-' . $langfs . '.csv') as $fname) {
       $thislang=explode('.', explode('/GeoLite2-City-Locations-', $fname)[1])[0];
       if ($altfile == ' ') { $altfile=str_replace('-' . $thislang . '.csv','-en.csv',$fname);  }
       for ($jj=0; $jj<sizeof($garr); $jj++) {
       $fgc='';
       if (1 == 1) {
         $fgc="\n" . shell_exec('fgrep "' . $garr[$jj] . '," ' . $fname) . "\n";
       } else {
         $fgc="\n" . file_get_contents($fname) . "\n";
       }
       $listis="\n" . $fgc . "\n";
       if (strpos($listis, "\n" . $garr[$jj] . ",") !== false) {
         $lis=explode("\n" . $garr[$jj] . ",", $listis);
         for ($ii=1; $ii<sizeof($lis); $ii++) {
           $cols=explode(',',$lis[$ii]);
           if ($cols[9] == '' && $cols[7] != '') {
             $cols[9]=$cols[7];
           }
            //echo "6where #" . $altfile . $thislang . ' garr0=' . $garr[0] . ' ' . sizeof($garr) . ' lissize=' . sizeof($lis) . ' cols9=' . $cols[9] . ' lisii=' . explode("\n",$lis[$ii])[0];
            //exit;
           if ($cols[9 - 0] != '' || sizeof($cols) >= 12) {
            if ($cols[9 - 0] == '' && trim($altfile) != '') {
            $altfgc="\n" . shell_exec('fgrep "' . $garr[$jj] . '," ' . $altfile) . "\n";
            $altlistis="\n" . $altfgc . "\n";
            if (strpos($altlistis, "\n" . $garr[$jj] . ",") !== false) {
            $altlis=explode("\n" . $garr[$jj] . ",", $altlistis);
            $altcols=explode(',',$altlis[1]);
           if ($altcols[9] == '' && $altcols[7] != '') {
             $altcols[9]=$altcols[7];
           }
            }
            $cols[9 - 0]=$altcols[9 - 0];
            }
            if ($city == '') { $city='<table border=1  style=width:80%;><tr><td title="' . $thislang . '">'; } else { $city=str_replace('</td><td>', '</td><td title="' . $thislang . '">', $city);  }
            if ($langfs == '*' && strpos($fname, '-en.csv') !== false) {
            $urlifsuffix='?placegeo=' . urlencode(str_replace('"','',$cols[9 - 0]));
            $urlifsuffixmore='?placegeo=' . urlencode(str_replace('"','',$cols[9 - 0]));
            if ($cname == '' || 5 == 5) {
            $cname=str_replace('"','',$cols[4]);
            $cst=$cols[6];
            $ctz=$cols[11];
            $ctwo=$cols[3];
            }
            } else if ($langfs != '*' && ($urlifsuffix == '' || trim($altfile) != '')) {
            if (trim($altfile) != '') {
            $altfgc="\n" . shell_exec('fgrep "' . $garr[$jj] . '," ' . $altfile) . "\n";
            $altfile='';
            $altlistis="\n" . $altfgc . "\n";
            if (strpos($altlistis, "\n" . $garr[$jj] . ",") !== false) {
            $altlis=explode("\n" . $garr[$jj] . ",", $altlistis);
            $altcols=explode(',',$altlis[1]);
            $urlifsuffix='?geoplace=' . urlencode(str_replace('"','',$cols[9 - 0])) . '&placegeo=' . urlencode(str_replace('"','',$altcols[9 - 0]));
            $urlifsuffixmore='?geoplace=' . urlencode(str_replace('"','',$cols[9 - 0])) . '&placegeo=' . urlencode(str_replace('"','',$altcols[9 - 0]) . ',_' . str_replace('"','',$altcols[6]));
            //$cname=str_replace('"','',$altcols[4]);
            //$cst=$altcols[6];
            //$ctz=$altcols[11];
            $ctwo=$altcols[3];
            } else {
            $urlifsuffix='?placegeo=' . urlencode(str_replace('"','',$cols[9 - 0]));
            }
            } else {
            $urlifsuffix='?placegeo=' . urlencode(str_replace('"','',$cols[9 - 0]));
            }
            }
            $city.=' ' . str_replace('"','',$cols[9 - 0]) . '</td><td>';
           }
           if ($cols[3] != '') {
            if ($ccode == '') { $ccode='<table border=1 style=width:80%;><tr><td title="' . $thislang . '">'; } else { $ccode=str_replace('</td><td>', '</td><td title="' . $thislang . '">', $ccode);  }
            $ccode.=' ' . str_replace('"','',$cols[3]) . '</td><td>';
            if ($ctwo == '' && ($langfs != '*' || $thislang != 'en')) { $ctwo=$cols[3]; }
           }
           if ($cols[6] != '') {
            if ($state == '') { $state='<table border=1  style=width:80%;><tr><td title="' . $thislang . '">'; } else { $state=str_replace('</td><td>', '</td><td title="' . $thislang . '">', $state);  }
            $state.=' ' . str_replace('"','',$cols[6]) . '</td><td>';
            if ($cst == '' && ($langfs != '*' || $thislang != 'en')) { $cst=$cols[6]; }
            if ($urlifsuffixmore != '' && $thislang == 'en') {
             $urlifsuffixmore.=',_' . urlencode(str_replace('"','',$cols[6]));
            }
           }
           if ($cols[4] != '') {
            if ($country == '') { $country='<table border=1  style=width:80%;><tr><td title="' . $thislang . '">'; } else { $country=str_replace('</td><td>', '</td><td title="' . $thislang . '">', $country);  }
            $country.=' ' . str_replace('"','',$cols[4]) . '</td><td>';
            if ($cname == '' && ($langfs != '*' || $thislang != 'en')) { $cname=str_replace('"','',$cols[4]); }
            if ($urlifsuffix != '' && 1 == 5) {
             $urlifsuffix.='' . urlencode(', ' . str_replace('"','',$cols[4]));
            }
           }
           if ($cols[11] != '') {
            if ($tzplace == '') { $tzplace='<table border=1  style=width:80%;><tr><td title="' . $thislang . '">'; } else { $tzplace=str_replace('</td><td>', '</td><td title="' . $thislang . '">', $tzplace);  }
            if ($ctz == '' && ($langfs != '*' || $thislang != 'en')) { $ctz=$cols[11]; }
            $tzplace.=' ' . str_replace('"','',$cols[11]) . '</td><td>';
           }
           if ($cols[2] != '') {
            if ($continent == '') { $continent='<table border=1  style=width:80%;><tr><td title="' . $thislang . '">'; }
            $continent.=' ' . str_replace('"','',$cols[2]) . '</td><td>';
           }
         }
       }
       }
       $results="<br><br>" . ($city == '' ? 'Company: ' . $city . $hostn : 'City: ' . substr($city,0,(-1 + strlen($city))) . ' class=toright id=tdcity title=""></td></tr></table>');
       $results.="<br>" . ($state == '' ? $state : 'State: ' . substr($state,0,(-1 + strlen($state))) . ' class=toright id=tdstate></td></tr></table>');
       $results.="<br>" . ($country == '' ? $country : 'Country: ' . substr($country,0,(-1 + strlen($country))) . ' class=toright id=tdcountry></td></tr></table>');
       $results.="<br>" . ($ccode == '' ? $ccode : 'Country Code: ' . substr($ccode,0,(-1 + strlen($ccode))) . ' class=toright id=tdccode></td></tr></table>');
       $results.="<br>" . ($continent == '' ? $continent : 'Continent: ' . substr($continent,0,(-1 + strlen($continent))) . ' class=toright id=tdcontinent></td></tr></table>');
       $results.="<br>" . ($tzplace == '' ? $tzplace : 'Timezone: ' . substr($tzplace,0,(-1 + strlen($tzplace))) . ' class=toright id=tdtzplace></td></tr></table>') . "<br><br>"; 
    }
    }
  }
  }
  
  if ($preresults != '' && $results == '') {  $preresults.=' ... not found.'; }
  
  echo "<html>
<head>
<meta charset='UTF-8'/>
<title>Hostname Lookup geoip_hostname.php - RJM Programming - September, 2024</title>
<style>
  .toright { text-align: right; }
</style>
<scr" . "ipt type=text/javascript>
 var langfs='" . $langfs . "'; 
 var ccode='" . $ctwo . "'; 
 var cname='" . $cname . "'; 
 var ctz='" . $ctz . "'; 
 var cst='" . $cst . "'; 

 function checkit(iois) {
  var otherplace='';
  var pgeq='placegeo=';
  var mbit=\"&label=\" + (\"['Lat',\") + \"&value=\" + (\"'Lon','Name']\");
  if (iois != null) {
    var jfnd=iois.src.indexOf('geoplace=');
    var ifnd=iois.src.indexOf('placegeo=');
    if (jfnd != -1) {
      otherplace=iois.src.split('geoplace=')[1].split('&')[0];
      pgeq='geoplace=';
    }
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null && ifnd != -1) {
       if (aconto.document) { aconto = aconto.document; }
       if (aconto.body != null) {
          if (document.getElementById('tdcity')) {
            //document.getElementById('tdcity').innerHTML=document.getElementById('placegeo').value;
            document.getElementById('tdcity').title=document.getElementById('placegeo').title;
            if (document.getElementById('tdcity').title.indexOf(',') == 2) {
              if (document.getElementById('tdstate')) {
                document.getElementById('tdstate').innerHTML=\"<iframe style=width:550px;height:400px; src='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=\" + document.getElementById('tdcity').title.split(',')[0] + ';' + iois.src.split(pgeq)[1].split('&')[0] + encodeURIComponent(', ' + cst) + '&aregexographicals=y&aregeographicals=&width=500&height=312&onclick=y&country=Places&text=text&popularity=&data=%20[' + document.getElementById('placegeo').value.replace(',','|') + '|~' + iois.src.split(pgeq)[1].split('&')[0] + \"~,2]'></iframe>\";
              }
              if (document.getElementById('tdcity')) {
                document.getElementById('tdcity').innerHTML='<iframe style=width:550px;height:400px; src=\"//www.rjmprogramming.com.au/PHP/Map/map.php?title=' + iois.src.split(pgeq)[1].split('&')[0] + \"&width=500&height=312&onclick=y\" + mbit + \"&data=,[\" + document.getElementById('placegeo').value + ',~' + iois.src.split(pgeq)[1].split('&')[0] + '~]\"></iframe>';
              }
              if (document.getElementById('tdccode')) {
                document.getElementById('tdccode').innerHTML=\"<iframe style=width:550px;height:400px; src='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=\" + iois.src.split(pgeq)[1].split('&')[0] + encodeURIComponent(', ' + cname) + '&width=500&height=312&onclick=y&country=Places&popularity=Score&data=%20[~' + document.getElementById('tdcity').title.split(',')[0] + \"~,2]'></iframe>\";
              }
              if (document.getElementById('tdtzplace')) {
                document.getElementById('tdtzplace').innerHTML=\"<iframe style=width:850px;height:900px; src='//www.rjmprogramming.com.au/HTMLCSS/colour_wheel.html?mode=\" + ctz + \"'></iframe>\";
              }
            } else if (document.getElementById('tdcity').title.indexOf('?') == -1) {
              if (document.getElementById('tdstate')) {
                document.getElementById('tdstate').innerHTML=\"<iframe style=width:550px;height:400px; src='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=\" + iois.src.split(pgeq)[1].split('&')[0] + encodeURIComponent(', ' + cst) + '&aregexographicals=y&aregeographicals=&width=500&height=312&onclick=y&country=Places&popularity=&text=text&data=%20[' + document.getElementById('placegeo').value.replace(',','|') + '|~' + iois.src.split(pgeq)[1].split('&')[0] + \"~,2]'></iframe>\";
              }
              if (document.getElementById('tdcity')) {
                document.getElementById('tdcity').innerHTML=\"<iframe style=width:550px;height:400px; src=\"//www.rjmprogramming.com.au/PHP/Map/map.php?title=' + iois.src.split(pgeq)[1].split('&')[0] + \"&width=500&height=312&onclick=y\" + mbit + \"&data=,[\" + document.getElementById('placegeo').value + ',~' + iois.src.split(pgeq)[1].split('&')[0] + '~]\"></iframe>';
              }
              if (document.getElementById('tdccode')) {
                document.getElementById('tdccode').innerHTML=\"<iframe style=width:550px;height:400px; src='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=\" + iois.src.split(pgeq)[1].split('&')[0] + encodeURIComponent(', ' + cname) + '&width=500&height=312&onclick=y&country=Places&popularity=Score&data=%20[~' + ccode + \"~,2]'></iframe>\";
              }
              if (document.getElementById('tdtzplace')) {
                document.getElementById('tdtzplace').innerHTML=\"<iframe style=width:850px;height:900px; src='//www.rjmprogramming.com.au/HTMLCSS/colour_wheel.html?mode=\" + ctz + \"'></iframe>\";
              }
            }
          }
       }
    } 
  }
 }  

 function checkittwo(iois) {
  var otherplace='';
  var pgeq='placegeo=';
  var mbit=\"&label=\" + (\"['Lat',\") + \"&value=\" + (\"'Lon','Name']\");
  if (iois != null) {
    var jfnd=iois.src.indexOf('geoplace=');
    var ifnd=iois.src.indexOf('placegeo=');
    if (jfnd != -1) {
      otherplace=iois.src.split('geoplace=')[1].split('&')[0];
      pgeq='geoplace=';
    }
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null && ifnd != -1) {
       if (aconto.document) { aconto = aconto.document; }
       if (aconto.body != null) {
          if (document.getElementById('tdcity')) {
            //document.getElementById('tdcity').innerHTML=document.getElementById('placegeo').value;
            document.getElementById('tdcity').title=document.getElementById('placegeo').title;
            if (document.getElementById('tdcity').title.indexOf(',') == 2) {
              if (document.getElementById('tdstate')) {
                document.getElementById('tdstate').innerHTML=\"<iframe style=width:550px;height:400px; src='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=\" + document.getElementById('tdcity').title.split(',')[0] + ';' + iois.src.split(pgeq)[1].split('&')[0].replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20') + '&aregexographicals=y&aregeographicals=&width=500&height=312&onclick=y&country=Places&text=text&popularity=&data=%20[' + document.getElementById('placegeo').value.replace(',','|') + '|~' + iois.src.split(pgeq)[1].split('&')[0].replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20') + \"~,2]'></iframe>\";
              }
              if (document.getElementById('tdcity')) {
                document.getElementById('tdcity').innerHTML='<iframe style=width:550px;height:400px; src=\"//www.rjmprogramming.com.au/PHP/Map/map.php?title=' + iois.src.split(pgeq)[1].split('&')[0].replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20') + \"&width=500&height=312&onclick=y\" + mbit + \"&data=,[\" + document.getElementById('placegeo').value + ',~' + iois.src.split(pgeq)[1].split('&')[0].replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20') + '~]\"></iframe>';
              }
              if (document.getElementById('tdccode')) {
                document.getElementById('tdccode').innerHTML=\"<iframe style=width:550px;height:400px; src='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=\" + iois.src.split(pgeq)[1].split('&')[0].replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20') + encodeURIComponent(', ' + cname) + '&width=500&height=312&onclick=y&country=Places&popularity=Score&data=%20[~' + document.getElementById('tdcity').title.split(',')[0] + \"~,2]'></iframe>\";
              }
              if (document.getElementById('tdtzplace')) {
                document.getElementById('tdtzplace').innerHTML=\"<iframe style=width:850px;height:900px; src='//www.rjmprogramming.com.au/HTMLCSS/colour_wheel.html?mode=\" + ctz + \"'></iframe>\";
              }
            } else if (document.getElementById('tdcity').title.indexOf('?') == -1) {
              if (document.getElementById('tdstate')) {
                document.getElementById('tdstate').innerHTML=\"<iframe style=width:550px;height:400px; src='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=\" + iois.src.split(pgeq)[1].split('&')[0].replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20') + '&aregexographicals=y&aregeographicals=&width=500&height=312&onclick=y&country=Places&popularity=&text=text&data=%20[' + document.getElementById('placegeo').value.replace(',','|') + '|~' + iois.src.split(pgeq)[1].split('&')[0] + \"~,2]'></iframe>\";
              }
              if (document.getElementById('tdcity')) {
                document.getElementById('tdcity').innerHTML=\"<iframe style=width:550px;height:400px; src=\"//www.rjmprogramming.com.au/PHP/Map/map.php?title=' + iois.src.split(pgeq)[1].split('&')[0].replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20') + \"&width=500&height=312&onclick=y\" + mbit + \"&data=,[\" + document.getElementById('placegeo').value + ',~' + iois.src.split(pgeq)[1].split('&')[0].replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20') + '~]\"></iframe>';
              }
              if (document.getElementById('tdccode')) {
                document.getElementById('tdccode').innerHTML=\"<iframe style=width:550px;height:400px; src='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=\" + iois.src.split(pgeq)[1].split('&')[0].replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20').replace(encodeURIComponent('_'),'%20') + encodeURIComponent(', ' + cname) + '&width=500&height=312&onclick=y&country=Places&popularity=Score&data=%20[~' + ccode + \"~,2]'></iframe>\";
              }
              if (document.getElementById('tdtzplace')) {
                document.getElementById('tdtzplace').innerHTML=\"<iframe style=width:850px;height:900px; src='//www.rjmprogramming.com.au/HTMLCSS/colour_wheel.html?mode=\" + ctz + \"'></iframe>\";
              }
            }
          }
       }
    } 
  }
 }  
</scri" . "pt>
</head>
<body onload=\"  if (document.getElementById('langsel')) { document.getElementById('langsel').value='" . $langfs . "';  } if (document.getElementById('hostname').value != '') { setTimeout(function() { document.getElementById('blook').click(); }, 2000);  } \">
<h1>Hostname Lookup" . $honesel . "</h1>
<h3>RJM Programming - September, 2024 ... thanks to <a target=_blank title=MaxMind href='//www.maxmind.com/'>MaxMind</a></h3>
<div id=results>" . $preresults . str_replace("\n","<br>",$results) . "</div><br><br>
<form method=POST action=./geoip_hostname.php>
<input style=width:80%; type=text name=hostname id=hostname placeholder='Enter host name or domain name or host IP address to show information regarding ...' value='" . $newhname . "'></input><br><br>
<input type=hidden name=via id=via value='" . $hname . "'></input> 
<input type=hidden name=lang id=lang value='" . $langfs . "'></input> 
<input type=submit id=blook value=Lookup></input>
</form>
<input type=hidden id=placegeo title='' value=''></input>
<iframe onload=checkit(this); id=placeif src='/PHP/fgc/index.php" . $urlifsuffix . "' style=display:none;></iframe>
<iframe onload=\" checkittwo(this);\" id=placeifmore src='/PHP/fgc/index.php" . $urlifsuffixmore . "' style=display:none;></iframe>
</body>
</html>";

  exit;
?>