Settings('face_app_id'), 'secret' => Settings('face_app_secret'), )); if (isset($_GET['error']) || isset($_GET['error_code'])) { echo ""; exit(); } $loginUrl = $facebook->getLoginUrl(array( 'scope' => 'email,publish_stream,publish_pages,public_profile', 'canvas' => 0, 'fbconnect' => 1, )); $logoutUrl = $facebook->getLogoutUrl(); $uid = $facebook->getUser(); if ($uid == 0 || !$uid) { echo ""; exit(); } else { try { $me = $facebook->api('/me?fields=first_name,last_name,email,gender,link'); } catch (FacebookApiException $e) { echo ""; exit(); } } //Gelen Bilgiler $faceName = $me['first_name']; $faceLastName = $me['last_name']; $faceEmail = $me['email']; $faceLink = $me['link']; $faceGender = $me['gender'] == 'male' ? 1 : 2; //daha once facelogin ile kayıt olan varmı? // varsa login yap. // yoksa gelen mail ile üye olan varmı? // varsa üye bilgilerini güncelle ve login yap. // yoksa onu üye yap ve login yap $isUser = $db->select('user')->where('facebook_id', $uid)->run(1); if ($isUser) { $_SESSION['u_USER_ID'] = $isUser['user_id']; $_SESSION['u_USER_MAIL'] = $isUser['email']; $_SESSION['u_USER_NAME'] = $isUser['firstname']; $_SESSION['u_USER_SURNAME'] = $isUser['lastname']; $upUser = $db->update('user') ->where('user_id', $isUser['user_id']) ->set(array( 'last_login' => date('Y:m:d H:i:s'), 'last_ip' => $_SERVER['REMOTE_ADDR'] )); } else { $isUserforMail = $db->select('user')->where('email', $faceEmail)->run(1); if ($isUserforMail) { $upUserforMail = $db->update('user') ->where('user_id', $isUserforMail['user_id']) ->set(array( 'facebook_id' => $uid, 'facebook_link' => $faceLink, 'last_login' => date('Y:m:d H:i:s'), 'last_ip' => $_SERVER['REMOTE_ADDR'] )); $_SESSION['u_USER_ID'] = $isUserforMail['user_id']; $_SESSION['u_USER_MAIL'] = $isUserforMail['email']; $_SESSION['u_USER_NAME'] = $isUserforMail['firstname']; $_SESSION['u_USER_SURNAME'] = $isUserforMail['lastname']; } else { $insertUser = $db->insert('user') ->set(array( 'facebook_id' => $uid, 'facebook_link' => $faceLink, 'email' => $faceEmail, 'firstname' => $faceName, 'lastname' => $faceLastName, 'gender' => $faceGender, 'last_login' => date('Y:m:d H:i:s'), 'last_ip' => $_SERVER['REMOTE_ADDR'] )); if ($insertUser) { $returnId = $db->lastInsertId('user'); $_SESSION['u_USER_ID'] = $returnId; $_SESSION['u_USER_MAIL'] = $faceEmail; $_SESSION['u_USER_NAME'] = $faceName; $_SESSION['u_USER_SURNAME'] = $faceLastName; } } } echo ''; }else{ echo ''; } ?>