Skip to content

Commit

Permalink
SDK updated, minor installation improvements and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Filippo Rossi authored and Filippo Rossi committed Apr 28, 2015
1 parent 59e300d commit 470d338
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 21 deletions.
9 changes: 5 additions & 4 deletions README.md
@@ -1,7 +1,8 @@
## MyFacebook Connect

> **Latest version** 2.1
> **Dependencies** [PluginLibrary](http://mods.mybb.com/view/PluginLibrary), PHP cURL with https module enabled, port 443 opened on your server
> **Latest version** 2.2
> **Dependencies** [PluginLibrary](http://mods.mybb.com/view/PluginLibrary), PHP cURL with https module enabled, port 443 opened on your server
> **Donations** [here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=89NU4PS5BZZQE)
MyFacebook Connect is the ultimate solution for bridging between MyBB and Facebook, featuring smooth login and registration.

Expand All @@ -19,8 +20,8 @@ The official documentation can be found [here](http://github.com/Shade-/MyFacebo

### Pricing

MyFacebook Connect is free as in freedom.
MyFacebook Connect is free as in freedom. However, since I am a Medicine and Surgery student and I have to pay avg 2.2k euros per year to study in the local university I am attending, **donations via PayPal** are much appreciated! I haven’t received a single donation for this plugin so far. [Be the first](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=89NU4PS5BZZQE)!

### License and other informations

MyFacebook Connect is licensed under [MIT](http://opensource.org/licenses/mit-license.php) and it is based upon Facebook SDK version 3.2.3, which is known to expire in April, 2015.
MyFacebook Connect is licensed under [MIT](http://opensource.org/licenses/mit-license.php) and it is based upon a custom version of Facebook SDK version 4.0, adapted to be compatible with PHP versions supported by v3.2.3.
4 changes: 4 additions & 0 deletions inc/languages/english/admin/myfbconnect.lang.php
Expand Up @@ -68,6 +68,10 @@
// Errors
$l['myfbconnect_error_needtoupdate'] = "You seem to have currently installed an outdated version of MyFacebook Connect. Please <a href=\"index.php?module=config-settings&update=myfbconnect\">click here</a> to run the upgrade script.";
$l['myfbconnect_error_nothingtodohere'] = "Ooops, MyFacebook Connect is already up-to-date! Nothing to do here...";
$l['myfbconnect_error_port_443_not_open'] = "A connection test has been made, and your server's 443 port seems to be closed. Facebook needs port 443 open to communicate and authenticate users. If:<br /><br />
<li>you are running on a <b>dedicated or premium hosting</b>, you most probably have access to a port manager or something similar. You can easily open 443 port on TCP protocol by accessing the manager.</li>
<li>you are running on a <b>shared hosting</b>, or you don't have access to a port manager, you must contact your host and ask for port 443 to be opened for you. This is the only way to let your users login and register with Facebook.</li>
The installation has been aborted for security reasons.";

// Success
$l['myfbconnect_success_updated'] = "MyFacebook Connect has been updated correctly from version {1} to {2}. Good job!";
Expand Down
12 changes: 10 additions & 2 deletions inc/plugins/MyFacebookConnect/class_facebook.php
Expand Up @@ -4,7 +4,7 @@
* A bridge between MyBB with Facebook, featuring login, registration and more.
*
* @package Main API class
* @version 2.1
* @version 2.2
*/

class MyFacebook
Expand Down Expand Up @@ -87,12 +87,14 @@ public function authenticate()
global $mybb;

$permissions = array(
'public_profile',
'user_about_me',
'user_birthday',
'user_location',
'email'
);
if ($mybb->settings['myfbconnect_postonwall']) {
$permissions[] = 'publish_stream';
$permissions[] = 'publish_actions';
}

// Get the URL and redirect the user
Expand Down Expand Up @@ -184,6 +186,12 @@ private function post_on_wall($message, $link = '')
$this->facebook->api('/me/feed', 'POST', $options);
}
catch (FacebookApiException $e) {

$result = $e->getResult();

if ($result['error']['code'] == 200) {
return false;
}

// The user should have denied posting permissions, but other errors might rise.
error($lang->sprintf($lang->myfbconnect_error_report, $e->getMessage()));
Expand Down
55 changes: 44 additions & 11 deletions inc/plugins/myfbconnect.php
Expand Up @@ -6,7 +6,7 @@
* @package MyFacebook Connect
* @author Shade <legend_k@live.it>
* @license http://opensource.org/licenses/mit-license.php MIT license
* @version 2.1
* @version 2.2
*/

if (!defined('IN_MYBB')) {
Expand All @@ -17,6 +17,25 @@
define("PLUGINLIBRARY", MYBB_ROOT . "inc/plugins/pluginlibrary.php");
}

function verify_port_443()
{
global $lang;

// 3 seconds timeout to check for port 443 is enough
$fp = @fsockopen('127.0.0.1', 443, $errno, $errstr, 3);

// Port 443 is closed or blocked
if (!$fp) {

flash_message($lang->myfbconnect_error_port_443_not_open, 'error');
admin_redirect("index.php?module=config-plugins");

}

return false;

}

function myfbconnect_info()
{
return array(
Expand All @@ -25,7 +44,7 @@ function myfbconnect_info()
'website' => 'https://github.com/Shade-/MyFacebook-Connect',
'author' => 'Shade',
'authorsite' => '',
'version' => '2.1',
'version' => '2.2',
'compatibility' => '16*,17*,18*',
'guid' => 'c5627aab08ec4d321e71afd2b9d02fb2'
);
Expand All @@ -50,6 +69,8 @@ function myfbconnect_install()
$lang->load('myfbconnect');
}

verify_port_443();

if (!file_exists(PLUGINLIBRARY)) {
flash_message($lang->myfbconnect_pluginlibrary_missing, "error");
admin_redirect("index.php?module=config-plugins");
Expand Down Expand Up @@ -197,16 +218,28 @@ function myfbconnect_install()
),
));

$columns_to_check = array('fbavatar', 'fbsex', 'fbdetails', 'fbbio', 'fbbday', 'fblocation', 'bigint(50) NOT NULL DEFAULT 0' => 'myfb_uid');
$columns_to_add = '';

// Check if columns are already there (this prevents duplicate installation errors)
foreach ($columns_to_check as $type => $name) {

if (!$db->field_exists($name, 'users')) {

if (is_int($type)) {
$type = 'int(1) NOT NULL DEFAULT 1';
}

$columns_to_add .= "`{$name}` $type,";

}

}

$columns_to_add = rtrim($columns_to_add, ',');

// Insert our Facebook columns into the database
$db->query("ALTER TABLE " . TABLE_PREFIX . "users ADD (
`fbavatar` int(1) NOT NULL DEFAULT 1,
`fbsex` int(1) NOT NULL DEFAULT 1,
`fbdetails` int(1) NOT NULL DEFAULT 1,
`fbbio` int(1) NOT NULL DEFAULT 1,
`fbbday` int(1) NOT NULL DEFAULT 1,
`fblocation` int(1) NOT NULL DEFAULT 1,
`myfb_uid` bigint(50) NOT NULL DEFAULT 0
)");
$db->query("ALTER TABLE " . TABLE_PREFIX . "users ADD ({$columns_to_add})");

// Insert our templates
$dir = new DirectoryIterator(dirname(__FILE__) . '/MyFacebookConnect/templates');
Expand Down
8 changes: 4 additions & 4 deletions myfbconnect/src/base_facebook.php
Expand Up @@ -121,7 +121,7 @@ public function __toString() {
abstract class BaseFacebook
{
/**
* Version.
* Version. 4.0 adapted for old PHP versions
*/
const VERSION = '3.2.3';

Expand Down Expand Up @@ -154,12 +154,12 @@ abstract class BaseFacebook
* Maps aliases to Facebook domains.
*/
public static $DOMAIN_MAP = array(
'api' => 'https://api.facebook.com/',
'api' => 'https://api.facebook.com/v2.0/',
'api_video' => 'https://api-video.facebook.com/',
'api_read' => 'https://api-read.facebook.com/',
'graph' => 'https://graph.facebook.com/',
'graph' => 'https://graph.facebook.com/v2.0/',
'graph_video' => 'https://graph-video.facebook.com/',
'www' => 'https://www.facebook.com/',
'www' => 'https://www.facebook.com/v2.0/',
);

/**
Expand Down

0 comments on commit 470d338

Please sign in to comment.