
Script Que Mostra País
#16
Whitesnake
Posted 20/02/2005, 22:06
Cheque as permissões de CHMOD para 755.
E não esqueça de enviar o arquivo countries.txt, se não ele não funciona mesmo
Até
#17
Posted 20/02/2005, 22:22
#18
Posted 20/02/2005, 22:46
pelo que eu seu script pega o host e pelo host filtra se tem algum dado comparativo com o banco de dados senao ele retorna desconhecido(unknow)Pessoal vê esse script em anexo... acho ele bem mais fácil. Porém como falado, tem alguns erros.
Ele nao seria tao eficiente quanto ao q estamos discutindo aqui. ehh
ache a linha:
print "$_[1]";
mude para:
print qq|$_[1] <img src="imagem aqui">|;
Edição feita por: prix, 20/02/2005, 22:50.
print join'',(reverse map{/d([a-z])d/}split/W/,'$5x6@314&60f%3i4#moo^1r2#moo^1p2')," ", pack ("B*",'01110000011001010111001001101100')," ", pack ("B*",'011011010110111101101110011010110110010101111001'), "n";
sleep 5;
E-Mails, topicos ou mensagens privadas não serão respondidas a menos que eu considere uma relevancia/necessidade na mesma.
#19
Whitesnake
Posted 20/02/2005, 23:16
Óia...eu tinha kolokado la na sessão de links... um site q tem umas banderinhas q encaxam perfeitamente no q vc precisa...perfeitamente mesmo... pq os nomes dos arquivos são os mesmos do banco de dados do seu script... + a galerinha legal aki sumiu com o link hehehe já revirei a cat de links e num ta...
+ Tipo...se vc axar...arquivos .gif que tenham nomes como... br.gif, us.gif, ar.gif.. sigla dos países aí fica moleza... vo passah o script como ficaria:
#!/usr/bin/perl
##############################################################################
# Country Determinator Version 1.0 #
# Copyright 1998 UtilMind Solutions info@utilmind.com #
# #
# Created Nov 19, 1998 Last Modified Nov 19, 1998 #
##############################################################################
$path="http://www.site.com.....br/bandeiras"; # Local onde se encontram as imagens em formato gif. Sem barra no final.
# Set Variables
$countries_path = "countries.txt";
print "Content-Type: text/html\n\n";
$host = &gethostname;
$host =~ tr/a-z/A-Z/; # UpperCase
$hostlength = length($host);
&smartdetect;
# Get domain extension
$tempstr = $host;
for ($i = $hostlength; $i >= 0; $i--) {
$ch = chop($tempstr);
if ($ch eq '.') {
$host = substr($host, $i, $hostlength - $i);
$i = 0;
}
}
# Get needed Country name from file
open(FILE,$countries_path) || die Cant locate countries.txt file;
@LINES = <FILE>;
close(FILE);
$SIZE = @LINES;
for ($i = 0; $i <= $SIZE; $i++) {
$countrystr = $LINES[$i];
$tempstr = $countrystr;
$len = length($countrystr);
for ($j = $len; $j >= 0; $j--) {
$ch = chop($tempstr);
if ($ch eq '`') {
$country_ext = substr($countrystr, 0, $j - 1);
if ($host eq $country_ext) {
$img=lc($country_ext).".gif";
$host = substr($countrystr, $j, $len - $j - 1);
$pais=$host;
print qq|
<font style="font-family:Tahoma; font-size:8pt; color:#343434">
Olá, seu IP é referente ao país <b><img src="$path/$img" border="0"> $pais</b>
</font>
|;
exit;
}
$j = 0;
}
}
}
print "Unknown";
exit;
################################################
# Detecting Country by other parameters
# For example, my RemoteHost - xxx.Kiev.dial.sovam.com, but country is Ukraine
# - .KIEV. is Ukraine
sub smartdetect {
&seeksubstr('.KIEV.', 'Ukraine');
}
########################################################################
# Usage: seeksubstr(SubString, Country); #
# Returns: nothing, but print country name and exit if substring found #
########################################################################
sub seeksubstr {
$len = length($_[0]);
if ($hostlength > $len) {
for ($i = $hostlength - $len; $i >= 0; $i--) {
$tempstr = substr($host, $i, $len);
if ($tempstr eq $_[0]) {
print "$_[1]";
exit;
}
}
}
}
###############################
# #
# GET HOST NAME FUNCTION #
# #
###############################
sub gethostname {
$ipnum =$ENV{REMOTE_ADDR};
@digits = split (/\./, $ipnum);
$address = pack ("C4", @digits);
$host = gethostbyaddr ($address, 2);
return $host;
}
Aí vai aparecer tipo assim:
Olá, seu IP é referente ao país Brazil.
Para mudar o valor de Brazil para Brasil é só editar o arquivo countries.txt

Falow
#20
Posted 21/02/2005, 00:15
Attached Files
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)