/** * @param string $logoutUrl */ public function logout($logoutUrl = '') { if (empty($logoutUrl)) { $logoutUrl = self::$object->getLogoutUrl(array('next' => self::getRedirectUrl() . '#postJobs')); } self::$object->setAccessToken(''); self::$object->destroySession(); SJB_HelperFunctions::redirect($logoutUrl); }
public function logout() { $this->session->sess_destroy(); include dirname(dirname(dirname(__FILE__))) . '/fb/src/facebook.php'; $facebook = new Facebook(array('appId' => appId, 'secret' => secret)); $fb_users = $facebook->getUser(); $facebook->destroySession(); redirect('/'); }
/** * Soft logout, delete everything links to the customer * but leave there affiliate's informations * * @since 1.5.0 */ public function mylogout() { if (file_exists(_PS_ROOT_DIR_ . '/modules/fbconnect_psb/fb_sdk/facebook.php')) { include _PS_ROOT_DIR_ . '/modules/fbconnect_psb/fb_sdk/facebook.php'; $facebook = new Facebook(array('appId' => Configuration::get('FB_CONNECT_APPID'), 'secret' => Configuration::get('FB_CONNECT_APPKEY'))); $facebook->destroySession(); } parent::mylogout(); }
public function startFacebookSession($params = array('scope' => '')) { //I need to make sure the session is started before facebook does it's thing $this->Session->check("FacebookID"); //This just makes sure the session is started // Create an application instance with Younique's App ID and Secret (can be found or reset in the App settings on developer.facebook.com) $this->set("facebookloginurl", Router::url(["controller" => "account", "action" => "signin"], true)); $this->facebookuser = $this->facebook->getUser(); if ($this->facebookuser) { try { $this->facebookprofile = $this->facebook->api('/me'); return $this->facebookuser; } catch (FacebookApiException $e) { error_log($e); $this->facebook->destroySession(); $this->facebookuser = null; $this->facebookprofile = null; } } return null; }
function nextend_api_auth_flow() { $api_key = NextendRequest::getVar('api_key'); $api_secret = NextendRequest::getVar('api_secret'); $redirect_uri = NextendRequest::getVar('redirect_uri'); if (session_id() == "") { @session_start(); } if (!$api_key || !$api_secret || !$redirect_uri) { $api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null; $api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null; $redirect_uri = isset($_SESSION['redirect_uri']) ? $_SESSION['redirect_uri'] : null; } else { $_SESSION['api_key'] = $api_key; $_SESSION['api_secret'] = $api_secret; $_SESSION['redirect_uri'] = $redirect_uri; } if ($api_key && $api_secret) { require_once dirname(__FILE__) . "/api/facebook.php"; $facebook = new Facebook(array('appId' => $api_key, 'secret' => $api_secret)); $user = $facebook->getUser(); if (!$user) { header('Location: ' . $facebook->getLoginUrl(array('redirect_uri' => $redirect_uri, 'scope' => 'user_photos'))); exit; } else { $facebook->setExtendedAccessToken(); $accessToken = $facebook->getAccessToken(); $facebook->destroySession(); unset($_SESSION['api_key']); unset($_SESSION['api_secret']); unset($_SESSION['redirect_uri']); echo '<script type="text/javascript">'; echo 'window.opener.setToken("' . $accessToken . '");'; echo '</script>'; } } }
public static function distroy_fb_session() { $myparams = JComponentHelper::getParams('com_fbconnct'); $mainframe = JFactory::getApplication(); $getappid = $myparams->get('appid'); $getappsec = $myparams->get('appsecret'); $facebook = new Facebook(array('appId' => $getappid, 'secret' => $getappsec)); $fbuser = $facebook->getUser(); $loginUser_url = JRoute::_('index.php?task=login&option=com_fbconnct&format=raw'); if ($fbuser) { $facebook->destroySession(); $mainframe->redirect($loginUser_url); } }
/** * {@inheritdoc} */ function logout() { $this->api->destroySession(); parent::logout(); }
$loginUrl = $facebook->getLoginUrl(); } include "connectdb.php"; // Save to mysql if ($user) { if ($_GET["code"] != "") { $strSQL = " INSERT INTO tb_facebook (FACEBOOK_ID,NAME,LINK,CREATE_DATE) \n\t\t\t\t\tVALUES\n\t\t\t\t\t('" . trim($user_profile["id"]) . "',\n\t\t\t\t\t'" . trim($user_profile["name"]) . "',\n\t\t\t\t\t'" . trim($user_profile["link"]) . "',\n\t\t\t\t\t'" . trim(date("Y-m-d H:i:s")) . "')"; $objQuery = mysql_query($strSQL); mysql_close(); header("location:indexfb.php"); exit; } } // Logout if ($_GET["Action"] == "Logout") { $facebook->destroySession(); header("location:index.php"); exit; } ?> <!doctype html> <html xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <title>php-sdk</title> <style> body { font-family: 'Lucida Grande', Verdana, Arial, sans-serif; } h1 a { text-decoration: none; color: #3b5998;
<?php define("FACEBOOK_ROOT", dirname(__FILE__) . "/.."); require_once FACEBOOK_ROOT . "/common.php"; // yes, this is messy. no, I don't care. function endOutput($html = "", $exit = true) { echo $html . "\n</body>\n</html>\n"; if ($exit) { exit; } } // we're not going to be uploading content to Facebook, so fileUpload can be false $fb = new Facebook(array("appId" => FACEBOOK_APP_ID, "secret" => FACEBOOK_APP_SECRET, "fileUpload" => false, "allowSignedRequest" => false)); if (isset($_GET["logout"])) { $fb->destroySession(); header("Location: {$_SERVER['PHP_SELF']}"); exit; } if (isset($_POST["gid"])) { $gid = $_POST["gid"]; if ($gid + 0 == $gid && is_int($gid + 0)) { // TODO: completely refactor this into a sustainable [i.e. offline] form $db = mysqli_connect(FACEBOOK_DB_SERVER, FACEBOOK_DB_USERNAME, FACEBOOK_DB_PASSWORD, FACEBOOK_DB_NAME); mysqli_set_charset($db, "utf8mb4"); if (mysqli_connect_error()) { endOutput('<p class="error">Unable to connect to the database. Please check the connection settings and try again.</p>'); } $dbPost = mysqli_prepare($db, "insert into posts (gid, post_id, user_id, created_time, updated_time, message, permalink, last_fetched) values (?, ?, ?, ?, ?, ?, ?, utc_timestamp()) on duplicate key update last_fetched = utc_timestamp(), fetch_count = fetch_count + 1, updated_time = values(updated_time), message = values(message), permalink = values(permalink)"); $dbComment = mysqli_prepare($db, "insert into comments (gid, comment_id, attached_to, attached_type, parent_id, user_id, created_time, message, last_fetched) values (?, ?, ?, ?, ?, ?, ?, ?, utc_timestamp()) on duplicate key update last_fetched = utc_timestamp(), fetch_count = fetch_count + 1, message = values(message)"); $dbPhoto = mysqli_prepare($db, "insert into photos (gid, photo_id, attached_to, attached_type, album_id, owner_id, height, width, src, src_ext, src_big, src_big_ext, caption, permalink) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) on duplicate key update last_fetched = utc_timestamp(), fetch_count = fetch_count + 1, album_id = values(album_id), height = values(height), width = values(width), src = values(src), src_ext = values(src_ext), src_big = values(src_big), src_big_ext = values(src_big_ext), caption = values(caption), permalink = values(permalink)");
/** * Function to login with Facebook and store Oauth tokens * @author Rohan Julka * */ public function fbLogin($userIdApp = null) { $userId = !empty($userIdApp) ? $userIdApp : $this->Session->read('Auth.Front.id'); $userIsConnected = $this->User->find('first', array('conditions' => array('User.id' => array($this->Encryption->decode($userId))), 'fields' => array('User.fb_connected'))); if (!empty($userIsConnected['User']['fb_connected'])) { $this->Session->setFlash('Your Facebook account has already been linked', 'Front/flash_good'); if (!empty($userIdApp)) { $this->redirect('foxhoprapplication://alreadyfacebook'); } else { return $this->redirect(array('controller' => 'businessOwners', 'action' => 'social', 'facebook')); } } if (!empty($userIdApp)) { $this->Session->write('Auth.Front.id', $userIdApp); $this->Session->write('AccessedBy', 'WebService'); } //Call Facebook API $facebook = new Facebook(array('appId' => Configure::read('appId'), 'secret' => Configure::read('appSecret'))); $fbuser = $facebook->getUser(); if ($fbuser) { try { $accessToken = $facebook->getAccessToken(); $loginUserId = $this->Encryption->decode($this->Session->read('Auth.Front.id')); $this->User->id = $loginUserId; $this->User->save(array('User' => array('fb_connected' => 1, 'fb_access_token' => "{$accessToken}"))); $buisnessOwndata = $this->BusinessOwner->find('first', array('conditions' => array('User.id' => $loginUserId))); if (!empty($buisnessOwndata)) { $fbData = $buisnessOwndata['BusinessOwner']['notifications_enabled']; $fbData .= ',fbReferralSend,fbMessageSend,fbInviteSend'; $this->BusinessOwner->id = $this->Encryption->decode($buisnessOwndata['BusinessOwner']['id']); $this->BusinessOwner->saveField('notifications_enabled', $fbData); } $this->Session->setFlash('Your Facebook account has been successfully linked', 'Front/flash_good'); $facebook->destroySession(); $checkAccessSession = $this->Session->read('AccessedBy'); if (!empty($checkAccessSession)) { $this->Session->delete('AccessedBy'); $this->Session->delete('Auth.Front.id'); $this->redirect('foxhoprapplication://facebook'); } $this->redirect(array('controller' => 'businessOwners', 'action' => 'social', 'facebook')); } catch (FacebookApiException $e) { echo $e->getMessage(); $fbuser = null; } } else { //Show login button for guest users $loginUrl = $facebook->getLoginUrl(array('redirect_uri' => Configure::read('SITE_URL') . 'businessOwners/fbLogin', 'scope' => Configure::read('fbPermissions'))); $fbuser = null; // Reditrect to facebook to login $this->redirect($loginUrl); } exit; }
public function ajax_set_google_vote() { $poll_id = xss_clean(yop_poll_base64_decode($_GET['poll_id'])); $unique_id = xss_clean(yop_poll_base64_decode($_GET['unique_id'])); require_once YOP_POLL_MODELS . 'poll_model.php'; $yop_poll_model = new YOP_POLL_Poll_Model($poll_id); $publish = false; $error = ''; if (isset($_GET['error'])) { $error = $_GET['error']; } else { require_once YOP_POLL_PATH . "lib/Google/facebook.php"; $options = get_option('yop_poll_options'); if (isset($options['google_integration']) && 'yes' == $options['google_integration']) { if (isset($options['google_appID']) && '' != $options['google_appID']) { if (isset($options['google_appSecret']) && '' != $options['google_appSecret']) { $config = array('appId' => $options['google_appID'], 'secret' => $options['google_appSecret'], 'allowSignedRequest' => false, 'cookie' => true); $facebook = new Facebook($config); $user = $facebook->getUser(); // We may or may not have this data based on whether the user is logged in. // // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($user) { try { $fb_user_details = $facebook->api("/me"); $return_data = array('user_details' => array('id' => $user, 'name' => $fb_user_details['name'], 'first_name' => $fb_user_details['first_name'], 'last_name' => $fb_user_details['last_name'], 'username' => $fb_user_details['username'], 'email' => $fb_user_details['email'], 'link' => $fb_user_details['link'], 'gender' => $fb_user_details['gender'], 'picture' => 'https://graph.facebook.com/' . $user . '/picture')); $facebook_user_details = yop_poll_base64_encode(json_encode($return_data)); $permissions = $facebook->api("/me/permissions"); if ($permissions[0]['publish_stream']) { $publish = true; } } catch (FacebookApiException $e) { echo "access token not available"; $error = $e; } } else { $error = __yop_poll("Please log in to cast your vote"); } } else { $error = __yop_poll('Request Failed'); } } else { $error = __yop_poll('Request Failed'); } } else { $error = __yop_poll('Request Failed'); } $public_config = array('poll_options' => array('share_after_vote' => $yop_poll_model->share_after_vote, 'share_name' => html_entity_decode((string) $yop_poll_model->share_name, ENT_QUOTES, 'UTF-8'), 'share_caption' => html_entity_decode((string) $yop_poll_model->share_caption, ENT_QUOTES, 'UTF-8'), 'share_description' => html_entity_decode((string) $yop_poll_model->share_description, ENT_QUOTES, 'UTF-8'), 'share_picture' => html_entity_decode((string) $yop_poll_model->share_picture, ENT_QUOTES, 'UTF-8'), 'share_poll_name' => html_entity_decode((string) $yop_poll_model->title, ENT_QUOTES, 'UTF-8'), 'share_link' => $yop_poll_model->poll_options['poll_page_url'] == '' ? site_url() : $yop_poll_model->poll_page_url, 'redirect_after_vote' => html_entity_decode((string) $yop_poll_model->redirect_after_vote, ENT_QUOTES, 'UTF-8'), 'redirect_after_vote_url' => html_entity_decode((string) $yop_poll_model->redirect_after_vote_url, ENT_QUOTES, 'UTF-8'))); } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript"> function close_window() { var yop_poll_various_config = new Object(); yop_poll_various_config.poll_id = '<?php echo yop_poll_base64_decode($_GET['poll_id']); ?> '; yop_poll_various_config.unique_id = '<?php echo yop_poll_base64_decode($_GET['unique_id']); ?> '; yop_poll_various_config.poll_location = '<?php echo yop_poll_base64_decode($_GET['poll_location']); ?> '; yop_poll_various_config.is_modal = <?php echo yop_poll_base64_decode($_GET['is_modal']) == 'true' ? 'true' : 'false'; ?> ; yop_poll_various_config.vote_loading_image_target = '<?php echo yop_poll_base64_decode($_GET['vote_loading_image_target']); ?> '; yop_poll_various_config.vote_loading_image_id = '<?php echo yop_poll_base64_decode($_GET['vote_loading_image_id']); ?> '; yop_poll_various_config.vote_type = '<?php echo yop_poll_base64_decode($_GET['vote_type']); ?> '; yop_poll_various_config.facebook_user_details = '<?php echo $facebook_user_details; ?> '; yop_poll_various_config.facebook_error = '<?php echo $error; ?> '; yop_poll_various_config.public_config = <?php echo json_encode($public_config); ?> ; window.opener.jQuery( '#yop-poll-nonce-' + yop_poll_various_config.poll_id + yop_poll_various_config.unique_id ).val( '<?php echo wp_create_nonce('yop_poll-' . $poll_id . $unique_id . '-user-actions'); ?> ' ); result = window.opener.yop_poll_do_vote( yop_poll_various_config ); if( result ) { window.close(); } } </script> </head> <body onload="close_window()"> <div style="margin:auto; width: 100px; height: 100px; text-align: center;"> <img src="<?php echo YOP_POLL_URL; ?> images/loading100x100.gif" alt="<?php _e('Loading', 'yop_poll'); ?> "/><br> </div> </body> </html> <?php $facebook->destroySession(); die; }
/** jika user tutup browser tanpa login, maka time_end yg tersimpan adl time last request saat user login, cek apakah ada data di table session utk user_id dia jika ada, pindahkan dulu datanya ke table SessionLog (user_id, session_id, time_start, time_end), baru kemudian data di Session dihapus table SessionLog ini yg digunakan utk menghitung achievement 'online_time' */ function user_user_logout() { // hapus session terkait login // mengeset field time_end di table Session $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Users'); if (isset($_SESSION['session_id'])) { $session_id = $_SESSION['session_id']; $lilo_mongo->selectCollection('Session'); $array_criteria = array('session_id' => $session_id); // sementara hapus dulu data di Session // informasi tentang time_start dan time_end nantinya disimpan di table lain $session_data = $lilo_mongo->findOne($array_criteria); // $cur_date = date("Y-m-d H:i:s"); // $array_newobj = array('$set' => array('time_end' => $cur_date)); // $array_options = array('upsert' => true); // // $lilo_mongo->update($array_criteria, $array_newobj, $array_options); $array_criteria = array('user_id' => $_SESSION['user_id']); $lilo_mongo->delete($array_criteria); $lilo_mongo->selectCollection('SessionLog'); $lilo_mongo->insert($session_data); } // die("<pre>" . print_r($_SESSION, true) . "<pre>"); unset($_SESSION['session_id']); unset($_SESSION['username']); unset($_SESSION['user_id']); $redirect_to_fb_logout = 0; if (isset($_SESSION['fb_id'])) { $redirect_to_fb_logout = 1; } unset($_SESSION['fb_me']); unset($_SESSION['fb_id']); unset($_SESSION['signed_request']); $basepath = $_SESSION['basepath']; $config = array(); $config['appId'] = '353789864649141'; $config['secret'] = '9e066419bed7d9ff07f4475f26318aa8'; $config['fileUpload'] = false; // optional $facebook = new Facebook($config); $fb_logoutUrl = $facebook->getLogoutUrl(); $facebook->destroySession(); session_start(); session_unset(); session_destroy(); session_write_close(); setcookie(session_name(), '', 0, '/'); session_regenerate_id(true); // ob_start(); // session_start(); /*$_SESSION['just_logout'] = 1;*/ // die("<pre>" . print_r($_SESSION, true) . "</pre>"); if ($redirect_to_fb_logout) { // header("Location: " . $_SESSION['fb_logoutUrl']); write_log(array('log_text' => time() . ": Redirect ke logouturl: " . $fb_logoutUrl)); header("Location: " . $fb_logoutUrl); // header("Location: " . $_SESSION['fb_logoutUrl']); exit; } // header("Location: " . $_SESSION['basepath']); header("Location: " . $basepath); exit; $html = "<script>\r\n\t\tvar oauth_url = '" . $basepath . "';\r\n\t\twindow.top.location = oauth_url;\r\n\t\t\r\n\t</script>"; write_log(array('log_text' => time() . ": Redirect dgn html: " . $html)); print $html; exit; // return "1"; }
public function logout() { require ROOT . '/config/fbApi/facebook.php'; $facebook = new Facebook(array('appId' => '1681772598704166', 'secret' => '4b6804fc91280077edf58ebb3a55a4e2')); $facebook->destroySession(); echo "<script>window.location.href='" . BASE . "'</script>"; die; }
function fbLogout() { $facebook = new Facebook(array('appId' => '1458199551164642', 'secret' => 'c85e0bc13252f28f0f27a8b0e88e7dc2')); $facebook->destroySession(); echo "<script>window.location.href ='" . base_url() . "';</script>"; }
/** * Log the user out of the application. * * @return \Illuminate\Http\Response */ public function getLogout() { $facebook = new \Facebook(\Config::get('facebook')); $this->auth->logout(); $uid = $facebook->getUser(); if ($uid != 0) { $params = array('next' => url('/facebook/callback')); $facebookLogoutUrl = $facebook->getLogoutUrl($params); $facebook->destroySession(); return redirect($facebookLogoutUrl); } return redirect('/'); }