$url. (strpos($url, '?') === FALSE ? '?' : ''). http_build_query($get), CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_TIMEOUT => 4 ); $ch = curl_init(); curl_setopt_array($ch, ($options + $defaults)); if( ! $result = curl_exec($ch)) { trigger_error(curl_error($ch)); } curl_close($ch); return $result; } $data = @curl_get("https://oauth.vk.com/access_token",array('client_id'=>'3079859','client_secret'=>'l1UuAupvdiL8q8R6J7v3','code'=>trim($_GET['code']))); $datas = @json_decode(@$data); if(trim($datas->user_id)!="") $id_a = @$db->super_query("SELECT * FROM `zlo_users` WHERE `UID`='".$datas->user_id."' LIMIT 1;"); //echo "1"; if(!@$id_a['id'] && trim($datas->user_id)!=''){ $dataf = curl_get("https://api.vk.com/method/getProfiles",array('uid'=>$datas->user_id,'access_token'=>$datas->access_token)); $dataf = json_decode($dataf); $first_name = iconv("UTF-8","cp1251",$dataf->response[0]->first_name); $last_name = iconv("UTF-8","cp1251",$dataf->response[0]->last_name); $db->query("INSERT INTO `zlo_users` (`username`,`group`,`registered`,`mailing`,`UID`) VALUES ('".$first_name." ".$last_name."',2,'".date("Y-m-d H:i:s")."',1,'".trim($datas->user_id)."');"); session_start(); if(trim($first_name)!="" && trim($last_name)!=""){ $_SESSION['user'] = array('id'=>$db->insert_id(),'login'=>$first_name." ".$last_name); @header("Location: /account/info/"); } else @header("Location: /"); }else{ if(@$id_a['username']!=""){ $_SESSION['user'] = array('id'=>@$id_a['id'],'login'=>@$id_a['username']); @header("Location: /account/info/"); }else @header("Location: /"); } ?>