srand(time());
sub localtime2sql {
   my @time = localtime(shift);
   return ($time[5]+1900)."-".($time[4]+1)."-".$time[3]." ".$time[2].":".$time[1].":".$time[0];
}
my $time = time();
unless ($ARGV[0]) {
   print "Ticketanzahl fehlt!\n";
   exit(1);
}
# TODO:XXX:FIXME: Defaulttage aus Installationscluster holen!
unless (defined($ARGV[1])) {
   print "You must specify the number of days, or - if none!";
   exit(2);
}
my $days = $ARGV[1] eq "-" ? "" : $ARGV[1];
while($i++ < $ARGV[0]) {
   my $string = "";
   for(my $i=0; $i < 8; $i++){
      my $badnew = 1;
      my $new = "";
      while ($badnew) {
         $badnew = 0;
         $new = chr(int(rand(26)) + 97);
         $badnew++
            if ((lc($new) eq "o") ||
                (lc($new) eq "i") ||
                (lc($new) eq "j") ||
                (lc($new) eq "l") ||
                (lc($new) eq "0") ||
                (lc($new) eq "1"));
      }
      $string = $string.$new;
   }
   print "INSERT INTO tickets (password, maxusedays, vorlage_id, customer_id, nomultiple,mydate,created,deleted) VALUES ('".$string."', ".($days || "").", 1, 1, 1, '2030-01-01', '".localtime2sql($time)."', 0);\n";
}

