diff --git a/e107_plugins/facebook/facebook.js b/e107_plugins/facebook/facebook.js
index 227f74bcb..3930ec21c 100644
--- a/e107_plugins/facebook/facebook.js
+++ b/e107_plugins/facebook/facebook.js
@@ -52,7 +52,7 @@ function facebook_onload(already_logged_into_facebook) {
* dialog and the Facebook session has been set in the cookies.
*/
function facebook_onlogin_ready() {
-FB.Connect.ifUserConnected("/news.php?login", null);
+FB.Connect.ifUserConnected("/index.php?login", null);
// In this app, we redirect the user back to index.php. The server will read
// the cookie and see that the user is logged in, and will deliver a new page
// with content appropriate for a logged-in user.
diff --git a/e107_plugins/facebook/facebook_function.php b/e107_plugins/facebook/facebook_function.php
index 0843164f2..c87d01ee3 100644
--- a/e107_plugins/facebook/facebook_function.php
+++ b/e107_plugins/facebook/facebook_function.php
@@ -10,8 +10,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/facebook/facebook_function.php,v $
- | $Revision: 1.5 $
- | $Date: 2009-11-10 13:41:41 $
+ | $Revision: 1.6 $
+ | $Date: 2009-11-10 15:25:50 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -108,7 +108,16 @@ function Add_Facebook_Connect_User($info = '', $user_id)
}
- $sql->db_Insert('facebook', $query);
+ if(!$sql->db_Select('facebook',"facebook_user_id = ".$user_id))
+ {
+ $sql->db_Insert('facebook', $query);
+ }
+ else
+ {
+ $query['WHERE'] = "facebook_uid = ".is_fb();
+ $sql->db_Update('facebook', $query);
+ }
+
}
@@ -273,10 +282,13 @@ function Fb_Connect_Me()
$nid = $sql->db_Insert('user', array('user_name'=>$nickname, 'user_loginname'=>$username, 'user_password'=>$password, 'user_login'=>Get_Facebook_Info('name'), 'user_image'=>Get_Facebook_Info('pic')));
- Add_Facebook_Connect_User('', $nid);
+ Add_Facebook_Connect_User('', $nid);
+
+ require_once(e_HANDLER.'login.php');
+ $usr = new userlogin($row['user_loginname'], md5($row['user_name'].$row['user_password'].$row['user_join']), 'signup', '');
+
set_cookies($nid, md5($password));
-
- fb_redirect(e_SELF);
+ // fb_redirect(e_SELF);
}
}
@@ -389,17 +401,8 @@ function Get_Connection_Status()
*/
function Facebook_User_Is_Connected()
{
- $sql = e107::getDb();
-
- if ($sql->db_Select("facebook", "*", "facebook_user_id = '".get_id_from_uid(is_fb())."' AND facebook_uid = ".is_fb()." "))
- {
- return true;
-
- }
- else
- {
- return false;
- }
+ $sql = e107::getDb(); //
+ return ($sql->db_Select("facebook", "*", "facebook_user_id = '".get_id_from_uid(is_fb())."' AND facebook_uid = ".is_fb()." "))? TRUE : FALSE;
}
/**
@@ -846,7 +849,7 @@ function get_info($info, $uid)
function Log_In_Registered_User()
{
- if (!USER)
+ if (!USERID)
{
$uid = get_id_from_uid(is_fb());
set_cookies(get_info('user_id', $uid), md5(get_info('user_password', $uid)));
@@ -884,3 +887,123 @@ function fb_redirect($loc)
header('Content-Length: 0');
exit();
}
+
+
+class e_facebook
+{
+
+ function fb_login()
+ {
+ global $pref;
+
+
+ if (!vartrue($pref['user_reg']))
+ {
+ if (ADMIN)
+ {
+ $html = "User Registration is turned off.";
+ }
+ return $html;
+ }
+
+ $fb_pref = e107::getPlugConfig('facebook')->getPref();
+
+ if (vartrue($fb_pref['Facebook_Api-Key']) && vartrue($fb_pref['Facebook_Secret-Key']))
+ {
+
+ if (USER)
+ {
+
+ if (USERID == get_id_from_uid(is_fb()))
+ {
+
+ if (Facebook_User_Is_Connected() === true)
+ {
+ $html .= Render_Facebook_Profile();
+ $html .= Render_Connect_Invite_Friends();
+
+ }
+ else
+ {
+
+ $html .= uid_check();
+
+ }
+
+ }
+ else
+ {
+ if (is_fb() && uid_exists() && (single_uid() == 1))
+ {
+
+ Add_Facebook_Connect_User('', USERID);
+ header('Location:'.e_SELF);
+
+
+ }
+ else if (is_fb() && (USERID != get_id_from_uid(is_fb())))
+ {
+
+ //return Facebook_LogOut();
+
+ $html .= uid_check();
+
+ }
+
+ }
+ if ((Get_Connection_Status() == '') && (Facebook_User_Is_Connected() === true))
+ {
+
+ $html .= uid_check();
+
+ }
+ else
+ {
+ $html .= Render_Facebook_Connect_Button();
+
+ }
+
+ }
+ else
+ {
+
+ if (is_fb())
+ {
+
+ if (Get_Connection_Status() == '')
+ {
+
+ $html .= '
+
+ ';
+
+ // Fb_Connect_Me();
+
+ }
+ else if (Get_Connection_Status() == 1)
+ {
+ //not a real error! just some problem with Facebook ID
+
+ $html .= 'Ops... Some error Occur';
+ }
+ else if (Get_Connection_Status() == 0)
+ {
+ $html .= Render_Fcuk_Facebook_Connect_Button();
+
+ }
+
+ }
+
+ $html .= Render_Facebook_Connect_Button();
+
+ }
+
+ }
+
+
+ return $html;
+
+
+ }
+
+}
diff --git a/e107_plugins/facebook/fb_login_menu.php b/e107_plugins/facebook/fb_login_menu.php
index fc929f4d3..e7d2dfe27 100644
--- a/e107_plugins/facebook/fb_login_menu.php
+++ b/e107_plugins/facebook/fb_login_menu.php
@@ -13,120 +13,8 @@ if (isset($_POST['fb_sig_in_canvas']))
return;
}
-/**
- * start the logic...
- *
- */
-
-global $pref;
-
-if (!vartrue($pref['user_reg']))
-{
- if (ADMIN)
- {
- $ns->tablerender("Facebook", "User Registration is turned off.");
- }
- return;
-}
-
-$fb_pref = e107::getPlugConfig('facebook')->getPref();
-
-if (vartrue($fb_pref['Facebook_Api-Key']) && vartrue($fb_pref['Facebook_Secret-Key']))
-{
-
- if (USER)
- {
-
- if (USERID == get_id_from_uid(is_fb()))
- {
-
- if (Facebook_User_Is_Connected() === true)
- {
-
- $html .= Render_Facebook_Profile();
-
- $html .= Render_Connect_Invite_Friends();
-
- }
- else
- {
-
- $html .= uid_check();
-
- }
-
- }
- else
- {
- if (is_fb() && uid_exists() && (single_uid() == 1))
- {
-
- Add_Facebook_Connect_User('', USERID);
-
- header('Location:'.e_SELF);
-
-
- }
- else if (is_fb() && (USERID != get_id_from_uid(is_fb())))
- {
-
- //return Facebook_LogOut();
-
- $html .= uid_check();
-
- }
-
- }
- if ((Get_Connection_Status() == '') && (Facebook_User_Is_Connected() === true))
- {
-
- $html .= uid_check();
-
- }
- else
- {
-
- $html .= Render_Facebook_Connect_Button();
-
- }
-
- }
- else
- {
-
- if (is_fb())
- {
-
- if (Get_Connection_Status() == '')
- {
-
- $html .= '
-
- ';
-
- // Fb_Connect_Me();
-
- }
- else if (Get_Connection_Status() == 1)
- {
- //not a real error! just some problem with Facebook ID
-
- $html .= 'Ops... Some error Occur';
- }
- else if (Get_Connection_Status() == 0)
- {
-
- $html .= Render_Fcuk_Facebook_Connect_Button();
-
- }
-
- }
-
- $html .= Render_Facebook_Connect_Button();
-
- }
-
-}
+$fb = e107::getSingleton('e_facebook',e_PLUGIN.'facebook/facebook_function.php');
+$html = $fb->fb_login();
$caption = 'Facebook';
// $text = $tp->parseTemplate($html, true, $facebook_shortcodes);