via '; } } $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('', '', $honesel); //echo str_replace('<','<',str_replace('>','>',$honesel)) . ''; //exit; } } //echo str_replace('<','<',str_replace('>','>',$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= 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='
'; } else { $city=str_replace('', '', $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]) . ''; } if ($cols[3] != '') { if ($ccode == '') { $ccode='
'; } else { $ccode=str_replace('', '', $ccode); } $ccode.=' ' . str_replace('"','',$cols[3]) . ''; if ($ctwo == '' && ($langfs != '*' || $thislang != 'en')) { $ctwo=$cols[3]; } } if ($cols[6] != '') { if ($state == '') { $state='
'; } else { $state=str_replace('', '', $state); } $state.=' ' . str_replace('"','',$cols[6]) . ''; if ($cst == '' && ($langfs != '*' || $thislang != 'en')) { $cst=$cols[6]; } if ($urlifsuffixmore != '' && $thislang == 'en') { $urlifsuffixmore.=',_' . urlencode(str_replace('"','',$cols[6])); } } if ($cols[4] != '') { if ($country == '') { $country='
'; } else { $country=str_replace('', '', $country); } $country.=' ' . str_replace('"','',$cols[4]) . ''; 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='
'; } else { $tzplace=str_replace('', '', $tzplace); } if ($ctz == '' && ($langfs != '*' || $thislang != 'en')) { $ctz=$cols[11]; } $tzplace.=' ' . str_replace('"','',$cols[11]) . ''; } if ($cols[2] != '') { if ($continent == '') { $continent='
'; } $continent.=' ' . str_replace('"','',$cols[2]) . ''; } } } } $results="

" . ($city == '' ? 'Company: ' . $city . $hostn : 'City: ' . substr($city,0,(-1 + strlen($city))) . ' class=toright id=tdcity title="">
'); $results.="
" . ($state == '' ? $state : 'State: ' . substr($state,0,(-1 + strlen($state))) . ' class=toright id=tdstate>
'); $results.="
" . ($country == '' ? $country : 'Country: ' . substr($country,0,(-1 + strlen($country))) . ' class=toright id=tdcountry>
'); $results.="
" . ($ccode == '' ? $ccode : 'Country Code: ' . substr($ccode,0,(-1 + strlen($ccode))) . ' class=toright id=tdccode>
'); $results.="
" . ($continent == '' ? $continent : 'Continent: ' . substr($continent,0,(-1 + strlen($continent))) . ' class=toright id=tdcontinent>
'); $results.="
" . ($tzplace == '' ? $tzplace : 'Timezone: ' . substr($tzplace,0,(-1 + strlen($tzplace))) . ' class=toright id=tdtzplace>
') . "

"; } } } } if ($preresults != '' && $results == '') { $preresults.=' ... not found.'; } echo " Hostname Lookup geoip_hostname.php - RJM Programming - September, 2024 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=\"\"; } if (document.getElementById('tdcity')) { document.getElementById('tdcity').innerHTML=''; } if (document.getElementById('tdccode')) { document.getElementById('tdccode').innerHTML=\"\"; } if (document.getElementById('tdtzplace')) { document.getElementById('tdtzplace').innerHTML=\"\"; } } else if (document.getElementById('tdcity').title.indexOf('?') == -1) { if (document.getElementById('tdstate')) { document.getElementById('tdstate').innerHTML=\"\"; } if (document.getElementById('tdcity')) { document.getElementById('tdcity').innerHTML=\"'; } if (document.getElementById('tdccode')) { document.getElementById('tdccode').innerHTML=\"\"; } if (document.getElementById('tdtzplace')) { document.getElementById('tdtzplace').innerHTML=\"\"; } } } } } } } 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=\"\"; } if (document.getElementById('tdcity')) { document.getElementById('tdcity').innerHTML=''; } if (document.getElementById('tdccode')) { document.getElementById('tdccode').innerHTML=\"\"; } if (document.getElementById('tdtzplace')) { document.getElementById('tdtzplace').innerHTML=\"\"; } } else if (document.getElementById('tdcity').title.indexOf('?') == -1) { if (document.getElementById('tdstate')) { document.getElementById('tdstate').innerHTML=\"\"; } if (document.getElementById('tdcity')) { document.getElementById('tdcity').innerHTML=\"'; } if (document.getElementById('tdccode')) { document.getElementById('tdccode').innerHTML=\"\"; } if (document.getElementById('tdtzplace')) { document.getElementById('tdtzplace').innerHTML=\"\"; } } } } } } }

Hostname Lookup" . $honesel . "

RJM Programming - September, 2024 ... thanks to MaxMind

" . $preresults . str_replace("\n","
",$results) . "




"; exit; ?>