Пример #1
0
$arr['username'] = $_REQUEST['username'];
$old_pass = $_REQUEST['old_password'];
$new_pass = $_REQUEST['password'];
if ($old_pass == base64_encode($new_pass)) {
    $arr['password'] = $old_pass;
} else {
    $arr['password'] = base64_encode($new_pass);
}
$arr['email'] = $_REQUEST['emailaddress'];
//print_r($arr); exit;
if ($arr['parent_id'] != '' && $arr['email'] && $arr['password'] && $arr['username']) {
    if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
        $arr['id'] = $_REQUEST['id'];
        //print_r($arr); exit;
        if ($user->update_user($arr)) {
            send_update_mail($arr['email'], $pass, $arr['user_type']);
            header('Location: http://wmlmusicguide.com/site/admin/master_admin/viewusers.php?act=updated');
            exit;
        } else {
            header('Location: http://wmlmusicguide.com/site/admin/master_admin/adduser.php?success=fail');
            exit;
        }
    } else {
        //echo "";
        if ($user->add_user($arr)) {
            send_create_account_mail($arr['email'], $pass, $arr['user_type']);
            header('Location: http://wmlmusicguide.com/site/admin/master_admin/viewusers.php?act=added');
            exit;
        } else {
            header('Location: http://wmlmusicguide.com/site/admin/master_admin/adduser.php?success=fail');
            exit;
Пример #2
0
function change_user_data($array)
{
    $conf = configurations();
    $action = array(null, null);
    if (!strlen($_POST['usr_email']) || !strlen($_POST['username'])) {
        return null;
    }
    //trigger_error($array['email'].' != '.$_POST['usr_email']);
    if (strlen($_POST['usr_email'])) {
        if (is_array(myfilter($_POST['usr_email'], 'email'))) {
            return getvalue(myfilter($_POST['usr_email'], 'email'), 1);
        } elseif ($array['email'] != $_POST['usr_email'] && !check_user(array('email' => $_POST['usr_email']))) {
            $action[0] = change_email_user(array('mail_change_id' => uniqid('', true), 'new_mail' => myfilter($_POST['usr_email'], 'email')), $array['_id'], 'premail');
        } elseif (check_user(array('email' => $_POST['usr_email'])) && $array['email'] != $_POST['usr_email']) {
            return 'mailused';
        }
    }
    if (strlen($_POST['username'])) {
        if (is_array(myfilter($_POST['username'], 'user'))) {
            return getvalue(myfilter($_POST['username'], 'user'), 1);
        } elseif ($array['user'] != $_POST['username']) {
            trigger_error($array['user'] . ' != ' . $_POST['username']);
            $action[1] = change_email_user(array('user' => myfilter($_POST['username'], 'user')), $array['_id'], 'user');
        }
    }
    if (is_array($_POST['project']) && $array['lvl'] !== 'admin') {
        foreach ($_POST['project'] as $value) {
            if (!is_array(myfilter($value, '_id'))) {
                $projects[] = myfilter($value, '_id');
            }
        }
    } else {
        $projects[] = null;
    }
    //mise à jour des projets
    if ($array['lvl'] === 'user' && !$array['vip']) {
        $con = new Mongo();
        $db = $con->{$conf}['base']->{$conf}['user'];
        try {
            $db->update(array('_id' => new MongoID($array['_id'])), array('$set' => array('projects' => $projects)), array('safe' => true, 'upsert' => true));
        } catch (MongoCursorException $e) {
            trigger_error("Insert failed " . $e->getMessage());
            return html5_db_error($conf['lang']);
        }
        send_update_mail($array['_id'], $projects);
    }
    trigger_error($action[0] . $action[1]);
    return $action[0] . $action[1];
}