function userRegistrationAction()
{
    $user = isset($_POST['user']) ? $_POST['user'] : [];
    $errors = [];
    if ($user) {
        $user = userSave($user, $errors);
        if (!$errors) {
            addFlashMessages('Вы успешно зарегистрировались!');
            $redirectUrl = $_SERVER['HTTP_REFERER'] ?: 'index.php';
            header('location: ' . $redirectUrl);
            exit;
        }
    }
    var_dump($user, $errors);
    require_once __DIR__ . '/../views/registration.php';
}
Example #2
0
defined('_VALID_MOS') or die('Restricted access');
// Editor usertype check
$access = new stdClass();
$access->canEdit = $acl->acl_check('action', 'edit', 'users', $my->usertype, 'content', 'all');
$access->canEditOwn = $acl->acl_check('action', 'edit', 'users', $my->usertype, 'content', 'own');
require_once $mainframe->getPath('front_html');
switch ($task) {
    case 'UserDetails':
        userEdit($option, $my->id, _UPDATE);
        break;
    case 'saveUserEdit':
        // check to see if functionality restricted for use as demo site
        if ($_VERSION->RESTRICT == 1) {
            mosRedirect('index.php?mosmsg=Functionality Restricted');
        } else {
            userSave($option, $my->id);
        }
        break;
    case 'CheckIn':
        CheckIn($my->id, $access, $option);
        break;
    case 'cancel':
        mosRedirect('index.php');
        break;
    default:
        HTML_user::frontpage();
        break;
}
function userEdit($option, $uid, $submitvalue)
{
    global $database, $mainframe;
Example #3
0
$oldignoreuserabort	=	null;

$_CB_framework->document->_outputToHeadCollectionStart();
ob_start();

switch( $task ) {

	case "userDetails":
	case "userdetails":
	userEdit( $option, $uid, _UE_UPDATE );
	break;

	case "saveUserEdit":
	case "saveuseredit":
	$oldignoreuserabort = ignore_user_abort(true);
	userSave( $option, (int) cbGetParam( $_POST, 'id', 0 ) );
	break;

	case "userProfile":
	case "userprofile":
	userProfile($option, $_CB_framework->myId(), _UE_UPDATE);
	break;

	case "usersList":
	case "userslist":
	usersList( $_CB_framework->myId() );
	break;

	case "userAvatar":
	case "useravatar":
	userAvatar($option, $uid, _UE_UPDATE);
Example #4
0
                print "Password too short, or too long.";
                break;
            } elseif (preg_match('/[^a-zA-Z0-9\\.\\-\\_\\@\\s]/', $_POST['Pass'])) {
                print "Invalid caracter: use \"a-z A-Z 0-9 . - _ @ / ? = &\"";
                break;
            }
            $userEmail = @sanitize_paranoid_string($_POST['email']);
            if ($userEmail == "") {
                $userEmail = null;
            } elseif (!preg_match('/@/i', $userEmail)) {
                print "Invalid email address";
                break;
            }
            $userToSave = "new";
            if ($userToSave) {
                $userSaveResult = userSave($userToSave, $userName, $userEmail, $userPass);
                if (!$userSaveResult) {
                    print $userSaveResult;
                }
            }
        }
    } while (false);
}
?>

<!-- <div id="page-wrap"> -->
<div id="page-wrap">
   <div id="main-content">

      <div id="management_menu">
         <p>
 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']);
                 }
             }
         }
     }
 }
Example #6
0
    if (isset($_POST['Pass']) and $_POST['Pass'] == "Change Password" and $_POST['UserID'] > 0) {
        $userToSave = @sanitize_int($_POST['UserID'], $min = '0');
        if ($_POST['newPass'] != $_POST['newPass2']) {
            $changeResult[] = "The passwords don't match!<br>Please try again.";
            break;
        }
        $userPass = @sanitize_paranoid_string($_POST['newPass'], $min = '5', $max = '30');
        if (!$userPass) {
            $changeResult[] = "Password too short, or too long.";
            break;
        } elseif (preg_match('/[^a-zA-Z0-9\\.\\-\\_\\@\\s]/', $_POST["Pass"])) {
            $changeResult[] = "Invalid caracter: use \"a-z A-Z 0-9 . - _ @ / ? = &\", case sensitive.";
            break;
        }
        if ($userToSave) {
            $userSaveResult = userSave($userToSave, '', '', $userPass);
            if (!$userSaveResult) {
                $changeResult[] = "An error occour with password change, please check it and try again";
            } else {
                $changeResult[] = "Password change sucessfully!";
                if (isset($_SESSION['forceChangePass']) and $_SESSION['forceChangePass'] and $userToSave == "1") {
                    unset($_SESSION['forceChangePass']);
                }
            }
        }
    }
} while (false);
?>
<!-- <div id="page-wrap"> -->
<div id="page-wrap">
   <div id="main-content">