// THE API
/* Initialize Joomla framework */
define( '_JEXEC', 1 );
define('JPATH_BASE', $_SERVER['DOCUMENT_ROOT'] );
define( 'DS', DIRECTORY_SEPARATOR );
/* Required Files */
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
/* To use Joomla's Database Class */
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'config.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'base'.DS.'observable.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'base'.DS.'object.php' );
/* Create the Application */
$mainframe =& JFactory::getApplication('site');
global $pagination, $total, $limitstart, $limit;
/* Load CB Foundation */
global $_CB_framework, $mainframe;
if ( defined( 'JPATH_ADMINISTRATOR' ) ) {
if ( ! file_exists( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' ) ) {
echo 'CB not installed!';
return;
}
include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );
} else {
if ( ! file_exists( $mainframe->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/plugin.foundation.php' ) ) {
echo 'CB not installed!';
return;
}
include_once( $mainframe->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/plugin.foundation.php' );
}
cbimport( 'cb.database' );
cbimport( 'cb.plugins' );
cbimport( 'language.front' );
cbimport( 'cb.snoopy' );
cbimport( 'cb.imgtoolbox' );
cbimport( 'cb.html' );
// THE FUNCTION
function registerUser( $fname, $lname, $email, $username, $password, $approve = 0, $confirm = 0 ) {
global $_CB_framework, $_CB_database, $ueConfig;
$approval = ( $approve == 2 ? $ueConfig['reg_admin_approval'] : $approve );
$confirmation = ( $confirm == 2 ? $ueConfig['reg_confirmation'] : $confirm );
$usertype = $_CB_framework->getCfg( 'new_usertype' );
$row = new moscomprofilerUser( $_CB_database );
$row->usertype = ( $usertype ? $usertype : 'Registered' );
$row->gid = $_CB_framework->acl->get_group_id( $row->usertype, 'ARO' );
$row->sendEmail = 0;
$row->registerDate = date( 'Y-m-d H:i:s', $_CB_framework->now() );
$row->name = $fname . ' ' . $lname;
$row->firstname = $fname;
$row->lastname = $lname;
$row->username = $username;
$row->email = $email;
$row->password = cbHashPassword( $password );
$row->registeripaddr = cbGetIPlist();
if ( $approval == 0 ) {
$row->approved = 1;
} else {
$row->approved = 0;
}
if ( $confirmation == 0 ) {
$row->confirmed = 1;
} else {
$row->confirmed = 0;
}
if ( ( $row->confirmed == 1 ) && ( $row->approved == 1 ) ) {
$row->block = 0;
} else {
$row->block = 1;
}
if ( $row->store() ) {
if ( ( $row->confirmed == 0 ) && ( $confirmation != 0 ) ) {
$row->_setActivationCode();
if ( ! $row->store() ) {
return false;
}
}
return true;
}
return false;
}
registerUser($nmfname, $nmlname, $nmemail, $nmusername, $nmpass, 0, 0);
Please Log in to join the conversation.