Created
April 24, 2014 10:12
-
-
Save alherd-by/11249177 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$id = $this->in['id']; | |
if ($id == $this->uid || $this->permissions['profile.get_users'] == 3) | |
{ | |
$path = $this->core->path_project . "/images/avatars"; | |
$this->sql->query_var("SELECT * FROM `users` WHERE id=:id", array(':id' => $id)); | |
$data = $this->sql->fetch(); | |
if ($data['vkontakte'] != '') | |
{ | |
$vk_id = $data['vkontakte']; | |
$params = file_get_contents("https://api.vk.com/method/users.get?uids=$vk_id&fields=photo_medium,photo_big"); | |
$param = json_decode($params); | |
$img = file_get_contents($param->response[0]->photo_big); // фотка малая 100 на 100 | |
file_put_contents($path . "/" . $data['id'] . ".jpg", $img); | |
$this->sql->query_var("UPDATE users SET logo_url=:img WHERE id=:id", array(":img" => "/images/avatars/" . $data['id'] . ".jpg", ":id" => $id)); | |
$this->send(array('cmd' => str_replace('::', ':', __METHOD__), 'logo_url' => "/images/avatars/" . $data['id'] . ".jpg")); | |
} | |
else | |
{ | |
$this->send(array('cmd' => str_replace('::', ':', __METHOD__), 'error' => 'Vkontakte field id empty.')); | |
} | |
} | |
else | |
{ | |
$this->send(array('cmd' => str_replace('::', ':', __METHOD__), 'error' => 'Permission denied.')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment