Welcome to TheGillis.net

Consider this site a collection of random notes about a variety of topics. I hope this information helps you in some way.

16 September 2005 - 22:50Xaneon Mambo User Registration Bug Fix

Recently someone mentioned to me that my site registration wasn’t working. He also mentioned that it was a Xaneon Extension issue and I wasn’t the only person to experience it. Although he was able to provide some examples that people had done to fix it, they appeared to be very complex and I couldn’t see how they would even work. Since I had been looking through the default Mambo /includes/sef.php code, I had a feeling I knew what the problem was and I was able to come up with a very simple fix.

NOTE: This refers to a very old Mambo version. This is for information purposes only.

Problem

Unfortunately, I was not enthusiastic into solving this problem. The registration code appeared complex and the issue of not being able to trace through PHP only irritated me further. One helpful piece of information that I had remembered while digging through the Mambo SEF code is that there were some conditions where the SEF code was not used. They appeared to be special cases where SEF would probably only complicate matters so it was simply disabled temporarily for some pages.

includes/sef.php line 228

} else if (eregi("option=com_",$string) && !eregi("option=com_registration",$string)
	&& !eregi("task=new",$string) && !eregi("task=edit",$string)) {
  /*
  Components
  index.php?option=com_xxxx&...
  */

After checking the Xaneon SEF code, I determined that there were also instances where the SEF code was disabled, but that the conditions were not the same.

components/com_sef/sef.php line 26

if ($sefEnabled && $_SERVER['REQUEST_METHOD'] == 'POST'
		&& !empty( $_POST['option'] ))
  $sefEnabled = !($_POST['option'] == 'login' || $_POST['option'] == 'login' ||
	$_POST['option'] == 'com_phpshop');

Solution

The first most basic solution that I came up with was to add the com_registration check to the Xaneon SEF code and disable if it is present. This solution is very simple and will only have a minimal impact on the site since the registration page is rarely used.

The Xaneon code is changed to:

if ($sefEnabled && $_SERVER['REQUEST_METHOD'] == 'POST'
		&& !empty( $_POST['option'] ))
  $sefEnabled = !($_POST['option'] == 'login' || $_POST['option'] == 'login' ||
	$_POST['option'] == 'com_registration' ||
	$_POST['option'] == 'com_phpshop');

Conclusion

The patch for the code can be found here. A paper on patches can be found at the Patch Command paper.

This change solves the registration problem. Registration now works. The only side effect appears to be that links off of the confirmation registration page are not SEF. For me this is definitely something I can live with so I left it as is. Hopefully this will help some of you out.

No Comments | Tags: Programming

Add a Comment