$versions{'main_page_mgr.pl'} = '06.6.00.0000';

# Contains all sub routines (functions) to display the main 'welcome' page and
# for the store manager/admin areas.

#######################################################################
#
# AgoraCart and all associated files, except where noted, are
# Copyright 2001 to Present jointly by K-Factor Technologies, Inc.
# and by C E Mayo (aka Mister Ed) at AgoraCart.com & K-Factor.net
#
# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This copyright notice may not be removed or altered in any way.
#
#######################################################################

sub welcome_screen {
    &$manager_welcome_screen;
}

#######################################################################

sub dash66_welcome_screen {
    # future feature
    &std_welcome_screen;
}

#######################################################################

sub std_welcome_screen {

    my ( $news_html, $promo_html ) = q{};
    my $news_url = 'https://agoracart.com/misc_info/route66cnews.html';
    my $promo_url = 'https://agoracart.com/misc_info/promoc66.html';
    my $agoracart_url = 'https://agoracart.com/misc_info/agoracart.cgi?stloc=';
    my $today = time();
    my $imageURLthingy = 'images';
    my $today = time();

    if ( -e "$mc_version_lastchecked_path" ) {
        require_supporting_libraries( __FILE__, __LINE__,  "$mc_version_lastchecked_path" );
    }

    my $current_versions = $mgr_current_versions_string;
    my $compareTimes = $today - $mgr_version_lastchecked_time;

    print &$manager_page_header( 'Welcome!', '', '', '', '' );
    print '</div>';

    # only check once every period of time set by $mc_version_time_difference, set in main settings manager
    if ( $compareTimes > $mc_version_time_difference )  {
        $current_versions = simple_secure_URL_file_getter($mgr_versions_URL);
        $mgr_version_lastchecked_time = $today;
        $mgr_current_versions_string = $current_versions;
        update_version_status_file_routine();

        # Grab versions from known locations
        my $versions = `grep -h "^\\\$versions{'.*'}\\ *=" ./*.cgi 2> /dev/null`;

        # Build hash of installed versions
        my %installed_versions;

        for my $version ( split /\n/, $versions ) {
            my ( $key, $val ) = $version =~ /versions{'(.*?)'}\s*=\s*'(.*?)'/;
            if ( $val eq '' ) {
                ( $key, $val ) = $version =~ /versions{'(.*?)'}\s*=\s*"(.*?)"/;
            }
            $installed_versions{$key} = $val;
        }

        my ($curent_cur_version,$edge_cur_version,$agoracgi_version,$lang_version,$viewers_version) = split(/\|/, "$current_versions");
        my $version_to_check_against = $curent_cur_version;
        if ( $sc_mgr_upgrade_tier eq 'Edge' ) {
            $version_to_check_against = $edge_cur_version;
        }

        if ( ( $installed_versions{'agora.cgi'} lt $agoracgi_version ) || ( $versions{'manager.cgi'} lt $version_to_check_against ) ) {
            print qq|
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <p><br></p>
</div>
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-warning">
    <h4 class="text-primary mgr-center">Updates are Available</h4>
    <p class="mgr-center">To upgrade to the newest version of AgoraCart, go to the <a href=manager.cgi?mgr_seshun=$in{'mgr_seshun'}&display_upgrade_options=yes>Upgrade Manager</a></p>
    </div>
</div>
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <p><br></p>
</div>
|;
        }
    }

    if (   ( $sc_self_serve_images =~ /yes/i )
        || ( ${sc_domain_name_for_cookie} =~ /^cgi/i ) )
    {
        $imageURLthingy = "manager.cgi?mgr_seshun=$mgr_seshun&picserve=";
    }

    # clear out old carts
    delete_old_carts();

    if ( $sc_secure_domain_name_for_cookie eq $sc_domain_name_for_cookie ) {
        $agoracart_url .= $sc_secure_domain_name_for_cookie;
    } else {
        $agoracart_url .= $sc_domain_name_for_cookie;
    }
    if ( $sc_secure_path_for_cookie eq $sc_path_for_cookie ) {
        $agoracart_url .= $sc_secure_path_for_cookie;
    } else {
        $agoracart_url .= $sc_path_for_cookie;
    }
    $agoracart_url .= '/&stdom=';
    if ( $sc_secure_domain_name_for_cookie eq $sc_domain_name_for_cookie ) {
        $agoracart_url .= $sc_secure_domain_name_for_cookie;
    } else {
        $agoracart_url .= $sc_domain_name_for_cookie;
    }
    $agoracart_url .= '/&stip=' . $ENV{SERVER_ADDR} . '&agcfun=mgr&mgrgp=c&mgrver=' . $versions{'manager.cgi'};
    my $ping = simple_secure_URL_file_getter($agoracart_url);

    if ( ( !-e "$mgrdir/.htaccess" ) && ( $mc_show_htaccess_error_at_welcome ne 'no') ) {
        &no_htaccess_welcome_error;
    }

    if ( $error_message ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 mgr-warning mgr-center">
        <h3>Oops!</h3><h4>$error_message</h4>
    </div>
</div>
ENDOFTEXT
    }

    print <<ENDOFTEXT;
<div class="row mgr-center col-xs-12 col-sm-12 col-md-12 col-lg-12">
ENDOFTEXT

    $news_html = simple_secure_URL_file_getter($news_url);
    $news_html = escapeHTML($news_html);
    $promo_html = simple_secure_URL_file_getter($promo_url);
    $promo_html = escapeHTML($promo_html);

    print <<ENDOFTEXT;

<div class="row col-xs-12 col-sm-12 col-md-12"><p><br></p></div>

<div class="row mgr-center col-xs-12 col-sm-12 col-md-12 col-lg-12">

<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 pull-left main-news-title" style="padding: 7px 0;">
<i class="fa fa-commenting" aria-hidden="true"></i> AgoraCart News Feed</div>

<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
<ul class="social-fonts">
  <li data-toggle="tooltip" data-placement="top" title="Visit AgoraCart on Facebook"><a href="http://www.facebook.com/pages/AgoraCart/10150152104945576" target="_blank"><span class="fa-stack fa-lg testshadow">
      <i class="fa fa-square-o fa-stack-2x"></i>
      <i class="fa fa-facebook fa-stack-1x"></i>
      </span></a></li>
  <li data-toggle="tooltip" data-placement="top" title="Visit AgoraCart on Twitter"><a href="http://www.twitter.com/agoracart" target="_blank"><span class="fa-stack fa-lg testshadow">
      <i class="fa fa-square-o fa-stack-2x"></i>
      <i class="fa fa-twitter fa-stack-1x"></i>
      </span></a></li>
  <li data-toggle="tooltip" data-placement="top" title="Visit the AgoraCart/AgoraSuite channel on Youtube"><a href="https://www.youtube.com/user/AgoraSuite" target="_blank"><span class="fa-stack fa-lg testshadow">
      <i class="fa fa-square-o fa-stack-2x"></i>
      <i class="fa fa-youtube fa-stack-1x"></i>
      </span></a></li>
  <li data-toggle="tooltip" data-placement="top" title="Visit AgoraCart on LinkedIn"><a href="http://www.linkedin.com/groups?gid=3610138" target="_blank"><span class="fa-stack fa-lg testshadow">
      <i class="fa fa-square-o fa-stack-2x"></i>
      <i class="fa fa-linkedin fa-stack-1x"></i>
      </span></a></li>
</ul>
</div>
</div>

<div class="row mgr-center col-xs-12 col-sm-12 col-md-12 col-lg-12">
<a href="https://www.patreon.com/bePatron?u=20060477" data-patreon-widget-type="become-patron-button">Become a Patron!</a><script async src="https://c6.patreon.com/becomePatronButton.bundle.js"></script><p><br></p>
<div class="mgr-center col-xs-12 col-sm-12 col-md-7 col-lg-8">
		<iframe name="news" class="main_text2" srcdoc="$news_html" width="100%" height="380" marginheight="10" marginwidth="10"></iframe>
</div>
<div class="mgr-center col-xs-12 col-sm-12 col-md-5 col-lg-4">
        <iframe name="news" class="main_text2" srcdoc="$promo_html" width="100%" height="380" marginheight="10" marginwidth="10"></iframe>
</div>
</div>
$other_welcome_message
<br>
</div>

<div class="row col-xs-12 col-sm-12 col-md-12"><p><br></p></div>

<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12">
<span style="display: block; text-align: left; margin: 2px 0 0; padding: 0; color: #999; font: 12px Arial, Helvetica, sans-serif;">
Terms of Service Note: Marketplace and/or Gold Version files are licensed for one domain name. Additional licenses should be purchased if you wish to copies on multiple sites.</span>
</div>
<div class="row col-xs-12 col-sm-12 col-md-12"><p><br></p></div>
</div>
ENDOFTEXT
    print &$manager_page_footer;

}

#######################################################################

1;
