#!/usr/bin/perl -I../../.. package Pos::Webtop::Web::OEMLoader; use strict; use Pos::web; use Pos::Webtop::Web::OEM::1; use Pos::Webtop::Web::OEM::1::Box; use Pos::Webtop::Web::OEM::2; use Pos::Webtop::Web::OEM::2::Box; use Pos::Webtop::Web::OEM::20; use Pos::Webtop::Web::OEM::20::Box; use Pos::Webtop::Web::OEM::28; use Pos::Webtop::Web::OEM::28::Box; sub load { my ($inOemId,$db,$realOemId,$userId,$cgi) = @{{@_}}{qw/oemId db realOemId userId cgi/}; my @info; $cgi = new CGI unless defined $cgi; # incase we're called outside of a web server # this checks to see if a oemId is specified in the url...if it is # we set the oemId accordingly...this is so the login.pl page can # be rebranded without having to get ssl cert or something since # the user hasn't logged in yet and you don't have anyway to know # what oem stuff to use if (defined($cgi->param('oemId')) and length($cgi->param('oemId'))) { my $inUrlOemId = $cgi->param('oemId'); my $test = 0; if (defined($inUrlOemId)) { $test = $db->query( sql=> " select oem_name from oems where oem_id = '" . $db->escape( dirty => $inUrlOemId ) . "' "); } if ($test) { $inOemId = $inUrlOemId; } else { $inOemId = 1; } } my $query = " select oem_id, oem_name, oem_rebrand_name, oem_name_short, oem_vpn_product_name, oem_webtop_product_name, oem_customer_service_url, oem_customer_service_phone, oem_webtop_learnmore_url, oem_installer_path, oem_installer_filename, oem_webtop_url, oem_getting_started_url, oem_help_url, oem_support_email, domain, detect_domain, oem_webtop_tutorial_url, oem_client_tutorial_url, oem_pm_tutorial_url, oem_webtop_contact_url, oem_netcon_installer_path, oem_network_connector_name, oem_netcon_installer_filename, oem_webtop_supporttool_link, oem_webtop_installer_path, oem_webtop_installer_filename from oems where "; if (not defined($inOemId)) { my $httpHost = uc($ENV{'HTTP_HOST'}); my ($detectedOemId) = $db->query( sql=> " select oem_id from oems where '" . $db->escape( dirty=> $httpHost ) . "' like '%.' || upper(detect_domain) "); if (defined($userId)) { @info = $db->query(sql => "$query oem_id = ( select oem_id from customers where customer_id = ( select customer_id from groups where group_id = ( select group_id from users where user_id = '" . $db->escape(dirty => $userId) . "' ) ) )"); } elsif ( defined $cgi->param('testingOemId') ) { @info = $db->query(sql => "$query oem_id = " . Pos::web::digitize( dirty=> $cgi->param('testingOemId') ) ); } elsif ( defined $detectedOemId ) { @info = $db->query(sql => "$query oem_id = $detectedOemId"); } else { @info = $db->query(sql => "$query oem_id = '1'"); } } else { @info = $db->query(sql => "$query oem_id = '" . $db->escape(dirty => $inOemId) . "'"); } if (scalar(@info) == 0) { return undef; } my ($oemId, $oemName, $oemRebrandName, $oemShortName, $oemVpnProductName, $oemWebtopProductName, $oemCustomerServiceUrl, $oemCustomerServicePhone, $oemLearnMoreUrl, $oemInstallerPath, $oemInstallerFileName, $oemWebtopUrl, $oemGettingStartedUrl, $oemHelpUrl, $oemSupportEmail, $oemDomain, $oemDetectDomain, $oemWebtopTutorialUrl, $oemClientTutorialUrl, $oemPmTutorialUrl, $oemWebtopContactUrl, $oemNetconInstallerPath, $oemNetworkConnectorName, $oemNetconInstallerFilename, $webtopSupportToolLink, $oemWebtopInstallerPath, $oemWebtopInstallerFilename) = @{ $info[0] }; my $obj; my $codeOemId = getSkinOemId(oemId=> $oemId); eval "\$obj = Pos::Webtop::Web::OEM::" . $codeOemId . "->new(oemId => $oemId);"; if (defined($realOemId)) { $$realOemId = $oemId; } if (defined($obj)) { # Get the installer path for this user -- this is for software version control if (defined($userId)) { $oemInstallerPath = getSpecificInstallerPath(userId => $userId, installerPath => $oemInstallerPath, db => $db, fileName => $oemInstallerFileName, mode=> 'vpn'); $oemNetconInstallerPath = getSpecificInstallerPath(userId => $userId, installerPath => $oemNetconInstallerPath, db => $db, fileName => $oemNetconInstallerFilename, mode=> 'netcon'); $oemWebtopInstallerPath = getSpecificInstallerPath(userId => $userId, installerPath => $oemWebtopInstallerPath, db => $db, fileName => $oemWebtopInstallerFilename , mode=> 'webtop'); } $obj->setOemInformation( id => $oemId, name => $oemName, rebrandName => $oemRebrandName, short => $oemShortName, vpnProductName => $oemVpnProductName, webtopProductName => $oemWebtopProductName, customerServiceUrl => $oemCustomerServiceUrl, customerServicePhone => $oemCustomerServicePhone, learnMoreUrl => $oemLearnMoreUrl, installerPath => $oemInstallerPath, webtopUrl => $oemWebtopUrl, gettingStartedUrl => $oemGettingStartedUrl, helpUrl => $oemHelpUrl, supportEmail => $oemSupportEmail, domain => $oemDomain, webtopTutorialUrl => $oemWebtopTutorialUrl, clientTutorialUrl => $oemClientTutorialUrl, pmTutorialUrl => $oemPmTutorialUrl, webtopContactUrl => $oemWebtopContactUrl, netconInstallerPath => $oemNetconInstallerPath, networkConnectorName => $oemNetworkConnectorName, webtopSupportToolLink => $webtopSupportToolLink, webtopInstallerPath => $oemWebtopInstallerPath ); } return $obj; } sub getSpecificInstallerPath { my ($userId, $oemInstallerPath, $db, $fileName, $mode) = @{{@_}}{qw/userId installerPath db fileName mode/}; my $releaseId; # since we have more than one vpn client now we have made software_product_type # to group the different products...groups(vpn,netcon,webtop)...so we check the # mode which should be the group type, then we see if one in that group has # been selected...if one hasn't been selected then it takes the default of that # group whose distribution_identifier is the same as the software_product_name my ($selectedMode) = $db->query(sql => " select sp.distribution_identifier from software_products sp, user_software_versions usv where usv.user_id = '$userId' and sp.software_product_type = '$mode' and usv.software_product_id = sp.software_product_id and usv.selected = '1' "); if (defined($selectedMode)) { $mode = $selectedMode; } # Extract the three possible releases for this user my @info = $db->query(sql => " select ( select software_release_id from user_software_versions where user_id = '$userId' AND software_product_id = sp.software_product_id ) as USER_SOFTWARE_ACTUAL_RELEASE, ( select spb.software_release_id from software_product_branches spb, user_software_versions usv where spb.software_branch_type_id = usv.software_branch_type_id AND usv.software_product_id = sp.software_product_id AND spb.software_product_id = usv.software_product_id AND usv.user_id = '$userId' ) as USER_SOFTWARE_BRANCH_RELEASE, ( select software_release_id from software_product_branches where software_branch_type_id = ( select software_branch_type_id from software_branch_types where upper(software_branch_type_name) = upper('latest') ) AND software_product_id = sp.software_product_id ) as GLOBAL_SOFTWARE_RELEASE from software_products sp where sp.distribution_identifier = '$mode' "); my ($branch) = $db->query(sql => " select sbt.software_branch_type_name from user_software_versions usv, software_product_branches spb, software_branch_types sbt where usv.user_id = '$userId' AND usv.software_branch_type_id = sbt.software_branch_type_id "); # If the user does not have release enforcement, default to the global installer if (scalar(@info) == 0) { return $oemInstallerPath . $fileName; } my ($userActualRelease, $userBranchRelease, $globalRelease) = @{ $info[0] }; $releaseId = $globalRelease; if (defined($userActualRelease)) { $releaseId = $userActualRelease; } elsif (defined($userBranchRelease)) { $releaseId = $userBranchRelease; return $oemInstallerPath . "$mode-$branch/$fileName"; } if (not defined($releaseId)) { $releaseId = ''; } @info = $db->query(sql => " select major_release_number, minor_release_number from software_releases where software_release_id = '$releaseId' "); if (scalar(@info) == 0) { return $oemInstallerPath . $fileName; } my ($major, $minor) = @{ $info[0] }; if (length($fileName) == 0) { print STDERR "warning: oem installer file name is empty.\n"; } return $oemInstallerPath . "$mode-$major.$minor/$fileName"; } # since we have a few oem's that look the same, we need to # streamline things by making a way to return the 'oem id to use' for # skinning settings. our %skinOemIds = ( 1 => 1, 4 => 1, 6 => 1, 3 => 1, 5 => 2, 2 => 2, 8 => 2, 20 => 20, 28 => 28, default => 1 ); sub createBox { my ($constructorArgs,$oemId) = @{{@_}}{qw/constructorArgs oemId/}; my $codeOemId = getSkinOemId(oemId=> $oemId); my $b = undef; eval '$b = Pos::Webtop::Web::OEM::' . $codeOemId . '::Box->new( @{ $constructorArgs } );'; return $b; } sub getSkinOemId { my ($oemId) = @{{@_}}{qw/oemId/}; my $id = undef; $id = $skinOemIds{$oemId}; $id = $skinOemIds{'default'} unless defined $id; return $id; } sub getStylesheetFileVersion { my ($oemId) = @{{@_}}{qw/oemId/}; my $oemStylesheetSource = "/usr/local/positive/WebInterface/LocalWebLib/OEM/" . getSkinOemId(oemId=> $oemId) . "/"; open(HANDLE,"$oemStylesheetSource/stylesheet.css"); my $date = localtime((stat HANDLE)[9]); close(HANDLE); return $date; } 1;