public function signinfromwidgetAction() { try { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $request = $this->getRequest(); $storage = new Zend_Auth_Storage_Session(); $data = $storage->read(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity() && isset($data['User_Id'])) { if (isset($request->code)) { echo "<script type=\"text/javascript\">"; echo "window.opener.location.href = '" . $loginProfile['widgetlink'] . "';window.close(); </script>"; } else { echo 'auth'; } } else { if (isset($request->error_reason) && isset($request->error)) { $auth->clearIdentity(); echo "<script type=\"text/javascript\">"; echo "window.close(); </script>"; } else { $storage = new Zend_Auth_Storage_Session('fblogin'); $data = $storage->read(); $auth = Zend_Auth::getInstance(); /* facebook*/ include 'facebook/src/facebook.php'; $app_id = "1701350336753170"; $app_secret = "a9feac008bab4610efcb5082158f4858"; $my_url = "http://www.rdine.com/User/Client/signinfromwidget"; $loginProfile = $data; if (isset($request->widgetlink)) { $loginProfile['widgetlink'] = $request->widgetlink; } $facebook = new Facebook(array('appId' => '1701350336753170', 'secret' => 'a9feac008bab4610efcb5082158f4858')); $code = $request->code; if (empty($code)) { $loginProfile['state'] = md5(uniqid(rand(), TRUE)); // CSRF protection $dialog_url = "https://www.facebook.com/dialog/oauth?display=popup&domain=www.rdine.com&locale=en_US&client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=email&state=" . $loginProfile['state']; // echo '<a href="'.$dialog_url.'" onclick="window.open (this.href, "child", "height=400,width=300"); return false">Click to log out</a>'; $storage->write($loginProfile); echo $dialog_url; } if ($loginProfile['state'] && $loginProfile['state'] === $request->state) { $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&client_secret=" . $app_secret . "&code=" . $code . "&scope=email"; try { $response = file_get_contents($token_url); $params = null; parse_str($response, $params); $loginProfile['access_token'] = $params['access_token']; $graph_url = "https://graph.facebook.com/me?access_token=" . $params['access_token']; $user = json_decode(file_get_contents($graph_url)); $emailObj = new User_Model_Signin(); $emailObj->setEmailAddress(strtolower(trim($user->email))); $result = $this->_userService->manageLoginProfileWidget($user, $loginProfile); if ($result['Status']) { $auth->clearIdentity(); $auth = Zend_Auth::getInstance(); $storage = new Zend_Auth_Storage_Session(); $storage->write($result['loginprofile']); echo "<script type=\"text/javascript\">"; echo "window.opener.location.href = '" . $loginProfile['widgetlink'] . "';window.close(); </script>"; } else { $auth->clearIdentity(); echo "<script type=\"text/javascript\">"; echo "window.close(); </script>"; } } catch (Exception $e) { unset($loginProfile['access_token']); $storage->write($loginProfile); } } } } } catch (Exception $ex) { throw new Exception($ex->getMessage()); } }
public function getEmailStatus(User_Model_Signin $email) { try { $db = Zend_Db_Table::getDefaultAdapter(); $result = $db->fetchOne("select count(usremail) from rd.user where usremail= :title", array('title' => $email->getEmailAddress())); if ($result == 1) { $status = true; } else { $status = false; } return $status; } catch (Exception $ex) { throw new Exception($ex->getMessage()); } }