#!/usr/bin/perl -w
#
# CheckModules version 0a
# Checks and installs modules needed for YoSucker to run
#
# Copyright Dirk Diggler & Som One 1981-2002. All rides reserved.
# Coded by Som One and Pierrot Lunaire (French version)
# Redistribution and use, with or without modification,
# is permitted in the sense of GDWYWL
# (GeneralDoWhateverYouWantLicense)
# -z3r0-

use strict;

my %modulez = (
	"IO::Socket" 		=> 0,
	"IO::Socket::SSL" 	=> 0,
	"Digest::MD5"		=> 0,
	"Term::ReadKey"		=> 0,
	"MIME::Base64"		=> 0	
);

# Check and...
foreach (keys %modulez) {
  	print "Module $_: ";
	eval "require $_";
	if ($@) {
	  print "Missing.\n";
	  $modulez{$_} = 1;
	}
	else { print "Found.\n"; }
}

if ($modulez{"IO::Socket::SSL"} == 1) {
  print "\nDo you plan to use the secure login ([y]/n)? ";
  my $tmp = <STDIN>;
  chomp($tmp);

  if ($tmp =~ /^[nN]$/ || $tmp =~ /^[nN][oO]$/) {
	$modulez{"IO::Socket::SSL"} = 0;
  }
}

if ($modulez{"MIME::Base64"} == 1) {
  print "\nDo you plan to use the FastCheck feature ([y]/n)? ";
  my $tmp = <STDIN>;
  chomp($tmp);

  if ($tmp =~ /^[nN]$/ || $tmp =~ /^[nN][oO]$/) {
        $modulez{"MIME::Base64"} = 0;
  }
}

# ... install!
foreach (keys %modulez) {
	if ($modulez{$_}) {
	  print "\nInstalling $_ module...\n";
	  `perl -MCPAN -e 'install $_'`;
	}
}

exit;
