Example #1
0
 function LinkExistingUser()
 {
     global $mainframe;
     jimport('joomla.user.helper');
     $db =& JFactory::getDBO();
     $optionlinkacc = JRequest::getVar('linkacc', '0', 'post');
     list($uid, $me) = JfbgconnectController::try_connect();
     if (JfbgconnectController::count_this_user($uid) > 0) {
         $db->setQuery("SELECT  #__users.username as username\r\n\t\t\t\tFROM #__facebook_joomla_connect LEFT JOIN #__users \r\n\t\t\t\tON #__facebook_joomla_connect.joomla_userid=#__users.id\r\n\t\t\t\tWHERE #__facebook_joomla_connect.facebook_userid={$uid}");
         $userDetails = $db->loadObjectList();
         $row = $userDetails[0];
         $errortext = JText::sprintf(JText::_('USERALREADYLINKED'), $uid, $row->username);
         $mainframe->enqueueMessage($errortext, 'error');
         $mainframe->redirect(JRoute::_('index.php?re=' . JfbgconnectController::getreturnurl(), false));
     } elseif ($optionlinkacc == 1 && $me) {
         $linkusername = JRequest::getVar('iusername', '', 'post');
         $linkpassword = JRequest::getVar('ipassword', '', 'post');
         $intdatetime = time();
         $fullname = $me['first_name'] . " " . $me['last_name'];
         $query = 'SELECT id, password FROM #__users WHERE username='******':', $results->password);
             $crypt = $parts[0];
             $salt = @$parts[1];
             $testcrypt = JUserHelper::getCryptedPassword($linkpassword, $salt);
             if ($crypt == $testcrypt) {
                 $joomla_userid = $results->id;
                 $db->setQuery("INSERT INTO #__facebook_joomla_connect(joomla_userid,facebook_userid,joined_date,linked) VALUES ({$joomla_userid},{$uid},{$intdatetime},1)");
                 if (!$db->query()) {
                     $mainframe->enqueueMessage($db->getErrorMsg(), 'error');
                     $mainframe->redirect(JRoute::_('index.php?re=' . JfbgconnectController::getreturnurl(), false));
                 } else {
                     $db->setQuery("UPDATE #__users SET name=" . $db->Quote($fullname) . ",joined_date={$intdatetime} WHERE username=" . $db->Quote($linkusername));
                     if (!$db->query()) {
                         $mainframe->enqueueMessage($db->getErrorMsg(), 'error');
                         $mainframe->redirect(JRoute::_('index.php?re=' . JfbgconnectController::getreturnurl(), false));
                     }
                 }
                 //preform login
                 JPluginHelper::importPlugin('user');
                 $response->username = $linkusername;
                 $result = $mainframe->triggerEvent('onLoginUser', array((array) $response, $options));
                 if ($result) {
                     //publish it on the wall
                     JfbgconnectController::try_connect(1, JURI::base(), JText::_('FBPUBLISHMESSAGE'));
                     $successmsg = JText::sprintf(JText::_('LINKSUCESS'), $mainframe->getCfg('sitename'));
                     $mainframe->enqueueMessage($successmsg, 'message');
                     $mainframe->redirect(JfbgconnectController::getreturnurl(true));
                 }
             } else {
                 $mainframe->enqueueMessage(JText::_('PASSWORDWRONG'), 'error');
                 $mainframe->redirect(JRoute::_('index.php?re=' . JfbgconnectController::getreturnurl(), false));
             }
         } else {
             $errortext = JText::sprintf(JText::_('USERNAMENOTFOUND'), $linkusername);
             $mainframe->enqueueMessage($errortext, 'error');
             $mainframe->redirect(JRoute::_('index.php?re=' . JfbgconnectController::getreturnurl(), false));
         }
     }
 }
Example #2
0
* @package 		FacebookGraphConnect
* @version 		1.2
* @copyright	Copyright (C) Computer - http://www.sikkimonline.info. All rights reserved.
* @license		http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @author		Saran Chamling (saaraan@gmail.com)
* @download URL	http://www.sikkimonline.info/joomla-facebook-graph-connect
*/
defined('_JEXEC') or die('Restricted access');
$document =& JFactory::getDocument();
list($uid, $me, $session) = JfbgconnectController::try_connect();
$myparams =& JComponentHelper::getParams('com_fbjconnect');
$viewlayout = $myparams->get('viewlayout', 1);
$viewstyle = $myparams->get('cssstyle', 1);
$rndstrnglength = $myparams->get('length-of-randstring', 0);
$document->addStyleSheet('components' . DS . 'com_fbjconnect' . DS . 'fbstyle.css');
if (JfbgconnectController::count_this_user($uid) == 0) {
    //variables used here in this template, just copy/paste variables where u need them.
    $fbflnames = $me["first_name"] . " " . $me["last_name"];
    $full_name_of_user_with_txt = JText::sprintf(JText::_('YOUARECONNECTED'), $fbflnames, $mainframe->getCfg('sitename'));
    $note_text_below_heading = JText::_('NOTETEXT');
    $return_url = JfbgconnectController::getreturnurl();
    $new_visitor_heading = JText::_('NEWVISITORS');
    $username_text = JText::_('ENTERUSERNAME');
    $password_text = JText::_('ENTERPASSWORD');
    $email_will_be_sent_to = JText::sprintf(JText::_('EMAILWILLBESENTTO'), $me["email"]);
    $returning_member_heading = JText::_('RETURNINGMEMBERS');
    $create_new_user_button = JText::_('CREATENEWUSEBUTT');
    $link_my_account_button = JText::_('LINKMYACCOUNTBUTT');
    $randomusername = strtolower($me['first_name']) . JfbgconnectController::random_str($rndstrnglength);
    if (strlen($me["email"]) < 1) {
        $additionalpermissionhead = JText::_('ADDITIONALHEAD');