function inscription($nom, $mdp, $mdpBIS, $status = USER_NUM) { if ($mdp != $mdpBIS) { return ERROR_NOT_SAME_VALUE; } $_nom = htmlspecialchars($nom); $_mdp = htmlspecialchars($mdp); $_nom = htmlspecialchars($nom); $_mdp = htmlspecialchars($mdp); $_mdp = md5($_mdp); $res = get_user_by_login($_nom); if (count($res) != 0) { return ERROR_EXISTING_USER; } $bd = new mysqlObject(HOST, DB, USER, MDP); $req = 'insert into compte values(null, "' . $_nom . '", "' . $_mdp . '", ' . $status . ', ' . time() . ');'; return $bd->execQuery($req); }
protected function syncUserToFA($ldap, $username, $password, $primaryGroup) { // FIXME: these should probably be fetched from the configuration variables // default user settings for LDAP-based users $language = 'en_GB'; $profile = ''; $rep_popup = '1'; $pos = '1'; $isActive = '1'; $userArray = ''; // settings available from LDAP $uid = $ldap->getAttribute('uid'); $name = $ldap->getAttribute('sn') . " " . $ldap->getAttribute('givenname'); $mobilephone = $ldap->getAttribute('mobile'); $email = $ldap->getAttribute('mail'); // connect to FA database set_global_connection(); // get role ID from primary group $map = $this->getConfigValue('group_role_map'); $userRole = $map[$primaryGroup]; // FIXME: should error if empty $sql = "SELECT id FROM " . TB_PREF . "security_roles WHERE role = " . db_escape($userRole); $query = db_query($sql, "could not get user role for {$userRole}"); $ret = db_fetch($query); // FIXME: should error if empty $role_id = $ret[0]; // check for existing user in FA $user = get_user_by_login($username); // if user exists if ($user) { // update FA user from LDAP $dbid = $user[0]; // FIXME: LDAP attribute IDs could be supplied in config for site-specific LDAP compatibility update_user($dbid, $uid, $name, $mobilephone, $email, $role_id, $language, $profile, $rep_popup, $pos); // FIXME: update password hash? what about re-auth requests? // else } else { // prepare to create FA user from LDAP // FIXME: LDAP attribute IDs could be supplied in config for site-specific LDAP compatibility add_user($uid, $name, md5($password), $mobilephone, $email, $role_id, $language, $profile, $rep_popup, $pos); // endif } }
function do_install() { global $path_to_root, $db_connections, $def_coy, $installed_extensions, $tb_pref_counter, $dflt_lang, $installed_languages; $coa = $_SESSION['inst_set']['coa']; if (install_connect_db() && db_import($path_to_root . '/sql/' . $coa, $_SESSION['inst_set'])) { $con = $_SESSION['inst_set']; $table_prefix = $con['tbpref']; $def_coy = 0; $tb_pref_counter = 0; $db_connections = array(0 => array('name' => $con['name'], 'host' => $con['host'], 'dbuser' => $con['dbuser'], 'dbpassword' => $con['dbpassword'], 'dbname' => $con['dbname'], 'tbpref' => $table_prefix)); $_SESSION['wa_current_user']->cur_con = 0; update_company_prefs(array('coy_name' => $con['name'])); $admin = get_user_by_login('admin'); update_user_prefs($admin['id'], array('language' => $con['lang'], 'password' => md5($con['pass']), 'user_id' => $con['admin'])); if (!copy($path_to_root . "/config.default.php", $path_to_root . "/config.php")) { display_error(_("Cannot save system configuration file 'config.php'.")); return false; } $err = write_config_db($table_prefix != ""); if ($err == -1) { display_error(_("Cannot open 'config_db.php' configuration file.")); return false; } else { if ($err == -2) { display_error(_("Cannot write to the 'config_db.php' configuration file.")); return false; } else { if ($err == -3) { display_error(_("Configuration file 'config_db.php' is not writable. Change its permissions so it is, then re-run installation step.")); return false; } } } // update default language if (file_exists($path_to_root . "/lang/installed_languages.inc")) { include_once $path_to_root . "/lang/installed_languages.inc"; } $dflt_lang = $_POST['lang']; write_lang(); return true; } return false; }
$ret = upgrade_step($i, $conn); if (!$ret) { display_error(sprintf(_("Database upgrade to version %s failed for company '%s'."), $inst->version, $conn['name']) . '<br>' . _('You should restore company database from latest backup file')); } } // db_close($conn); ? if (!$ret) { break; } } set_global_connection(); if ($ret) { // re-read the prefs global $path_to_root; include_once $path_to_root . "/admin/db/users_db.inc"; $user = get_user_by_login($_SESSION["wa_current_user"]->username); $_SESSION["wa_current_user"]->prefs = new user_prefs($user); display_notification(_('All companies data has been successfully updated')); } refresh_sys_prefs(); // re-read system setup $Ajax->activate('_page_body'); } start_form(); start_table(TABLESTYLE); $th = array(_("Version"), _("Description"), _("Sql file"), _("Install"), _("Force upgrade")); table_header($th); $k = 0; //row colour counter $partial = 0; foreach ($installers as $i => $inst) {