#!/usr/bin/perl

# ispCP ω (OMEGA) a Virtual Hosting Control Panel
# Copyright (C) 2001-2006 by moleSoftware GmbH - http://www.molesoftware.com
# Copyright (C) 2006-2010 by isp Control Panel - http://ispcp.net
#
# Version: $Id: check-perl-modules 2505 2010-01-06 20:30:53Z nuxwin $
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is "VHCS - Virtual Hosting Control System".
#
# The Initial Developer of the Original Code is moleSoftware GmbH.
# Portions created by Initial Developer are Copyright (C) 2001-2006
# by moleSoftware GmbH. All Rights Reserved.
# Portions created by the ispCP Team are Copyright (C) 2006-2010 by
# isp Control Panel. All Rights Reserved.
#
# The ispCP ω Home Page is:
#
#    http://isp-control.net
#

my @needed = (strict, warnings, IO::Socket, DBI, DBD::mysql, Mail::Address, MIME::Entity,
MIME::Parser, Crypt::CBC, Crypt::Blowfish, MIME::Base64,
Term::ReadPassword, Net::LibIDN);

my ($mod, $mod_err, $mod_missing) = ('', '_off_', '');

for $mod (@needed) {
    print STDERR "Checking for '$mod'...\t";

    if (eval "require $mod") {
        $mod -> import();
        printf " Ok.\n";
    } else {
        print STDERR "CRITICAL ERROR: Module '$mod' WAS NOT FOUND !\n" ;

        $mod_err = '_on_';

        if ($mod_missing eq '') {
            $mod_missing .= $mod;
        } else {
            $mod_missing .= ", $mod";
        }
    }
}

if ($mod_err eq '_on_') {
    print STDERR "\nModules [$mod_missing] WERE NOT FOUND in your system...\n";
    print STDERR "\nPlease INSTALL them before using ispCP Omega !\n";
    exit 1;
} else {
    $| = 1;
}

return 0;

# hack for dh_perl

require IO::Socket;
require DBI;
require DBD::mysql;
require Mail::Address;
require MIME::Entity;
require MIME::Parser;
require Crypt::CBC;
require Crypt::Blowfish;
require MIME::Base64;
require Term::ReadPassword;
require Net::LibIDN;
