示例#1
0
/**
 * Add user
 */
function sumo_add_user($data = array())
{
    if (!empty($data)) {
        global $SUMO;
        $user = strtolower($data['username']);
        $datasource_id = intval($data['datasource_id']);
        $active = isset($data['active']) ? intval($data['active']) : FALSE;
        $firstname = ucwords(preg_replace('/[\\s\\,]+/', ' ', $data['firstname']));
        $lastname = ucwords(preg_replace('/[\\s\\,]+/', ' ', $data['lastname']));
        $firstname = get_magic_quotes_gpc() ? $firstname : addslashes($firstname);
        $lastname = get_magic_quotes_gpc() ? $lastname : addslashes($lastname);
        $ip = str_replace(";;", ";", str_replace(",", ";", preg_replace('/[\\s\\,]+/', ';', $data['ip'])));
        $email = strtolower($data['email']);
        $password = $data['password'];
        $language = $data['language'];
        $sumogroup = sumo_verify_sumogroup($data['group']);
        $group = $sumogroup ? $sumogroup : $data['group'];
        $group = sumo_get_normalized_group($group);
        $day_limit = intval($data['day_limit']);
        $day_limit = $day_limit > 0 ? $day_limit : 'NULL';
        $query = "INSERT INTO " . SUMO_TABLE_USERS . "\n\t\t\t  (\n\t\t\t  \tusername,firstname,lastname,password,active,ip,usergroup,datasource_id,\n\t\t\t  \tlast_login,day_limit,language,email,pwd_updated,created,owner_id,modified,updated\n\t\t\t  )\n\t\t\t  VALUES (\n\t\t  \t\t'" . $user . "', '" . $firstname . "', '" . $lastname . "', '" . $password . "', '" . $active . "',\n\t\t  \t\t'" . $ip . "', '" . $group . "', '" . $datasource_id . "', NULL , " . $day_limit . ",\n\t\t  \t\t'" . $language . "', '" . $email . "', NULL , " . $SUMO['server']['time'] . ",\n\t\t   \t\t" . $SUMO['user']['id'] . ", NULL, NULL\n\t\t\t  )";
        $SUMO['DB']->Execute($query);
        // if user was added
        if (sumo_verify_user_exist($user)) {
            sumo_write_log('I01001X', array($user, $SUMO['user']['user']), 3, 3, 'system', FALSE);
            // Send user notify
            if ($SUMO['config']['accounts']['notify']['updates'] && $email) {
                $object = sumo_get_message("I00001M", $SUMO['server']['name']);
                $message = sumo_get_message("I00107M", array($firstname . " " . $lastname, $SUMO['server']['name'], $SUMO['user']['user']));
                if (!$SUMO['config']['server']['admin']['email']) {
                    sumo_write_log('E06000X', '', '0,1', 2, 'system', FALSE);
                } else {
                    $m = new Mail();
                    $m->From($SUMO['config']['server']['admin']['email']);
                    $m->To($email);
                    $m->Subject($object);
                    $m->Body($message, SUMO_CHARSET);
                    $m->Priority(3);
                    $m->Send();
                }
            }
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
示例#2
0
         } else {
             $sumo_message = $validate[1];
             session_destroy();
         }
     } else {
         $sumo_message = sumo_get_message('W00013C');
         session_destroy();
     }
     break;
 case 'REGCONFIRMED':
     $sumo_template = 'registration';
     if ($SUMO['config']['accounts']['registration']['enabled']) {
         $data = array(array('username', $sumo_reg_data['reg_user'], 1), array('email', $sumo_reg_data['reg_email'], 1), array('password', $_SESSION['reg_password'], 1));
         $validate = sumo_validate_data($data, TRUE);
         if ($validate[0]) {
             if (sumo_verify_user_exist($sumo_reg_data['reg_user'])) {
                 $sumo_message = sumo_get_message('W00008C');
             } elseif (sumo_verify_email_exist($sumo_reg_data['reg_email'])) {
                 $sumo_message = sumo_get_message('W00009C');
             } else {
                 $sumo_message = sumo_get_message('I00007C');
                 $sumo_template = 'message';
                 sumo_request_register();
             }
         } else {
             $sumo_message = $validate[1];
         }
     } else {
         $sumo_template = 'message';
         $sumo_message = sumo_get_message('W00013C');
     }
示例#3
0
/**
 * SUMO MODULE: Users | Add
 *
 * @version    0.5.0
 * @link       http://sumoam.sourceforge.net SUMO Access Manager
 * @author     Alberto Basso <*****@*****.**>
 * @copyright  Copyright &copy; 2003-2009, Alberto Basso
 * @package    SUMO
 * @category   Console
 */
if (sumo_verify_permissions(5, $SUMO['user']['group'])) {
    $data = array(array('username', $_POST['user'], 1), array('name', $_POST['firstname']), array('name', $_POST['lastname']), array('active', $_POST['active'], 1), array('datasource_id', $_POST['datasource_id'], 1), array('email', $_POST['email']), array('language', $_POST['language']), array('usergroup', $_POST['newgroup'], 1), array('ip', $_POST['ip']), array('day_limit', $_POST['day_limit']), array('new_password', array($_POST['new_password'], $_POST['renew_password'])));
    $validate = sumo_validate_data($data, TRUE);
    // verify if user already exist
    if (sumo_verify_user_exist($_POST['user'])) {
        $validate = array(FALSE, sumo_get_message('W00028C', $_POST['user']));
    }
    // verify if password is not null (for SUMO datasource)
    $ds = sumo_get_datasource_info($_POST['datasource_id']);
    if (!$_POST['new_password'] && $ds['type'] == 'SUMO') {
        $validate = array(FALSE, $language['NoPasswordForSumoDS']);
    }
    if ($validate[0]) {
        // Verify submittedd groups with current user group
        $available_group = sumo_get_available_group();
        $newgroup = explode(":", $_POST['newgroup']);
        if (!in_array($newgroup[0], $available_group)) {
            $validate = array(FALSE, sumo_get_message('GroupNotAvailable', $newgroup[0]));
        }
        if (!in_array('sumo', $SUMO['user']['group']) || $newgroup[0] == 'sumo') {