1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

Small changes before the big ones.

This commit is contained in:
CaMer0n
2009-11-10 12:46:43 +00:00
parent 523aa60153
commit d7f52135ae
8 changed files with 251 additions and 201 deletions

View File

@@ -8,16 +8,13 @@ if (!defined('e107_INIT')) { exit; }
* *
* but we can use a popup page instead ? * but we can use a popup page instead ?
*/ */
//TODO use popup window for 'invite friends'.
$CUSTOMPAGES = array_push( explode( ' ' , $CUSTOMPAGES ) , ' facebook.php' ); $CUSTOMPAGES = array_push( explode( ' ' , $CUSTOMPAGES ) , ' facebook.php' );
include_once (e_PLUGIN.'facebook/facebook_function.php'); include_once (e_PLUGIN.'facebook/facebook_function.php');
//echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>'; //echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>';
echo '<link rel="stylesheet" href="'.e_PLUGIN.'facebook/facebook.css" type="text/css" />'; echo '<link rel="stylesheet" href="'.e_PLUGIN.'facebook/facebook.css" type="text/css" />';

View File

@@ -1,18 +1,19 @@
<?php <?php
//error_reporting(E_ALL); //error_reporting(E_ALL);
include_once (e_PLUGIN.'facebook/facebook_function.php');
include_once(e_PLUGIN.'facebook/facebook_function.php' ); if (function_exists('prevent_cache_headers'))
{
prevent_cache_headers(); prevent_cache_headers();
}
/** /**
* just define facebook XMLNS * just define facebook XMLNS
* *
*/ */
define(XMLNS, "xmlns:fb='http://www.facebook.com/2008/fbml'");
define(XMLNS,"xmlns:fb='http://www.facebook.com/2008/fbml'");
/** /**
* Ensure "Make entering an email address optional" is setted to "ON"; * Ensure "Make entering an email address optional" is setted to "ON";
@@ -21,138 +22,139 @@ define(XMLNS,"xmlns:fb='http://www.facebook.com/2008/fbml'");
global $pref; global $pref;
if ( $pref['disable_emailcheck'] == 0 ) { if ($pref['disable_emailcheck'] == 0)
{
$pref['disable_emailcheck'] = 1; $pref['disable_emailcheck'] = 1;
save_prefs(); save_prefs();
} }
/** /**
* when clicked it insert a new User * when clicked it insert a new User
* *
*/ */
if ( e_QUERY == 'facebook' ) { if (e_QUERY == 'facebook')
{
Fb_Connect_Me(); Fb_Connect_Me();
} }
/** /**
* simple Re-Login after logged out from e107 * simple Re-Login after logged out from e107
* *
*/ */
if ( e_QUERY == 'login' ) { if (e_QUERY == 'login')
{
Fb_LogIn(); Fb_LogIn();
} }
/** /**
* simulate Facebook logOut when logged out from e107 * simulate Facebook logOut when logged out from e107
* *
*/ */
if ( e_QUERY == 'logout') { if (e_QUERY == 'logout')
{
Fb_LogOut(); Fb_LogOut();
} }
if (e_QUERY == 'facebook_switch')
{
Switch_Facebook_User();
}
if (e_QUERY == 'facebook_delete')
{
Delete_Duplicate_Facebook_User();
}
function theme_foot()
{
/**
* the init js needs to be at the bottom of the document, within the </body> tag
* this is so that any xfbml elements are already rendered by the time the xfbml
* rendering takes over. otherwise, it might miss some elements in the doc.
*
*/
global $onload_js;
$text .= render_facebook_init_js(is_fb());
// Print out all onload function calls
if ($onload_js)
{
$text .= '<script type="text/javascript">'.'window.onload = function() { '.$onload_js.' };'.'</script>';
}
return $text;
}
/**
*
* Facebook Deprecated get Feed Story trough Template Bundle 2009
*
function getTemplateData() {
$template_data = array(
'post_title' => $_POST[ 'subject' ],
'body' => $_POST[ 'comment' ],
'body_short' => $_POST[ 'comment' ],
'post_permalink' => e_SELF,
'blogname' => SITENAME,
'blogdesc' => SITEDESCRIPTION,
'siteurl' => SITEURLBASE);
return $template_data;
}
*/
if ( e_QUERY == 'facebook_switch') { /**
* get Feed Story infos to send to Facebook
*
* the new way FB.Connect.streamPublish();
*
*/
Switch_Facebook_User(); function getStreamToPublish()
{
//global $pref;
//$stream = facebook_client()->api_client->stream_get('','','','','',''.$pref[ 'Facebook_App-Bundle' ].'','');
} // $stream = facebook_client()->api_client->stream_publish($_POST[ 'comment' ]);
return $_POST['comment'];
}
if ( e_QUERY == 'facebook_delete') { /**
* if comment is submitted and "publish_to_facebook" is checked send a copy to Facebook
*
*/
Delete_Duplicate_Facebook_User(); if (isset($_POST['commentsubmit']) && ($_POST['publish_to_facebook'] == true))
{
} register_feed_form_js();
function theme_foot(){ }
/**
* the init js needs to be at the bottom of the document, within the </body> tag
* this is so that any xfbml elements are already rendered by the time the xfbml
* rendering takes over. otherwise, it might miss some elements in the doc.
*
*/
global $onload_js;
$text .= render_facebook_init_js( is_fb() );
// Print out all onload function calls
if ( $onload_js ) {
$text .= '<script type="text/javascript">'
.'window.onload = function() { ' . $onload_js . ' };'
.'</script>';
}
return $text;
}
/**
*
* Facebook Deprecated get Feed Story trough Template Bundle 2009
*
function getTemplateData() {
$template_data = array(
'post_title' => $_POST[ 'subject' ],
'body' => $_POST[ 'comment' ],
'body_short' => $_POST[ 'comment' ],
'post_permalink' => e_SELF,
'blogname' => SITENAME,
'blogdesc' => SITEDESCRIPTION,
'siteurl' => SITEURLBASE);
return $template_data;
}
*/
/**
* get Feed Story infos to send to Facebook
*
* the new way FB.Connect.streamPublish();
*
*/
function getStreamToPublish() {
//global $pref;
//$stream = facebook_client()->api_client->stream_get('','','','','',''.$pref[ 'Facebook_App-Bundle' ].'','');
// $stream = facebook_client()->api_client->stream_publish($_POST[ 'comment' ]);
return $_POST[ 'comment' ];
}
/**
* if comment is submitted and "publish_to_facebook" is checked send a copy to Facebook
*
*/
if ( isset( $_POST[ 'commentsubmit' ] ) && ( $_POST[ 'publish_to_facebook' ] == true ) ) {
register_feed_form_js();
}
?> ?>

View File

@@ -3,8 +3,9 @@
require_once('../../class2.php'); require_once('../../class2.php');
require_once(HEADERF); require_once(HEADERF);
//TODO include_lan();
$text = '<fb:serverfbml style="width: 100%;"> $text = '<fb:serverfbml style="'.USER_WIDTH.'">
<script type="text/fbml"> <script type="text/fbml">
<fb:fbml> <fb:fbml>
<fb:request-form <fb:request-form

View File

@@ -20,11 +20,20 @@ if (isset($_POST['fb_sig_in_canvas']))
global $pref; global $pref;
if (!vartrue($pref['user_reg']))
{
if (ADMIN)
{
$ns->tablerender("Facebook", "User Registration is turned off.");
}
return;
}
$html = ''; $html = '';
$fb_pref = e107::getPlugConfig('facebook')->getPref(); $fb_pref = e107::getPlugConfig('facebook')->getPref();
if (($fb_pref['Facebook_Api-Key'] != '') && ($fb_pref['Facebook_Secret-Key'] != '') && ($pref['user_reg'] == 1)) if (($fb_pref['Facebook_Api-Key'] != '') && ($fb_pref['Facebook_Secret-Key'] != ''))
{ {
$html = ''; $html = '';

View File

@@ -30,7 +30,7 @@ if (is_fb())
$html .= Render_Fun_Box('0', '10', '200px'); $html .= Render_Fun_Box('0', '10', '200px');
$caption = 'Fun Box'; $caption = 'Fan Box';
$ns->tablerender($caption, $html); $ns->tablerender($caption, $html);

View File

@@ -28,7 +28,8 @@ class facebook_admin extends e_admin_dispatcher
protected $adminMenu = array( protected $adminMenu = array(
'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => '0'), 'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => '0'),
'main/custom' => array('caption'=> 'Instructions', 'perm' => '0') 'main/custom' => array('caption'=> 'Instructions', 'perm' => '0'),
'main/list' => array('caption'=> 'Facebook Users', 'perm' => '0')
); );
protected $menuTitle = 'Facebook'; protected $menuTitle = 'Facebook';
@@ -40,6 +41,11 @@ class facebook_main_ui extends e_admin_ui
{ {
protected $pluginTitle = 'Facebook Connect'; protected $pluginTitle = 'Facebook Connect';
protected $pluginName = 'facebook'; protected $pluginName = 'facebook';
protected $table = "facebook";
protected $pid = "facebook_id";
protected $fields; //coming soon.
protected $prefs = array( protected $prefs = array(
@@ -48,6 +54,45 @@ class facebook_main_ui extends e_admin_ui
'Facebook_Secret-Key' => array('title'=> 'Facebook Secret Key', 'type'=>'text') 'Facebook_Secret-Key' => array('title'=> 'Facebook Secret Key', 'type'=>'text')
); );
function init()
{
$this->fields = array();
// echo $this->readSQLFile();
}
function readSQLFile()
{
$convert = array('varchar'=>'text','int'=>'int','text'=>'textarea');
$text = "<pre>";
$text .= "\$fields = array(\n";
$text .= "\t'checkboxes' => array('title'=> '', 'type' => null),\n";
$tmp = file_get_contents(e_PLUGIN.$this->pluginName."/".$this->pluginName."_sql.php");
$lines = explode("\n",$tmp);
foreach($lines as $line)
{
$line = trim($line);
$line = str_replace(" "," ",$line);
list($field,$tmp2,$other) = explode(" ",$line,3);
list($type,$dummy) = explode("(",$tmp2);
if($field == 'CREATE' || $field == 'PRIMARY' || $field == 'UNIQUE')
{
continue;
}
$title = str_replace("_"," ",$field);
if($convert[$type])
{
$text .= "\t'".$field."' => array('title'=> '".ucwords($title)."', 'type'=> '".$convert[$type]."' ),\n";
}
}
$text .= "\t'options' => array('title'=> '', 'type' => null)\n);\n";
$text .= "</pre>";
return $text;
}
function customPage() function customPage()
{ {
global $ns,$pref; global $ns,$pref;
@@ -60,11 +105,11 @@ class facebook_main_ui extends e_admin_ui
<table style="'.ADMIN_WIDTH.'"> <table style="'.ADMIN_WIDTH.'">
<tr> <tr>
<td> <td>
<p>If you don\'t already have a Facebook Platform API key for your site, create an application with the <a href="http://www.facebook.com/developers" class="external text" title="http://www.facebook.com/developers" rel="nofollow">Facebook Developer application</a>. <p>If you don\'t already have a Facebook Platform API key for your site, create an application with the <a href="http://www.facebook.com/developers" class="external text" title="http://www.facebook.com/developers" rel="external nofollow">Facebook Developer application</a>.
</p><p><b>Note:</b> Even if you have created an application and received an API key, you should review steps 1.4 through 1.7 and make sure your application settings are appropriate. </p><p><b>Note:</b> Even if you have created an application and received an API key, you should review steps 1.4 through 1.7 and make sure your application settings are appropriate.
</p> </p>
<ol><li>1. Go to <a rel="external" href="http://www.facebook.com/developers/createapp.php" class="external free" title="http://www.facebook.com/developers/createapp.php" rel="nofollow">http://www.facebook.com/developers/createapp.php</a> to create a new application. <ol><li>1. Go to <a rel="external nofollow" href="http://www.facebook.com/developers/createapp.php" class="external free" title="http://www.facebook.com/developers/createapp.php">http://www.facebook.com/developers/createapp.php</a> to create a new application.
</li><li>2. Enter a name for your application in the <b>Application Name</b> field. </li><li>2. Enter a name for your application in the <b>Application Name</b> field.
</li><li>3. Accept the <a href="http://developers.facebook.com/terms.php" class="external text" title="http://developers.facebook.com/terms.php" rel="nofollow">Developer Terms of Service</a>, then click <b>Save Changes</b>. </li><li>3. Accept the <a href="http://developers.facebook.com/terms.php" class="external text" title="http://developers.facebook.com/terms.php" rel="nofollow">Developer Terms of Service</a>, then click <b>Save Changes</b>.
</li><li>4. On the <b>Basic</b> tab, keep all of the defaults. </li><li>4. On the <b>Basic</b> tab, keep all of the defaults.

View File

@@ -8,6 +8,8 @@ if (!defined('e107_INIT'))
require_once (e_PLUGIN.'facebook/facebook-client/facebook.php'); require_once (e_PLUGIN.'facebook/facebook-client/facebook.php');
define("FB_DEBUG",TRUE); // Debug this script.
/** /**
* simple get the Facebook User ID one is logged in! * simple get the Facebook User ID one is logged in!
* *
@@ -37,6 +39,7 @@ function is_fb()
function Add_Facebook_Connect_User($info = '', $user_id) function Add_Facebook_Connect_User($info = '', $user_id)
{ {
$sql = e107::getDb();
/* $full = array ( /* $full = array (
'facebook_about_me' => Get_Facebook_Info ( 'about_me' ) , 'facebook_about_me' => Get_Facebook_Info ( 'about_me' ) ,
@@ -89,7 +92,6 @@ function Add_Facebook_Connect_User($info = '', $user_id)
$query = array_push($standard, $full); $query = array_push($standard, $full);
} }
global $sql;
$sql->db_Insert('facebook', $query); $sql->db_Insert('facebook', $query);
@@ -156,8 +158,6 @@ function Render_Facebook_Profile()
function facebook_client() function facebook_client()
{ {
global $pref;
$pref = e107::getPlugConfig('facebook')->getPref(); $pref = e107::getPlugConfig('facebook')->getPref();
static $facebook = null; static $facebook = null;
@@ -246,30 +246,24 @@ function Get_Facebook_Info($info, $friend = '')
* Add new e107 User , by using Facebook Infos * Add new e107 User , by using Facebook Infos
* *
*/ */
function Fb_Connect_Me() function Fb_Connect_Me()
{ {
$sql = e107::getDb();
global $sql; if (!$sql->db_Select("user_extended", "*", "user_plugin_facebook_ID = '".is_fb()."' "))
$sql4 = new db;
if (!$sql4->db_select("user_extended", "*", "user_plugin_facebook_ID = '".is_fb()."' "))
{ {
$nickname = username_exists(Get_Facebook_Info('first_name')); $nickname = username_exists(Get_Facebook_Info('first_name'));
$password = md5(is_fb()); $password = md5(is_fb());
$username = "FacebookUser_".is_fb(); $username = "FacebookUser_".is_fb();
$sql2 = new db; $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')));
$sql->db_Insert('user_extended', array('user_extended_id'=>last_user(), 'user_plugin_facebook_ID'=>is_fb()));
$sql2->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')));
$sql3 = new db;
$sql3->db_Insert('user_extended', array('user_extended_id'=>last_user(), 'user_plugin_facebook_ID'=>is_fb()));
Add_Facebook_Connect_User('', last_user()); Add_Facebook_Connect_User('', last_user());
set_cookies(last_user(), md5($password)); set_cookies(last_user(), md5($password));
header('Location:'.e_SELF); fb_redirect(e_SELF);
} }
} }
@@ -289,13 +283,12 @@ function UEID()
* When logging out e107 , simulate a Log-Out from Facebook instead of expire Facebook session! * When logging out e107 , simulate a Log-Out from Facebook instead of expire Facebook session!
* *
*/ */
function Fb_LogOut() function Fb_LogOut()
{ {
$sql = e107::getDb();
//$uid = UEID() ? UEID() : is_fb(); //$uid = UEID() ? UEID() : is_fb();
global $sql;
if ($sql->db_Select("facebook", "*", "facebook_connected = '1' AND facebook_user_id = '".USERID."' ")) if ($sql->db_Select("facebook", "*", "facebook_connected = '1' AND facebook_user_id = '".USERID."' "))
{ {
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
@@ -303,7 +296,8 @@ function Fb_LogOut()
$sql2 = new db; $sql2 = new db;
$sql2->db_Update("facebook", "facebook_connected = '0' WHERE facebook_uid = '".$facebook_uid."' "); $sql2->db_Update("facebook", "facebook_connected = '0' WHERE facebook_uid = '".$facebook_uid."' ");
header('Location: '.e_SELF);
fb_redirect(e_SELF);
} }
} }
@@ -338,7 +332,8 @@ function Fb_LogIn()
} }
header('Location: '.e_SELF); fb_redirect(e_SELF);
} }
/** /**
@@ -355,20 +350,21 @@ function your_facebook_is()
function Get_Connection_Status() function Get_Connection_Status()
{ {
$sql = new db; $sql = e107::getDb();
$sql2 = new db;
if (($sql->db_Select("facebook", "*", "facebook_uid = '".is_fb()."' ")) || if ($sql->db_Select("facebook", "facebook_connected", "facebook_uid = '".is_fb()."' "))
($sql2->db_Select("user_extended", "*", "user_plugin_facebook_ID = '".is_fb()."' "))
)
{ {
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
return $row['facebook_connected'] ? $row['facebook_connected'] : '0'; return $row['facebook_connected'] ? $row['facebook_connected'] : '0';
} }
elseif($sql->db_Select("user_extended", "*", "user_plugin_facebook_ID = '".is_fb()."' "))
{
$row = $sql->db_Fetch();
return $row['user_extended_id'] ? $row['user_extended_id'] : '0';
}
else else
{ {
return ''; return '';
} }
@@ -380,7 +376,7 @@ function Get_Connection_Status()
*/ */
function Facebook_User_Is_Connected() function Facebook_User_Is_Connected()
{ {
global $sql; $sql = e107::getDb();
if ($sql->db_select("user_extended", "*", "user_extended_id = '".get_id_from_uid(is_fb())."' AND user_plugin_facebook_ID = '".is_fb()."' ")) if ($sql->db_select("user_extended", "*", "user_extended_id = '".get_id_from_uid(is_fb())."' AND user_plugin_facebook_ID = '".is_fb()."' "))
{ {
@@ -418,6 +414,7 @@ function Delete_Duplicate_Facebook_User()
$sql = e107::getDb(); $sql = e107::getDb();
$id = get_id_from_uid(is_fb()); $id = get_id_from_uid(is_fb());
// $sql->db_Update('user_extended', "user_plugin_facebook_ID = '' WHERE user_extended_id = ".$id." LIMIT 1");
$sql->db_Delete("user_extended", "user_extended_id='".$id."'"); $sql->db_Delete("user_extended", "user_extended_id='".$id."'");
$sql->db_Delete("facebook", "facebook_uid='".is_fb()."'"); $sql->db_Delete("facebook", "facebook_uid='".is_fb()."'");
$sql->db_Delete("user", "user_loginname='FacebookUser_".is_fb()."'"); $sql->db_Delete("user", "user_loginname='FacebookUser_".is_fb()."'");
@@ -426,23 +423,17 @@ function Delete_Duplicate_Facebook_User()
function Switch_Facebook_User() function Switch_Facebook_User()
{ {
$sql = e107::getDb();
$sql1 = new db; if (!$sql->db_Insert('user_extended', array('user_extended_id'=>USERID, 'user_plugin_facebook_ID'=>is_fb())))
$sql2 = new db;
$sql3 = new db;
$sql4 = new db;
if (!$sql1->db_Insert('user_extended', array('user_extended_id'=>USERID, 'user_plugin_facebook_ID'=>is_fb())))
{ {
$sql->db_Update("user_extended", "user_plugin_facebook_ID = '".is_fb()."' WHERE user_extended_id = '".USERID."' ");
$sql2->db_Update("user_extended", "user_plugin_facebook_ID = '".is_fb()."' WHERE user_extended_id = '".USERID."' ");
} }
$id = get_id_from_uid(is_fb()); $id = get_id_from_uid(is_fb());
$sql3->db_Update("user_extended", "user_plugin_facebook_ID = '' WHERE user_extended_id = '".$id."' "); $sql->db_Update("user_extended", "user_plugin_facebook_ID = '' WHERE user_extended_id = '".$id."' ");
$sql4->db_Update("facebook", "facebook_user_id = '".USERID."' WHERE facebook_uid = '".is_fb()."' "); $sql->db_Update("facebook", "facebook_user_id = '".USERID."' WHERE facebook_uid = '".is_fb()."' ");
} }
/** /**
@@ -460,48 +451,45 @@ function single_uid()
function uid_check() function uid_check()
{ {
$sql = e107::getDb(); $sql = e107::getDb();
$sql = new db;
$sql2 = new db;
$sql3 = new db;
$sql4 = new db;
$sql5 = new db;
$sql6 = new db;
$msg = ""; $msg = "";
if ($sql->db_select("user_extended", "*", "user_plugin_facebook_ID = '".is_fb()."' AND user_extended_id !='".USERID."'")) if ($sql->db_Select("user_extended", "*", "user_plugin_facebook_ID = '".is_fb()."' AND user_extended_id !='".USERID."'"))
{ {
// header ( 'Location: ' . e_SELF ) ; // header ( 'Location: ' . e_SELF ) ;
$msg .= "<div class='facebook_notice'><a href='".e_SELF."?facebook_switch' title='switch user'>would you like to use facebook with this account? press this link!</a></div>"; $msg .= "<div class='facebook_notice'><a href='".e_SELF."?facebook_switch' title='switch user'>would you like to use facebook with this account? press this link!</a></div>";
$msg .= "<div class='facebook_notice'><a href='".e_SELF."?facebook_delete' title='delete user'>would you like to delete this facebook account? press this link!</a></div>"; $msg .= "<div class='facebook_notice'><a href='".e_SELF."?facebook_delete' title='delete user'>would you like to delete this facebook account? press this link!</a></div>";
} }
else if ($sql->db_select("user_extended", "*", "user_plugin_facebook_ID != '".is_fb()."' ")) else if($sql->db_Select("user_extended", "*", "user_plugin_facebook_ID != '".is_fb()."' AND user_plugin_facebook_ID != '' "))
{ {
$msg .= "<div class='facebook_notice'><a href='".e_SELF."?facebook_link' title='click here'>The provided Facebook ID is wrong!</a> </div> <div class='fb_green'>".your_facebook_is()."</div>";
$msg = "<div class='facebook_notice'> <a href='usersettings.php' title='click here'>The provided Facebook ID is wrong!</a> </div> <div class='fb_green'>".your_facebook_is()."</div>";
} }
else if ($sql->db_select("user_extended", "*", "user_plugin_facebook_ID = '' ")) else if($sql->db_Select("user_extended", "*", "user_plugin_facebook_ID = '' "))
{ {
$msg .= "<div class='facebook_notice'><a href='usersettings.php' title='click here'>Specify your Facebook ID in the Profile Settings! </a></div><div class='fb_green'>".your_facebook_is()."</div>";
$msg = "<div class='facebook_notice'><a href='usersettings.php' title='click here'>Specify your Facebook ID in the Profile Settings! </a></div><div class='fb_green'>".your_facebook_is()."</div>";
} }
else else
{ {
$msg .= '<a href="#" onclick="facebook_onlogin_ready();">
$msg = '<a href="#" onclick="facebook_onlogin_ready();"> <img id="fb_login_image" src="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_light_medium_long.gif" alt="Connect" />
<img id="fb_login_image" src="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_light_medium_long.gif" alt="Connect" /> </a>';
</a>';
} }
return $msg; return $msg;
} }
function Link_Facebook_User()
{
if(!USERID)
{
return;
}
// Set the extended field to the value of the Facebook ID.
return e107::getUserExt()->set(USERID, 'user_plugin_facebook_ID', is_fb());
}
function uid_exists() function uid_exists()
{ {
$sql = e107::getDb(); $sql = e107::getDb();
@@ -830,10 +818,9 @@ function get_info($info, $uid)
{ {
$sql = e107::getDb(); $sql = e107::getDb();
if ($sql->db_select("user", "*", "user_id = '$uid'")) if ($sql->db_Select("user", "*", "user_id = '$uid'"))
{ {
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
extract($row);
return $row[$info]; return $row[$info];
} }
else else
@@ -846,12 +833,9 @@ function Log_In_Registered_User()
{ {
if (!USER) if (!USER)
{ {
$uid = get_id_from_uid(is_fb()); $uid = get_id_from_uid(is_fb());
set_cookies(get_info('user_id', $uid), md5(get_info('user_password', $uid))); set_cookies(get_info('user_id', $uid), md5(get_info('user_password', $uid)));
fb_redirect(e_SELF);
header('Location:'.e_SELF);
} }
} }
@@ -877,3 +861,11 @@ function last_user()
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
return $row['user_id']; return $row['user_id'];
} }
function fb_redirect($loc)
{
header('Location:'.$loc);
// Stops endless loop issues.
header('Content-Length: 0');
exit();
}

View File

@@ -6,9 +6,6 @@ if (!defined('e107_INIT'))
exit; exit;
} }
$fb_pref = e107::getPlugConfig('facebook')->getPref();
include_once (e_PLUGIN.'facebook/facebook_function.php'); include_once (e_PLUGIN.'facebook/facebook_function.php');
if (isset($_POST['fb_sig_in_canvas'])) if (isset($_POST['fb_sig_in_canvas']))
@@ -23,9 +20,18 @@ if (isset($_POST['fb_sig_in_canvas']))
global $pref; 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 (($fb_pref['Facebook_Api-Key'] != '') && ($fb_pref['Facebook_Secret-Key'] != '') && ($pref['user_reg'] == 1)) if (vartrue($fb_pref['Facebook_Api-Key']) && vartrue($fb_pref['Facebook_Secret-Key']))
{ {
if (USER) if (USER)
@@ -52,7 +58,6 @@ if (($fb_pref['Facebook_Api-Key'] != '') && ($fb_pref['Facebook_Secret-Key'] !=
} }
else else
{ {
if (is_fb() && uid_exists() && (single_uid() == 1)) if (is_fb() && uid_exists() && (single_uid() == 1))
{ {
@@ -60,6 +65,7 @@ if (($fb_pref['Facebook_Api-Key'] != '') && ($fb_pref['Facebook_Secret-Key'] !=
header('Location:'.e_SELF); header('Location:'.e_SELF);
} }
else if (is_fb() && (USERID != get_id_from_uid(is_fb()))) else if (is_fb() && (USERID != get_id_from_uid(is_fb())))
{ {
@@ -95,19 +101,17 @@ if (($fb_pref['Facebook_Api-Key'] != '') && ($fb_pref['Facebook_Secret-Key'] !=
{ {
$html .= '<a href="#" onclick="facebook_onlogin_ready();"> $html .= '<a href="#" onclick="facebook_onlogin_ready();">
<img id="fb_login_image" src="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_light_medium_long.gif" alt="Connect" /> <img id="fb_login_image" src="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_light_medium_long.gif" alt="Connect" />
</a>'; </a>';
// Fb_Connect_Me(); // Fb_Connect_Me();
} }
else if (Get_Connection_Status() == 1) else if (Get_Connection_Status() == 1)
{ {
//not a real error! just some problem with Facebook ID //not a real error! just some problem with Facebook ID
$html .= 'Ops... Some error Occur'; $html .= 'Ops... Some error Occur';
} }
else if (Get_Connection_Status() == 0) else if (Get_Connection_Status() == 0)
{ {
@@ -124,7 +128,7 @@ if (($fb_pref['Facebook_Api-Key'] != '') && ($fb_pref['Facebook_Secret-Key'] !=
} }
$caption = 'facebook'; $caption = 'Facebook';
// $text = $tp->parseTemplate($html, true, $facebook_shortcodes); // $text = $tp->parseTemplate($html, true, $facebook_shortcodes);
$ns->tablerender($caption, $html); $ns->tablerender($caption, $html);