#include a_samp
// =============================================================================
#define URL_******** "brunosilva.net16.net/tubi.php?user=%s"
#define URL_INFORMACOES "graph.********.com/%s/"
// =============================================================================
#if !defined HTTP_ERROR_BAD_HOST
#include a_http
#endif
#if !defined MAX_TEXTS
#define MAX_TEXTS 10000
#endif
#define function::%0(%1) forward %0(%1); public %0(%1)
new textID[MAX_TEXTS + 1];
// ===========================================================================
public OnFilterScriptInit() {
printf("Visualizador de Imagem do Perfil do ******** !!");
return true;
}
public OnFilterScriptExit()
{
return true;
}
public OnPlayerSpawn(playerid) {
SendClientMessage(playerid, -1, "[Info] Caso deseja ver a imagem do perfil /imagemfb [perfil] ..");
return true;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext[1], "deletarfb", true)) {
for(new i; i < MAX_TEXTS-100; i++ ) {
if(bool: textID[i])
{
TextDrawDestroy(Text: i);
}
}
return true;
}
if(!strcmp(cmdtext[1], "imagemfb", true, 8))
{
if( !cmdtext[8] ) {
return SendClientMessage(playerid, -1, "[Erro] Use corretamente: /imagemfb [perfil]");
}
OnPlayerCommandText(playerid, "/deletarfb");
********Check(playerid, cmdtext[10]);
return true;
}
return false;
}
// ===========================================================================
forward ExTextDrawCreate(playerid, x, y, cor);
public ExTextDrawCreate(playerid, x, y, cor) {
new Text:id = TextDrawCreate(float(x)+320-70, float(y)+240-50, ".");
if(_:id < MAX_TEXTS) {
textID [_:id] = 1;
}
TextDrawColor(id, cor);
TextDrawShowForPlayer(playerid, id);
return true;
}
// ===========================================================================
function::********Check(playerid, nome[]) {
SendClientMessage(playerid, -1, "[Info] Pegando informaзхes do ******** !! Aguarde !!");
new link[0xff];
format(link, 0xff, URL_********, nome);
HTTP(playerid, HTTP_GET, link, "\0", "********TratarImagem");
format(link, 0xff, URL_INFORMACOES, nome);
HTTP(playerid, HTTP_GET, link, "\0", "********TratarInformacoes");
return true;
}
#pragma dynamic 400000
function::********TratarInformacoes(playerid, c, data[]) {
if(strlen(data) < 0xf || c != 200)
return SendClientMessage(playerid, -1, "[Erro] Erro ao pegar informacoes!");
/////////////////////////////////////////////////////////
new genero[24];
if(!strcmp(jsonGet(data, "gender"), "male")) {
genero = "masculino";
}
else {
genero = "feminino";
}
////////////////////////////////////////////////////////
new espaco[2]; espaco = " ";
new dialog[1024];
format(dialog, 1024,
"\
{FF0000}Foto:\n\n\
%50s{FF0000}Nome: {FFFFFF}%s\n\
%50s{FF0000}Pais: {FFFFFF}%s\n\
%50s{FF0000}Gкnero: {FFFFFF}%s\n\n\n\n\
",
espaco, jsonGet(data, "name"),
espaco, jsonGet(data, "locale"),
espaco, genero
);
ShowPlayerDialog(playerid, 0xfff, DIALOG_STYLE_MSGBOX, "******** Info", dialog, "Fechar", "");
return true;
}
function::********TratarImagem(playerid, c, data[]) {
if(strlen(data) < 0xFF || c != 200)
return SendClientMessage(playerid, -1, "[Erro] Erro ao baixar a imagem!");
new array[8000][11];
SendClientMessage(playerid, -1, "[Info] Carregando a imagem na tela !!");
data[strfind(data, "<!--")] = EOS;
split(data, array, '|');
static
pixel_c,
pixel_x,
pixel_y;
for(new i; i < 8000; i += 3) {
if(strlen(array[i])) {
pixel_c = ((strval( array[i] ))) ;
pixel_x = strval( array[i + 1] );
pixel_y = strval( array[i + 2]);
ExTextDrawCreate(playerid, pixel_x, pixel_y, pixel_c);
}
}
return true;
}
//
// split function
// pego na wiki !
//
function::split(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc))
{
if(strsrc[i] == delimiter || i == strlen(strsrc))
{
len = strmid(strdest[aNum], strsrc, li, i, 11);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
//
// jsonGet
// pegar um dado json e filtra- lo
// por bruno da si lva
///
jsonGet(json[], jsonid[])
{
//////////////////////////////
new json_info[72];
new json_value[72];
format(json_info, 72, "\"%s\":\"", jsonid);
new i = strfind(json, json_info);
if(i != -1)
{
format(json_value, 56, "%s", json[i+ strlen(json_info)]);
i = strfind(json_value, "\"");
if(i != -1) {
json_value[i] = EOS;
}
}
return json_value;
//////////////////////////////
}
<?php
//_____________________________________________________
$usuario = $_GET['user'];
$imagem = Redirect("http://graph.********.com/$usuario/picture");
$dados = file_get_contents( $imagem );
file_put_contents("imagem.jpg", $dados);
//_____________________________________________________
list($width, $height) = getimagesize("imagem.jpg");
//________________________________________________
$img = imagecreatefromjpeg("imagem.jpg");
for($w = 0; $w < $width; $w ++ ) {
for($h = 0; $h < $height; $h ++ ) {
$dd = imagecolorat($img, $w, $h);
$r = ($dd >> 16) & 0xFF;
$g = ($dd >> 8) & 0xFF;
$b = $dd & 0xFF;
echo RGBToHex($r,$g,$b) . "|$w|$h|";
}
}
//_____________________________________________________
function RGBToHex($r, $g, $b) {
$hex = str_pad(dechex($r), 2, "0", STR_PAD_LEFT);
$hex.= str_pad(dechex($g), 2, "0", STR_PAD_LEFT);
$hex.= str_pad(dechex($b), 2, "0", STR_PAD_LEFT);
return hexdec($hex."FF");
}
//_____________________________________________________
// Thanks to: http://stackoverflow.com/questions/3519939/make-curl-follow-redirects
function Redirect($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$a = curl_exec($ch);
curl_close( $ch );
$headers = explode("\n",$a);
$redir = $url;
$j = count($headers);
for($i = 0; $i < $j; $i++){
if(strpos($headers[$i],"Location:") !== false){
$redir = trim(str_replace("Location:","",$headers[$i]));
break;
}
}
return $redir;
}
//_____________________________________________________
unlink("imagem.jpg");
?>
Antes que eu me esqueзa!
Agradecimentos a Joгo Pedro por ter me criado o hosting lб na 000web ![]() |
A unica coisa ruim й que quando a foto do perfil estб na dialog fica muito escura D: Serб que nгo tem como a foto ficar por 'cima' da dialog ?
|
O ъnico que nгo saiu na print foi eu -Okay, depois quando eu nгo te ensinar a programar, nгo vб achar ruim ein! -q
GenialІ. xD |
Bruno, essa й retirada direto do perfil do ******** mesmo ?
|
Obrigado pessoal
![]() Coloquei mais imagens! pra que me pediu em privado, sim, a imagem й retirada direto do ******** ¬¬ ![]() |