SSI Register Function

Started by [SiNaN], April 23, 2008, 03:37:00 PM

Previous topic - Next topic

Angelotus

Could you please make it also for 2.0 including the visual verification? Thanks!

NoidBer

For the visual verification you have to change to some like this:


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' | <a href="/register" onclick="refreshImages(); return false;">Request another image</a>
                    <tr>
                        <td colspan="2" align="center"><input type="submit" value="', $txt[97], '" /></td>
                    </tr>
                </table>
        </form>
    </div>


<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
function verifyAgree()
{
if (document.forms.creator.passwrd1.value != document.forms.creator.passwrd2.value)
{
alert("The two passwords you entered are not the same!");
return false;
}

if (!document.forms.creator.regagree.checked)
{
alert("Please read and accept the agreement before registering.");
return false;
}

return true;
}
function checkAgree()
{
document.forms.creator.regSubmit.disabled = isEmptyText(document.forms.creator.user) || isEmptyText(document.forms.creator.email) || isEmptyText(document.forms.creator.passwrd1) || !document.forms.creator.regagree.checked;
setTimeout("checkAgree();", 1000);
}
setTimeout("checkAgree();", 1000);
function refreshImages()
{
// Make sure we are using a new rand code.
var new_url = new String("', $context['verificiation_image_href'] ,'");
new_url = new_url.substr(0, new_url.indexOf("rand=") + 5);

// Quick and dirty way of converting decimal to hex
var hexstr = "0123456789abcdef";
for(var i=0; i < 32; i++)
new_url = new_url + hexstr.substr(Math.floor(Math.random() * 16), 1);
document.getElementById("verificiation_image").src = new_url;
}
// ]]></script>

';
}
else
return false;
}

cbearhoney

Quote from: NoidBer on May 18, 2009, 10:28:44 AM
1. I want to redirect after register to another page.

This is a great Mod - exactly what I was looking for.
I am also trying to use the Registration_Redirection Mod. (http://custom.simplemachines.org/mods/index.php?mod=1446) to redirect users back to my custom page after registering.
Corporate America gives me hives.

psynx

please i need help.

i've been using simple portal and this function should work using the 'custom php' in simple portal right?

i have this mod installed in my forum.

so i tried calling it using the 'custom php' block in my simple portal but it wont show.
perhaps i entered the code wrongly?

this is the code i used

<?php
require("my forum directory path/SSI.php");
ssi_register();
 
?>

darrenbeige

Is it possible to make this function show the rules aswell?

warmgrey11

hi, i installed the ssi_register() mod to test a registration form at a location outside the forum.

this was the test:

<?php
require("forum/SSI.php");
ssi_register(); 
?>



this was the result:

Warning: ssi_register(/Subs-Graphics.php) [function.ssi-register]: failed to open stream: No such file or directory in /nfs/c04/h03/mnt/66212/domains/foreclosureforcash.com/html/members/forum/SSI.php on line 1601

Fatal error: ssi_register() [function.require]: Failed opening required '/Subs-Graphics.php' (include_path='.:/usr/local/php-4.4.8-1/share/pear') in /nfs/c04/h03/mnt/66212/domains/foreclosureforcash.com/html/members/forum/SSI.php on line 1601


any help would be really appreciated.

thanks...

eg208


Advertisement: