Hi guys,
I am about to upgrade to SMF 2 (from 1.1.16) and I've found that the current registration form generated by the ssi_register() function isn't working with SMF 2, and I don't know why ! :-[
When used with SMF 2 the ssi_register() function seems to be working, the CAPTCHA image appears but the user never gets registered and there's no error message, after submitting the ssi_register() registration form the user ends up on the forum's empty registration page as if he never registered before.
What's wrong with SMF 2 ?
Any help would help :o
Thanks !
Vroum.
As far as I know there is no Register function at SSI.
There was even een MOD for it but this dont'work well.
Hi CapadY, thanks for the reply !
the ssi_register() function is an add on function that works well with SMF 1.1.x, it shows a registration form including a CAPTCHA on the site's home page, outside of SMF.
I'm an IT, not primarily a coder, so I'm not aware of the tools that would make it easier to"reverse-engineer" SMF 2 's registration....It'd be wonderful if there was a tool which would make it possible to "graphically navigate" through the links between SMF functions & files ...etc. I've tried some PHP2XMI but it didn't work & I couldn't generate a diagram of the links between the functions/vars/files...a bit like a database's diagram or class diagram but at the functions/vars level.
ssi_register() works with SMF 1.1.x not working with SMF 2 :
// Show a form for guests to register.
function ssi_register($output_method = 'echo')
{
global $scripturl, $db_prefix, $txt, $settings, $modSettings, $context;
loadLanguage('Login');
// Generate a visual verification code to make sure the user is no bot.
$context['visual_verification'] = empty($modSettings['disable_visual_verification']) || $modSettings['disable_visual_verification'] != 1;
if ($context['visual_verification'])
{
$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
$context['verificiation_image_href'] = $scripturl . '?action=verificationcode;rand=' . md5(rand());
// Only generate a new code if one hasn't been set yet
if (!isset($_SESSION['visual_verification_code']))
{
// Skip I, J, L, O and Q.
$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P'), range('R', 'Z'));
// Generate a new code.
$_SESSION['visual_verification_code'] = '';
for ($i = 0; $i < 5; $i++)
$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
}
}
// If we have GD, try the nice code.
elseif (empty($_REQUEST['format']))
{
require_once($sourcedir . '/Subs-Graphics.php');
if (in_array('gd', get_loaded_extensions()) && !showCodeImage($_SESSION['visual_verification_code'])) {
header('HTTP/1.1 400 Bad Request');
die();
}
// Otherwise just show a pre-defined letter.
elseif (isset($_REQUEST['letter']))
{
$_REQUEST['letter'] = (int) $_REQUEST['letter'];
if ($_REQUEST['letter'] > 0 && $_REQUEST['letter'] <= strlen($_SESSION['visual_verification_code']) && !showLetterImage(strtolower($_SESSION['visual_verification_code']{$_REQUEST['letter'] - 1}))) {
header('HTTP/1.1 400 Bad Request');
die();
}
}
// You must be up to no good.
else {
header('HTTP/1.1 400 Bad Request');
die();
}
}
elseif ($_REQUEST['format'] === '.wav')
{
require_once($sourcedir . '/Subs-Sound.php');
if (!createWaveFile($_SESSION['visual_verification_code'])) {
header('HTTP/1.1 400 Bad Request');
die();
}
}
if($output_method = 'echo' && $context['user']['is_guest']) {
echo '
<div>
<form action="'. $scripturl. '?action=register2" method="post" style="margin: 0px 1px 1px 0; text-align:left;" name="creator" id="creator">
<table class="ssi_table">
<tr>
<td>', $txt[98], ':</td>
<td><input type="text" name="user" size="10" maxlength="30" /></td>
</tr>
<tr>
<td>', $txt[81], ':</td>
<td><input type="password" name="passwrd1" size="10" /></td>
</tr>
<tr>
<td>', $txt[82], ': </td>
<td><input type="password" name="passwrd2" size="10" /></td>
</tr>
<tr>
<td>', $txt[69], ':</td>
<td><input name="email" type="text" size="10" /><input name="regagree" type="hidden" value="checked" /></td>
</tr>';
if ($context['visual_verification'])
{
echo '
<tr>
<td>
', $txt['visual_verification_label'], ':
</td>
<td><input type="text" name="visual_verification_code" size="10" /></td>
</tr>
<tr>';
if ($context['use_graphic_library'])
echo '
<td colspan="2"><img src="', $context['verificiation_image_href'], '" alt="', $txt['visual_verification_description'], '" id="verificiation_image" /></td>';
else
echo '
<td colspan="2"><img src="', $context['verificiation_image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verificiation_image_1" />
<img src="', $context['verificiation_image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verificiation_image_2" />
<img src="', $context['verificiation_image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verificiation_image_3" />
<img src="', $context['verificiation_image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verificiation_image_4" />
<img src="', $context['verificiation_image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verificiation_image_5" /></td>';
echo '
</tr>
<tr>
<td class="smalltext" colspan="2">
<a href="', $context['verificiation_image_href'], ';sound" onclick="return reqWin(this.href, 400, 120);">', $txt['visual_verification_sound'], '</a>
</td>
</tr>';
}
echo'
<tr>
<td colspan="2" align="center"><input type="submit" value="', $txt[97], '" /></td>
</tr>
</table>
</form>
</div>';
}
else
return false;
}
Any ideas ?
Thanks !
Vroum.
Ah I've finally figured out how to show the CAPTCHA image and text field, the code was actually split over several files. (Register.php and Register.template.php)
Here is the code :
if (!empty($modSettings['reg_verification']))
{
require_once('Sources/Subs-Editor.php');
$verificationOptions = array(
'id' => 'register',
);
$context['visual_verification'] = create_control_verification($verificationOptions);
$context['visual_verification_id'] = $verificationOptions['id'];
}
// Otherwise we have nothing to show.
else
$context['visual_verification'] = false;
if ($context['visual_verification'])
{
echo '
<div class="title_bar">
<h4 class="titlebg">', $txt['verification'], '</h4>
</div>
<div class="windowbg2">
<span class="topslice"><span></span></span>
<fieldset class="content centertext">
', template_control_verification($context['visual_verification_id'], 'all'), '
</fieldset>
<span class="botslice"><span></span></span>
</div>';
}
I am still unable to get a member to register, but I'll be investigating that.
Any help will be appreciated.
Thanks !
Vroum.
template_control_verification($context['visual_verification_id']
My main problem is that the above code generates a wrong path to the CAPTCHA image when the calling file is outside the forum folder.
it generates a path like
example.com/maindir/CAPTCHA_PATH
instead of
example.com/maindir/forumdir/CAPTCHA_PATH
Any ideas how to fix this ?
Thanks !
Vroum.
My problem is also that $Settings['actual_theme_url'] contains a wrong path where could I correct that value ?