Guest User

Perfil Face PHP

a guest
Dec 8th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. <?php
  2.  
  3. //_____________________________________________________
  4.  
  5. $usuario = $_GET['user'];
  6. $imagem = Redirect("http://graph.facebook.com/$usuario/picture");
  7.  
  8. $dados = file_get_contents( $imagem );
  9.  
  10. file_put_contents("imagem.jpg", $dados);
  11.  
  12.  
  13. //_____________________________________________________
  14.  
  15. list($width, $height) = getimagesize("imagem.jpg");
  16.  
  17. //________________________________________________
  18.  
  19. $img = imagecreatefromjpeg("imagem.jpg");
  20.  
  21. for($w = 0; $w < $width; $w ++ ) {
  22. for($h = 0; $h < $height; $h ++ ) {
  23.  
  24. $dd = imagecolorat($img, $w, $h);
  25.  
  26. $r = ($dd >> 16) & 0xFF;
  27. $g = ($dd >> 8) & 0xFF;
  28. $b = $dd & 0xFF;
  29.  
  30. echo RGBToHex($r,$g,$b) . "|$w|$h|";
  31.  
  32. }
  33. }
  34.  
  35.  
  36. //_____________________________________________________
  37.  
  38.  
  39. function RGBToHex($r, $g, $b) {
  40.  
  41. $hex = str_pad(dechex($r), 2, "0", STR_PAD_LEFT);
  42. $hex.= str_pad(dechex($g), 2, "0", STR_PAD_LEFT);
  43. $hex.= str_pad(dechex($b), 2, "0", STR_PAD_LEFT);
  44.  
  45. return hexdec($hex."FF");
  46. }
  47.  
  48.  
  49. //_____________________________________________________
  50.  
  51. // Thanks to: http://stackoverflow.com/questions/3519939/make-curl-follow-redirects
  52. function Redirect($url) {
  53. $ch = curl_init();
  54.  
  55. curl_setopt($ch, CURLOPT_URL, $url);
  56. curl_setopt($ch, CURLOPT_HEADER, true);
  57. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
  58. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  59.  
  60. $a = curl_exec($ch);
  61. curl_close( $ch );
  62.  
  63. $headers = explode("\n",$a);
  64. $redir = $url;
  65.  
  66. $j = count($headers);
  67. for($i = 0; $i < $j; $i++){
  68.  
  69. if(strpos($headers[$i],"Location:") !== false){
  70. $redir = trim(str_replace("Location:","",$headers[$i]));
  71. break;
  72. }
  73. }
  74. return $redir;
  75. }
  76.  
  77. //_____________________________________________________
  78.  
  79. unlink("imagem.jpg");
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment