コード例 #1
0
ファイル: default.php プロジェクト: akksi/jcg
        ?>
</td>
        <td align="left"><input  name="ipassword" type="password" /></td>
      </tr>
      <tr>
        <td colspan="2" align="center">	<input  name="linkacc" type="hidden" value="1" />
	<input name="" type="submit" class="submitbutt" value="<?php 
        echo $link_my_account_button;
        ?>
"/></td>
        </tr>
        </tbody>
    </table>
    </form></td>
  </tr>
</table>
<?php 
    }
    ?>
	<div style="clear:both"></div>
	<div align="center">
	
	</div>
<?php 
    ####################### END YOUR HTML EDITING HERE ##############################
} else {
    $errortext = "<a href='" . JfbgconnectController::getreturnurl(true) . "'>" . JText::_('REVIOUSPAGE') . "</a>";
    // line below causes infinite redirection cusing error ..
    //$mainframe->enqueueMessage($errortext, 'error');
    //$mainframe->redirect(JRoute::_('index.php?re='.JfbgconnectController::getreturnurl(), false));
}
コード例 #2
0
ファイル: fbgccontroller.php プロジェクト: akksi/jcg
 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));
             }
         }
     }
 }
コード例 #3
0
ファイル: fbjconnect.php プロジェクト: akksi/jcg
<?php

/**
* @package 		FacebookGraphConnect for joomla 1.5
* @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');
// Require the base controller
require_once JPATH_COMPONENT . DS . 'fbgccontroller.php';
require_once JPATH_COMPONENT . DS . 'inc' . DS . 'facebook.php';
// Create the controller
$classname = 'JfbgconnectController' . $controller;
$controller = new $classname();
// Perform the Request task
$controller->execute(JRequest::getWord('task'));
JfbgconnectController::LogInUsers();
JfbgconnectController::LinkExistingUser();
JfbgconnectController::varAccNewCrt();
// Redirect if set by the controller
$controller->redirect();