diff --git a/README.md b/README.md index 6472b6d..1ca5d01 100644 --- a/README.md +++ b/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. @@ -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. diff --git a/inc/languages/english/admin/myfbconnect.lang.php b/inc/languages/english/admin/myfbconnect.lang.php index ff7060f..0ecccf9 100644 --- a/inc/languages/english/admin/myfbconnect.lang.php +++ b/inc/languages/english/admin/myfbconnect.lang.php @@ -68,6 +68,10 @@ // Errors $l['myfbconnect_error_needtoupdate'] = "You seem to have currently installed an outdated version of MyFacebook Connect. Please click here 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:

+
  • you are running on a dedicated or premium hosting, 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.
  • +
  • you are running on a shared hosting, 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.
  • +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!"; diff --git a/inc/plugins/MyFacebookConnect/class_facebook.php b/inc/plugins/MyFacebookConnect/class_facebook.php index 0509f8b..1587770 100644 --- a/inc/plugins/MyFacebookConnect/class_facebook.php +++ b/inc/plugins/MyFacebookConnect/class_facebook.php @@ -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 @@ -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 @@ -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())); diff --git a/inc/plugins/myfbconnect.php b/inc/plugins/myfbconnect.php index fcb05bf..c71276e 100644 --- a/inc/plugins/myfbconnect.php +++ b/inc/plugins/myfbconnect.php @@ -6,7 +6,7 @@ * @package MyFacebook Connect * @author Shade * @license http://opensource.org/licenses/mit-license.php MIT license - * @version 2.1 + * @version 2.2 */ if (!defined('IN_MYBB')) { @@ -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( @@ -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' ); @@ -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"); @@ -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'); diff --git a/myfbconnect/src/base_facebook.php b/myfbconnect/src/base_facebook.php index 8cf2504..a41d8fc 100755 --- a/myfbconnect/src/base_facebook.php +++ b/myfbconnect/src/base_facebook.php @@ -121,7 +121,7 @@ public function __toString() { abstract class BaseFacebook { /** - * Version. + * Version. 4.0 adapted for old PHP versions */ const VERSION = '3.2.3'; @@ -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/', ); /**