if ($mosConfig_frontend_login != NULL && ($mosConfig_frontend_login === 0 || $mosConfig_frontend_login === '0')) { echo _NOT_AUTH; return; } switch ($task) { case 'lostPassword': lostPassForm($option); break; case 'sendNewPass': sendNewPass($option); break; case 'register': registerForm($option, $mosConfig_useractivation); break; case 'saveRegistration': saveRegistration(); break; case 'activate': activate($option); break; } function lostPassForm($option) { global $mainframe; $mainframe->SetPageTitle(_PROMPT_PASSWORD); HTML_registration::lostPassForm($option); } function sendNewPass($option) { global $database; global $mosConfig_live_site, $mosConfig_sitename;
static function saveUserRegistration($var, $internal = false, $overrideActivation = false, $overrideEmails = false, $overrideJS = false) { $db = JFactory::getDBO(); global $task, $aecConfig; $app = JFactory::getApplication(); ob_start(); // Let CB/JUSER think that everything is going fine if (aecComponentHelper::detect_component('anyCB')) { if (aecComponentHelper::detect_component('CBE') || $overrideActivation) { global $ueConfig; } $savetask = $task; $_REQUEST['task'] = 'done'; include_once JPATH_SITE . '/components/com_comprofiler/comprofiler.php'; $task = $savetask; if ($overrideActivation) { $ueConfig['reg_confirmation'] = 0; } if ($overrideEmails) { $ueConfig['reg_welcome_sub'] = ''; // Only disable "Pending Approval / Confirmation" emails if it makes sense if (!$ueConfig['reg_confirmation'] || !$ueConfig['reg_admin_approval']) { $ueConfig['reg_pend_appr_sub'] = ''; } } } elseif (aecComponentHelper::detect_component('JUSER')) { $savetask = $task; $task = 'blind'; include_once JPATH_SITE . '/components/com_juser/juser.php'; include_once JPATH_SITE . '/administrator/components/com_juser/juser.class.php'; $task = $savetask; } elseif (aecComponentHelper::detect_component('JOMSOCIAL')) { } // For joomla and CB, we must filter out some internal variables before handing over the POST data $badbadvars = array('userid', 'method_name', 'usage', 'processor', 'recurring', 'currency', 'amount', 'invoice', 'id', 'gid'); foreach ($badbadvars as $badvar) { if (isset($var[$badvar])) { unset($var[$badvar]); } } if (empty($var['name']) && !empty($var['jform'])) { // Must be K2 $var['name'] = aecEscape($var['jform']['name'], array('string', 'clear_nonalnum')); unset($var['jform']); } $_POST = $var; $var['username'] = aecEscape($var['username'], array('string', 'badchars')); $savepwd = aecEscape($var['password'], array('string', 'badchars')); if (aecComponentHelper::detect_component('anyCB')) { // This is a CB registration, borrowing their code to save the user if ($internal && !aecComponentHelper::detect_component('CBE')) { include_once JPATH_SITE . '/components/com_acctexp/lib/codeofshame/cbregister.php'; if (empty($_POST['firstname']) && !empty($_POST['name'])) { $name = metaUser::_explodeName($_POST['name']); $_POST['firstname'] = $name['first']; if (empty($name['last'])) { $_POST['lastname'] = $name['first']; } else { $_POST['lastname'] = $name['last']; } } $_POST['password__verify'] = $_POST['password2']; unset($_POST['password2']); @saveRegistrationNOCHECKSLOL('com_acctexp'); } else { @saveRegistration('com_acctexp'); $cbreply = ob_get_contents(); $indicator = '<script type="text/javascript">alert(\''; $alertstart = strpos($cbreply, $indicator); // Emergency fallback if ($alertstart !== false) { ob_clean(); $alertend = strpos($cbreply, '\'); </script>', $alertstart); $alert = substr($cbreply, $alertstart + strlen($indicator), $alertend - $alertstart - strlen($indicator)); if ($aecConfig->cfg['plans_first']) { aecErrorAlert($alert, $action = 'window.history.go(-2);'); } else { aecErrorAlert($alert, $action = 'window.history.go(-3);'); } } } } elseif (aecComponentHelper::detect_component('JUSER')) { // This is a JUSER registration, borrowing their code to save the user saveRegistration('com_acctexp'); $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `username` = \'' . $var['username'] . '\''; $db->setQuery($query); $uid = $db->loadResult(); JUser::saveUser_ext($uid); //synchronize dublicate user data $query = 'SELECT `id`' . ' FROM #__juser_integration' . ' WHERE `published` = \'1\'' . ' AND `export_status` = \'1\''; $db->setQuery($query); $components = $db->loadObjectList(); if (!empty($components)) { foreach ($components as $component) { $synchronize = require_integration($component->id); $synchronize->synchronizeFrom($uid); } } } elseif (aecComponentHelper::detect_component('JOMSOCIAL') && !$overrideJS) { } else { $data = array('username' => $var['username'], 'password' => $var['password'], 'password2' => $var['password2'], 'email' => $var['email'], 'name' => $var['name']); if (isset($var['jform']['profile'])) { $data['profile'] = $var['jform']['profile']; } if (defined('JPATH_MANIFESTS')) { $params = JComponentHelper::getParams('com_users'); // Initialise the table with JUser. JUser::getTable('User', 'JTable'); $user = new JUser(); // Prepare the data for the user object. $useractivation = $params->get('useractivation'); // Check if the user needs to activate their account. if (($useractivation == 1 || $useractivation == 2) && !$overrideActivation) { jimport('joomla.user.helper'); $data['activation'] = xJ::getHash(); $data['block'] = 1; } $usersConfig = JComponentHelper::getParams('com_users'); $system = $usersConfig->get('new_usertype', 2); $data['groups'][] = $system; // Bind the data. if (!$user->bind($data)) { JError::raiseWarning(500, JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError())); return false; } // Load the users plugin group. JPluginHelper::importPlugin('users'); // Store the data. if (!$user->save()) { JError::raiseWarning(500, JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError())); return false; } } else { // This is a joomla registration, borrowing their code to save the user // Check for request forgeries if (!$internal) { JRequest::checkToken() or die('Invalid Token'); } // Get required system objects $user = clone JFactory::getUser(); //$pathway =& $app->getPathway(); $config = JFactory::getConfig(); $authorize = JFactory::getACL(); $document = JFactory::getDocument(); // If user registration is not allowed, show 403 not authorized. $usersConfig = JComponentHelper::getParams('com_users'); if ($usersConfig->get('allowUserRegistration') == '0') { JError::raiseError(403, JText::_('Access Forbidden')); return; } // Initialize new usertype setting $newUsertype = $usersConfig->get('new_usertype'); if (!$newUsertype) { $newUsertype = 'Registered'; } // Bind the post array to the user object if (!$user->bind($data)) { JError::raiseError(500, $user->getError()); unset($_POST); subscribe('com_acctexp'); return false; } // Set some initial user values $user->set('id', 0); $user->set('usertype', ''); $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO')); $user->set('sendEmail', 0); $user->set('registerDate', date('Y-m-d H:i:s', (int) gmdate('U'))); // If user activation is turned on, we need to set the activation information $useractivation = $usersConfig->get('useractivation'); if ($useractivation == '1' && !$overrideActivation) { jimport('joomla.user.helper'); $user->set('activation', md5(JUserHelper::genRandomPassword())); $user->set('block', '1'); } // If there was an error with registration, set the message and display form if (!$user->save()) { JError::raiseWarning('', JText::_($user->getError())); echo JText::_($user->getError()); return false; } } $row = $user; $name = $row->name; $email = $row->email; $username = $row->username; $subject = sprintf(JText::_('AEC_SEND_SUB'), $name, $app->getCfg('sitename')); $subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8'); $usersConfig = JComponentHelper::getParams('com_users'); $activation = $usersConfig->get('useractivation'); if ($activation > 0 && !$overrideActivation) { $atext = JText::_('AEC_USEND_MSG_ACTIVATE'); if (defined('JPATH_MANIFESTS')) { $activation_link = JURI::root() . 'index.php?option=com_users&task=registration.activate&token=' . $row->activation; if ($activation == 2) { $atext = JText::_('COM_USERS_MSG_ADMIN_ACTIVATE'); } } else { $activation_link = JURI::root() . 'index.php?option=com_user&task=activate&activation=' . $row->activation; } $message = sprintf($atext, $name, $app->getCfg('sitename'), $activation_link, JURI::root(), $username, $savepwd); } else { $message = sprintf(JText::_('AEC_USEND_MSG'), $name, $app->getCfg('sitename'), JURI::root()); } $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); // check if Global Config `mailfrom` and `fromname` values exist if ($app->getCfg('mailfrom') != '' && $app->getCfg('fromname') != '') { $adminName2 = $app->getCfg('fromname'); $adminEmail2 = $app->getCfg('mailfrom'); } else { // use email address and name of first superadmin for use in email sent to user $rows = xJACLhandler::getSuperAdmins(); $row2 = $rows[0]; $adminName2 = $row2->name; $adminEmail2 = $row2->email; } // Send email to user if (!($aecConfig->cfg['nojoomlaregemails'] || $overrideEmails)) { xJ::sendMail($adminEmail2, $adminEmail2, $email, $subject, $message); } // Send notification to all administrators $aecUser = AECToolbox::aecIP(); $subject2 = sprintf(JText::_('AEC_SEND_SUB'), $name, $app->getCfg('sitename')); $message2 = sprintf(JText::_('AEC_ASEND_MSG_NEW_REG'), $adminName2, $app->getCfg('sitename'), $row->name, $email, $username, $aecUser['ip'], $aecUser['isp']); $subject2 = html_entity_decode($subject2, ENT_QUOTES, 'UTF-8'); $message2 = html_entity_decode($message2, ENT_QUOTES, 'UTF-8'); // get email addresses of all admins and superadmins set to recieve system emails $admins = AECToolbox::getAdminEmailList(); foreach ($admins as $adminemail) { if (!empty($adminemail)) { xJ::sendMail($adminEmail2, $adminEmail2, $adminemail, $subject2, $message2); } } } ob_clean(); // We need the new userid, so we're fetching it from the newly created entry here $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `username` = \'' . $var['username'] . '\''; $db->setQuery($query); return $db->loadResult(); }
case "CheckIn": CheckIn($my->id, $access, $option); break; // standard options 4.5.1 // standard options 4.5.1 case "lostPassword": lostPassForm($option); break; case "sendNewPass": sendNewPass($option); break; case "register": registerForm($option, $mosConfig_useractivation); break; case "saveRegistration": saveRegistration($option); break; case "activate": activate($option); break; } function lostPassForm($option) { global $mainframe; $mainframe->SetPageTitle(_PROMPT_PASSWORD); UserExtended_registration::lostPassForm($option); } function sendNewPass($option) { global $database, $Itemid; global $mosConfig_live_site, $mosConfig_sitename;
function register_save() { $option = JRequest::getCmd('option'); $extension = JRequest::getVar('component'); $extension = version_compare(JVERSION, '1.6.0', 'ge') && $extension == 'com_user' ? 'com_users' : $extension; $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $lang =& JFactory::getLanguage(); $task = JRequest::getVar('oldtask'); //com_user if ($extension == 'com_user' || $extension == 'com_users') { if (version_compare(JVERSION, '1.6.0', 'ge')) { $jform = JRequest::getVar('jform'); $name = $jform['name']; $email_address = $jform['email1']; } else { $name = JRequest::getVar('name'); $email_address = JRequest::getVar('email'); } $name = explode(' ', $name); $email_address = $email_address; $controller = '/controller.php'; $cname = version_compare(JVERSION, '1.6.0', 'ge') ? 'UsersController' : 'UserController'; $lang->load($extension, JPATH_BASE); //Jomsocial } elseif ($extension == 'com_community') { if ($user->email) { $email_address = $user->email; $name = explode(' ', $user->name); $_POST['view'] = 'profile'; } else { $query = 'SELECT token FROM #__community_register_auth_token WHERE auth_key="' . $_POST['authkey'] . '"'; $db->setQuery($query); $token = $db->loadResult(); $query = 'SELECT name, email FROM #__community_register WHERE token="' . $token . '"'; $db->setQuery($query); $details = $db->loadAssocList(); $name = explode(' ', $details[0]['name']); $email_address = $details[0]['email']; } $cntrllr = JRequest::getVar('cntrllr'); $controller = '/controllers/' . $cntrllr . '.php'; $cname = 'Community' . strtoupper($cntrllr[0]) . substr($cntrllr, 1) . 'Controller'; $this->_name = str_replace('com_', '', $extension); require_once JPATH_SITE . DS . 'components' . DS . $extension . DS . 'controllers' . DS . 'controller.php'; require_once JPATH_SITE . DS . 'components' . DS . $extension . DS . 'libraries' . DS . 'core.php'; require_once JPATH_SITE . DS . 'components' . DS . $extension . DS . 'libraries' . DS . 'template.php'; require_once JPATH_SITE . DS . 'components' . DS . $extension . DS . 'views' . DS . 'views.php'; require_once JPATH_SITE . DS . 'components' . DS . $extension . DS . 'views' . DS . 'register' . DS . 'view.html.php'; require_once JPATH_SITE . DS . 'components' . DS . $extension . DS . 'views' . DS . 'profile' . DS . 'view.html.php'; $lang->load($extension, JPATH_BASE); $_POST['option'] = $extension; $_POST['task'] = $task; $view = JRequest::getCmd('view'); //Community Builder } elseif ($extension == 'com_comprofiler') { $name[0] = JRequest::getVar('firstname'); $name[1] = JRequest::getVar('lastname'); $name = explode(' ', JRequest::getVar('name')); $email_address = JRequest::getVar('email'); $controller = '/comprofiler.php'; $cname = 'Comprofiler'; $_POST['option'] = $extension; $GLOBALS['_JREQUEST']['option'] = array('DEFAULTCMD0' => 'com_comprofiler'); $cbtask = JRequest::getVar('oldtask'); } elseif ($extension == 'com_virtuemart') { $name[0] = JRequest::getVar('first_name'); $name[1] = JRequest::getVar('middle_name'); $name[2] = JRequest::getVar('last_name'); $email_address = JRequest::getVar('email'); } $email_address_old = JRequest::getVar('oldEmail', $email_address); $fname = $name[0]; $lname = ''; if (isset($name[1])) { for ($i = 1; $i < count($name); $i++) { $lname .= $name[$i] . ' '; } $lname = trim($lname); } //Create the api object $params =& JComponentHelper::getParams('com_joomailermailchimpintegration'); $paramsPrefix = version_compare(JVERSION, '1.6.0', 'ge') ? 'params.' : ''; $MCapi = $params->get($paramsPrefix . 'MCapi'); $api = new joomlamailerMCAPI($MCapi); //Get the ID of the mailing list jimport('joomla.html.parameter'); $plugin =& JPluginHelper::getPlugin('system', 'joomailermailchimpsignup'); $pluginParams = new JParameter($plugin->params); $listId = $pluginParams->get('listid'); //Check if the user is already logged in and subscribed if ($user->email) { $userlists = $api->listsForEmail($email_address_old); if ($userlists && in_array($listId, $userlists)) { $sub = 1; } } //User wishes to subscribe/update interests if (isset($_POST['newsletter'])) { $double_optin = false; $update_existing = false; $replace_interests = false; $send_welcome = false; //Get merge vars from API $fields = $api->listMergeVars($listId); $fieldids = $pluginParams->get('fields'); $key = 'tag'; $val = 'name'; //Get interests from API $interests = $api->listInterestGroupings($listId); $interestids = $pluginParams->get('interests'); $groupings = array(); $merges = array(); if ($extension == 'com_user' || $extension == 'com_users') { //Default registration if ($fields) { foreach ($fields as $f) { if (isset($_POST['mf_' . $f['tag']])) { $val = $_POST['mf_' . $f['tag']]; $merges[$f['tag']] = $val; } } } if ($interests) { foreach ($interests as $i) { if ($_POST['interest_' . $i['id']]) { $groups = ''; if (is_array($_POST['interest_' . $i['id']])) { foreach ($_POST['interest_' . $i['id']] as $g) { //var_dump($i['groups']);die; foreach ($i['groups'] as $gg) { if ($g == $gg['bit']) { $groups .= $gg['name'] . ','; } } } $groups = substr($groups, 0, -1); $groupings[$i['name']] = array('name' => $i['name'], 'id' => $i['id'], 'groups' => $groups); } else { foreach ($i['groups'] as $gg) { if ($_POST['interest_' . $i['id']] == $gg['bit']) { $groups .= $gg['name']; } } $groupings[$i['name']] = array('name' => $i['name'], 'id' => $i['id'], 'groups' => $groups); } } } } } elseif ($extension == 'com_comprofiler' || $extension == 'com_community' || $extension == 'com_virtuemart') { //Get custom fields $query = 'SELECT dbfield, grouping_id as gid, type, framework FROM #__joomailermailchimpintegration_custom_fields WHERE listID="' . $listId . '"'; $db->setQuery($query); $customfields = $db->loadAssocList(); if ($customfields) { //loop over groupings if ($interests) { foreach ($interests as $i) { foreach ($customfields as $cf) { if ($cf['type'] == 'group') { if ($i['id'] == $cf['gid']) { $groups = ''; if ($extension == 'com_comprofiler' && $cf['framework'] == 'CB' || $extension == 'com_virtuemart' && $cf['framework'] == 'VM') { $field = $_POST[$cf['dbfield']]; } else { if (isset($_POST['field' . $cf['dbfield']])) { $field = $_POST['field' . $cf['dbfield']]; } } if (isset($field) && is_array($field)) { foreach ($field as $g) { foreach ($i['groups'] as $gg) { if ($g == $gg['name']) { $groups .= $gg['name'] . ','; } } } $groups = substr($groups, 0, -1); } else { foreach ($i['groups'] as $gg) { if (isset($field) && $field == $gg['name']) { $groups .= $gg['name']; } } } $groupings[$i['name']] = array('name' => $i['name'], 'id' => $i['id'], 'groups' => $groups); } } } } } } //loop over merge vars if ($fields) { foreach ($fields as $f) { foreach ($customfields as $cf) { if ($cf['type'] == 'field') { if ($f['tag'] == strtoupper($cf['gid'])) { if ($extension == 'com_comprofiler' && $cf['framework'] == 'CB' || $extension == 'com_virtuemart' && $cf['framework'] == 'VM') { if ($f['field_type'] == 'date') { if ($extension == 'com_virtuemart') { $valDay = $_POST['birthday_selector_day']; $valMonth = $_POST['birthday_selector_month']; $valYear = $_POST['birthday_selector_year']; $val = $valMonth . '/' . $valDay . '/' . $valYear; } else { $val = $_POST[$cf['dbfield']]; } $merges[$f['tag']] = substr($val, 3, 2) . '-' . substr($val, 0, 2) . '-' . substr($val, 6, 4); } else { $val = $_POST[$cf['dbfield']]; $merges[$f['tag']] = $val; } } else { if (isset($_POST['field' . $cf['dbfield']])) { $val = $_POST['field' . $cf['dbfield']]; if ($f['field_type'] == 'date') { $merges[$f['tag']] = $val[2] . '-' . $val[1] . '-' . $val[0]; } else { $merges[$f['tag']] = $val; } } } } } } } } } //If this is a new user then subscribe the user at activation if (!$user->id) { $merges_string = ''; if ($merges) { foreach ($merges as $k => $v) { $merges_string .= "name=" . $k . "\n"; if (is_array($v)) { $merges_string .= "value="; foreach ($v as $vv) { $merges_string .= $vv . "||"; } } else { $merges_string .= "value=" . $v; } $merges_string .= "\n\n"; } } $groupings_string = ''; foreach ($groupings as $g) { $groupings_string .= 'name=' . $g['name'] . "\n"; $groupings_string .= 'id=' . $g['id'] . "\n"; $groupings_string .= 'groups=' . $g['groups'] . "\n" . '||' . "\n"; } $groupings_string = substr($groupings_string, 0, -3); $merges_string = substr($merges_string, 0, -2); $query = "INSERT INTO #__joomailermailchimpsignup (fname,lname,email,groupings,merges)\r\n\t\t\t VALUES ('" . $fname . "','" . $lname . "','" . $email_address . "','" . $groupings_string . "','" . $merges_string . "')"; $db->setQuery($query); $db->query(); //Otherwise workout whether to update or subscribe the user } else { //Get the users ip address $ip = $this->get_ip_address(); $merge_vars = array('FNAME' => $fname, 'LNAME' => $lname, 'INTERESTS' => '', 'GROUPINGS' => $groupings, 'OPTINIP' => $ip); $merge_vars = array_merge($merge_vars, $merges); $email_type = ''; if (!isset($sub)) { //Subscribe the user $retval = $api->listSubscribe($listId, $email_address, $merge_vars, $email_type, $double_optin, $update_existing, $replace_interests, $send_welcome); $query = 'INSERT INTO #__joomailermailchimpintegration VALUES ("", ' . $user->id . ', "' . $email_address . '", "' . $listId . '")'; $db->setQuery($query); $db->Query(); } else { //Update the users subscription // email address changed in CB? if (($extension == 'com_comprofiler' || $extension == 'com_user' || $extension == 'com_users') && $email_address != $email_address_old) { // update local database entry $query = 'UPDATE #__joomailermailchimpintegration SET email = "' . $email_address . '" WHERE email="' . $email_address_old . '" AND listid = "' . $listId . '"'; $db->setQuery($query); $db->query(); // add new email address to merge vars array $merge_vars['EMAIL'] = $email_address; $email_address = $email_address_old; } $retval = $api->listUpdateMember($listId, $email_address, $merge_vars, $email_type, true); } } //User wishes to unsubscribe } elseif (!isset($_POST['newsletter']) && isset($sub)) { $api->listUnsubscribe($listId, $email_address, false, false, false); $query = 'DELETE FROM #__joomailermailchimpintegration WHERE email="' . $email_address . '" AND listid = "' . $listId . '"'; $db->setQuery($query); $db->query(); } if ($api->errorCode && $api->errorCode != 215 && $api->errorCode != 211) { echo "Unable to load listSubscribe()!\n"; echo "\tCode=" . $api->errorCode . "\n"; echo "\tMsg=" . $api->errorMessage . "\n"; } else { if ($option == 'com_user' || $option == 'com_users' || $extension == 'com_virtuemart' || $extension == 'com_community' && $task != 'edit' || $extension == 'com_comprofiler') { // we're done at this point return; } else { if ($extension != 'com_comprofiler') { if ($extension != 'com_community') { if (version_compare(JVERSION, '1.6.0', 'ge')) { JRequest::setVar('task', $task); JRequest::setVar('option', 'com_users'); $task = explode('.', $task); $controllerpath = JPATH_SITE . DS . 'components/com_users/controller.php'; require_once $controllerpath; $controllerpath = JPATH_SITE . DS . 'components/com_users/controllers/' . $task[0] . '.php'; require_once $controllerpath; $userController = JController::getInstance('Users', array('base_path' => JPATH_ROOT . DS . 'components' . DS . $extension, 'name' => str_replace('com_', '', $extension))); $task = $task[1]; } else { $controllerpath = JPATH_SITE . DS . 'components/' . $extension . $controller; require_once $controllerpath; $userController = new $cname(array('base_path' => JPATH_ROOT . DS . 'components' . DS . $extension, 'name' => $view)); $this->_name = str_replace('com_', '', $extension); } } else { $controllerpath = JPATH_SITE . DS . 'components/' . $extension . $controller; require_once $controllerpath; $userController = new $cname(array('base_path' => JPATH_ROOT . DS . 'components' . DS . $extension, 'name' => $view)); $this->_name = str_replace('com_', '', $extension); } $userController->execute($task); $userController->redirect(); } else { $controllerpath = JPATH_SITE . DS . 'components/' . $extension . $controller; require_once $controllerpath; if ($cbtask == 'saveUserEdit') { userSave($_POST['option'], $_POST['id']); } else { saveRegistration($_POST['option']); } } } } }