On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • After we set up friendly url, the link we got when we registered was not working.
    we got a Error Code: 500 Internal Server Error. Friendly url off worked fine.
    we thought that it had to do with the .htaccess.
    // htaccess code
    RewriteEngine On
    RewriteBase /
    # The Friendly URLs part
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NE]


    the link we have is "?lp=NjE5cWpyMm4%253D&lu=bWFydHluMg%253D%253D"
    we saw that the url is encoded 2 times. Becauce %253D should be =
    But the translation the first time "%3D" is "=" which is correct, but after the second loop it took "%3D" and translated the "%" into "%253D" because "%25" is equal to "%"

    after we had remove d 1 encode and decode from the login code it worked .

    //code from core/components/login/processors/register.php
    change on line 122 and 123
    $confirmParams['lp'] = urlencode(base64_encode($pword));
        $confirmParams['lu'] = urlencode(base64_encode($user->get('username')));

    to
    $confirmParams['lp'] = base64_encode($pword);
        $confirmParams['lu'] = base64_encode($user->get('username'));


    //code from snippet ConfirmRegister
    change on line 45 and 46
    $username = base64_decode(urldecode(rawurldecode($_REQUEST['lu'])));
        $password = base64_decode(urldecode(rawurldecode($_REQUEST['lp'])));

    to
    $username = base64_decode(rawurldecode($_REQUEST['lu']));
        $password = base64_decode(rawurldecode($_REQUEST['lp']));


    the url is now "?lp=NjE5cWpyMm4%3D&lu=bWFydHluMg%3D%3D"
    this link is working with friendly url
    • Very old thread, but the problem still persist in latest version of "Login" add-on!
      Thanks alot for workaround!
        Freelancer @bitego http://www.bitego.com
        ---
        GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
        More infos here: http://www.bitego.com/extras/goodnews/
      • BTW - found a perfect URL safe method in PHP Docs:
        (http://php.net/manual/de/function.base64-encode.php)

        function base64url_encode($data) { 
            return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); 
        } 
        
        function base64url_decode($data) { 
            return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); 
        }
        
          Freelancer @bitego http://www.bitego.com
          ---
          GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
          More infos here: http://www.bitego.com/extras/goodnews/