Esempio n. 1
0
    $passwPat = '/^[a-zA-Z0-9_-]{1,50}$/';
    if ($Check->check('password', 'strlen($test)>5 && strlen($test)<51', 'The password must have at least 6 symbols and max. 50, without diacritical marks and whitespaces!', $_POST['passw'])) {
        $Check->check('password', '$test==true', 'Verification of password is not correct!', $_POST['passw'] == $_POST['passw_ver']);
    }
    $Logs->addLog($Check->isValid(), 'add new one valid');
    if (!$Check->isValid()) {
        foreach ($Check->getErrors() as $k => $error) {
            $aErrors[] = admin_getErrorToPrint($k, $error);
        }
    } else {
        try {
            $aVals = array();
            $aVals[] = array('name', $_POST['name']);
            $aVals[] = array('surname', $_POST['surname']);
            $aVals[] = array('login', $_POST['login']);
            $aVals[] = array('password', cAuthentication::cyphrePassword($_POST['passw']));
            $aVals[] = array('role', $_POST['role'], false);
            /// insert values ///
            if (!$DB->insert('core_users', $aVals)) {
                throw new cException("Some error during insert operation!");
            }
            $aAlerts[] = "New user was added.";
        } catch (cException $e) {
            $msg = $e->getDbMessageError(__METHOD__ . '(line:' . __LINE__ . ')', $query);
            $aErrors[] = $msg;
            cLogsDb::addFileLog($msg);
        }
    }
}
/// end of POST data sent ///
$roles = admin_getAllRoles();