#!/usr/local/bin/perl -w use strict; use OTP qw(authenticate); require "/Daten/collin/Sources/projects/pronto-cvs/pronto/prontolib.pl"; &read_prefs(); my $conn = &open_db_conn; print "Please enter the user id: "; my $user_id = ; chomp $user_id; print "Please enter the six words: "; my $string = ; chomp $string; print "Please enter the number of md5-runs it took to generate the above words: "; my $runs = ; chomp $runs; $runs--; print "Please enter the seed: "; my $seed = ; chomp $seed; my $sth = $conn->prepare("SELECT * FROM web_otp WHERE user_id = '$user_id'") || die $conn->errstr; $sth->execute() || die $conn->errstr; my @row = $sth->fetchrow(); $sth->finish(); if (@row > 0) { print "Updating $user_id\n"; $conn->do("UPDATE web_otp SET last_otp = '" . authenticate($string) . "', runs = $runs, seed = '$seed' " . "WHERE user_id = '$user_id'"); } else { print "Inserting new user\n"; my $sql = "INSERT INTO web_otp (user_id, last_otp, seed, runs) VALUES ('$user_id', '" . authenticate($string) . "', '$seed', $runs)"; $conn->do($sql) || die $conn->errstr; } END { $conn->disconnect(); }