function varAccNewCrt() { global $mainframe; $db =& JFactory::getDBO(); $myparams =& JComponentHelper::getParams('com_fbjconnect'); $mailsender = $myparams->get('emailsender', 1); $connecttype = $myparams->get('connect-type', 0); $linkwithemail = $myparams->get('link-with-email', 1); $rndstrnglength = $myparams->get('length-of-randstring', 0); list($uid, $me) = JfbgconnectController::try_connect(); $optioncreateacc = JRequest::getVar('newacc', '0', 'post'); if ($connecttype == 1 && $me || $optioncreateacc == 1 && $me) { if (strlen(JRequest::getVar('newusername', '', 'post')) > 1 || $connecttype == 1) { if ($connecttype == 1) { // generate a random username if auto registration is set $musername = strtolower(JfbgconnectController::just_clean($me['first_name'])) . JfbgconnectController::random_str($rndstrnglength); } else { $musername = JRequest::getVar('newusername', '', 'post'); } jimport('joomla.user.helper'); // Get required system objects $user = clone JFactory::getUser(); $pathway =& $mainframe->getPathway(); $config =& JFactory::getConfig(); $authorize =& JFactory::getACL(); $document =& JFactory::getDocument(); // Use the Joomla helper $usersConfig =& JComponentHelper::getParams('com_users'); $newUsertype = $usersConfig->get('new_usertype'); if (!$newUsertype) { $newUsertype = 'Registered'; } $fullname = $me['first_name'] . " " . $me['last_name']; $email = $me['email']; $newpassword = JUserHelper::genRandomPassword(5); $intdatetime = time(); // let's check email address before we proceed, we will take action acording to params if (JfbgconnectController::count_this_useremail($me['email']) > 0 && $linkwithemail == 1) { $query = 'SELECT username,id FROM #__users WHERE email=' . $db->Quote($me['email']); $db->setQuery($query); $results = $db->loadObject(); $retrivedbid = $results->id; $retrivedusername = $results->username; $fbinsertifemail = "INSERT INTO #__facebook_joomla_connect(joomla_userid,facebook_userid,joined_date,linked) VALUES ({$retrivedbid},{$uid},{$intdatetime},1)"; $db->setQuery($fbinsertifemail); if (!$db->query()) { $mainframe->enqueueMessage("Email link Error", 'error'); if ($connecttype == 1) { $mainframe->redirect(str_replace('option=com_fbjconnect', '', JRoute::_(JURI::base() . 'index.php?errtxt=1', false))); } else { $mainframe->redirect(JRoute::_('index.php?errtxt=1&re=' . JfbgconnectController::getreturnurl(), false)); } } else { JPluginHelper::importPlugin('user'); $response->username = $retrivedusername; $result = $mainframe->triggerEvent('onLoginUser', array((array) $response, $options)); // Publish on user's wall $publishonwall = JText::sprintf(JText::_('FBPUBLISHMESSAGE'), $mainframe->getCfg('sitename')); JfbgconnectController::try_connect(1, JURI::base(), $publishonwall); $regsuccessmsg = JText::sprintf(JText::_('FOUNDYOUREMAIL'), $retrivedusername, $me['email']); $mainframe->enqueueMessage($regsuccessmsg, 'message'); $mainframe->redirect(JfbgconnectController::getreturnurl(true)); exit; } } $userData = array(); $userData['name'] = $fullname; $userData['username'] = $musername; $userData['email'] = $email; $userData['password'] = $newpassword; $userData['password2'] = $newpassword; // Bind the post array to the user object if (!$user->bind($userData, 'usertype')) { $mainframe->enqueueMessage($user->getError(), 'error'); if ($connecttype == 1) { $mainframe->redirect(str_replace('option=com_fbjconnect', '', JRoute::_(JURI::base() . 'index.php?errtxt=1', false))); } else { $mainframe->redirect(JRoute::_('index.php?errtxt=1&re=' . JfbgconnectController::getreturnurl(), false)); } } // Set some initial user values $user->set('id', 0); $user->set('usertype', $newUsertype); $user->set('gid', '18'); $date =& JFactory::getDate(); $user->set('registerDate', $date->toMySQL()); // If there's an error with registration if (!$user->save()) { $mainframe->enqueueMessage($user->getError() . '<br />If you are experiancing problem accessing site, <a href="#" onclick="javascript:fb_logout(); return false;">Clear Facebook session</a>!', 'error'); //auto rise errors if ($connecttype == 1) { $mainframe->redirect(str_replace('option=com_fbjconnect', '', JRoute::_(JURI::base() . 'index.php?errtxt=1', false))); } else { $mainframe->redirect(JRoute::_('index.php?errtxt=1&re=' . JfbgconnectController::getreturnurl(), false)); } } JPluginHelper::importPlugin('user'); $response->username = $musername; $result = $mainframe->triggerEvent('onLoginUser', array((array) $response, $options)); // everything done redirect user and log him in...preform the login action if ($result) { $user =& JFactory::getUser(); $jomuserid = $user->get('id'); if (JfbgconnectController::count_this_fb_user($uid) >= 1) { $fbinsertquary = "UPDATE #__facebook_joomla_connect SET joomla_userid={$jomuserid},joined_date={$intdatetime} WHERE facebook_userid={$uid}"; } else { $fbinsertquary = "INSERT INTO #__facebook_joomla_connect(joomla_userid,facebook_userid,joined_date,linked) VALUES ({$jomuserid},{$uid},{$intdatetime},1)"; } $db->setQuery($fbinsertquary); if (!$db->query()) { //try insert into fb table $mainframe->enqueueMessage($db->getErrorMsg() . '<br />If you are experiancing problem accessing site, <a href="#" onclick="javascript:fb_logout(); return false;">Clear Facebook session</a>!', 'error'); if ($connecttype == 1) { $mainframe->redirect(str_replace('option=com_fbjconnect', '', JRoute::_(JURI::base() . 'index.php?errtxt=1', false))); } else { $mainframe->redirect(JRoute::_('index.php?errtxt=1&re=' . JfbgconnectController::getreturnurl(), false)); } } //let's send email $mailfrom = $mainframe->getCfg('mailfrom'); $fromname = $mainframe->getCfg('fromname'); $sitename = $mainframe->getCfg('sitename'); $subject = JText::sprintf(JText::_('EMAILSUBJECT'), $sitename); $bodytext = str_replace("***", "<br />", JText::_('EMAILBODY')); // replace *** with <br> html tag. $bodytext = JText::sprintf($bodytext, $fullname, $sitename, JURI::base(), $musername, $newpassword, JURI::base() . '<br /> ' . $sitename . ' Team'); $bodytext = html_entity_decode($bodytext, ENT_QUOTES); //get all super administrator $query = 'SELECT name, email, sendEmail' . ' FROM #__users' . ' WHERE LOWER( usertype ) = "super administrator"'; $db->setQuery($query); $rows = $db->loadObjectList(); // Send email to user if (!$mailfrom || !$fromname) { $fromname = $rows[0]->name; $mailfrom = $rows[0]->email; } jimport('joomla.utilities.utility'); if ($mailsender == 0) { $SendRegMail = JUtility::sendMail($mailfrom, $fromname, $email, $subject, $bodytext, true); } else { $SendRegMail = JfbgconnectController::fbj_mailer($fromname, $mailfrom, $email, $subject, $bodytext); } if (!$SendRegMail) { $mainframe->enqueueMessage(JText::sprintf(JText::_('EMAILERRORSEND'), '<a href="index.php?option=com_user&view=reset">Click here</a>'), 'error'); if ($connecttype == 1) { $mainframe->redirect(str_replace('option=com_fbjconnect', '', JRoute::_(JURI::base() . 'index.php?errtxt=1', false))); } else { $mainframe->redirect(JRoute::_('index.php?errtxt=1&re=' . JfbgconnectController::getreturnurl(), false)); } } // Send notification to all administrators $subject2 = sprintf(JText::_('NEWACCOUNTOF'), $fullname); $message2 = sprintf(JText::_('SEND_MSG_ADMIN'), $fullname, $sitename, $musername, $uid); // get superadministrators id foreach ($rows as $row) { if ($row->sendEmail) { if ($mailsender == 0) { JUtility::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2, true); } else { JfbgconnectController::fbj_mailer($fromname, $mailfrom, $row->email, $subject2, $message2); } } } // Publish on user's wall JfbgconnectController::try_connect(1, JURI::base(), JText::_('FBPUBLISHMESSAGE')); //end sending mail, redirect user $regsuccessmsg = JText::sprintf(JText::_('REGISTRATIONSUCCESS'), $mainframe->getCfg('sitename')); $mainframe->enqueueMessage($regsuccessmsg, 'message'); $mainframe->redirect(JfbgconnectController::getreturnurl(true)); } } } }
$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'); $fbauthlink = '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $myparams->get('appid') . '&redirect_uri=' . JURI::current() . '&scope=email,read_stream">Click Here</a>'; $additional_permiss_txt = JText::sprintf(JText::_('EXTENDEDPERMISSIOINREQUIRED'), $fbauthlink); ##################### EDIT HTML BELOW THIS LINE TO CUSTOMIZE YOUR FB REGISTRATION LOOK ################## ?> <!-- Show this div box if we need additional info, such as.. email address. --> <div class="additional_permission_class"> <h2><?php echo $additionalpermissionhead; ?> </h2> <ul> <li> <?php