0 Members and 1 Guest are viewing this topic.

*

CBG

  • *****
  • 953
    • osDate Forum
  • osDate Version: osDateEvo v1.2
Facebook Login Mod
« on: September 25, 2017, 09:39:26 AM »
This is a updated Facebook Login based on Vink's version.
Should work with osDate v2.19 to 2.6.5 and osDate Evo.

The way Vink FB Mod worked it suggested for the member to change their password, but by doing this, it meant they could no longer login with Facebook.
This is no longer a problem :)

As standard Facebook will only providers email, first name, last name and gender.
To get around this, after the member has logged in for the furst time, it ask them for variuos details.



How to setup a Facebook App ID
1. Go to: https://developers.facebook.com/
2. Login if you are not already
3. Put your mouse over My Apps
4. Click on Add a New App
5. Give it a display name and click Create App ID
6. Pick Facebook Login and click Set Up on the Select a Products
7. On 'Choose a Platform' click on: Web
8. Enter the website address to your osDate and Click Save
9. On the Left click on Settings (Under Prodicts -> Facebook Login)
10. You should be taken to Client OAuth Settings
11. For 'Valid OAuth redirect URIs' You need to enter your website address to your osDate
12. Change 'Use Strict Mode for Redirect URIs' to 'Yes'
13. Click Save Changes'
14. On the Left click on 'App Review'
15. Change 'Make osdate public?' to Yes
16. At the to you will see App ID: you need to copy this as it needed.

First please BACKUP your files and database


Step 1.
Download the attached file in this post and extract it.


Step 1.1.
Open: facebook/fbconfig.php

Add your Facebook App ID.


Step 2.
Open phpMyAdmin and go to the database you install osDate into.
- I am persuming you are using osdate as your database prefix, if not change it.

Then click on Import and add the following in the box:

Code: [Select]
CREATE TABLE `osdate_facebook` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` varchar(254) NOT NULL,
  `username` varchar(254) NOT NULL,
  `firstname` varchar(254) NOT NULL,
  `lastname` varchar(254) NOT NULL,
  `email` varchar(254) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


Step 3.
Open: /temp/myconfigs/config.php

Find:
Code: [Select]
define('PROMO_USED_TABLE', DB_PREFIX . '_promo_used');


Add After:
Code: [Select]
define('FB_TABLE', DB_PREFIX . '_facebook');



Step 4.
Open: /includes/internal/Functions.php

Find:
Code: [Select]
$osDB->query('delete from ! where userid = ? or ref_userid = ?', array(USER_WATCHED_PROFILES, $userId, $userId) );


After Add
Code: [Select]
$osDB->query('DELETE FROM ! WHERE username = ?', array(FB_TABLE, $username));


Step 5.
Open: index.php

Find:
Code: [Select]
if ( strlen( $_SERVER['QUERY_STRING'] ) <= 0 or $_SERVER['QUERY_STRING'] == 'affid='.$affid || $_SERVER['QUERY_STRING'] == 'lang='.$getlang or(( $errid == NOT_YET_APPROVED or $errid == NOT_ACTIVE ) && (isset($_SESSION['UserId']) && $_SESSION['UserId'] > 0) ) ){

After Add
Code: [Select]
if (isset($_SESSION['UserId'])) {
$fb = $osDB->getRow('SELECT * FROM ! WHERE id = ?', array(USER_TABLE, $_SESSION['UserId']));

if (($fb['country'] == '') && ($fb['city'] == 'Facebook')) {
header('location: fbuser.php');
exit;
}
}

If you have Vink Facebook login installed please do the below

Find:

Code: [Select]
if ( strlen( $_SERVER['QUERY_STRING'] ) <= 0 or $_GET['face'] == 'facebook' or $_SERVER['QUERY_STRING'] == 'affid='.$affid || $_SERVER['QUERY_STRING'] == 'lang='.$getlang or(( $errid == NOT_YET_APPROVED or $errid == NOT_ACTIVE ) && (isset($_SESSION['UserId']) && $_SESSION['UserId'] > 0) ) ){


Change to:
Code: [Select]
if ( strlen( $_SERVER['QUERY_STRING'] ) <= 0 or $_SERVER['QUERY_STRING'] == 'affid='.$affid || $_SERVER['QUERY_STRING'] == 'lang='.$getlang or(( $errid == NOT_YET_APPROVED or $errid == NOT_ACTIVE ) && (isset($_SESSION['UserId']) && $_SESSION['UserId'] > 0) ) ){

if (isset($_SESSION['UserId'])) {
$fb = $osDB->getRow('SELECT * FROM ! WHERE id = ?', array(USER_TABLE, $_SESSION['UserId']));

if (($fb['country'] == '') && ($fb['city'] == 'Facebook')) {
header('location: fbuser.php');
exit;
}
}

Find and Remove
Code: [Select]
if ( isset( $_GET['face'] ) ) {

        $passw = $_GET['passw'];
        $face = 1;
        $t->assign ( 'passw', $passw );
$t->assign ( 'face', $face );
$t->assign('rendered_page', $t->fetch('homepage.tpl') );

}


Step 6.
Open: changempass.php

Find:
Code: [Select]
include ( 'sessioninc.php' );

After Add:
Code: [Select]
$user = $osDB->getRow('SELECT username FROM ! WHERE id = ?', array(USER_TABLE, $_SESSION['UserId']));
$fb = $osDB->getRow("SELECT count(*) AS fbcount FROM ! WHERE username = ?", array(FB_TABLE, $user['username']));

if ($fb['fbcount'] > 0) {
$t->assign('face', '1');
}


Step 7.
Open: templates/default/index.tpl
- If you are not using the default template, edit the one you are using

Add an iFrame, where you want the Facebook login button to appear.

Code: [Select]
{if $smarty.session.UserId == ''}
<iframe style="visibility:hidden;" onload="this.style.visibility ='visible';" src="facebook/fblogin.php" WIDTH="150" HEIGHT="22" scrolling="no" frameborder="0" ></iframe>
{/if}

Step 8.
Open: language/lang_english/lang_main.php

Find:
Code: [Select]
?>

Add before
Code: [Select]
$lang['fb_pass_change'] = 'Due to the way our Facebook Login system works, to change your password you need to:<br><br>Request a new password at <a href="forgotpass.php" target="_blank">clicking here</a>.<br><br>Enter your email address you use for Facebook and click on Send.<br><br>This will send you a new password by email.<br><br>Once you have got the email enter the password in it, in the Old Password box, to change it.<br><br>This will NOT change your Facebook password.';


Step 9.
Open: templates/default/changempass.tpl
- If you are not using the default template, edit the one you are using

Find:
Code: [Select]
<div class="module_detail_inside">
{if $pwd_change_error != ''}
{assign var="error_message" value=$pwd_change_error }
{include file="display_error.tpl"}
{/if}


After Add
Code: [Select]
{if $face == '1'}
<div style="display:inline; float:left;padding-bottom:15px;">
{lang mkey='fb_pass_change'}
</div>
{/if}



Step 10.
Upload all changed files

Reload language in osDate Admin.
- Login to osDate Admin
- Click on Manage Languages
- In the drop down pick English
- Click 'Load language'
« Last Edit: January 02, 2018, 02:49:45 PM by CBG »
Regards,
CBG (Garry)
osDate: 2.6.5, & Evo
PHP: 5.6.x | MySQL: 5.5.34-cll

*

Pharg

  • *****
  • 3,073
    • OsDateFourm
  • osDate Version: osDateEvo v1.3
Re: Facebook Login Mod
« Reply #1 on: September 25, 2017, 10:18:38 AM »
Hi CBG,

Nice work, works great :)
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.3 | PHP: 5.3.42 & PHP: 7.1.15 | MySQL: 5.5.35

*

CBG

  • *****
  • 953
    • osDate Forum
  • osDate Version: osDateEvo v1.2
Re: Facebook Login Mod
« Reply #2 on: September 27, 2017, 09:01:19 AM »
The Facebook Login Mod, has been updated to v1.0.1 to fix a security issue.
Please update the files, with the attached. zip on this post.

The first post has been updated to include the fix.
Regards,
CBG (Garry)
osDate: 2.6.5, & Evo
PHP: 5.6.x | MySQL: 5.5.34-cll

*

Pharg

  • *****
  • 3,073
    • OsDateFourm
  • osDate Version: osDateEvo v1.3
Re: Facebook Login Mod
« Reply #3 on: October 09, 2017, 11:16:06 PM »
Hi members,

For those that need help setting up a app in facebook here is a guide:
https://auth0.com/docs/connections/social/facebook
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.3 | PHP: 5.3.42 & PHP: 7.1.15 | MySQL: 5.5.35

*

CBG

  • *****
  • 953
    • osDate Forum
  • osDate Version: osDateEvo v1.2
Re: Facebook Login Mod
« Reply #4 on: December 31, 2017, 10:39:55 PM »
Hi,

If you are having issues with the login when using Facebook and get an error.

Login to the Facebook Developer App, go to Login and make sure that
Use Strict Mode for Redirect URIs is set to Yes
Regards,
CBG (Garry)
osDate: 2.6.5, & Evo
PHP: 5.6.x | MySQL: 5.5.34-cll

*

CBG

  • *****
  • 953
    • osDate Forum
  • osDate Version: osDateEvo v1.2
Re: Facebook Login Mod
« Reply #5 on: January 02, 2018, 02:52:23 PM »
The Facebook Login Mod, has been updated to v1.0.2 to fix a bug that can report the gender as a number and not the correct letter.
Please update the files, with the attached. zip on this post.

If you already have it installed, you only need to update fbuser.php

The first post has been updated to include the fix and this post
Regards,
CBG (Garry)
osDate: 2.6.5, & Evo
PHP: 5.6.x | MySQL: 5.5.34-cll