Esempio n. 1
0
function CreateUser($Username, $PasswordHash, $Name, $Email, $PhoneNumber, $Role)
{
    //check if account already exists
    if (AccountExists($Username)) {
        echo "Account Already Exists";
        return;
    }
    //insert account variables into database;
    global $conn;
    $query = $conn->prepare("INSERT INTO Users (Username, PasswordHash, Email, Name, Phone, Role) VALUES (:user,:pass,:email,:name,:phone,:role)");
    $query->bindValue(':user', $Username);
    $query->bindValue(':pass', $PasswordHash);
    $query->bindValue(':name', $Name);
    $query->bindValue(':email', $Email);
    $query->bindValue(':phone', $PhoneNumber);
    $query->bindValue(':role', $Role);
    $query->execute();
}
Esempio n. 2
0
include_once 'scripts/account_functions.php';
include_once 'scripts/session_functions.php';
//Startup
include_once 'scripts/connect_to_mysql.php';
$username = $_POST['username'];
$password = $_POST['password'];
$success = 0;
//Check DB Version
$expectedDBVersion = $_POST['DBVersion'];
if (!CheckDBVersion($expectedDBVersion)) {
    //Invalid DB Version
    print "Success={$success}&Error='Invalid DB version'";
    return;
}
//Check if username is being used already
if (AccountExists($username) != 0) {
    print "Success={$success}&Error='Username already in use'";
    return;
}
//Login
$userID = CreateNewAccount($username, $password);
if ($userID == -1) {
    print "Success={$success}&Error='Unable to create new user'";
    return;
}
//There will never be an existing session for a new user, no sense in even checking for it
$sessionID = CreateNewSession($userID);
if ($sessionID == 0) {
    print "Success={$success}&Error='Could not acquire session'";
    return;
}
Esempio n. 3
0
        $SESSION->redirect('?m=aliaslist');
    }
    if (!isset($alias['domainalias'])) {
        if ($alias['login'] == '') {
            $error['login'] = trans('You have to specify alias name!');
        } elseif (!preg_match('/^[a-z0-9._-]+$/', $alias['login'])) {
            $error['login'] = trans('Login contains forbidden characters!');
        }
    } else {
        $alias['login'] = '';
    }
    if (!$alias['domainid']) {
        $error['domainid'] = trans('You have to select domain for alias!');
    } elseif (AliasExists($alias['login'], $alias['domainid'])) {
        $error['login'] = trans('Alias with that login name already exists in that domain!');
    } elseif (AccountExists($alias['login'], $alias['domainid'])) {
        $error['login'] = trans('Account with that login name already exists in that domain!');
    }
    if (!empty($_GET['delaccount'])) {
        unset($alias['accounts'][intval($_GET['delaccount'])]);
    }
    if ($alias['accountid'] && !isset($alias['accounts'][$alias['accountid']])) {
        if ($account = $DB->GetRow('SELECT p.id, p.login, d.name AS domain
				FROM passwd p, domains d WHERE p.domainid = d.id
					AND p.id = ?', array(intval($alias['accountid'])))) {
            $alias['accounts'][$account['id']] = $account;
        }
    }
    if (!empty($_GET['delmailforward'])) {
        unset($alias['mailforwards'][array_search($_GET['delmailforward'], $alias['mailforwards'])]);
    }
Esempio n. 4
0
<?php

//Functions
include_once 'scripts/account_functions.php';
include_once 'scripts/session_functions.php';
//Startup
include_once 'scripts/connect_to_mysql.php';
$username = $_POST['username'];
$success = 0;
//Check DB Version
$expectedDBVersion = $_POST['DBVersion'];
if (!CheckDBVersion($expectedDBVersion)) {
    //Invalid DB Version
    print "Success={$success}&Error='Invalid DB version'";
    return;
}
$exists = AccountExists($username);
if ($exists == -1) {
    print "Success={$success}&Error='Unable to check account at this time'";
    return;
}
$success = 1;
print "Success={$success}&Result={$exists}&Username={$username}";
return;