skin Posted July 21, 2006 at 11:18 PM Report #39492 Posted July 21, 2006 at 11:18 PM //http://joaopedropereira.com/ // IP Saver $ip = $_SERVER['REMOTE_ADDR']; //Escreve o IP na página. echo "$ip"; //Hora $hora = date("H:i:s"); //Data $data = date("j/m/y"); //Abre o ficheiro ip.skin $fp = fopen("ip.skin", "a"); //Escreve no ficheiro aberto o IP a data e a hora de entrada fputs ($fp, "IP: $ip - Data: $data - Hora: $hora \r\n"); //Fecha o ficheiro fclose($fp); Our lives begin to end the day we become silent about things that matter - Martin Luther King
IceBrain Posted August 10, 2006 at 03:19 PM Report #43619 Posted August 10, 2006 at 03:19 PM Esse código é bastante simples, aparece em qualquer site para principiantes, mas mesmo assim pode dar jeito. O problema é que é bastante fácil "saltar" uma verificaçao por IP (do género os bans por IP dos fóruns ou assim), usando um "proxy" como o Proxomitron (a minha IP actual é ICEBRAIN PC, e qualquer site do género www.showmyip.com mostra-me essa). Conhecem alguma maneira de criar um registo que nao possa ser falsificado tao facilmente? Eu pensei em fazer um traceroute, mas ainda nao implementei nada. ❝The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.❞- John Carmack on software patents A list of command line apps
kingless Posted August 10, 2006 at 04:30 PM Report #43631 Posted August 10, 2006 at 04:30 PM Para descobrir o verdadeiro IP de um usuário mesmo que ele estiver a utilizar um proxy é só chamar $_SERVER['HTTP_X_FORWARDED_FOR']; mas não é 100% garantido que vai retornar o IP do usuário e pode ser facilmente enganado.
PHP Posted August 25, 2006 at 03:42 PM Report #46441 Posted August 25, 2006 at 03:42 PM Mas esse método não mostra o IP das pessoas que NÃO estejam a usar proxy. Pelo menos a mim não mostrou. Não mostrou nada.
kingless Posted August 25, 2006 at 04:12 PM Report #46448 Posted August 25, 2006 at 04:12 PM Mas esse método não mostra o IP das pessoas que NÃO estejam a usar proxy. Pelo menos a mim não mostrou. Não mostrou nada. Porque é preciso adicionar mais algumas variaveis <?php if (isset ($_SERVER['HTTP_X_FORWARDED_FOR'])) { $IP = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset ($_SERVER['HTTP_CLIENT_IP'])) { $IP = $_SERVER['HTTP_CLIENT_IP']; } elseif (isset ($_SERVER['HTTP_FROM '])) { $IP = $_SERVER['HTTP_FROM']; } elseif (isset ($_SERVER['REMOTE_ADDR'])) { $IP = $_SERVER['REMOTE_ADDR']; } echo $IP; ?>
PHP Posted August 25, 2006 at 04:48 PM Report #46454 Posted August 25, 2006 at 04:48 PM Muito obrigado, kingless. Bem precisava disso para um scriptzinho que estou a fazer.
PHP Posted August 29, 2006 at 09:42 PM Report #47197 Posted August 29, 2006 at 09:42 PM @skin, tens de ter em conta que \r\n só dá para windows, \n para linux e \r para mac.
kingless Posted August 29, 2006 at 11:36 PM Report #47215 Posted August 29, 2006 at 11:36 PM @skin, tens de ter em conta que \r\n só dá para windows, \n para linux e \r para mac. Errado.... \r > não serve para nova linha \r\n > nova linha no windows e linux (acho que mac também) \n > nova linha no linux e mac etc //Testado no Linux e Windows <? echo "bla bla bla\r\nbla1 bla1 bla1\nbla2 bla2 bla2"; ?>
_elf Posted August 30, 2006 at 01:34 AM Report #47231 Posted August 30, 2006 at 01:34 AM prefiro fzr echo '<br>'; ou echo '<p> </p>';
kingless Posted August 30, 2006 at 02:42 AM Report #47241 Posted August 30, 2006 at 02:42 AM prefiro fzr echo '<br>'; ou echo '<p> </p>'; Não se deve juntar PHP com HTML 😛
_elf Posted August 30, 2006 at 06:21 AM Report #47248 Posted August 30, 2006 at 06:21 AM eu como ja disse num outro topico a minha programação em php é bastante má, ou seja não tenho boas pratics de programação. Em quase todos os sites que faço vejo me obrigado a usar html senão como é que apresento as páginas? E já agora porque é que não se deve usar html junto com php?
helt Posted August 30, 2006 at 06:47 AM Report #47251 Posted August 30, 2006 at 06:47 AM eu como ja disse num outro topico a minha programação em php é bastante má, ou seja não tenho boas pratics de programação. Em quase todos os sites que faço vejo me obrigado a usar html senão como é que apresento as páginas? E já agora porque é que não se deve usar html junto com php? Por razão nenhuma... ficas com o script mais organizado... ––––•(-• [ ђєlt ] •-)•––––
_elf Posted August 30, 2006 at 08:06 AM Report #47257 Posted August 30, 2006 at 08:06 AM mas tens spr de colocar html para conseguires formatar a pagina!
helt Posted August 30, 2006 at 08:22 AM Report #47261 Posted August 30, 2006 at 08:22 AM sim, mas não tem de estar obrigatóriamente misturado com o php. Podes por exemplo, guardar o html num ficheiro à parte e depois chamá-lo com um include.. ––––•(-• [ ђєlt ] •-)•––––
skin Posted August 30, 2006 at 11:42 AM Author Report #47317 Posted August 30, 2006 at 11:42 AM Include ou Require A difrença entre a expressão include e a expressão require reside na forma como lidam com os erros encontrados no script externo. Enquanto que a expressão include apenas dá um "Warning" a expressão require produz um "Fatal Error". Our lives begin to end the day we become silent about things that matter - Martin Luther King
helt Posted August 30, 2006 at 11:45 AM Report #47320 Posted August 30, 2006 at 11:45 AM Exacto, escrevi um tutorial sobre isso à uns tempos, se quiserem dar uma olhadela -> http://www.inforlandia.pt/forum/viewtopic.php?t=14594 ––––•(-• [ ђєlt ] •-)•––––
PHP Posted August 30, 2006 at 06:40 PM Report #47417 Posted August 30, 2006 at 06:40 PM @kingless, eu tinha lido num site de PHP que era assim p fxr no mac. Se estou enganado, peço desculpas, (my bad) 😉
Neptune(o verdadeiro) Posted July 2, 2008 at 11:09 PM Report #195125 Posted July 2, 2008 at 11:09 PM aqui fica um mais complexo function validip($ip) { if (!empty($ip) && $ip == long2ip(ip2long($ip))) { // reserved IANA IPv4 addresses // http://www.iana.org/assignments/ipv4-address-space $reserved_ips = array ( array('0.0.0.0','2.255.255.255'), array('10.0.0.0','10.255.255.255'), array('127.0.0.0','127.255.255.255'), array('169.254.0.0','169.254.255.255'), array('172.16.0.0','172.31.255.255'), array('192.0.2.0','192.0.2.255'), array('192.168.0.0','192.168.255.255'), array('255.255.255.0','255.255.255.255') ); foreach ($reserved_ips as $r) { $min = ip2long($r[0]); $max = ip2long($r[1]); if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false; } return true; } else return false; } function mostrarip() { if (isset($_SERVER)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } else { $ip = $_SERVER['REMOTE_ADDR']; } } else { if (getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) { $ip = getenv('HTTP_X_FORWARDED_FOR'); } elseif (getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) { $ip = getenv('HTTP_CLIENT_IP'); } else { $ip = getenv('REMOTE_ADDR'); } } return $ip; }
GPAV Posted July 24, 2009 at 11:01 AM Report #280839 Posted July 24, 2009 at 11:01 AM para linux não da 😉
IceBrain Posted August 7, 2009 at 11:35 AM Report #282504 Posted August 7, 2009 at 11:35 AM Não? No meu não teve problemas, tirando o facto de me aparecer ::1 🙂 ❝The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.❞- John Carmack on software patents A list of command line apps
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now