function import_sql_scripts_to_databases($schema_files, $db_ids, $psa_modify_hash, $db_modify_hash, $settings_modify_hash, $crypt_settings_modify_hash, $settings_enum_modify_hash, $additional_modify_hash) { foreach ($db_ids as $db_id) { if (get_db_type($db_id) != "mysql") { print "FIXME: database type " . get_db_type($db_id) . " is not supported.\n"; exit(1); } foreach ($schema_files as $schema_filename => $schema_db_id) { if ($schema_db_id == $db_id) { mysql_db_connect(get_db_address($db_id), get_db_login($db_id), get_db_password($db_id), get_db_name($db_id)); $sql = modify_content($schema_filename, array_merge($psa_modify_hash, $db_modify_hash, $settings_modify_hash, $settings_enum_modify_hash, $crypt_settings_modify_hash, $additional_modify_hash)); populate_mysql_db($sql); } } } }
/** * Change Password * Connect to the database, check that the username and password * combination is correct, finally update the password field to * the new user chosen password. * @param string $user_name Username typed by the user. * @param string $old_password Old password in the database. * @param string $new_password New password chosen by the user. * @return integer The function result code (for error handling) **/ function change_password($user_name, $old_password, $new_password) { $mysql_query = ""; $query_result = SUCCESS_NO_ERROR; // connect to our database $database_connection = mysql_db_connect(); if ($database_connection == FALSE) { return CHANGE_PWD_DB_CANT_CONNECT; } // check if our username and password exist. $mysql_query = "select * from users where user_name='" . $user_name . "' \n and user_password=sha1('" . $old_password . "')"; $query_result = $database_connection->query($mysql_query); if ($query_result == FALSE) { return CHANGE_PWD_DB_QUERY_ERROR; } elseif ($query_result->num_rows <= 0) { // less-than is unnecessary(but this is client code). return CHANGE_PWD_DB_INVALID_PASSWORD; } else { // ok, we validated user credentials, proceed to update their // password. $mysql_query = "update users set user_password=sha1('" . $new_password . "') \n where user_name='" . $user_name . "'"; $query_result = $database_connection->query($mysql_query); if ($query_result == FALSE) { return CHANGE_PWD_DB_CANT_UPDATE; } else { return SUCCESS_NO_ERROR; } } }