How to integrate custom registration form with Coppermine's functionality - Page 2 How to integrate custom registration form with Coppermine's functionality - Page 2
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

How to integrate custom registration form with Coppermine's functionality

Started by matheso, December 30, 2014, 01:13:47 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

matheso

Ideally I'd want to use the custom form in it's entirety, while simply *sending the values* from my custom form to Coppermine's register.php file to submit. This seems like a very clean solution if possible.

I only need the fields email,password, and confirm password to be required.   The 3 optional fields (Shown in step #2 of the form)  will be Keyword 1, Keyword 2, and Keyword 3.



Αndré

Quote from: matheso on December 30, 2014, 04:29:31 PM
Ideally I'd want to use the custom form in it's entirety, while simply *sending the values* from my custom form to Coppermine's register.php file to submit.

Exactly as I said ;)
Quote from: Αndré on December 30, 2014, 10:03:30 AM
I think it should also be possible to pass the values of the custom registration form to register.php.

Will check this now.

Αndré

I created a simple test form:
<form action="register.php" method="post">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="password" name="password_verification" />
<input type="text" name="email" />
<input type="submit" name="submit"" />
</form>


It works as expected if registrations are enabled in the config. I haven't checked if it also works if captcha for registrations is enabled, but I assume it won't.

allvip

I was so not paying attention before, but the form is so easy to use inside the register.php.
It works with captcha, error warnning and all copp registration functions.
Only thing is to separate the username and optional fields to not be the same anymore so I can you custom placeholder for each one. Same for password and renter pass.

registration.php  part 1 (is just a draft,can not actually be used)


<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2014 Coppermine Dev Team
  v1.0 originally written by Gregory Demar

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.

  ********************************************
  Coppermine version: 1.5.34
  $HeadURL: https://svn.code.sf.net/p/coppermine/code/trunk/cpg1.5.x/register.php $
  $Revision: 8753 $
**********************************************/

define('IN_COPPERMINE'true);
define('REGISTER_PHP'true);

require(
'include/init.inc.php');
require(
'include/mailer.inc.php');

if (!
$CONFIG['allow_user_registration']) {
    
cpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);
}

if (
defined('UDB_INTEGRATION')) {
    
$cpg_udb->register_page();
}

js_include('js/register.js');
js_include('js/thumbnails.js');
js_include('js/jquery.easing.min.js');

$icon_array = array(
    
'ok'       => cpg_fetch_icon('ok'0),
    
'username' => cpg_fetch_icon('my_profile'2),
    
'password' => cpg_fetch_icon('key_enter'2),
    
'email'    => cpg_fetch_icon('contact'2),
    
'blank'    => cpg_fetch_icon('blank'2),
);

/*****************************
* function definitions start *
*****************************/

/**
* display_disclaimer()
*
* Display the disclaimer
*
* @param void
* @return void
**/
function display_disclaimer()
{
    global 
$CONFIG$CPG_PHP_SELF$lang_register_php$icon_array;

    echo <<< EOT
        <form name="cpgform" id="cpgform" method="post" action="$CPG_PHP_SELF">

EOT;
    echo 
'<div id="regisWrapper">';
    echo 
'<div id="regis" class="regisAgree">';
    
starttable(-1cpg_fetch_icon('add_user'2) . $lang_register_php['term_cond']);

    echo <<< EOT
    <tr>
        <td class="tableb" style="padding: 10px;">

EOT;
    echo 
str_replace('{SITE_NAME}'$CONFIG['gallery_name'], $lang_register_php['disclamer']);

    echo <<< EOT
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center" class="tablef">
            <button type="submit" class="button" name="agree" id="agree" value="
{$lang_register_php['i_agree']}">{$icon_array['ok']}{$lang_register_php['i_agree']}</button>
        </td>
    </tr>

EOT;
    
endtable();
    echo 
'</div>';
    echo 
'</div>';
    print 
'</form>';
}

/**
* input_user_info()
*
* Display the form fields
*
* @param string $errors
* @return void
**/
function input_user_info($errors '')
{
    global 
$CONFIG$CPG_PHP_SELF$lang_register_php$lang_common$icon_array;

    
$superCage Inspekt::makeSuperCage();
    echo 
'<div id="regisWrapper">';
    echo <<<EOT
    <form name="cpgform" id="msform" method="post" action="$CPG_PHP_SELF" onsubmit="return checkRegisterFormSubmit();">
EOT;

    echo 
'<ul id="progressbar">';
echo '<li class="active">Account Setup</li>';
echo '<li>Social Profiles</li>';
echo '<li>Personal Details</li>';
echo '</ul>';
    echo 
'<fieldset>';
    echo 
'<h2 class="fs-title">Create your account</h2>';
    echo 
'<h3 class="fs-subtitle">This is step 1</h3>';

    echo <<< EOT
            <div id="form_not_submit_top" class="formFieldWarning" style="display:none;">
                
{$lang_register_php['form_not_submit']}
            </div>


EOT;

    
$inline_disclaimer str_replace('{SITE_NAME}'$CONFIG['gallery_name'], $lang_register_php['disclamer']);

    
$form_data = array(
        array(
'label'$lang_register_php['required_info']),
        array(
'input''username'$icon_array['username'] . $lang_register_php['username'], 25),
        !empty(
$CONFIG['global_registration_pw']) ? array('password''global_registration_pw'$icon_array['password'] . $lang_register_php['global_registration_pw'], 25) : '',
        array(
'password''password'$icon_array['password'] . $lang_register_php['password']),
        array(
'password''password_verification'$icon_array['password'] . $lang_register_php['password_again']),
        array(
'input''email'$icon_array['email'] . $lang_register_php['email'], 255),
        array(
'label'$lang_register_php['optional_info'])
    );
    
$optional_data 0;
    if (
$CONFIG['user_profile1_name'] != '') {
        
$form_data[] = array('input''user_profile1'$icon_array['blank'] . $CONFIG['user_profile1_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile2_name'] != '') {
        
$form_data[] = array('input''user_profile2'$icon_array['blank'] . $CONFIG['user_profile2_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile3_name'] != '') {
        
$form_data[] = array('input''user_profile3'$icon_array['blank'] . $CONFIG['user_profile3_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile4_name'] != '') {
        
$form_data[] = array('input''user_profile4'$icon_array['blank'] . $CONFIG['user_profile4_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile5_name'] != '') {
        
$form_data[] = array('input''user_profile5'$icon_array['blank'] . $CONFIG['user_profile5_name'], 255);
        
$optional_data++;
    }
    if (
$CONFIG['user_profile6_name'] != '') {
        
$form_data[] = array('textarea''user_profile6'$icon_array['blank'] . $CONFIG['user_profile6_name'], 255);
        
$optional_data++;
    }
    if (
$optional_data == 0) {
        
$form_data array_slice($form_data0count($form_data)-1);
    }

    
$form_data CPGPluginAPI::filter('register_form_create'$form_data);

    if (
$CONFIG['user_registration_disclaimer'] == 2) {
        
$form_data[] = array('label'$lang_register_php['term_cond']);
        
$form_data[] = array('checkbox''agree'$inline_disclaimer$lang_register_php['i_agree'], 1);
    } else {
        
$form_data[] = array('hidden''agree'1);
    }

    
$loopCounter 0;

    foreach (
$form_data as $element) {

        if (empty(
$element)) {
            continue;
        }

        if (
$loopCounter == floor($loopCounter 2)) {
            
$row_style 'tableb';
        } else {
            
$row_style 'tableb tableb_alternate';
        }

        
$loopCounter++;

        switch (
$element[0]) {

        case 
'label':

              echo <<< EOT
        <div class="regisTitle">
            
{$element[1]}
        </div>

EOT;
            break;

        case 
'input':

            if (
$superCage->post->keyExists($element[1])) {
                
$value $superCage->post->getEscaped($element[1]);
            } else {
                
$value '';
            }

            if (isset(
$lang_register_php[$element[1].'_warning1'])) {
                
$warning1 '<div id="'.$element[1].'_warning1" class="cpg_message_validation formFieldWarning" style="display:none;">' $lang_register_php[$element[1].'_warning1'] . '</div>';
            } else {
                
$warning1 '';
            }

            if (isset(
$lang_register_php[$element[1].'_warning2']) == TRUE) {
                
$warning2 '<div id="'.$element[1].'_warning2" class="cpg_message_validation formFieldWarning" style="display:none;">' $lang_register_php[$element[1].'_warning2'] . '</div>';
            } else {
                
$warning2 '';
            }

            if (
$element[2]) {

                echo <<< EOT

          <div width="20%" class="regis regisFieldsTitle">
            
{$element[2]}
          </div>
            <input type="text" style="width: 100%" name="
{$element[1]}" id="{$element[1]}" maxlength="{$element[3]}" value="$value" class="textinput" />
            
{$warning1}
            
{$warning2}



EOT;
            }

            break;

        case 
'radio':

            
// added the radio option for possible future use. The array definition would have to look like this:
            // array('radio', 'user_var', 'Text label', 'option 1','option 2'),
            // enabling this option requires changes in profile.php and usermgr.php as well

            
if ($superCage->post->keyExists($element[1])) {
                
$value $superCage->post->getAlnum($element[1]);
            } else {
                
$value '';
            }

            if (
$element[2]) {

                echo <<< EOT
    <tr>
        <td width="20%" class="
{$row_style}"  height="25">
            
{$element[2]}
        </td>
        <td width="80%" class="
{$row_style}" valign="top">
            <input type="radio" name="
{$element[1]}" id="{$element[1]}1" value="{$element[3]}" class="radio" />
            <label for="
{$element[1]}1" class="clickable_option">{$element[3]}</label>
            <input type="radio" name="
{$element[1]}" id="{$element[1]}2" value="{$element[4]}" class="radio" />
            <label for="
{$element[1]}2" class="clickable_option">{$element[4]}</label>
        </td>
    </tr>

EOT;
            }

            break;

        case 
'checkbox':

            
// added the checkbox option for possible future use. The array definition would have to look like this:
            // array('checkbox', 'user_var', 'preceeding text', 'Text label', 'value', 'Number of columns', 'attribute'),
            // enabling this option requires changes in profile.php and usermgr.php as well
            // Number of columns can be 1 or 2, default is 1.
            // Attribute can be anything that you want to pass to the <input>-tag, e.g. the parameter 'checked="checked"'.
            // or an event handler.

            
if ($superCage->post->keyExists($element[1])) {
                
$value $superCage->post->getAlnum($element[1]);
            } else {
                
$value '';
            }

            if (
$element[3]) {

                if (
$element[5] == 2) {
                    echo <<<EOT
    <tr>
        <td width="20%" class="
{$row_style}">
            
{$element[2]}
        </td>
        <td width="80%" class="
{$row_style}" valign="top">
            <input type="checkbox" name="
{$element[1]}" id="{$element[1]}" value="{$element[4]}" class="checkbox" {$element[6]} />
            <label for="
{$element[1]}" class="clickable_option">{$element[3]}</label>
        </td>
    </tr>

EOT;
                } else {
                    echo <<<EOT
    <tr>
        <td class="
{$row_style}" colspan="2">
            
{$element[2]}
            <br />
            <input type="checkbox" name="
{$element[1]}" id="{$element[1]}" value="{$element[4]}" class="checkbox" />
            <label for="
{$element[1]}" class="clickable_option">{$element[3]}</label>
        </td>
    </tr>

EOT;
                }
            }

            break;

        case 
'textarea':

            if (
$superCage->post->keyExists($element[1])) {
                
$value $superCage->post->getEscaped($element[1]);
            } else {
                
$value '';
            }

            if (
$element[2]) {

                echo <<< EOT
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset>
<h2 class="fs-title">Personal Details</h2>
<h3 class="fs-subtitle">We will never sell it</h3>
            <textarea name="
{$element[1]}" rows="7" cols="60" class="textinput" style="width:100%" placeholder="Biography" >$value</textarea>




EOT;
            }
            break;

        case 
'password':

            if (isset(
$lang_register_php[$element[1].'_warning1'])) {
                
$warning1 '<div id="'.$element[1].'_warning1" class="cpg_message_validation formFieldWarning" style="display:none;">' $lang_register_php[$element[1].'_warning1'] . '</div>';
            } else {
                
$warning1 '';
            }

            if (isset(
$lang_register_php[$element[1].'_warning2'])) {
                
$warning2 '<div id="'.$element[1].'_warning2" class="cpg_message_validation formFieldWarning" style="display:none;">' $lang_register_php[$element[1].'_warning2'] . '</div>';
            } else {
                
$warning2 '';
            }

            echo <<< EOT

            <input type="password" style="width: 100%" name="
{$element[1]}" id="{$element[1]}" value="" class="textinput" / placeholder="Password" >
            
{$warning1}
            
{$warning2}
EOT;

            break;

        case 
'hidden':

            echo <<< EOT
    <tr>
        <td colspan="2" class="regis">
            <input type="hidden" name="
{$element[1]}" id="{$element[1]}" value="{$element[2]}" />
        </td>
    </tr>

EOT;

            break;

        default:
            
cpg_die(CRITICAL_ERROR'Invalid action for form creation ' $element[0], __FILE____LINE__);
        }
    }

    if (
$errors) {

        echo <<< EOT
    <tr>
        <td colspan="2" class="tableh2">
            
{$lang_register_php['error']}
        </td>
    </tr>
    <tr>
        <td colspan="2" class="tablef">
                <ul>
$errors</ul>
        </td>
    </tr>

EOT;
    }

allvip

registration.php part2



    // captcha code
    if ($CONFIG['registration_captcha'] != 0) {

        $help = cpg_display_help('f=empty.htm&amp;h=lang_common[captcha_help_title]&amp;t=lang_common[captcha_help]', 470, 245);

        $captcha_print = <<< EOT
    <tr>
        <td align="right" class="regis regisCaptchaTitle">
            {$lang_common['confirm']}&nbsp;{$help}
        </td>
        <td class="regis regisCaptcha">
            <input type="text" name="confirmCode" id="confirmCode" size="5" maxlength="5" class="textinput" />
            <img src="captcha.php" align="middle" border="0" alt="" />
        </td>
    </tr>
EOT;

        $captcha_print = CPGPluginAPI::filter('captcha_register_print', $captcha_print);
        echo $captcha_print;
    }

    echo <<< EOT
<input type="button" name="previous" class="previous action-button" value="Previous" />
            <button type="submit" class="button" name="submit" id="submit" value="{$lang_register_php['submit']}">{$icon_array['ok']}{$lang_register_php['submit']}</button>
            <div id="form_not_submit_bottom" class="formFieldWarning" style="display:none;">
                {$lang_register_php['form_not_submit']}
            </div>
</fieldset>
EOT;

    print '</form>';

}
/**
* get_post_var()
*
* Check the posted data
*
* @param array $var
* @return array $var
**/
function get_post_var($var)
{
    global $lang_errors;

    $superCage = Inspekt::makeSuperCage();

    if (!$superCage->post->keyExists($var) || !trim($superCage->post->getEscaped($var))) {
        cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'] . " ($var)", __FILE__, __LINE__);
    }

    return $superCage->post->getEscaped($var);
}

function check_user_info(&$error)
{
    global $CONFIG;
    global $lang_register_php, $lang_common, $lang_register_approve_email;
    global $lang_register_user_login, $lang_errors;

    $superCage = Inspekt::makeSuperCage();

    $user_name = trim(get_post_var('username'));
    $password = trim(get_post_var('password'));
    $password_again = trim(get_post_var('password_verification'));
    $email = trim(get_post_var('email'));
    $profile1 = $superCage->post->getEscaped('user_profile1');
    $profile2 = $superCage->post->getEscaped('user_profile2');
    $profile3 = $superCage->post->getEscaped('user_profile3');
    $profile4 = $superCage->post->getEscaped('user_profile4');
    $profile5 = $superCage->post->getEscaped('user_profile5');
    $profile6 = $superCage->post->getEscaped('user_profile6');
    $agree_disclaimer = $superCage->post->getEscaped('agree');
    $captcha_confirmation = $superCage->post->getEscaped('confirmCode');

    $sql = "SELECT null FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '$user_name'";
    $result = cpg_db_query($sql);

    if (mysql_num_rows($result)) {
        $error = '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_user_exists'] . '</li>';
        return false;
    }

    mysql_free_result($result);

    if (utf_strlen($user_name) < 2) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['username_warning2'] . '</li>';
    }

    if (!empty($CONFIG['global_registration_pw'])) {

        $global_registration_pw = get_post_var('global_registration_pw');

        if ($global_registration_pw != $CONFIG['global_registration_pw']) {
            $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_global_pw'] . '</li>';
        } elseif ($password == $CONFIG['global_registration_pw']) {
            $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_global_pass_same'] . '</li>';
        }
    }

    if (utf_strlen($password) < 2) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['password_warning1'] . '</li>';
    }

    if ($password == $user_name) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['password_warning2'] . '</li>';
    }

    if ($password != $password_again) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['password_verification_warning1'] . '</li>';
    }

    if (!Inspekt::isEmail($email)) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['email_warning2'] . '</li>';
    }

    if ($CONFIG['user_registration_disclaimer'] == 2 && $agree_disclaimer != 1) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_disclaimer'] . '</li>';
    }

    // Perform the ban check against email address and username
    $result = cpg_db_query("SELECT null FROM {$CONFIG['TABLE_BANNED']} WHERE user_name = '$user_name' AND brute_force = 0 LIMIT 1");

    if (mysql_num_rows($result)) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['user_name_banned'] . '</li>';
    }

    mysql_free_result($result);

    $result = cpg_db_query("SELECT null FROM {$CONFIG['TABLE_BANNED']} WHERE email = '$email' AND brute_force = 0 LIMIT 1");

    if (mysql_num_rows($result)) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['email_address_banned'] . '</li>';
    }

    mysql_free_result($result);

    // check captcha
    if ($CONFIG['registration_captcha'] != 0) {

        if (!captcha_plugin_enabled('register')) {
            require("include/captcha.inc.php");
            if (!PhpCaptcha::Validate($captcha_confirmation)) {
                $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_errors['captcha_error'] . '</li>';
            }
        } else {
            $error = CPGPluginAPI::filter('captcha_register_validate', $error);
        }
    }

    if (!$CONFIG['allow_duplicate_emails_addr']) {

        $sql = "SELECT null FROM {$CONFIG['TABLE_USERS']} WHERE user_email = '$email'";
        $result = cpg_db_query($sql);

        if (mysql_num_rows($result)) {
            $error = '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['err_duplicate_email'] . '</li>';
        }

        mysql_free_result($result);
    }

    $error = CPGPluginAPI::filter('register_form_validate', $error);

    if ($error != '') {
        return false;
    }

    if ($CONFIG['reg_requires_valid_email'] || $CONFIG['admin_activation']) {
        $active = 'NO';
        list($usec, $sec) = explode(' ', microtime());
        $seed = (float) $sec + ((float) $usec * 100000);
        srand($seed);
        $act_key = md5(uniqid(rand(), 1));
    } else {
        $active = 'YES';
        $act_key = '';
    }

    $encpassword = md5($password);

    $user_language = $CONFIG['lang'];

    $sql = "INSERT INTO {$CONFIG['TABLE_USERS']} (user_regdate, user_active, user_actkey, user_name, user_password, user_email, user_profile1, user_profile2, user_profile3, user_profile4, user_profile5, user_profile6, user_language) VALUES (NOW(), '$active', '$act_key', '$user_name', '$encpassword', '$email', '$profile1', '$profile2', '$profile3', '$profile4', '$profile5', '$profile6', '$user_language')";
    $result = cpg_db_query($sql);
    $user_array = array();
    $user_array['user_id'] = mysql_insert_id();
    $user_array['user_name'] = $user_name;
    $user_array['user_email'] = $email;
    $user_array['user_active'] = $active;
    CPGPluginAPI::action('register_form_submit', $user_array);

    if ($CONFIG['log_mode']) {
        log_write('New user "'.$user_name.'" registered', CPG_ACCESS_LOG);
    }

    // Create a personal album if corresponding option is enabled
    if ($CONFIG['personal_album_on_registration'] == 1) {
        $user_id = mysql_insert_id();
        $catid = $user_id + FIRST_USER_CAT;
        cpg_db_query("INSERT INTO {$CONFIG['TABLE_ALBUMS']} (`title`, `category`, `owner`) VALUES ('$user_name', $catid, $user_id)");
    }

    // Registrations must be activated/verified by the user clicking a link in an email
    if ($CONFIG['reg_requires_valid_email']) {
        // Mail the user the activation/verification link
        $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key;

        $template_vars = array(
            '{SITE_NAME}' => $CONFIG['gallery_name'],
            '{USER_NAME}' => $user_name,
            '{ACT_LINK}'  => $act_link,
        );

        if (!cpg_mail($email, sprintf($lang_register_php['confirm_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_php['confirm_email'], $template_vars)))) {
            cpg_die(CRITICAL_ERROR, $lang_register_php['failed_sending_email'], __FILE__, __LINE__);
        }
        msg_box($lang_register_php['information'], $lang_register_php['thank_you'], $lang_common['continue'], 'index.php');
    } else {
        if ($CONFIG['admin_activation']) {
            // We need admin activation only
            msg_box($lang_register_php['information'], $lang_register_php['thank_you_admin_activation'], $lang_common['continue'], 'index.php');
        } else {
            // No activation required, account is ready for login
            msg_box($lang_register_php['information'], $lang_register_php['acct_active'], $lang_common['continue'], 'index.php');
        }
    }

    // email notification or actication link to admin
    if ($CONFIG['reg_notify_admin_email'] || ($CONFIG['admin_activation'] && !$CONFIG['reg_requires_valid_email'])) {
        if (UDB_INTEGRATION == 'coppermine') {
            // get default language in which to inform the admins
            $result = cpg_db_query("SELECT user_id, user_email, user_language FROM {$CONFIG['TABLE_USERS']} WHERE user_group = 1");
            while ( ($row = mysql_fetch_assoc($result)) ) {
                if (!empty($row['user_email'])) {
                    $admins[$row['user_id']] = array('email' => $row['user_email'], 'lang' => $row['user_language']);
                }
            }
        } else {
            //@todo: is it possible to get the language from bridged installs?
            $admins[] = array('email' => $CONFIG['gallery_admin_email'], 'lang' => 'english');
        }
        foreach($admins as $admin) {
            //check if the admin language is available
            if (file_exists("lang/{$admin['lang']}.php")) {
                $lang_register_php_def = cpg_get_default_lang_var('lang_register_php', $admin['lang']);
                $lang_register_approve_email_def = cpg_get_default_lang_var('lang_register_approve_email', $admin['lang']);
            } else {
                $lang_register_php_def = cpg_get_default_lang_var('lang_register_php');
                $lang_register_approve_email_def = cpg_get_default_lang_var('lang_register_approve_email');
            }


            // if the admin has to activate the login, give them the link to do so; but only if users don't have to verify their email address
            if ($CONFIG['admin_activation'] && !$CONFIG['reg_requires_valid_email']) {

                $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key;

                $template_vars = array(
                    '{SITE_NAME}' => $CONFIG['gallery_name'],
                    '{USER_NAME}' => $user_name,
                    '{ACT_LINK}' => $act_link,
                );

                cpg_mail($admin['email'], sprintf($lang_register_php_def['notify_admin_request_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_approve_email_def, $template_vars)));

            } elseif ($CONFIG['reg_notify_admin_email']) {

                // otherwise, email is for information only
                cpg_mail($admin['email'], sprintf($lang_register_php_def['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_register_php_def['notify_admin_email_body'], $user_name));
            }
        }
    }

    return true;
}

/***************************
* function definitions end *
***************************/




/***************************
* main code start          *
***************************/

// Activate pending registration
if ($superCage->get->keyExists('activate')) {

    $act_key = $superCage->get->getAlnum('activate');

    if (strlen($act_key) != 32) {
        cpg_die(ERROR, $lang_register_php['acct_act_failed'], __FILE__, __LINE__);
    }

    $sql = "SELECT user_active, user_email, user_email_valid, user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_actkey = '$act_key' LIMIT 1";
    $result = cpg_db_query($sql);

    if (!mysql_num_rows($result)) {
        cpg_die(ERROR, $lang_register_php['acct_act_failed'], __FILE__, __LINE__);
    }

    $row = mysql_fetch_assoc($result);
    mysql_free_result($result);

    if ($row['user_active'] == 'YES') {
        cpg_die(ERROR, $lang_register_php['acct_already_act'], __FILE__, __LINE__);
    }

    pageheader($lang_register_php['page_title']);

    if ($CONFIG['reg_requires_valid_email'] && !$CONFIG['admin_activation']) {
         // activate user (by user)
        $sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_active = 'YES', user_actkey = '' WHERE user_actkey = '$act_key' LIMIT 1";
        $user_status = 'active_user';
    } elseif ($CONFIG['admin_activation'] && !$CONFIG['reg_requires_valid_email']) {
        // activate user (by admin)
        $sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_active = 'YES', user_actkey = '' WHERE user_actkey = '$act_key' LIMIT 1";
        $user_status = 'active_admin';
    } else {
        if ($row['user_email_valid'] == 'YES') {
            // activate user (by admin)
            if (GALLERY_ADMIN_MODE) {
                $sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_active = 'YES', user_actkey = '' WHERE user_actkey = '$act_key' LIMIT 1";
                $user_status = 'active_admin';
            } else {
                msg_box($lang_register_php['information'], $lang_register_php['thank_you_admin_activation'], $lang_common['continue'], 'index.php');
                pagefooter();
                exit;
            }
        } else {
            // email validated by user, send activation link to admin
            $sql = "UPDATE {$CONFIG['TABLE_USERS']} SET user_email_valid = 'YES' WHERE user_actkey = '$act_key' LIMIT 1";
            $user_status = 'valid';
        }
    }
    cpg_db_query($sql);
    CPGPluginAPI::action('register_user_activation', $act_key);

    //after admin approves, user receives email notification
    if ($user_status == 'active_admin') {

        msg_box($lang_register_php['information'], $lang_register_php['acct_active_admin_activation'], $lang_common['continue'], 'index.php');

        $template_vars = array(
            '{SITE_LINK}' => $CONFIG['site_url'],
            '{USER_NAME}' => $row['user_name'],
            '{SITE_NAME}' => $CONFIG['gallery_name'],
        );

        cpg_mail($row['user_email'], sprintf($lang_register_php['notify_user_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_php['activated_email'], $template_vars)));

    } elseif ($user_status == 'valid') {
        // send activation link to admin

        msg_box($lang_register_php['information'], $lang_register_php['thank_you_admin_activation'], $lang_common['continue'], 'index.php');

        if (UDB_INTEGRATION == 'coppermine') {
            // get default language in which to inform the admins
            $result = cpg_db_query("SELECT user_id, user_email, user_language FROM {$CONFIG['TABLE_USERS']} WHERE user_group = 1");
            while ($row2 = mysql_fetch_assoc($result)) {
                if (!empty($row2['user_email'])) {
                    $admins[$row2['user_id']] = array('email' => $row2['user_email'], 'lang' => $row2['user_language']);
                }
            }
            mysql_free_result($result);
        } else {
            //@todo: is it possible to get the language from bridged installs?
            $admins[] = array('email' => $CONFIG['gallery_admin_email'], 'lang' => 'english');
        }
        foreach($admins as $admin) {
            //check if the admin language is available
            if (file_exists("lang/{$admin['lang']}.php")) {
                $lang_register_php_def = cpg_get_default_lang_var('lang_register_php', $admin['lang']);
                $lang_register_approve_email_def = cpg_get_default_lang_var('lang_register_approve_email', $admin['lang']);
            } else {
                $lang_register_php_def = cpg_get_default_lang_var('lang_register_php');
                $lang_register_approve_email_def = cpg_get_default_lang_var('lang_register_approve_email');
            }

            $act_link = rtrim($CONFIG['site_url'], '/') . '/register.php?activate=' . $act_key;

            $template_vars = array(
                '{SITE_NAME}' => $CONFIG['gallery_name'],
                '{USER_NAME}' => $row['user_name'],
                '{ACT_LINK}' => $act_link,
            );

            cpg_mail($admin['email'], sprintf($lang_register_php_def['notify_admin_request_email_subject'], $CONFIG['gallery_name']), nl2br(strtr($lang_register_approve_email_def, $template_vars)));
        }
    } else {
        //user self-activated, gets message box that account was activated
        msg_box($lang_register_php['information'], $lang_register_php['acct_active'], $lang_common['continue'], 'index.php');
    }

} else {

    pageheader($lang_register_php['page_title']);

    if ($CONFIG['user_registration_disclaimer'] == 1 && !$superCage->post->keyExists('submit') && !$superCage->post->keyExists('agree')) {

        // display the disclaimer page
        display_disclaimer();

    } else {

        if (!$superCage->post->keyExists('submit')) {
            input_user_info();
        } else {
            if (!check_user_info($errors)) {
                input_user_info($errors);
            }
        }
    }
}
echo '<div class="clearer">';
echo '</div>';
echo '</div>';
echo <<< EOT
      <script language="javascript" type="text/javascript">
      //jQuery time
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches

$(".next").click(function(){
if(animating) return false;
animating = true;

current_fs = $(this).parent();
next_fs = $(this).parent().next();

//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");

//show the next fieldset
next_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
left = (now * 50)+"%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'transform': 'scale('+scale+')'});
next_fs.css({'left': left, 'opacity': opacity});
},
duration: 800,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});

$(".previous").click(function(){
if(animating) return false;
animating = true;

current_fs = $(this).parent();
previous_fs = $(this).parent().prev();

//de-activate current step on progressbar
$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");

//show the previous fieldset
previous_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale previous_fs from 80% to 100%
scale = 0.8 + (1 - now) * 0.2;
//2. take current_fs to the right(50%) - from 0%
left = ((1-now) * 50)+"%";
//3. increase opacity of previous_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'left': left});
previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
},
duration: 800,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});

$(".submit").click(function(){
return false;
})
      </script>
EOT;

pagefooter();

?>



Αndré

Off-topic: allvip, why don't you just attach (modified) files instead of splitting them as text to several posts? It's horrible to follow such threads.

I edited your post instead off quote.
Sorry.

allvip

For users to copy and paste. Is more easy then save php.txt files, but I will do it the forum way if I must.

For @matheso: listen to Andre is better.
I won't work on registration.php, but after holidays I want to have my won custom, elegant registration.php.

Can you please give me a hint how to to separate the username and optional fields to not be the same anymore so I can use custom placeholder for each one. Same for password and renter pass.

BTW: Thanks @matheso for this ideea. I will make my registration.php look nice too.
Of course not like or with the code you use.

matheso

Thanks to both of you, the end is in sight! I've created a new registration.html page here: http://taskbasket.net/gallery/registration.html

Except, when I click submit it doesn't do anything. The form code is below. I do *not* want username to be a required field, and my custom field doesn't include it so perhaps this is why it won't submit? I feel like everything in this code is fine:

<form id="msform" action="register.php" method="post">
<!-- progressbar -->
<ul id="progressbar">
<li class="active">Account Setup</li>
<li>Social Profiles</li>
<li>Personal Details</li>
</ul>
<!-- fieldsets -->
<fieldset>
<h2 class="fs-title">Create your account</h2>
<h3 class="fs-subtitle">This is step 1</h3>
<input type="text" name="email" placeholder="Email" />
<input type="password" name="password" placeholder="Password" />
<input type="password" name="password_verification" placeholder="Confirm Password" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset>
<h2 class="fs-title">Social Profiles</h2>
<h3 class="fs-subtitle">Your presence on the social network</h3>
<input type="text" name="twitter" placeholder="Twitter" />
<input type="text" name="facebook" placeholder="Facebook" />
<input type="text" name="gplus" placeholder="Google Plus" />
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<fieldset>
<h2 class="fs-title">Personal Details</h2>
<h3 class="fs-subtitle">We will never sell it</h3>
<input type="text" name="fname" placeholder="First Name" />
<input type="text" name="lname" placeholder="Last Name" />
<input type="text" name="phone" placeholder="Phone" />
<textarea name="address" placeholder="Address"></textarea>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="submit" name="submit" class="submit action-button" value="Submit" />
</fieldset>
</form>


Why is it not submitting like the test form you provided?

Thank you

matheso

I want e-mail to be used as the username... just eliminate username altogether if possible.

Αndré

Again on mobile phone, so I cannot test your form. However, you should be able to submit your form regardless of the included fields, as it doesn't know what is required in the target (register.php).

If you don't want to enter a user name, you probably have to adjust register.php, so it doesn't check for it and instead it adds the email address to the database, as I'm quite sure Coppermine internally requires a name for each user. Will check that later.

matheso

I've solved half the problem - I had to change the submit button's class from submit action-button to just action-button for some reason.

I can't figure out how to change register.php so that it treats the e-mail as the username. Feedback welcome! Thanks

matheso

Actually I've solved it completely (I think).

By removing this line from register.php

array('input', 'username', $icon_array['username'] . $lang_register_php['username'], 25),

and changing $user_name = trim(get_post_var('user_name'));   to   $user_name = trim(get_post_var('email'));

to seems to be working fine. Please let me know if I'm missing something.

Thanks

Αndré