0
http://dev."xxxxxyyyyy".com/xxxxx-community/register.html?&invite=5000

我需要使用会话将此 id ($invite=5000) 存储在一个名为 $fromid 的变量中。/components/com_com_community/controllers/register.php 中有两个函数

我应该在哪里称呼这个以及如何称呼?

class CommunityRegisterController extends CommunityBaseController
{
  public function register()
{

}

另一个

public function register_save()
{
    $mainframe  =& JFactory::getApplication();
    $modelRegister      = CFactory::getModel('register');

    // Check for request forgeries
    $mySess     =& JFactory::getSession();

    if(! $mySess->has('JS_REG_TOKEN'))
    {
        echo '<div class="error-box">' . JText::_('COM_COMMUNITY_INVALID_SESSION') . '</div>';
        return;     
    }

    $token      = $mySess->get('JS_REG_TOKEN','');
    $ipAddress  = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
    $authKey    = $modelRegister->getAssignedAuthKey($token, $ipAddress);
    $formToken  = JRequest::getVar( 'authkey', '', 'REQUEST');

    if(empty($formToken) || empty($authKey) || ($formToken != $authKey))
    {
        //echo $formToken .'|'. $authKey;
        echo '<div class="error-box">' . JText::_('COM_COMMUNITY_INVALID_TOKEN') . '</div>';
        return;
    }

    //update the auth key life span to another 180 sec.
    $modelRegister->updateAuthKey ($token, $authKey, $ipAddress);

    // Get required system objects
    $config     = CFactory::getConfig();
    $post       = JRequest::get('post');

    // If user registration is not allowed, show 403 not authorized.
    $usersConfig = &JComponentHelper::getParams( 'com_users' );
    if ($usersConfig->get('allowUserRegistration') == '0')      
    {
        //show warning message      
        $view =& $this->getView('register');
        $view->addWarning(JText::_( 'COM_COMMUNITY_REGISTRATION_DISABLED' ));
        echo $view->get('register');                                    
        return;
    }

我可以访问使用该类的 components/com_users/controllers/registration.php 中的 $fromid

 class UsersControllerRegistration extends UsersController

{

 }
4

1 回答 1

0

您可以使用 GET 方法获取值,然后将其存储在会话变量中,例如:

$_SESSION['fromid'] = $_GET['invite'];
$fromid = $_SESSION['fromid'];
于 2012-03-13T06:04:55.360 回答