/** * Add a new user * * @param mixed[] $details Array of User details * * @return boolean true on success, false otherwise */ function add_new_user_local($details) { global $db; if (!do_hook('verify_permission', 'user_add_new')) { error(ERR_PERM_ADD_USER); return false; } elseif (user_exists($details['username'])) { error(ERR_USER_EXIST); return false; } elseif (!is_valid_email($details['email'])) { error(ERR_INV_EMAIL); return false; } elseif ($details['active'] == 1) { $active = 1; } else { $active = 0; } $query = "INSERT INTO users (username, password, fullname, email, description,"; if (do_hook('verify_permission', 'user_edit_templ_perm')) { $query .= ' perm_templ,'; } $password_hash = Poweradmin\Password::hash($details['password']); $query .= " active) VALUES (" . $db->quote($details['username'], 'text') . ", " . $db->quote($password_hash, 'text') . ", " . $db->quote($details['fullname'], 'text') . ", " . $db->quote($details['email'], 'text') . ", " . $db->quote($details['descr'], 'text') . ", "; if (do_hook('verify_permission', 'user_edit_templ_perm')) { $query .= $db->quote($details['perm_templ'], 'integer') . ", "; } $query .= $db->quote($active, 'integer') . ")"; $response = $db->query($query); if (PEAR::isError($response)) { error($response->getMessage()); return false; } return true; }
if ($db_charset) { $options['charset'] = $db_charset; } if ($db_collation) { $options['collation'] = $db_collation; } $db->createTable($table['table_name'], $table['fields'], $options); } $fill_perm_items = $db->prepare('INSERT INTO perm_items VALUES (?, ?, ?)'); $db->extended->executeMultiple($fill_perm_items, $def_permissions); if (method_exists($fill_perm_items, 'free')) { $fill_perm_items->free(); } foreach ($def_remaining_queries as $query_nr => $user_query) { if ($query_nr === 0) { $user_query = sprintf($user_query, $db->quote(Poweradmin\Password::hash($pa_pass), 'text')); } $db->query($user_query); } echo _('done!') . "</p>"; echo $twig->render('step4.html', array('next_step' => ++$current_step, 'language' => $_POST['language'], 'db_user' => $db_user, 'db_pass' => $db_pass, 'db_host' => $db_host, 'db_port' => $db_port, 'db_name' => $db_name, 'db_type' => $db_type, 'db_charset' => $db_charset, 'pa_pass' => $pa_pass)); break; case 5: $current_step++; $db_user = $_POST['db_user']; $db_pass = $_POST['db_pass']; $db_host = $_POST['db_host']; $db_port = $_POST['db_port']; $db_name = $_POST['db_name']; $db_type = $_POST['db_type']; $db_charset = $_POST['db_charset'];